Changeset 1730
- Timestamp:
- 11/04/08 20:56:49 (2 months ago)
- Location:
- cobra/trunk
- Files:
-
- 9 modified
-
Source/BinaryOpExpr.cobra (modified) (5 diffs)
-
Source/Expr.cobra (modified) (1 diff)
-
Source/Indexer.cobra (modified) (1 diff)
-
Source/Members.cobra (modified) (4 diffs)
-
Source/Node.cobra (modified) (3 diffs)
-
Source/Property.cobra (modified) (1 diff)
-
Source/SharpGenerator.cobra (modified) (1 diff)
-
Source/Vars.cobra (modified) (7 diffs)
-
Tests/120-classes/705-implicit-this.cobra (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/BinaryOpExpr.cobra
r1729 r1730 50 50 return AssignExpr(opToken, op, left, right) 51 51 on 'DOT' 52 return DotExpr(opToken, op, left, right , false)52 return DotExpr(opToken, op, left, right) 53 53 on 'INHERITS' or 'IMPLEMENTS' 54 54 return InheritsExpr(opToken, op, left, right) … … 564 564 inherits BinaryOpExpr 565 565 implements IPotentialTypeExpr 566 """ 567 When creating a DotExpr, set .isImplicit to true if the original expression did not actually 568 contain a dot (.), but only implied it. For example: `_foo()` 569 """ 566 570 567 571 var _dotRightExpr as IDotRightExpr 568 var _isImplicit as bool 569 570 def init(opToken as IToken, op as String, left as Expr, right as Expr) 571 require 572 op == 'DOT' 573 right inherits IDotRightExpr 574 body 575 .init(opToken, op, left, right, false) 576 577 def init(opToken as IToken, op as String, left as Expr, right as Expr, isImplicit as bool) 572 573 def init(opToken as IToken, op as String, left as Expr, right as Expr) 578 574 require 579 575 op == 'DOT' … … 582 578 base.init(opToken, op, left, right) 583 579 _dotRightExpr = right to IDotRightExpr 584 _isImplicit = isImplicit585 580 586 581 get dotRight as IDotRightExpr … … 589 584 """ 590 585 return _dotRightExpr 591 592 pro isImplicit from var593 """594 True if the original expression did not actually contain a dot (.), but only implied it.595 For example: `_foo()`596 """597 586 598 587 def _bindImp … … 699 688 # try to use right.contains(left) 700 689 # this is more direct and offers speed up on some classes like Set 701 contains = DotExpr(.token, 'DOT', _right, CallExpr(.token, 'contains', List<of Expr>([_left]), true ))690 contains = DotExpr(.token, 'DOT', _right, CallExpr(.token, 'contains', List<of Expr>([_left]), true, isImplicit=true)) 702 691 try 703 692 contains.bindImp -
cobra/trunk/Source/Expr.cobra
r1729 r1730 1465 1465 # _foo(x) --> ._foo(x) 1466 1466 newCall = CallExpr(.token, .name, .args, true) 1467 dotted = DotExpr(.token, 'DOT', ThisLit(.token, isVisible=false), newCall, true,isVisible=false).bindImp1467 dotted = DotExpr(.token, 'DOT', ThisLit(.token, isVisible=false), newCall, isVisible=false).bindImp 1468 1468 _type = dotted.type to IType 1469 1469 _transformTo(dotted) -
cobra/trunk/Source/Indexer.cobra
r1645 r1730 80 80 81 81 if indexer.returnType 82 p = Param(t, indexer.returnType, true)82 p = Param(t, indexer.returnType, isImplicit=true) 83 83 else if indexer.returnTypeNode 84 p = Param(t, indexer.returnTypeNode, true)84 p = Param(t, indexer.returnTypeNode, isImplicit=true) 85 85 else 86 86 throw FallThroughException(indexer) -
cobra/trunk/Source/Members.cobra
r1729 r1730 1362 1362 var _codeMember as AbstractMethod 1363 1363 var _exprs as List<of Expr> 1364 var _isImplicit as bool # meaning the source code did not define this object1365 1364 1366 1365 def init(codeMember as AbstractMethod) 1367 1366 base.init(codeMember.token) 1368 _isImplicit = true1367 .isImplicit = true 1369 1368 _codeMember = codeMember 1370 1369 _exprs = List<of Expr>() … … 1379 1378 base.addMinFields 1380 1379 .addField('connectToken', _connectToken) 1381 .addField('isImplicit', _isImplicit)1382 1380 1383 1381 def addSubFields … … 1400 1398 return _codeMember.canHaveDetailedStackTrace and .compiler.options['contracts'] <> 'none' and not (.willInlineSharp and not .haveConditions) 1401 1399 1402 get isImplicit from var1403 1404 1400 def _bindImp is override 1405 1401 base._bindImp … … 1423 1419 """ 1424 1420 isNames = _codeMember.isNames 1425 if not _isImplicit1421 if not .isImplicit 1426 1422 if _connectToken 1427 1423 if 'override' not in isNames -
cobra/trunk/Source/Node.cobra
r1711 r1730 341 341 var _serialNum as int is private 342 342 343 var _isImplicit as bool is private 344 343 345 var _didStartBindInh as bool is private 344 346 var _didStartBindInt as bool is private … … 387 389 388 390 get serialNum from var 391 392 pro isImplicit from var 393 """ 394 Indicates if the source code defined this node. Defaults to false. 395 Implicit nodes can include implicit symbols like `value` and nodes defined for _transfromTo purposes. 396 Checking .isImplicit is used for various purposes including avoiding false warnings. 397 Setting .isImplicit to true is only required in cases where it affects the compiler. 398 """ 389 399 390 400 def setSerialNum(serialNum as int) is protected … … 753 763 Subclasses should override to add minimal fields. 754 764 """ 755 if . didStartBindInh756 .addField('didStartBindInh', .didStartBindInh) 757 if . isBindingInh758 .addField('isBindingInh', .isBindingInh)765 if .isImplicit, .addField('isImplicit', .isImplicit) 766 767 if .didStartBindInh, .addField('didStartBindInh', .didStartBindInh) 768 if .isBindingInh, .addField('isBindingInh', .isBindingInh) 759 769 .addField('didBindInh', .didBindInh) 760 770 761 if .didStartBindInt 762 .addField('didStartBindInt', .didStartBindInt) 763 if .isBindingInt 764 .addField('isBindingInt', .isBindingInt) 771 if .didStartBindInt, .addField('didStartBindInt', .didStartBindInt) 772 if .isBindingInt, .addField('isBindingInt', .isBindingInt) 765 773 .addField('didBindInt', .didBindInt) 766 774 767 if .didStartBindImp 768 .addField('didStartBindImp', .didStartBindImp) 769 if .isBindingImp 770 .addField('isBindingImp', .isBindingImp) 775 if .didStartBindImp, .addField('didStartBindImp', .didStartBindImp) 776 if .isBindingImp, .addField('isBindingImp', .isBindingImp) 771 777 .addField('didBindImp', .didBindImp) 772 778 -
cobra/trunk/Source/Property.cobra
r1645 r1730 58 58 59 59 if prop.returnType 60 p = Param(t, prop.returnType, true)60 p = Param(t, prop.returnType, isImplicit=true) 61 61 else if prop.returnTypeNode 62 p = Param(t, prop.returnTypeNode, true)62 p = Param(t, prop.returnTypeNode, isImplicit=true) 63 63 else 64 64 throw FallThroughException(prop) -
cobra/trunk/Source/SharpGenerator.cobra
r1718 r1730 1255 1255 decl.sharpExtraIsNames = {'static'} 1256 1256 if decl inherits AbstractMethod 1257 decl.params.insert(0, Param('_lh_this', .extendedBox, true).bindAll to Param)1257 decl.params.insert(0, Param('_lh_this', .extendedBox, isImplicit=true).bindAll to Param) 1258 1258 base.writeSharpDef(sw) 1259 1259 -
cobra/trunk/Source/Vars.cobra
r1713 r1730 36 36 var _type as IType? 37 37 var _typeNode as ITypeProxy? 38 var _isImplicit as bool39 38 var _isTracked as bool 40 39 var _ifInheritsStack = Stack<of IType>() … … 43 42 var _useSharpNameStack = Stack<of String>() # for if-inherits 44 43 45 def init(token as IToken, type as IType , isImplicit as bool)44 def init(token as IToken, type as IType) 46 45 base.init(token, token.text) 47 46 _type = type 48 47 assert not _type inherits NameSpace # TODO: can remove with NameSpace is no longer an IType 49 _init (isImplicit)50 51 def init(token as IToken, typeNode as ITypeProxy , isImplicit as bool)48 _init 49 50 def init(token as IToken, typeNode as ITypeProxy) 52 51 base.init(token, token.text) 53 52 _typeNode = typeNode 54 _init (isImplicit)53 _init 55 54 56 55 def init(name as String, typeNode as ITypeProxy) 57 .init(name, typeNode, false)58 59 def init(name as String, typeNode as ITypeProxy, isImplicit as bool)60 56 base.init(name) 61 57 _typeNode = typeNode 62 _init(isImplicit) 63 64 def _init(isImplicit as bool) 65 _isImplicit = isImplicit 58 _init 59 60 def _init 66 61 _isTracked = false 67 if _isImplicit62 if .isImplicit 68 63 sharpPrefix = '' 69 64 else if Utils.isSharpKeyWord(.name) … … 80 75 pro isAssignedTo from var 81 76 82 get isImplicit from var83 84 77 pro isTracked from var 85 78 … … 88 81 def addMinFields 89 82 base.addMinFields 90 if _isImplicit91 .addField('isImplicit', _isImplicit)92 83 .addField('isTracked', _isTracked) 93 84 … … 176 167 177 168 def init(token as IToken, type as IType) 178 .init(token, type, false)169 base.init(token, type) 179 170 180 171 def init(token as IToken, typeNode as ITypeProxy) 181 .init(token, typeNode, false) 182 183 def init(token as IToken, type as IType, isImplicit as bool) 184 base.init(token, type, isImplicit) 185 186 def init(token as IToken, typeNode as ITypeProxy, isImplicit as bool) 187 base.init(token, typeNode, isImplicit) 172 base.init(token, typeNode) 188 173 189 174 def init(name as String, typeNode as ITypeProxy) 190 175 base.init(name, typeNode) 191 192 def init(name as String, typeNode as ITypeProxy, isImplicit as bool)193 base.init(name, typeNode, isImplicit)194 176 195 177 get englishName as String is override … … 227 209 228 210 def init(token as IToken, type as IType) 229 .init(token, type, false)211 base.init(token, type) 230 212 231 213 def init(token as IToken, typeNode as ITypeProxy) 232 .init(token, typeNode, false) 233 234 def init(token as IToken, type as IType, isImplicit as bool) 235 base.init(token, type as IType, isImplicit) 236 237 def init(token as IToken, typeNode as ITypeProxy, isImplicit as bool) 238 base.init(token, typeNode, isImplicit) 214 base.init(token, typeNode) 239 215 240 216 def addMinFields … … 254 230 255 231 def init(token as IToken, codePart as AbstractMethod) 256 base.init(_makeToken(token, codePart), codePart.resultType, true) 232 base.init(_makeToken(token, codePart), codePart.resultType) 233 .isImplicit = true 257 234 _sharpName = codePart.sharpResultVarName 258 235 -
cobra/trunk/Tests/120-classes/705-implicit-this.cobra
r1181 r1730 26 26 def test 27 27 .setXY(1, 2) 28 _underscoredDoesNotRequireDot ()28 _underscoredDoesNotRequireDot 29 29 assert .equals(1, 2) 30 30 assert .sum==3
