Ticket #184: access-lc-namespace.patch
File access-lc-namespace.patch, 10.2 KB (added by hopscc, 15 years ago) |
---|
-
Source/TypeProxies.cobra
390 390 """ 391 391 # don't need to check "basic types" like int, bool, etc. here. the parser does those. 392 392 if name.isCapitalized 393 symbol = .compiler.symbolForName(name, true, false) # nested enum and class types are capitalized and can be members of the current class 393 symbol = .compiler.symbolForName(name, false) # nested enum and class types are capitalized and can be members of the current class 394 else if name == name.toLower # all lowercase 395 symbol = .compiler.symbolForName(name, false, true) 394 396 else 395 397 symbol = nil 396 398 if symbol is nil … … 399 401 if not name.isCapitalized 400 402 # not very sophisticated, but catches 'string', 'object', etc. 401 403 name = name.capitalized 402 symbol = .compiler.symbolForName(name, true,false)404 symbol = .compiler.symbolForName(name, false) 403 405 if symbol is not nil 404 406 if '<' in name # handle generics 405 407 # 'dictionary<of ' vs. 'Dictionary<of,>' … … 409 411 if symbol is nil 410 412 sugg = Compiler.suggestionFor(name) ? '' 411 413 if sugg == '' and not name.isCapitalized 412 other = .compiler.symbolForName(name.capitalized, true,false)414 other = .compiler.symbolForName(name.capitalized, false) 413 415 if other, sugg = name.capitalized 414 416 if sugg <> '', sugg = ' Try "[sugg]". Also, consider the -correct-source option (see cobra -h for details).' 415 417 .throwError('Cannot find type for "[_name]".[sugg]') -
Source/Expr.cobra
832 832 def _bindImp 833 833 base._bindImp 834 834 if not _definition 835 possible = .compiler.symbolForName(.name, true,false)835 possible = .compiler.symbolForName(.name, false) 836 836 if not possible 837 837 .throwError('Cannot locate enumeration type "[.name]".') 838 838 else if possible inherits EnumDecl … … 1002 1002 canBeUndottedMember = _name.canBeUndottedMemberName 1003 1003 if canBeUndottedMember 1004 1004 # assert .compiler.boxStack.count TODO: identifier expr is being used by PostCallExpr which is used for attribute calls 1005 _definition = .compiler.symbolForName(_name, canBeUndottedMember,false)1005 _definition = .compiler.symbolForName(_name, false) 1006 1006 else 1007 1007 # local var ref: foo 1008 1008 if .compiler.codeMemberStack.count # could be: var _x = y or: has foo 1009 1009 _definition = .compiler.findLocal(_name) 1010 1010 if _definition is nil 1011 _definition = .compiler.symbolForName(_name, false, false,true) # 3rd party DLLs have lowercase class names like iConnection1011 _definition = .compiler.symbolForName(_name, false, true) # 3rd party DLLs have lowercase class names like iConnection 1012 1012 if _definition is nil and not canBeUndottedMember 1013 1013 if _superNode inherits BinaryOpExpr 1014 1014 if _superNode.right is this … … 1615 1615 expr = .expr 1616 1616 1617 1617 if expr inherits IdentifierExpr 1618 if expr.name.startsWith('_') and not .compiler.symbolForName(expr.name, true,false) inherits BoxVar1618 if expr.name.startsWith('_') and not .compiler.symbolForName(expr.name, false) inherits BoxVar 1619 1619 # method invocation 1620 1620 # _foo(x) --> ._foo(x) 1621 1621 newCall = CallExpr(.token, .name, .args, true) … … 1777 1777 def _handleClassInitializer 1778 1778 initCall as Initializer? 1779 1779 if .args.count > 0 1780 theClass = .compiler.symbolForName(.name, true,false, true) to ClassOrStruct?1780 theClass = .compiler.symbolForName(.name, false, true) to ClassOrStruct? 1781 1781 if theClass is not nil 1782 1782 possibleCalls = theClass.memberForName("cue.init") 1783 1783 if possibleCalls is nil -
Source/Statements.cobra
60 60 usingExistingLocal = false 61 61 if canBeUndottedMember 62 62 assert .compiler.boxStack.count 63 definition = .compiler.symbolForName(ve.name, canBeUndottedMember,false) to passthrough63 definition = .compiler.symbolForName(ve.name, false) to passthrough 64 64 if definition is nil 65 65 ve.throwUnknownIdError 66 66 else -
Source/Compiler.cobra
832 832 _basicTypes.add(.intType(signed, size)) 833 833 return _basicTypes to ! 834 834 835 def symbolForName(name as String, canBeMember as bool,haveThis as bool) as IMember?836 return .symbolForName(name, canBeMember,haveThis, false)835 def symbolForName(name as String, haveThis as bool) as IMember? 836 return .symbolForName(name, haveThis, false) 837 837 838 def symbolForName(name as String, canBeMember as bool,haveThis as bool, isLowerOkay as bool) as IMember?838 def symbolForName(name as String, haveThis as bool, isLowerOkay as bool) as IMember? 839 839 """ 840 840 name - obvious. 841 canBeMember - the symbol can be a member of the current box842 TODO: can this be retired now that there is findLocal?843 841 haveThis - if false, symbols like methods, properties, etc. will not be returned while enums, nested classes, etc. could be. 842 isLowerOkay - true if a lowercase name (non capCased) is allowed. 844 843 """ 845 844 require 846 845 name.length … … 856 855 857 856 # check the current box which will ask its namespace which will ask its `use` directives 858 857 if _boxStack.count 859 #print '>> .compiler.symbolForName([name], [ canBeMember], [haveThis])'858 #print '>> .compiler.symbolForName([name], [haveThis])' 860 859 if not isLowerOkay and name[0].isLower 861 860 assert false, 'use findLocal instead. [name]' 862 861 return nil -
Source/Node.cobra
1146 1146 1147 1147 def findLocal(name as String) as AbstractLocalVar? 1148 1148 def suggestionForUnknown(word as String) as String? 1149 def symbolForName(name as String, canBeMember as bool,haveThis as bool) as IMember?1150 def symbolForName(name as String, canBeMember as bool,haveThis as bool, isLowerOkay as bool) as IMember?1149 def symbolForName(name as String, haveThis as bool) as IMember? 1150 def symbolForName(name as String, haveThis as bool, isLowerOkay as bool) as IMember? 1151 1151 1152 1152 1153 1153 ## Current objects -
Source/Attributes.cobra
56 56 .throwError('Expecting an attribute class instead of a [defi.englishName].') 57 57 else if _expr inherits PostCallExpr 58 58 name = _expr.name 59 if not name.endsWith('Attribute') and name.canBeUndottedMemberName and not .compiler.symbolForName(name, true,false)60 if .compiler.symbolForName(name+'Attribute', true,false)59 if not name.endsWith('Attribute') and name.canBeUndottedMemberName and not .compiler.symbolForName(name, false) 60 if .compiler.symbolForName(name+'Attribute', false) 61 61 _expr = PostCallExpr(_expr.token, IdentifierExpr(_expr.token, name+'Attribute'), _expr.args, isForAttribute=true) 62 62 else 63 63 _expr.isForAttribute = true -
Tests/720-libraries/400-other/lcase.cs
1 /* 2 lcase namespace in lib test - Library 3 cobra -t:lib lcase.cs 4 gmcs -t:library -out:lcase.dll lcase.cs 5 csc /t:library /out:lcase.dll lcase.cs 6 */ 7 namespace lcase { 8 public class A { 9 string _what = "class A"; 10 11 public int One = 1; 12 13 public string what { 14 get { return _what; } 15 set { _what = value;} 16 } 17 public string getWho() { 18 return "lc"; 19 } 20 } 21 } -
Tests/720-libraries/400-other/109-compile-lcase.cobra
1 # compile lowercase lib lcase.cs 2 class CobC 3 def main is shared 4 5 output = .runCobraExe('-t:lib lcase.cs') 6 try 7 assert 'Compilation succeeded' in output 8 assert File.exists('lcase.dll') 9 success 10 print 'lcase.cs compile' 11 12 def runCobraExe(args as String) as String is shared 13 p as System.Diagnostics.Process? 14 return CobraCore.runCobraExe(args, out p) 15 -
Tests/720-libraries/400-other/110-access-lc-namespace.cobra
1 # .args. -reference:./lcase 2 # Test access to classes/Types in a lowercase named namespace 3 # numbered lines were errors pre ticket:184 fix 4 use lcase 5 6 class Asub inherits lcase.A # /1 cannot find type for lcase.A 7 8 def main 9 a = lcase.A() 10 assert a.one == 1 11 a = A() 12 assert a.one == 1 13 14 aa as lcase.A = lcase.A() # /3 cannot find type for lcase.A 15 assert aa.one == 1 16 .x(aa) 17 18 assert aa.getWho == 'lc' 19 assert aa.what == 'class A' 20 aa.what = 'Ksrsly' 21 assert a.what == 'class A' 22 assert aa.what == 'Ksrsly' 23 24 def x(a as lcase.A) # /2 cannot find type for lcase.A 25 assert a.one == 1 26 -
Developer/IntermediateReleaseNotes.text
404 404 * Fixed: Numeric for expression broken for `get` expressions with types other than `int` ticket:158 405 405 406 406 * Fixed: Operators `?` and `?=` give error if left hand expression is not nilable. ticket:117 407 408 * Fixed: Better handling of access to items in lowercased namespaces (libs) : ticket:184 409