Changeset 1598

Show
Ignore:
Timestamp:
08/28/08 06:40:46 (3 months ago)
Author:
Chuck.Esterbrook
Message:

Fix a bug in extended initializers.
Also, make the helper methods for them private.

Location:
cobra/trunk
Files:
3 modified

Legend:

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

    r1591 r1598  
    14791479                """ 
    14801480                box = .compiler.curBox 
     1481                token = box.token.copy 
    14811482                paramsForDecl = List<of Param>() 
    14821483                argsForInitCall = List<of Expr>()  # args to pass to `Foo(arg0, arg1)` 
     
    14901491                                arg = arg.right 
    14911492                        else 
    1492                                 argsForInitCall.add(arg) 
     1493                                argsForInitCall.add(IdentifierExpr(token.copy('ID', 'arg[i]'))) 
    14931494                        paramsForDecl.add(Param(box.token.copy('ID', 'arg[i]'), arg.type)) 
    14941495                        i += 1 
    14951496                name = '_ch_ext_init_[.serialNum]'  # ch = class helper, ext = extended, init = initializer 
    1496                 token = box.token.copy 
    1497                 m = Method(token.copy('ID', name), box, name, paramsForDecl, _type, nil, ['shared'], AttributeList(), '') 
     1497                m = Method(token.copy('ID', name), box, name, paramsForDecl, _type, nil, ['shared', 'private'], AttributeList(), '') 
    14981498                m.locals.add(LocalVar(token.copy('ID', 'obj'), .type)) 
    14991499 
  • cobra/trunk/Source/SharpGenerator.cobra

    r1591 r1598  
    426426 
    427427        def writeSharpDef(sw as SharpWriter, parens as bool) is override 
    428                 if parens, sw.write('(') 
    429428                if _helperMethod 
    430429                        sw.write(_helperMethod.name + '(') 
     
    438437                        sw.write(')') 
    439438                else 
     439                        if parens, sw.write('(') 
    440440                        expr = _expr 
    441441                        isMethodSig = false 
     
    496496                                .writeSharpArgs(sw, ', ') 
    497497                                sw.write(')') 
    498                 if parens, sw.write(')') 
     498                        if parens, sw.write(')') 
    499499 
    500500        def writeSharpArgs(sw as SharpWriter) 
  • cobra/trunk/Tests/120-classes/320-construct-prop-set.cobra

    r1591 r1598  
    55                assert s.a == 1 
    66                assert s.b == 2 
     7 
    78                s = Stuff('a', b='b') 
    89                assert s.a == 'a' 
     10                assert s.b == 'b' 
     11 
     12                letters = 'aoeu' 
     13                s = Stuff(letters, b='b') 
     14                assert s.a == letters 
    915                assert s.b == 'b' 
    1016