Changeset 1729
- Timestamp:
- 11/04/08 20:00:30 (2 months ago)
- Location:
- cobra/trunk
- Files:
-
- 6 modified
-
Developer/IntermediateReleaseNotes.text (modified) (1 diff)
-
Source/BinaryOpExpr.cobra (modified) (1 diff)
-
Source/CobraParser.cobra (modified) (1 diff)
-
Source/Expr.cobra (modified) (4 diffs)
-
Source/Members.cobra (modified) (1 diff)
-
Tests/120-classes/400-methods.cobra (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Developer/IntermediateReleaseNotes.text
r1728 r1729 199 199 200 200 * Fixed: Assigning values less than zero to variables of type int8 and int16 gives a false compilation error. ticket:45 201 202 * Fixed: Invoking _someMethod without parens in an `if` statement or other expression causes a false compilation error. -
cobra/trunk/Source/BinaryOpExpr.cobra
r1717 r1729 601 601 .compiler.curCodeMember.usesBase # use of base implies override if the containing member is not already marked new 602 602 else if _left inherits ThisLit 603 if _left.is Explicit # CC: combine above603 if _left.isVisible 604 604 .compiler.warning(this, 'An explicit "this" literal is unnecessary for accessing members of the current object. You can remove "this".') 605 else if _right inherits MemberExpr 606 if _right.name.startsWith('_') 607 .compiler.warning(this, 'An explicit dot (".") is unnecessary for accessing underscored members of the current object. You can remove ".".') 605 else if .isVisible and .dotRight.name.startsWith('_') 606 .compiler.warning(this, 'An explicit dot (".") is unnecessary for accessing underscored members of the current object. You can remove ".".') 608 607 if not _type 609 608 assert _right.type -
cobra/trunk/Source/CobraParser.cobra
r1728 r1729 2671 2671 finally 2672 2672 .opStack.pop 2673 return BinaryOpExpr.make(token to !, 'DOT', ThisLit(token ), expr)2673 return BinaryOpExpr.make(token to !, 'DOT', ThisLit(token, isVisible=false), expr) 2674 2674 else if peek=='NIL' 2675 2675 return NilLiteral(.grab) -
cobra/trunk/Source/Expr.cobra
r1717 r1729 48 48 var _contextType as IType? 49 49 var _isParened as bool 50 var _isVisible as bool 50 51 var _argumentLabel = ArgumentLabel.None 51 52 52 53 def init(token as IToken) 53 54 base.init(token) 55 _isVisible = true 54 56 55 57 def addRefFields is override … … 60 62 """ 61 63 Indicates the label for an argument such as 'out' or 'inout'. 64 """ 65 66 pro isVisible from var 67 """ 68 Indicates if the expression is visible in the source code. 69 Defaults to true. 70 71 An expression may not be if it was generated by means other than parsing, 72 usually during _bindImp for the purpose of a _transformTo call. 73 It's not always imperative to set this to false--only in cases where it's needed. 74 Those cases are typically warnings centered around coding style ("favor succinct forms"). 62 75 """ 63 76 … … 871 884 if _type is nil 872 885 if _definition 873 _type = _definition.typeForIdentifier 874 _receiverType = _definition.typeForReceiver 886 if _definition inherits AbstractMethod or _definition inherits MemberOverload 887 _transformTo(DotExpr(.token, 'DOT', ThisLit(.token, isVisible=false), MemberExpr(.token), isVisible=false).bindAll) 888 else 889 _type = _definition.typeForIdentifier 890 _receiverType = _definition.typeForReceiver 875 891 else 876 892 if .binarySuperNode inherits AssignExpr and this is .binarySuperNode.left … … 1449 1465 # _foo(x) --> ._foo(x) 1450 1466 newCall = CallExpr(.token, .name, .args, true) 1451 dotted = DotExpr(.token, 'DOT', ThisLit(.token ), newCall, true).bindImp1467 dotted = DotExpr(.token, 'DOT', ThisLit(.token, isVisible=false), newCall, true, isVisible=false).bindImp 1452 1468 _type = dotted.type to IType 1453 1469 _transformTo(dotted) -
cobra/trunk/Source/Members.cobra
r1713 r1729 828 828 expr = IdentifierExpr(token, decl) to Expr 829 829 else 830 expr = BinaryOpExpr.make(token, 'DOT', ThisLit(token), MemberExpr(token, decl.name)) to Expr830 expr = DotExpr(token, 'DOT', ThisLit(token, isVisible=false), MemberExpr(token, decl.name), isVisible=false) to Expr 831 831 stmts.add(AssertStmt(token, IsNotNilExpr(token, expr), nil)) 832 832 if stmts.count -
cobra/trunk/Tests/120-classes/400-methods.cobra
r1181 r1729 17 17 p1.setXY(1, 2) 18 18 p2.setXY(1, 2) 19 p1.moreTests 20 21 def moreTests 22 .testInvocations 23 .testUnderInvocations 19 24 20 25 def setXY(x as int, y as int) 21 26 _x = x 22 27 _y = y 28 29 def x as int 30 # poor example as this would normally be a property 31 # but we're testing methods in this file, not properties 32 return _x 33 34 def y as int 35 return _y 23 36 24 37 def someInt as int … … 42 55 def someObject3 as Point 43 56 return Point() 57 58 def testInvocations 59 assert .someInt == 5 60 assert .someBool 61 assert .someString1 == 'aoeu' 62 assert .someString2 == '' 63 assert .someObject1 == 'aoeu' 64 assert .someObject2 == 5 65 assert .someObject3.x == 0 and .someObject3.y == 0 66 67 def _someInt as int 68 return 5 69 70 def _someBool as bool 71 return true 72 73 def _someString1 as String 74 return 'aoeu' 75 76 def _someString2 as String 77 return '' 78 79 def _someObject1 as Object 80 return 'aoeu' 81 82 def _someObject2 as Object 83 return 5 84 85 def _someObject3 as Point 86 return Point() 87 88 def testUnderInvocations 89 assert _someInt == 5 90 assert _someBool 91 assert _someString1 == 'aoeu' 92 assert _someString2 == '' 93 assert _someObject1 == 'aoeu' 94 assert _someObject2 == 5 95 assert _someObject3.x == 0 and .someObject3.y == 0
