Changeset 331

Show
Ignore:
Timestamp:
07/19/08 23:11:38 (1 month ago)
Author:
JarrettBillingsley
Message:

Updated to DMD 1.033 and Tango trunk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/v2new/minid/ast.d

    r330 r331  
    143143    "SuperCallExp", 
    144144    "RawNamespaceExp", 
     145    "InternalArrayComp", 
     146    "InternalTableComp", 
    145147 
    146148    "ForeachComprehension", 
     
    10021004    to "x".  This member may be null, in which case there is no variable there. 
    10031005    */ 
    1004     public Identifier condVar; 
     1006    public IdentExp condVar; 
    10051007     
    10061008    /** 
     
    10221024    /** 
    10231025    */ 
    1024     public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Identifier condVar, Expression condition, Statement ifBody, Statement elseBody) 
     1026    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, IdentExp condVar, Expression condition, Statement ifBody, Statement elseBody) 
    10251027    { 
    10261028        super(c, location, endLocation, AstTag.IfStmt); 
     
    10431045    to "x".  This member may be null, in which case there is no variable there. 
    10441046    */ 
    1045     public Identifier condVar; 
     1047    public IdentExp condVar; 
    10461048     
    10471049    /** 
     
    10571059    /** 
    10581060    */ 
    1059     public this(ICompiler c, CompileLoc location, Identifier condVar, Expression condition, Statement code) 
     1061    public this(ICompiler c, CompileLoc location, IdentExp condVar, Expression condition, Statement code) 
    10601062    { 
    10611063        super(c, location, code.endLocation, AstTag.WhileStmt); 
     
    31433145        this.parent = parent; 
    31443146        this.attrs = attrs; 
     3147    } 
     3148} 
     3149 
     3150/** 
     3151An internal AST node that is what TableComprehensions get transformed into during the semantic pass. 
     3152*/ 
     3153class InternalTableComp : PrimaryExp 
     3154{ 
     3155    /** 
     3156    */ 
     3157    public Statement loop; 
     3158 
     3159    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement loop) 
     3160    { 
     3161        super(c, location, endLocation, AstTag.InternalTableComp); 
     3162        this.loop = loop; 
     3163    } 
     3164} 
     3165 
     3166/** 
     3167An internal AST node that is what ArrayComprehensions get transformed into during the semantic pass. 
     3168*/ 
     3169class InternalArrayComp : PrimaryExp 
     3170{ 
     3171    /** 
     3172    */ 
     3173    public Statement loop; 
     3174 
     3175    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement loop) 
     3176    { 
     3177        super(c, location, endLocation, AstTag.InternalArrayComp); 
     3178        this.loop = loop; 
    31453179    } 
    31463180} 
  • branches/v2new/minid/baselib.d

    r327 r331  
    2525 
    2626import Integer = tango.text.convert.Integer; 
     27import tango.io.Buffer; 
    2728import tango.io.Console; 
    28 import tango.io.GrowBuffer; 
    2929import tango.io.Print; 
    3030import tango.io.Stdout; 
     
    499499        if(isInt(t, 1)) 
    500500        { 
    501             char style = 'd'
     501            dchar[1] style = "d"
    502502 
    503503            if(numParams > 1) 
    504                 style = getChar(t, 2); 
     504                style[0] = getChar(t, 2); 
    505505 
    506506            dchar[80] buffer = void; 
    507             pushString(t, Integer.format(buffer, getInt(t, 1), cast(Integer.Style)style)); // TODO: make this safe 
     507            pushString(t, Integer.format(buffer, getInt(t, 1), style)); // TODO: make this safe 
    508508        } 
    509509        else 
  • branches/v2new/minid/compiler.d

    r330 r331  
    8585    ~this() 
    8686    { 
    87         for(auto n = mHead, next = n.next; n !is null; n = next) 
    88         { 
     87        for(auto n = mHead; n !is null; ) 
     88        { 
     89            auto next = n.next; 
     90 
    8991            n.cleanup(t.vm.alloc); 
    9092            auto arr = n.toVoidArray(); 
    9193            t.vm.alloc.freeArray(arr); 
    9294 
    93             next = n.next; 
     95            n = next; 
    9496        } 
    9597 
  • branches/v2new/minid/interpreter.d

    r329 r331  
    24162416            return false; 
    24172417    } 
    2418  
    2419     assert(false); 
    24202418} 
    24212419 
     
    29322930        default: assert(false); 
    29332931    } 
    2934  
    2935     assert(false); 
    29362932} 
    29372933 
     
    30353031            } 
    30363032    } 
    3037  
    3038     assert(false); 
    30393033} 
    30403034 
     
    30883082            return ret; 
    30893083    } 
    3090      
    3091     assert(false); 
    30923084} 
    30933085 
     
    43014293            return getMethod(t, v.type, name); 
    43024294    } 
    4303  
    4304     assert(false); 
    43054295} 
    43064296 
     
    43294319            return getMethod(t, obj.type, name); 
    43304320    } 
    4331  
    4332     assert(false); 
    43334321} 
    43344322 
     
    44684456            return callPrologue2(t, method, slot, numReturns, slot + 1, numParams, proto); 
    44694457    } 
    4470  
    4471     assert(false); 
    44724458} 
    44734459 
  • branches/v2new/minid/lexer.d

    r329 r331  
    288288                return false; 
    289289        } 
    290  
    291         assert(false); 
    292290    } 
    293291     
  • branches/v2new/minid/opcodes.d

    r319 r331  
    396396            default:                 return Format.convert("??? opcode = {}", opcode); 
    397397        } 
    398          
    399         assert(false); 
    400398    } 
    401399     
  • branches/v2new/minid/parser.d

    r329 r331  
    5757            return stringValue; 
    5858    } 
    59      
     59 
    6060    /** 
    6161    */ 
     
    11261126        l.expect(Token.LParen); 
    11271127 
    1128         Identifier condVar; 
     1128        IdentExp condVar; 
    11291129 
    11301130        if(l.type == Token.Local) 
    11311131        { 
    11321132            l.next(); 
    1133             condVar = parseIdentifier(); 
     1133            condVar = parseIdentExp(); 
    11341134            l.expect(Token.Assign); 
    11351135        } 
     
    13981398        l.expect(Token.LParen); 
    13991399 
    1400         Identifier condVar; 
     1400        IdentExp condVar; 
    14011401 
    14021402        if(l.type == Token.Local) 
    14031403        { 
    14041404            l.next(); 
    1405             condVar = parseIdentifier(); 
     1405            condVar = parseIdentExp(); 
    14061406            l.expect(Token.Assign); 
    14071407        } 
     
    15321532            "default: assert(false, \"OpEqExp parse switch\");" 
    15331533        "}"); 
    1534  
    1535         assert(false); 
    15361534    } 
    15371535 
     
    24742472            } 
    24752473        } 
    2476          
    2477         assert(false); 
    24782474    } 
    24792475     
     
    26792675    private Identifier dummyForeachIndex(CompileLoc loc) 
    26802676    { 
    2681         dchar[50] dest; 
    2682         return new(c) Identifier(c, loc, c.newString(c.thread.vm.formatter.sprint(dest, "__dummy{}", dummyNameCounter++))); 
     2677        pushFormat(c.thread, "__dummy{}", dummyNameCounter++); 
     2678        auto str = c.newString(getString(c.thread, -1)); 
     2679        pop(c.thread); 
     2680        return new(c) Identifier(c, loc, str); 
    26832681    } 
    26842682     
    26852683    private Identifier dummyFuncLiteralName(CompileLoc loc) 
    26862684    { 
    2687         dchar[128] dest; 
    2688         return new(c) Identifier(c, loc, c.newString(c.thread.vm.formatter.sprint(dest, "<literal at {}({}:{})>", loc.file, loc.line, loc.col))); 
     2685        pushFormat(c.thread, "<literal at {}({}:{})>", loc.file, loc.line, loc.col); 
     2686        auto str = c.newString(getString(c.thread, -1)); 
     2687        pop(c.thread); 
     2688        return new(c) Identifier(c, loc, str); 
    26892689    } 
    26902690} 
  • branches/v2new/minid/semantic.d

    r330 r331  
    2727import minid.astvisitor; 
    2828import minid.compilertypes; 
     29import minid.interpreter; 
    2930import minid.types; 
    3031import minid.utils; 
     
    117118            d.attrs = visit(d.attrs); 
    118119 
     120        scope defaults = new List!(Statement)(c.alloc); 
     121 
     122        foreach(ref p; d.params) 
     123            if(p.defValue !is null) 
     124                defaults ~= new(c) CondAssignStmt(c, p.name.location, p.name.location, new(c) IdentExp(c, p.name), p.defValue); 
     125 
     126        if(defaults.length > 0) 
     127        { 
     128            defaults ~= d.code; 
     129            auto arr = defaults.toArray(); 
     130            d.code = new(c) BlockStmt(c, arr[0].location, arr[$ - 1].endLocation, arr); 
     131        } 
     132 
    119133        return d; 
    120134    } 
     
    224238        if(s.msg) 
    225239            s.msg = visit(s.msg); 
     240        else 
     241        { 
     242            pushFormat(c.thread, "Assertion failure at {}({}:{})", s.location.file, s.location.line, s.location.col); 
     243            auto str = c.newString(getString(c.thread, -1)); 
     244            pop(c.thread); 
     245            s.msg = new(c) StringExp(c, s.location, str); 
     246        } 
    226247 
    227248        return s; 
     
    319340        { 
    320341            if(s.condition.isTrue) 
    321                 return s.ifBody; 
     342            { 
     343                if(s.condVar is null) 
     344                    return new(c) ScopeStmt(c, s.ifBody); 
     345 
     346                scope names = new List!(Identifier)(c.alloc); 
     347                names ~= s.condVar.name; 
     348 
     349                scope temp = new List!(Statement)(c.alloc); 
     350                temp ~= new(c) VarDecl(c, s.condVar.location, s.condVar.endLocation, Protection.Local, names.toArray(), s.condition); 
     351                temp ~= s.ifBody; 
     352 
     353                return new(c) ScopeStmt(c, new(c) BlockStmt(c, s.location, s.endLocation, temp.toArray())); 
     354            } 
    322355            else 
    323356            { 
    324357                if(s.elseBody) 
    325                     return s.elseBody
     358                    return new(c) ScopeStmt(c, s.elseBody)
    326359                else 
    327360                    return new(c) BlockStmt(c, s.location, s.endLocation, null); 
     
    331364        return s; 
    332365    } 
    333      
     366 
    334367    public override Statement visit(WhileStmt s) 
    335368    { 
     
    729762                case AstTag.GTExp: return new(c) BoolExp(c, e.location, cmpVal > 0); 
    730763                case AstTag.GEExp: return new(c) BoolExp(c, e.location, cmpVal >= 0); 
    731                 default: assert(false, "CmpExp fold"); 
     764                default: assert(false, "BaseCmpExp fold"); 
    732765            } 
    733766        } 
     
    848881    public override Expression visit(CatExp e) 
    849882    { 
     883        if(e.collapsed) 
     884            return e; 
     885             
     886        e.collapsed = true; 
     887 
    850888        e.op1 = visit(e.op1); 
    851889        e.op2 = visit(e.op2); 
     
    853891        // Collapse 
    854892        { 
    855             assert(e.collapsed is false, "repeated CatExp fold"); 
    856             e.collapsed = true; 
    857  
    858893            scope tmp = new List!(Expression)(c.alloc); 
    859894 
     
    12721307            arg = visit(arg); 
    12731308 
     1309        // TODO: look at this?  change the way codegen is done? 
     1310 
    12741311        return e; 
    12751312    } 
  • branches/v2new/minid/types.d

    r329 r331  
    245245            default: assert(false); 
    246246        } 
    247  
    248         assert(false); 
    249247    } 
    250248 
     
    296294            default: return (this.mBaseObj is other.mBaseObj); 
    297295        } 
    298          
    299         assert(false); 
    300296    } 
    301297     
     
    414410            default: assert(false); 
    415411        } 
    416          
    417         assert(false); 
    418     } 
    419      
     412    } 
     413 
    420414    hash_t toHash() 
    421415    { 
     
    430424            default:          return cast(hash_t)cast(void*)mBaseObj; 
    431425        } 
    432  
    433         assert(false); 
    434426    } 
    435427} 
  • branches/v2new/samples/simple.md

    r330 r331  
    11module simple 
    2  
    3  
    42 
    53/+ 
  • branches/v2new/test.d

    r329 r331  
    3838    { 
    3939        scope c = new Compiler(t); 
    40         c.testParse(`samples\simple.md`); 
     40        c.testParse(`samples/simple.md`); 
    4141        memSize = bytesAllocated(vm); 
    4242    } 
    43      
     43 
    4444    Stdout.formatln("Compilation used {} bytes of non-GC'ed memory", memSize - bytesAllocated(vm)); 
    4545 
     
    5353//  Timer.init(t); 
    5454// 
    55 //      auto funcReg = loadFunc(t, `samples\simple.md`); 
     55//      auto funcReg = loadFunc(t, `samples/simple.md`); 
    5656//      pushNull(t); 
    5757//      rawCall(t, funcReg, 0);