Changeset 2315 for cobra/trunk/Source/Compiler.cobra
- Timestamp:
- 03/12/10 09:25:11 (2 years ago)
- Files:
-
- 1 modified
-
cobra/trunk/Source/Compiler.cobra (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/Compiler.cobra
r2304 r2315 286 286 BindImplementationPhase, 287 287 IdentifyMainPhase, 288 SuggestDefaultNumberPhase, 288 289 ] 289 290 … … 297 298 if .options.boolValue('timeit') 298 299 phases.add(CountNodesPhase(this)) 300 for i, phase in phases.numbered, phase.stableOrder = i 301 phases.sort # see Phase.order and .compareTo 299 302 return phases 300 303 301 def runPhase(phaseType as Type) 304 def runPhase(phaseType as Type) as bool 302 305 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 306 310 require 307 311 phase.compiler is this … … 311 315 not phase.isRunning 312 316 .lastPhase is phase 317 result implies .errors.count > old .errors.count 313 318 body 314 319 oldErrorCount = .errors.count … … 317 322 phase.run 318 323 .writeSourceCodeCorrections 324 return .errors.count > oldErrorCount 319 325 finally 320 326 _curPhase = nil 321 327 _lastPhase = phase 322 if .errors.count > oldErrorCount, _exitFromErrors323 328 324 329 … … 372 377 .willWriteTestInvocation = writeTestInvocation 373 378 _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 374 383 for phase in .makePhases 375 384 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 378 389 def testifyFilesNamed(fileNames as IList<of String>, options as OptionValues, resultsWriter as IndentedWriter, verbose as bool) 379 390 """ … … 387 398 .defaultOutName = if(.options.buildStandardLibrary, 'Cobra.Lang.dll', fileNames[0]) 388 399 _pathsToCompile = fileNames 400 hasErrors = false 389 401 for phase in .makePhases 390 402 if verbose, print 'Testify phase:', phase.description 391 .runPhase(phase) 403 if not hasErrors or phase.willRunWithErrors 404 if .runPhase(phase), hasErrors = true 392 405 if verbose 393 406 .dumpModulesForTestify(resultsWriter, 'Modules after: [phase.description]') 394 407 print bar 408 if hasErrors, throw StopCompilation(this) # testify runner wants this 395 409 # TODO: to display the intermediate source: 396 410 # for module in .modules … … 999 1013 1000 1014 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. 1002 1016 # 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 """ 1003 1022 .printMessages 1004 1023 _deleteIntermediateFiles



