Changeset 1766
- Timestamp:
- 11/15/08 20:18:22 (8 weeks ago)
- Location:
- cobra/trunk/Source
- Files:
-
- 3 modified
-
BackEndClr/SharpGenerator.cobra (modified) (3 diffs)
-
BinaryOpExpr.cobra (modified) (6 diffs)
-
Expr.cobra (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/BackEndClr/SharpGenerator.cobra
r1764 r1766 4304 4304 # Given Cobra "A.B.C()" where C is a class/type/struct, then the C# needs to be "new A.B.C()" 4305 4305 # (But stuff like this makes me wonder if the ASTs should be doing some transformations, like collapsing qualified types.) 4306 if _dotRightExpr.member inherits BoxMember4307 backing = (_dotRightExpr.member to BoxMember).sharedMethodBacking4306 if _dotRightExpr.memberDefinition inherits BoxMember 4307 backing = _dotRightExpr.definition.sharedMethodBacking 4308 4308 if backing 4309 4309 # example: Cobra: c.isUpper C#: char.IsUpper(c) 4310 4310 # also used for extension methods under .NET 2.0 4311 4311 sw.write(backing+'(') 4312 if not (_dotRightExpr.member to BoxMember).sharedMethodBackingIsAlias # guard against Cobra "decimal.parse('5.0')" --> C# "Decimal.Parse(decimal, "5.0")"4312 if not (_dotRightExpr.memberDefinition to BoxMember).sharedMethodBackingIsAlias # guard against Cobra "decimal.parse('5.0')" --> C# "Decimal.Parse(decimal, "5.0")" 4313 4313 _left.writeSharpDef(sw, false) 4314 4314 sep = ', ' … … 4326 4326 writeThis = true 4327 4327 if _left inherits ThisLit 4328 if _right inherits CallExpr 4329 writeThis = not _right.memberDefinition.isShared 4330 else if _right inherits MemberExpr 4331 writeThis = not _right.memberDefinition.isShared 4328 writeThis = not _dotRightExpr.memberDefinition.isShared 4332 4329 else if .curCodeMember inherits Initializer and _right inherits IDotRightExpr and (_right to IDotRightExpr).name == 'init' and _left inherits ThisOrBaseLit 4333 4330 # Well, in practice this doesn't really happen because Constructer.innerWriteSharpDef usurps the code gen for base calls … … 4407 4404 # x to? string? --> (x as String) 4408 4405 right = .right 4409 if right inherits TypeExpr 4410 t = right.containedType to ! 4411 else if right inherits IdentifierExpr 4412 t = right.namedDefinition to IType 4413 else 4414 throw FallThroughException(t) 4415 # TODO?: t = t.realType 4416 # assert t inherits IType 4417 if t inherits NilableType 4418 t = t.theWrappedType 4406 t = right.definition to IType 4407 if t inherits NilableType, t = t.theWrappedType 4419 4408 typeSharpRef = t.sharpRef 4420 4409 if t.isReference -
cobra/trunk/Source/BinaryOpExpr.cobra
r1763 r1766 556 556 """ 557 557 get name as String 558 get member as IMember?558 get memberDefinition as IMember? 559 559 get args as List<of Expr> 560 560 … … 613 613 if _left inherits IdentifierExpr # TODO: seems flawed. The error below should take place if left is a DotExpr 614 614 if _left.namedDefinition inherits Box # CC: combine with above if statement 615 if _dotRightExpr.member is not nil and not _dotRightExpr.member.isShared # when _dotRightExpr.memberis nil, it's a nested type615 if _dotRightExpr.memberDefinition is not nil and not _dotRightExpr.memberDefinition.isShared # when _dotRightExpr.memberDefinition is nil, it's a nested type 616 616 if _dotRightExpr.name == 'init' 617 617 # hack to support Application.init in ../HowTo/390-GTK.cobra … … 621 621 .throwError('Cannot access instance member "[_dotRightExpr.name]" on type "[_left.name]". Make the member "shared" or create an instance of the type.') 622 622 if _left inherits ThisOrBaseLit 623 if .curCodeMember and .curCodeMember.isShared and not _dotRightExpr.member .isShared # .curCodeMember is nil when bind imp'ing on var init exprs like "var _x = someExpr"623 if .curCodeMember and .curCodeMember.isShared and not _dotRightExpr.memberDefinition.isShared # .curCodeMember is nil when bind imp'ing on var init exprs like "var _x = someExpr" 624 624 .throwError('Cannot access instance member "[_dotRightExpr.name]" from the current shared member. Make the member "shared" or create an instance of the type.') 625 625 # Check for qualified type such as Foo.Bar … … 636 636 _transformTo(pc) 637 637 else 638 assert not _dotRightExpr.member inherits MemberOverload638 assert not _dotRightExpr.memberDefinition inherits MemberOverload 639 639 640 640 def afterStatementBindImp … … 643 643 # TODO: inheritance 644 644 # TODO: test on DLLs 645 member = _dotRightExpr.member 645 member = _dotRightExpr.memberDefinition 646 646 if member inherits MemberOverload 647 647 member = member.members[0] … … 768 768 else if defi inherits GenericParam 769 769 pass 770 else if defi inherits IType # int, decimal, etc. 771 if .op <> 'INHERITS', .throwError('Use the "inherits" operator when testing objects against structs.') 770 772 else if defi 771 773 .throwError('Cannot test "[.op.toLower]" against a [defi.englishName].') -
cobra/trunk/Source/Expr.cobra
r1765 r1766 428 428 429 429 get memberDefinition from _definition 430 431 get member as IMember?432 return _definition to? IMember433 430 434 431 def _bindImp is override … … 1294 1291 """ 1295 1292 1296 get member as IMember?1297 return _definition1298 1299 1293 get isCalling as bool is override 1300 1294 assert _definition … … 2003 1997 _receiverType = type 2004 1998 1999 get definition is override 2000 return _containedType 2001 2005 2002 get hasError as bool is override 2006 2003 return base.hasError or (.typeNode and .typeNode.hasError)
