Wiki
Show
Ignore:
Timestamp:
03/12/10 09:25:11 (2 years ago)
Author:
Chuck.Esterbrook
Message:

An above error about numeric types indicates that you may want to set the default numeric type with "@number [expectedType]" in a source file or "cobra -number:[expectedType]" at the command line.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/Compiler.cobra

    r2304 r2315  
    286286            BindImplementationPhase, 
    287287            IdentifyMainPhase, 
     288            SuggestDefaultNumberPhase, 
    288289        ] 
    289290 
     
    297298        if .options.boolValue('timeit') 
    298299            phases.add(CountNodesPhase(this)) 
     300        for i, phase in phases.numbered, phase.stableOrder = i 
     301        phases.sort  # see Phase.order and .compareTo 
    299302        return phases 
    300303 
    301     def runPhase(phaseType as Type) 
     304    def runPhase(phaseType as Type) as bool 
    302305        require phaseType.isSubclassOf(Phase) 
    303         .runPhase(phaseType(this) to Phase) 
    304  
    305     def runPhase(phase as Phase) 
     306        ensure result implies .errors.count > old .errors.count 
     307        return .runPhase(phaseType(this) to Phase) 
     308 
     309    def runPhase(phase as Phase) as bool 
    306310        require 
    307311            phase.compiler is this 
     
    311315            not phase.isRunning 
    312316            .lastPhase is phase 
     317            result implies .errors.count > old .errors.count 
    313318        body 
    314319            oldErrorCount = .errors.count 
     
    317322                phase.run 
    318323                .writeSourceCodeCorrections 
     324                return .errors.count > oldErrorCount 
    319325            finally 
    320326                _curPhase = nil 
    321327                _lastPhase = phase 
    322             if .errors.count > oldErrorCount, _exitFromErrors 
    323328 
    324329 
     
    372377        .willWriteTestInvocation = writeTestInvocation 
    373378        _pathsToCompile = paths 
     379        # now, essentially, do this: 
     380        #     for phase in .makePhases, runPhase(phase) 
     381        # but pay attention to things like errors and stopCompilation 
     382        hasErrors = false 
    374383        for phase in .makePhases 
    375384            if stopCompilation and stopCompilation(this), break 
    376             .runPhase(phase) 
    377      
     385            if not hasErrors or phase.willRunWithErrors 
     386                if .runPhase(phase), hasErrors = true 
     387        if hasErrors, _exitFromErrors 
     388 
    378389    def testifyFilesNamed(fileNames as IList<of String>, options as OptionValues, resultsWriter as IndentedWriter, verbose as bool) 
    379390        """ 
     
    387398        .defaultOutName = if(.options.buildStandardLibrary, 'Cobra.Lang.dll', fileNames[0]) 
    388399        _pathsToCompile = fileNames 
     400        hasErrors = false 
    389401        for phase in .makePhases 
    390402            if verbose, print 'Testify phase:', phase.description 
    391             .runPhase(phase) 
     403            if not hasErrors or phase.willRunWithErrors 
     404                if .runPhase(phase), hasErrors = true 
    392405            if verbose 
    393406                .dumpModulesForTestify(resultsWriter, 'Modules after: [phase.description]') 
    394407                print bar 
     408        if hasErrors, throw StopCompilation(this)  # testify runner wants this 
    395409        # TODO: to display the intermediate source: 
    396410        #   for module in .modules 
     
    9991013 
    10001014    def _exitFromErrors 
    1001         # TODO 2009-12 Having problems with this in same cases. Not important to enforce right now. 
     1015        # TODO 2009-12 Having problems with this requirement in same cases. Not important to enforce right now. 
    10021016        # require .errors.count 
     1017        """ 
     1018        This method should not be invoked from partial classes found in phases or back-ends. Some 
     1019        phases want to run even when there are errors from previous phases. This is managed by 
     1020        the compiler's execution of the phases. 
     1021        """ 
    10031022        .printMessages 
    10041023        _deleteIntermediateFiles