Changeset 1582

Show
Ignore:
Timestamp:
08/18/08 11:40:51 (3 months ago)
Author:
Chuck.Esterbrook
Message:

Fix a bug in partial class support.

Location:
cobra/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/CobraParser.cobra

    r1574 r1582  
    25292529                        finally 
    25302530                                .opStack.pop 
    2531                         return BinaryOpExpr.make(token to !, 'DOT', ThisLit(token, .curBox), expr) 
     2531                        return BinaryOpExpr.make(token to !, 'DOT', ThisLit(token), expr) 
    25322532                else if peek=='NIL' 
    25332533                        return NilLiteral(.grab) 
     
    25372537                        return BoolLit(.grab) 
    25382538                else if peek=='THIS' 
    2539                         return ThisLit(.grab, .curBox) 
     2539                        return ThisLit(.grab) 
    25402540                else if peek=='BASE' 
    2541                         return BaseLit(.grab, .curBox) 
     2541                        return BaseLit(.grab) 
    25422542                else if peek=='VAR' 
    25432543                        assert _curCodePart 
  • cobra/trunk/Source/Expr.cobra

    r1581 r1582  
    17481748                                # _foo(x) --> ._foo(x) 
    17491749                                newCall = CallExpr(.token, .name, .args) 
    1750                                 dotted = DotExpr(.token, 'DOT', ThisLit(.token, .curCodeMember.box), newCall, true).bindImp 
     1750                                dotted = DotExpr(.token, 'DOT', ThisLit(.token), newCall, true).bindImp 
    17511751                                _type = dotted.type to IType 
    17521752                                _transformTo(dotted) 
     
    29422942 
    29432943class ThisOrBaseLit 
     2944        is abstract 
    29442945        inherits AtomicLiteral 
    2945  
    2946         def init(token as IToken, box as Box) 
    2947                 base.init(token) 
    2948                 _type = box 
     2946        """ 
     2947        The "current box" used to be passed to .init rather than referenced in _bindImp, but that 
     2948        didn't work well with partial classes. Also, it's not necessary to creating a ThisOrBaseLit. 
     2949        """ 
     2950 
     2951        def init(token as IToken) 
     2952                base.init(token) 
    29492953 
    29502954        def _bindImp 
    29512955                base._bindImp 
     2956                _type = .compiler.curBox 
    29522957                if _type inherits Extension 
    29532958                        _type = _type.extendedBox 
     
    29572962        inherits ThisOrBaseLit 
    29582963 
    2959         def init(token as IToken, box as Box) 
    2960                 base.init(token, box) 
     2964        def init(token as IToken) 
     2965                base.init(token) 
    29612966 
    29622967        def checkType is override 
     
    29842989        # "this" (unless C# allows that which I doubt) 
    29852990 
    2986         def init(token as IToken, box as Box) 
    2987                 base.init(token, box) 
     2991        def init(token as IToken) 
     2992                base.init(token) 
    29882993 
    29892994        get isExplicit as bool 
  • cobra/trunk/Source/Members.cobra

    r1573 r1582  
    11521152                                                                expr = IdentifierExpr(token, decl) to Expr 
    11531153                                                        else 
    1154                                                                 expr = BinaryOpExpr.make(token, 'DOT', ThisLit(token, .box), MemberExpr(token, decl.name)) to Expr 
     1154                                                                expr = BinaryOpExpr.make(token, 'DOT', ThisLit(token), MemberExpr(token, decl.name)) to Expr 
    11551155                                                        stmts.add(AssertStmt(token, IsNotNilExpr(token, expr), nil)) 
    11561156                                if stmts.count 
  • cobra/trunk/Source/Statements.cobra

    r1576 r1582  
    12681268                                else 
    12691269                                        # since we don't have 'this', try prepending 'this' 
    1270                                         args.insert(0, ThisLit(.token, .compiler.boxStack.peek).bindImp) 
     1270                                        args.insert(0, ThisLit(.token).bindImp) 
    12711271                        else if args.count == 0 and params.count == 2 
    12721272                                # missing both 'this' and event args 
    1273                                 args.add(ThisLit(.token, .compiler.boxStack.peek).bindImp) 
     1273                                args.add(ThisLit(.token).bindImp) 
    12741274                                args.add(_postCallForType(params[params.count-1].type)) 
    12751275                        else 
  • cobra/trunk/Tests/200-misc/820-partial/110-partial-multi-file-1.cobra

    r1573 r1582  
    1010 
    1111        def over(i as int) as int is shared 
     12                assert .foo == 'foo' 
    1213                return i * 2 
     14 
     15        def bar as String is shared 
     16                return 'bar' 
  • cobra/trunk/Tests/200-misc/820-partial/112-partial-multi-file-2.cobra

    r1573 r1582  
    55         
    66        def foo as String is shared 
     7                assert .bar == 'bar' 
    78                return 'foo' 
    89