Changeset 2315
- Timestamp:
- 03/12/10 09:25:11 (2 years ago)
- Location:
- cobra/trunk
- Files:
-
- 6 added
- 8 modified
-
Developer/IntermediateReleaseNotes.text (modified) (1 diff)
-
Source/BackEndClr/SharpGenerator.cobra (modified) (1 diff)
-
Source/CobraTokenizer.cobra (modified) (1 diff)
-
Source/Compiler.cobra (modified) (7 diffs)
-
Source/files-to-compile.text (modified) (1 diff)
-
Source/Misc.cobra (modified) (2 diffs)
-
Source/Phases/Phase.cobra (modified) (2 diffs)
-
Source/Phases/SuggestDefaultNumberPhase.cobra (added)
-
Source/TestifyRunner.cobra (modified) (4 diffs)
-
Tests/800-warnings/500-suggest-numeric-type (added)
-
Tests/800-warnings/500-suggest-numeric-type/100-suggest-numeric-type.cobra (added)
-
Tests/800-warnings/500-suggest-numeric-type/110-suggest-numeric-type.cobra (added)
-
Tests/800-warnings/500-suggest-numeric-type/120-suggest-numeric-type.cobra (added)
-
Tests/800-warnings/500-suggest-numeric-type/130-suggest-numeric-type.cobra (added)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Developer/IntermediateReleaseNotes.text
r2301 r2315 54 54 55 55 * Added support for chain comparisons such as `0 <= i < 9`. 56 57 * Cobra's use of `decimal` has advantages around accuracy, but can also cause confusion when using libraries that are centered around `float`. The compiler now detects this situation and suggests, via warning: 58 59 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. 56 60 57 61 -
cobra/trunk/Source/BackEndClr/SharpGenerator.cobra
r2295 r2315 232 232 _compileSharpWithProcessCSC(optChar, .joinOptions(backEndOptions), sharpFileNameList) 233 233 else 234 print 'Unknown -native-compiler:[nativeCompiler]' 235 _exitFromErrors 236 237 if .errors.count 238 _exitFromErrors 234 .recordError(SourceException('Unknown -native-compiler:[nativeCompiler]')) 239 235 240 236 _deleteIntermediateFiles -
cobra/trunk/Source/CobraTokenizer.cobra
r2196 r2315 880 880 on 'skip', pass 881 881 on 'warning', pass 882 on 'warning-lax', pass 882 883 else, .throwError('Unrecognized compiler directive "[name]".') 883 884 return true -
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 -
cobra/trunk/Source/files-to-compile.text
r2221 r2315 47 47 Phases/BindImplementationPhase.cobra 48 48 Phases/CountNodesPhase.cobra 49 Phases/SuggestDefaultNumberPhase.cobra 49 50 50 51 BackEndCommon/CurlyWriter -
cobra/trunk/Source/Misc.cobra
r2006 r2315 12 12 13 13 var _fileName as String? 14 var _lineNum as int? 14 15 var _token as IToken? 15 16 16 17 cue init(message as String?) 17 18 .init(nil, nil, message) 19 20 cue init(fileName as String, lineNum as int, message as String) 21 base.init(message) 22 _fileName, _lineNum = fileName, lineNum 18 23 19 24 cue init(fileName as String?, token as IToken?, message as String) … … 31 36 32 37 get hasSourceSite as bool is override 33 return _token is not nil38 return _token or (_fileName and _lineNum) 34 39 35 40 get fileName as String is override 36 return _ token.fileName41 return _fileName ? _token.fileName 37 42 38 43 get lineNum as int is override 39 return _ token.lineNum44 return _lineNum ? _token.lineNum 40 45 41 46 -
cobra/trunk/Source/Phases/Phase.cobra
r2188 r2315 1 class Phase i s abstract1 class Phase implements IComparable<of Phase> is abstract 2 2 """ 3 3 A phase of the compiler. … … 22 22 return .compiler.options 23 23 24 get order as int 25 """ 26 Subclasses can override to change their order with respect to other phases. 27 Consecutive phases in the initial list of phases are kept in sequence with a "stable sort". 28 Default is 100. 29 """ 30 return 100 31 32 pro stableOrder from var as int 33 """ 34 Used to implement a "stable sort". 35 """ 36 37 get willRunWithErrors as bool 38 """ 39 Returns true if the phase will run correctly even if previously run phases produced errors. 40 Typically, phases will not want to run with errors because the AST nodes will in an 41 incomplete state that the phase cannot rely on. Hence, the default is false. 42 However, subclasses may override to return true if appropriate. 43 """ 44 return false 45 24 46 get verbosity as int 25 47 return .compiler.verbosity 26 48 49 def compareTo(other as Phase) as int 50 diff = .order - other.order 51 if diff == 0, diff = .stableOrder - other.stableOrder 52 return diff 53 27 54 var _didSucceed as bool 28 55 -
cobra/trunk/Source/TestifyRunner.cobra
r2252 r2315 419 419 index = firstLine.indexOf('.warning.') 420 420 warning = firstLine.substring(index+9).trim.toLower 421 return _testifyHeadWarning(warning, compilerVerbosity, fileNames, options, verbose) 421 return _testifyHeadWarning(warning, false, compilerVerbosity, fileNames, options, verbose) 422 423 if firstLineInsensitive.startsWith('#.warning-lax.') 424 # deprecated: put warnings on the lines where they occur. the "hasInlineMessages" code above will detect them. 425 index = firstLine.indexOf('.warning-lax.') 426 warning = firstLine.substring(index+13).trim.toLower 427 return _testifyHeadWarning(warning, true, compilerVerbosity, fileNames, options, verbose) 422 428 423 429 return _testifyStd(compilerVerbosity, fileNames, options, verbose) … … 509 515 return 0 510 516 511 if firstLineInsensitive.startsWith('#.error.') or firstLineInsensitive.startsWith('#.warning.') 517 if firstLineInsensitive.startsWith('#.error.') or firstLineInsensitive.startsWith('#.warning.') or firstLineInsensitive.startsWith('#.warning-lax.') 512 518 # these are handled below 513 519 break … … 639 645 return 1 640 646 641 def _testifyHeadWarning(warning as String, compilerVerbosity as int, fileNames as IList<of String>,647 def _testifyHeadWarning(warning as String, lax as bool, compilerVerbosity as int, fileNames as IList<of String>, 642 648 options as OptionValues, verbose as bool) as int 643 649 # TODO: the following code both checks for warnings to be thrown as well as going through a list of warnings. Seems like it should just need to do one or the other. … … 646 652 c.testifyFilesNamed(fileNames, options, _resultsWriter to !, verbose) 647 653 catch StopCompilation 648 print 'Expecting warning substring: "[warning]"' 649 print 'But got errors.' 650 .failed 651 return 0 654 if not lax 655 print 'Expecting warning substring: "[warning]"' 656 print 'But got errors.' 657 .failed 658 return 0 652 659 catch exc as Exception 653 660 print 'Internal exception: [exc]'



