Ticket #152: ticket152.patch
File ticket152.patch, 4.0 KB (added by eric.sellon, 15 years ago) |
---|
-
Source/CobraParser.cobra
492 492 if fileName.endsWith('.dll') or fileName.endsWith('.exe') 493 493 .throwError('Do not include the extension in the file name.') 494 494 .endOfLine 495 return UseDirective(token, names, fileName )495 return UseDirective(token, names, fileName, true) 496 496 497 497 var _syntaxForClassInheritanceMsg = 'The syntax for inheritance is to put "inherits BaseClass" on the following line, indented.' 498 498 -
Source/Compiler.cobra
761 761 # try system wide (GAC) 762 762 if reference.endsWith('.dll'), reference = reference[:-4] 763 763 referredAss = Utils.loadWithPartialName(reference) 764 reference += '.dll' # restore to original value 764 if referredAss is nil, return false 765 reference = referredAss.location 765 766 # TODO: handle all the exceptions from Assembly.loadFrom 766 767 if referredAss 767 768 for dependency in referredAss.getReferencedAssemblies -
Source/NameSpace.cobra
374 374 var _boundNameSpace as NameSpace? 375 375 var _fullName as String 376 376 var _fileName as String 377 var _explicitUses as bool 377 378 378 379 cue init(token as IToken, nameParts as List<of String>) 379 .init(token, nameParts, '' )380 .init(token, nameParts, '', false) 380 381 381 382 cue init(token as IToken, nameParts as List<of String>, fileName as String?) 383 .init(token, nameParts, fileName, false) 384 385 cue init(token as IToken, nameParts as List<of String>, fileName as String?, explicitUses as bool) 382 386 base.init(token) 383 387 _nameParts = nameParts 384 388 _fullName = nameParts.join('.') 385 389 _fileName = fileName ? '' 390 _explicitUses = explicitUses 386 391 387 392 def addMinFields 388 393 base.addMinFields -
Source/Phases/BindUsePhase.cobra
66 66 _bindUse(false) 67 67 68 68 def _bindUse(didAutoLoad as bool) 69 ignoreError = false 69 70 curNS = .compiler.globalNS to ? 70 71 for name in _nameParts 71 72 curNS = curNS.subNameSpaceForName(name) 72 73 if curNS is nil, break 74 if _explicitUses 75 # since this was an explicit uses directive, we need to make 76 # extra sure that we try to load a reference for it 77 _explicitUses = false # do not want to take this path again for this UseDirective 78 if curNS is not nil 79 # errors can be ignored because this namespace has already been loaded 80 ignoreError = true 81 curNS = nil # force reference attempt 73 82 if curNS is nil and not didAutoLoad 74 83 if _fileName <> '' 75 84 if .compiler.loadReference(_fileName + '.dll') … … 78 87 .throwError('Cannot find namespace "[_fullName]" in library "[_fileName]".') 79 88 return 80 89 else 90 if ignoreError 91 _bindUse(true) 92 return 81 93 .throwError('Cannot find library file "[_fileName]".') 82 94 else 83 95 if _fullName.endsWith('.dll') … … 88 100 .throwError('Cannot find namespace "[_fullName]" in loaded library "[_fullName]".') 89 101 return 90 102 else 103 if ignoreError 104 _bindUse(true) 105 return 91 106 # compute how far is valid, but only here where it's needed for the error message 92 107 partialName = '' 93 108 curNS = .compiler.globalNS to ? -
Tests/110-basics-two/500-namespaces/201-use.cobra
1 use System.Windows.Forms 2 use System.Drawing 3 4 class Program 5 6 def main is shared 7 print Color.red