Changeset 329

Show
Ignore:
Timestamp:
07/18/08 20:18:47 (1 month ago)
Author:
JarrettBillingsley
Message:

So, uh, semantic phase. It's not quite done yet, I want to put more AST rewriting into it that used to be in the codegen phase.

Files:

Legend:

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

    r328 r329  
    9292    debug(LEAK_DETECTOR) 
    9393    { 
     94        import minid.hash; 
     95 
    9496        struct MemBlock 
    9597        { 
     
    98100        } 
    99101 
    100         MemBlock[void*] _memBlocks; 
     102        Hash!(void*, MemBlock) _memBlocks; 
    101103    } 
    102104 
     
    191193        debug(LEAK_DETECTOR) 
    192194        { 
    193             void* realloc(void* p, size_t oldSize, size_t newSize) 
     195            // Do this so that the leak detector does not cause infinite recursion and also so it doesn't mess with the totalBytes 
     196            static if(is(T == Hash!(void*, MemBlock).Node[])) 
    194197            { 
    195                 if(oldSize > 0 && !(p in _memBlocks)) 
    196                     throw new Exception("AWFUL: You're trying to free something that wasn't allocated on the MiniD Heap!"); 
    197  
    198                 auto ret = reallocImpl(p, oldSize, newSize); 
    199  
    200                 if(newSize == 0) 
    201                     _memBlocks.remove(p); 
    202                 else if(oldSize == 0) 
    203                     _memBlocks[ret] = MemBlock(newSize, typeid(T)); 
    204                 else 
     198                void* realloc(void* p, size_t oldSize, size_t newSize) 
    205199                { 
    206                     if(p is ret) 
    207                         _memBlocks[ret].len = newSize; 
     200                    auto ret = memFunc(ctx, p, oldSize, newSize); 
     201                    assert(newSize == 0 || ret !is null, "allocation function should never return null"); 
     202                    return ret; 
     203                } 
     204            } 
     205            else 
     206            { 
     207                void* realloc(void* p, size_t oldSize, size_t newSize) 
     208                { 
     209                    if(oldSize > 0 && _memBlocks.lookup(p) is null) 
     210                        throw new Exception("AWFUL: You're trying to free something that wasn't allocated on the MiniD Heap!"); 
     211     
     212                    auto ret = reallocImpl(p, oldSize, newSize); 
     213     
     214                    if(newSize == 0) 
     215                        _memBlocks.remove(p); 
     216                    else if(oldSize == 0) 
     217                        *_memBlocks.insert(*this, ret) = MemBlock(newSize, typeid(T)); 
    208218                    else 
    209219                    { 
    210                         _memBlocks.remove(p); 
    211                         _memBlocks[ret] = MemBlock(newSize, typeid(T)); 
     220                        if(p is ret) 
     221                            _memBlocks.lookup(ret).len = newSize; 
     222                        else 
     223                        { 
     224                            _memBlocks.remove(p); 
     225                            *_memBlocks.insert(*this, ret) = MemBlock(newSize, typeid(T)); 
     226                        } 
    212227                    } 
     228     
     229                    return ret; 
    213230                } 
    214  
    215                 return ret; 
    216231            } 
    217232        } 
  • branches/v2new/minid/api.d

    r327 r329  
    9393{ 
    9494    openVMImpl(vm, memFunc, ctx); 
    95  
    9695    BaseLib.init(vm.mainThread); 
    97  
    9896    return mainThread(vm); 
    9997} 
     
    123121            for(auto obj = vm.alloc.gcHead; obj !is null; obj = obj.next) 
    124122            { 
    125                 auto block = vm.alloc._memBlocks[obj]
     123                auto block = vm.alloc._memBlocks.lookup(obj)
    126124                Stdout.formatln("Unfreed object: address 0x{:X}, length {} bytes, type {}", obj, block.len, block.ti); 
    127125            } 
     
    136134    vm.alloc.freeArray(vm.metaTabs); 
    137135    vm.alloc.freeArray(vm.metaStrings); 
    138     vm.stringTab.clear(vm.alloc); // can't hurt. 
     136    vm.stringTab.clear(vm.alloc); 
    139137    vm.alloc.freeArray(vm.traceback); 
    140138 
     
    149147        throw new Exception(Format("There are {} unfreed bytes!", vm.alloc.totalBytes)); 
    150148    } 
     149     
     150    debug(LEAK_DETECTOR) 
     151        vm.alloc._memBlocks.clear(vm.alloc); 
    151152 
    152153    delete vm.formatter; 
    153  
    154154    *vm = MDVM.init; 
    155155} 
  • branches/v2new/minid/ast.d

    r328 r329  
    2424module minid.ast; 
    2525 
     26import minid.alloc; 
    2627import minid.compilertypes; 
    2728import minid.opcodes; 
     
    272273    AstTag.YieldExp:             "yield expression", 
    273274    AstTag.SuperCallExp:         "super call expression", 
     275 
    274276    AstTag.ForeachComprehension: "'foreach' comprehension", 
    275277    AstTag.ForNumComprehension:  "numeric 'for' comprehension", 
     
    303305    new(uword size, ICompiler c) 
    304306    { 
    305         auto ret = cast(AstNode)c.alloc().allocArray!(void)(size).ptr; 
    306         c.addNode(ret); 
    307         return cast(void*)ret; 
     307        return c.alloc().allocArray!(void)(size).ptr; 
    308308    } 
    309309 
     
    313313 
    314314    Params: 
     315        c = The compiler with which the node will be associated. 
    315316        location = The location of the beginning of this node. 
    316317        endLocation = The location of the end of this node. 
    317318        type = The type of this node. 
    318319    */ 
    319     public this(CompileLoc location, CompileLoc endLocation, AstTag type) 
    320     { 
     320    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type) 
     321    { 
     322        c.addNode(this); 
    321323        this.location = location; 
    322324        this.endLocation = endLocation; 
     
    352354        return null; 
    353355    } 
     356     
     357    override void cleanup(ref Allocator alloc) 
     358    { 
     359        // nothing. 
     360    } 
     361} 
     362 
     363/** 
     364Dummy unknown node type. 
     365*/ 
     366class Unknown : AstNode 
     367{ 
     368    private this(ICompiler c) 
     369    { 
     370        super(c, CompileLoc.init, CompileLoc.init, AstTag.Unknown); 
     371        //assert(false); 
     372    } 
    354373} 
    355374 
     
    362381    public dchar[] name; 
    363382 
    364     public this(CompileLoc location, dchar[] name) 
    365     { 
    366         super(location, location, AstTag.Identifier); 
     383    public this(ICompiler c, CompileLoc location, dchar[] name) 
     384    { 
     385        super(c, location, location, AstTag.Identifier); 
    367386        this.name = name; 
    368387    } 
     
    419438    /** 
    420439    */ 
    421     public this(CompileLoc location, CompileLoc endLocation, Identifier name, Expression baseObject, Field[] fields, TableCtorExp attrs = null) 
    422     { 
    423         super(location, endLocation, AstTag.ObjectDef); 
     440    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Identifier name, Expression baseObject, Field[] fields, TableCtorExp attrs = null) 
     441    { 
     442        super(c, location, endLocation, AstTag.ObjectDef); 
    424443        this.name = name; 
    425444        this.baseObject = baseObject; 
    426445        this.fields = fields; 
    427446        this.attrs = attrs; 
     447    } 
     448 
     449    override void cleanup(ref Allocator alloc) 
     450    { 
     451        alloc.freeArray(fields); 
    428452    } 
    429453} 
     
    518542    /** 
    519543    */ 
    520     public this(CompileLoc location, Identifier name, Param[] params, bool isVararg, Statement code, TableCtorExp attrs = null) 
    521     { 
    522         super(location, code.endLocation, AstTag.FuncDef); 
     544    public this(ICompiler c, CompileLoc location, Identifier name, Param[] params, bool isVararg, Statement code, TableCtorExp attrs = null) 
     545    { 
     546        super(c, location, code.endLocation, AstTag.FuncDef); 
    523547        this.params = params; 
    524548        this.isVararg = isVararg; 
     
    526550        this.name = name; 
    527551        this.attrs = attrs; 
     552    } 
     553     
     554    override void cleanup(ref Allocator alloc) 
     555    { 
     556        foreach(ref p; params) 
     557            alloc.freeArray(p.objectTypes); 
     558 
     559        alloc.freeArray(params); 
    528560    } 
    529561} 
     
    576608    /** 
    577609    */ 
    578     public this(CompileLoc location, CompileLoc endLocation, Identifier name, Expression parent, Field[] fields, TableCtorExp attrs = null) 
    579     { 
    580         super(location, endLocation, AstTag.NamespaceDef); 
     610    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Identifier name, Expression parent, Field[] fields, TableCtorExp attrs = null) 
     611    { 
     612        super(c, location, endLocation, AstTag.NamespaceDef); 
    581613        this.name = name; 
    582614        this.parent = parent; 
     
    584616        this.attrs = attrs; 
    585617    } 
     618     
     619    override void cleanup(ref Allocator alloc) 
     620    { 
     621        alloc.freeArray(fields); 
     622    } 
    586623} 
    587624 
     
    603640    /** 
    604641    */ 
    605     public this(CompileLoc location, CompileLoc endLocation, ModuleDecl modDecl, Statement[] statements) 
    606     { 
    607         super(location, endLocation, AstTag.Module); 
     642    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, ModuleDecl modDecl, Statement[] statements) 
     643    { 
     644        super(c, location, endLocation, AstTag.Module); 
    608645        this.modDecl = modDecl; 
    609646        this.statements = statements; 
    610647    } 
     648     
     649    override void cleanup(ref Allocator alloc) 
     650    { 
     651        alloc.freeArray(statements); 
     652    } 
    611653} 
    612654 
     
    629671    /** 
    630672    */ 
    631     public this(CompileLoc location, CompileLoc endLocation, dchar[][] names, TableCtorExp attrs) 
    632     { 
    633         super(location, endLocation, AstTag.ModuleDecl); 
     673    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, dchar[][] names, TableCtorExp attrs) 
     674    { 
     675        super(c, location, endLocation, AstTag.ModuleDecl); 
    634676        this.names = names; 
    635677        this.attrs = attrs; 
    636678    } 
     679     
     680    override void cleanup(ref Allocator alloc) 
     681    { 
     682        alloc.freeArray(names); 
     683    } 
    637684} 
    638685 
     
    642689abstract class Statement : AstNode 
    643690{ 
    644     public this(CompileLoc location, CompileLoc endLocation, AstTag type) 
    645     { 
    646         super(location, endLocation, type); 
     691    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type) 
     692    { 
     693        super(c, location, endLocation, type); 
    647694    } 
    648695} 
     
    683730    /** 
    684731    */ 
    685     public this(CompileLoc location, CompileLoc endLocation, AstTag type, Protection protection) 
    686     { 
    687         super(location, endLocation, type); 
     732    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Protection protection) 
     733    { 
     734        super(c, location, endLocation, type); 
    688735        this.protection = protection; 
    689736    } 
     
    705752    The protection parameter can be any kind of protection. 
    706753    */ 
    707     public this(CompileLoc location, Protection protection, FuncDef def) 
    708     { 
    709         super(location, def.endLocation, AstTag.FuncDecl, protection); 
     754    public this(ICompiler c, CompileLoc location, Protection protection, FuncDef def) 
     755    { 
     756        super(c, location, def.endLocation, AstTag.FuncDecl, protection); 
    710757        this.def = def; 
    711758    } 
     
    725772    The protection parameter can be any kind of protection. 
    726773    */ 
    727     public this(CompileLoc location, Protection protection, ObjectDef def) 
    728     { 
    729         super(location, def.endLocation, AstTag.ObjectDecl, protection); 
     774    public this(ICompiler c, CompileLoc location, Protection protection, ObjectDef def) 
     775    { 
     776        super(c, location, def.endLocation, AstTag.ObjectDecl, protection); 
    730777        this.def = def; 
    731778    } 
     
    745792    The protection parameter can be any level of protection. 
    746793    */ 
    747     public this(CompileLoc location, Protection protection, NamespaceDef def) 
    748     { 
    749         super(location, def.endLocation, AstTag.NamespaceDecl, protection); 
     794    public this(ICompiler c, CompileLoc location, Protection protection, NamespaceDef def) 
     795    { 
     796        super(c, location, def.endLocation, AstTag.NamespaceDecl, protection); 
    750797        this.def = def; 
    751798    } 
     
    761808    */ 
    762809    public Identifier[] names; 
    763      
     810 
    764811    /** 
    765812    The initializer for the variables.  This can be null, in which case the variables 
     
    772819    The protection parameter must be either Protection.Local or Protection.Global. 
    773820    */ 
    774     public this(CompileLoc location, CompileLoc endLocation, Protection protection, Identifier[] names, Expression initializer) 
    775     { 
    776         super(location, endLocation, AstTag.VarDecl, protection); 
     821    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Protection protection, Identifier[] names, Expression initializer) 
     822    { 
     823        super(c, location, endLocation, AstTag.VarDecl, protection); 
    777824        this.names = names; 
    778825        this.initializer = initializer; 
     826    } 
     827     
     828    override void cleanup(ref Allocator alloc) 
     829    { 
     830        alloc.freeArray(names); 
    779831    } 
    780832} 
     
    799851    /** 
    800852    */ 
    801     public this(CompileLoc location, CompileLoc endLocation, Expression cond, Expression msg = null) 
    802     { 
    803         super(location, endLocation, AstTag.AssertStmt); 
     853    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression cond, Expression msg = null) 
     854    { 
     855        super(c, location, endLocation, AstTag.AssertStmt); 
    804856        this.cond = cond; 
    805857        this.msg = msg; 
     
    841893    /** 
    842894    */ 
    843     public this(CompileLoc location, CompileLoc endLocation, Identifier importName, Expression expr, Identifier[] symbols, Identifier[] symbolNames) 
    844     { 
    845         super(location, endLocation, AstTag.ImportStmt); 
     895    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Identifier importName, Expression expr, Identifier[] symbols, Identifier[] symbolNames) 
     896    { 
     897        super(c, location, endLocation, AstTag.ImportStmt); 
    846898        this.importName = importName; 
    847899        this.expr = expr; 
     
    849901        this.symbolNames = symbolNames; 
    850902    } 
     903     
     904    override void cleanup(ref Allocator alloc) 
     905    { 
     906        alloc.freeArray(symbols); 
     907        alloc.freeArray(symbolNames); 
     908    } 
    851909} 
    852910 
     
    863921    /** 
    864922    */ 
    865     public this(CompileLoc location, CompileLoc endLocation, Statement[] statements) 
    866     { 
    867         super(location, endLocation, AstTag.BlockStmt); 
     923    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement[] statements) 
     924    { 
     925        super(c, location, endLocation, AstTag.BlockStmt); 
    868926        this.statements = statements; 
     927    } 
     928     
     929    override void cleanup(ref Allocator alloc) 
     930    { 
     931        alloc.freeArray(statements); 
    869932    } 
    870933} 
     
    886949    /** 
    887950    */ 
    888     public this(Statement statement) 
    889     { 
    890         super(statement.location, statement.endLocation, AstTag.ScopeStmt); 
     951    public this(ICompiler c, Statement statement) 
     952    { 
     953        super(c, statement.location, statement.endLocation, AstTag.ScopeStmt); 
    891954        this.statement = statement; 
    892955    } 
     
    912975    /** 
    913976    */ 
    914     public this(CompileLoc location, CompileLoc endLocation, Expression expr) 
    915     { 
    916         super(location, endLocation, AstTag.ExpressionStmt); 
     977    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression expr) 
     978    { 
     979        super(c, location, endLocation, AstTag.ExpressionStmt); 
    917980        this.expr = expr; 
    918981    } 
     
    920983    /** 
    921984    */ 
    922     public this(Expression expr) 
    923     { 
    924         super(expr.location, expr.endLocation, AstTag.ExpressionStmt); 
     985    public this(ICompiler c, Expression expr) 
     986    { 
     987        super(c, expr.location, expr.endLocation, AstTag.ExpressionStmt); 
    925988        this.expr = expr; 
    926989    } 
     
    9571020    /** 
    9581021    */ 
    959     public this(CompileLoc location, CompileLoc endLocation, Identifier condVar, Expression condition, Statement ifBody, Statement elseBody) 
    960     { 
    961         super(location, endLocation, AstTag.IfStmt); 
     1022    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Identifier condVar, Expression condition, Statement ifBody, Statement elseBody) 
     1023    { 
     1024        super(c, location, endLocation, AstTag.IfStmt); 
    9621025 
    9631026        this.condVar = condVar; 
     
    9921055    /** 
    9931056    */ 
    994     public this(CompileLoc location, Identifier condVar, Expression condition, Statement code) 
    995     { 
    996         super(location, code.endLocation, AstTag.WhileStmt); 
     1057    public this(ICompiler c, CompileLoc location, Identifier condVar, Expression condition, Statement code) 
     1058    { 
     1059        super(c, location, code.endLocation, AstTag.WhileStmt); 
    9971060 
    9981061        this.condVar = condVar; 
     
    10191082    /** 
    10201083    */ 
    1021     public this(CompileLoc location, CompileLoc endLocation, Statement code, Expression condition) 
    1022     { 
    1023         super(location, endLocation, AstTag.DoWhileStmt); 
     1084    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement code, Expression condition) 
     1085    { 
     1086        super(c, location, endLocation, AstTag.DoWhileStmt); 
    10241087 
    10251088        this.code = code; 
     
    10851148    /** 
    10861149    */ 
    1087     public this(CompileLoc location, Init[] init, Expression cond, Statement[] inc, Statement code) 
    1088     { 
    1089         super(location, endLocation, AstTag.ForStmt); 
     1150    public this(ICompiler c, CompileLoc location, Init[] init, Expression cond, Statement[] inc, Statement code) 
     1151    { 
     1152        super(c, location, endLocation, AstTag.ForStmt); 
    10901153 
    10911154        this.init = init; 
     
    10941157        this.code = code; 
    10951158    } 
     1159     
     1160    override void cleanup(ref Allocator alloc) 
     1161    { 
     1162        alloc.freeArray(init); 
     1163        alloc.freeArray(increment); 
     1164    } 
    10961165} 
    10971166 
     
    11321201    /** 
    11331202    */ 
    1134     public this(CompileLoc location, Identifier index, Expression lo, Expression hi, Expression step, Statement code) 
    1135     { 
    1136         super(location, code.endLocation, AstTag.ForNumStmt); 
     1203    public this(ICompiler c, CompileLoc location, Identifier index, Expression lo, Expression hi, Expression step, Statement code) 
     1204    { 
     1205        super(c, location, code.endLocation, AstTag.ForNumStmt); 
    11371206 
    11381207        this.index = index; 
     
    11711240    /** 
    11721241    */ 
    1173     public this(CompileLoc location, Identifier[] indices, Expression[] container, Statement code) 
    1174     { 
    1175         super(location, code.endLocation, AstTag.ForeachStmt); 
     1242    public this(ICompiler c, CompileLoc location, Identifier[] indices, Expression[] container, Statement code) 
     1243    { 
     1244        super(c, location, code.endLocation, AstTag.ForeachStmt); 
    11761245 
    11771246        this.indices = indices; 
     
    11791248        this.code = code; 
    11801249    } 
     1250 
     1251    override void cleanup(ref Allocator alloc) 
     1252    { 
     1253        alloc.freeArray(indices); 
     1254        alloc.freeArray(container); 
     1255    } 
    11811256} 
    11821257 
     
    12031278    /** 
    12041279    */ 
    1205     public this(CompileLoc location, CompileLoc endLocation, Expression condition, CaseStmt[] cases, DefaultStmt caseDefault) 
    1206     { 
    1207         super(location, endLocation, AstTag.SwitchStmt); 
     1280    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression condition, CaseStmt[] cases, DefaultStmt caseDefault) 
     1281    { 
     1282        super(c, location, endLocation, AstTag.SwitchStmt); 
    12081283        this.condition = condition; 
    12091284        this.cases = cases; 
    12101285        this.caseDefault = caseDefault; 
    12111286    } 
     1287     
     1288    override void cleanup(ref Allocator alloc) 
     1289    { 
     1290        alloc.freeArray(cases); 
     1291    } 
    12121292} 
    12131293 
     
    12341314    /** 
    12351315    */ 
    1236     public this(CompileLoc location, CompileLoc endLocation, Expression[] conditions, Statement code) 
    1237     { 
    1238         super(location, endLocation, AstTag.CaseStmt); 
     1316    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression[] conditions, Statement code) 
     1317    { 
     1318        super(c, location, endLocation, AstTag.CaseStmt); 
    12391319        this.conditions = conditions; 
    12401320        this.code = code; 
    12411321    } 
     1322     
     1323    override void cleanup(ref Allocator alloc) 
     1324    { 
     1325        alloc.freeArray(conditions); 
     1326    } 
    12421327} 
    12431328 
     
    12541339    /** 
    12551340    */ 
    1256     public this(CompileLoc location, CompileLoc endLocation, Statement code) 
    1257     { 
    1258         super(location, endLocation, AstTag.DefaultStmt); 
     1341    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement code) 
     1342    { 
     1343        super(c, location, endLocation, AstTag.DefaultStmt); 
    12591344        this.code = code; 
    12601345    } 
     
    12681353    /** 
    12691354    */ 
    1270     public this(CompileLoc location) 
    1271     { 
    1272         super(location, location, AstTag.ContinueStmt); 
     1355    public this(ICompiler c, CompileLoc location) 
     1356    { 
     1357        super(c, location, location, AstTag.ContinueStmt); 
    12731358    } 
    12741359} 
     
    12811366    /** 
    12821367    */ 
    1283     public this(CompileLoc location) 
    1284     { 
    1285         super(location, location, AstTag.BreakStmt); 
     1368    public this(ICompiler c, CompileLoc location) 
     1369    { 
     1370        super(c, location, location, AstTag.BreakStmt); 
    12861371    } 
    12871372} 
     
    12991384    /** 
    13001385    */ 
    1301     public this(CompileLoc location, CompileLoc endLocation, Expression[] exprs) 
    1302     { 
    1303         super(location, endLocation, AstTag.ReturnStmt); 
     1386    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression[] exprs) 
     1387    { 
     1388        super(c, location, endLocation, AstTag.ReturnStmt); 
    13041389        this.exprs = exprs; 
     1390    } 
     1391     
     1392    override void cleanup(ref Allocator alloc) 
     1393    { 
     1394        alloc.freeArray(exprs); 
    13051395    } 
    13061396} 
     
    13391429    /** 
    13401430    */ 
    1341     public this(CompileLoc location, CompileLoc endLocation, Statement tryBody, Identifier catchVar, Statement catchBody, Statement finallyBody) 
    1342     { 
    1343         super(location, endLocation, AstTag.TryStmt); 
     1431    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Statement tryBody, Identifier catchVar, Statement catchBody, Statement finallyBody) 
     1432    { 
     1433        super(c, location, endLocation, AstTag.TryStmt); 
    13441434 
    13451435        this.tryBody = tryBody; 
     
    13621452    /** 
    13631453    */ 
    1364     public this(CompileLoc location, Expression exp) 
    1365     { 
    1366         super(location, exp.endLocation, AstTag.ThrowStmt); 
     1454    public this(ICompiler c, CompileLoc location, Expression exp) 
     1455    { 
     1456        super(c, location, exp.endLocation, AstTag.ThrowStmt); 
    13671457        this.exp = exp; 
    13681458    } 
     
    13901480    /** 
    13911481    */ 
    1392     public this(CompileLoc location, CompileLoc endLocation, Expression[] lhs, Expression rhs) 
    1393     { 
    1394         super(location, endLocation, AstTag.AssignStmt); 
     1482    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression[] lhs, Expression rhs) 
     1483    { 
     1484        super(c, location, endLocation, AstTag.AssignStmt); 
    13951485        this.lhs = lhs; 
    13961486        this.rhs = rhs; 
     1487    } 
     1488     
     1489    override void cleanup(ref Allocator alloc) 
     1490    { 
     1491        alloc.freeArray(lhs); 
    13971492    } 
    13981493} 
     
    14171512    /** 
    14181513    */ 
    1419     public this(CompileLoc location, CompileLoc endLocation, AstTag type, Expression lhs, Expression rhs) 
    1420     { 
    1421         super(location, endLocation, type); 
     1514    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Expression lhs, Expression rhs) 
     1515    { 
     1516        super(c, location, endLocation, type); 
    14221517        this.lhs = lhs; 
    14231518        this.rhs = rhs; 
     
    14321527    /** 
    14331528    */ 
    1434     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1435     { 
    1436         super(location, endLocation, AstTag.AddAssignStmt, lhs, rhs); 
     1529    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1530    { 
     1531        super(c, location, endLocation, AstTag.AddAssignStmt, lhs, rhs); 
    14371532    } 
    14381533} 
     
    14451540    /** 
    14461541    */ 
    1447     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1448     { 
    1449         super(location, endLocation, AstTag.SubAssignStmt, lhs, rhs); 
     1542    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1543    { 
     1544        super(c, location, endLocation, AstTag.SubAssignStmt, lhs, rhs); 
    14501545    } 
    14511546} 
     
    14671562    public Expression rhs; 
    14681563 
    1469     private Expression[] operands; 
    1470     private bool collapsed = false; 
    1471  
    1472     /** 
    1473     */ 
    1474     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1475     { 
    1476         super(location, endLocation, AstTag.CatAssignStmt); 
     1564    public Expression[] operands; 
     1565    public bool collapsed = false; 
     1566 
     1567    /** 
     1568    */ 
     1569    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1570    { 
     1571        super(c, location, endLocation, AstTag.CatAssignStmt); 
    14771572        this.lhs = lhs; 
    14781573        this.rhs = rhs; 
    14791574    } 
     1575     
     1576    override void cleanup(ref Allocator alloc) 
     1577    { 
     1578        alloc.freeArray(operands); 
     1579    } 
    14801580} 
    14811581 
     
    14871587    /** 
    14881588    */ 
    1489     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1490     { 
    1491         super(location, endLocation, AstTag.MulAssignStmt, lhs, rhs); 
     1589    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1590    { 
     1591        super(c, location, endLocation, AstTag.MulAssignStmt, lhs, rhs); 
    14921592    } 
    14931593} 
     
    15001600    /** 
    15011601    */ 
    1502     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1503     { 
    1504         super(location, endLocation, AstTag.DivAssignStmt, lhs, rhs); 
     1602    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1603    { 
     1604        super(c, location, endLocation, AstTag.DivAssignStmt, lhs, rhs); 
    15051605    } 
    15061606} 
     
    15131613    /** 
    15141614    */ 
    1515     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1516     { 
    1517         super(location, endLocation, AstTag.ModAssignStmt, lhs, rhs); 
     1615    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1616    { 
     1617        super(c, location, endLocation, AstTag.ModAssignStmt, lhs, rhs); 
    15181618    } 
    15191619} 
     
    15261626    /** 
    15271627    */ 
    1528     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1529     { 
    1530         super(location, endLocation, AstTag.OrAssignStmt, lhs, rhs); 
     1628    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1629    { 
     1630        super(c, location, endLocation, AstTag.OrAssignStmt, lhs, rhs); 
    15311631    } 
    15321632} 
     
    15391639    /** 
    15401640    */ 
    1541     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1542     { 
    1543         super(location, endLocation, AstTag.XorAssignStmt, lhs, rhs); 
     1641    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1642    { 
     1643        super(c, location, endLocation, AstTag.XorAssignStmt, lhs, rhs); 
    15441644    } 
    15451645} 
     
    15521652    /** 
    15531653    */ 
    1554     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1555     { 
    1556         super(location, endLocation, AstTag.AndAssignStmt, lhs, rhs); 
     1654    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1655    { 
     1656        super(c, location, endLocation, AstTag.AndAssignStmt, lhs, rhs); 
    15571657    } 
    15581658} 
     
    15651665    /** 
    15661666    */ 
    1567     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1568     { 
    1569         super(location, endLocation, AstTag.ShlAssignStmt, lhs, rhs); 
     1667    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1668    { 
     1669        super(c, location, endLocation, AstTag.ShlAssignStmt, lhs, rhs); 
    15701670    } 
    15711671} 
     
    15781678    /** 
    15791679    */ 
    1580     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1581     { 
    1582         super(location, endLocation, AstTag.ShrAssignStmt, lhs, rhs); 
     1680    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1681    { 
     1682        super(c, location, endLocation, AstTag.ShrAssignStmt, lhs, rhs); 
    15831683    } 
    15841684} 
     
    15911691    /** 
    15921692    */ 
    1593     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1594     { 
    1595         super(location, endLocation, AstTag.UShrAssignStmt, lhs, rhs); 
     1693    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1694    { 
     1695        super(c, location, endLocation, AstTag.UShrAssignStmt, lhs, rhs); 
    15961696    } 
    15971697} 
     
    16041704    /** 
    16051705    */ 
    1606     public this(CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
    1607     { 
    1608         super(location, endLocation, AstTag.CondAssignStmt, lhs, rhs); 
     1706    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression lhs, Expression rhs) 
     1707    { 
     1708        super(c, location, endLocation, AstTag.CondAssignStmt, lhs, rhs); 
    16091709    } 
    16101710} 
     
    16221722    /** 
    16231723    */ 
    1624     public this(CompileLoc location, CompileLoc endLocation, Expression exp) 
    1625     { 
    1626         super(location, endLocation, AstTag.IncStmt); 
     1724    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression exp) 
     1725    { 
     1726        super(c, location, endLocation, AstTag.IncStmt); 
    16271727        this.exp = exp; 
    16281728    } 
     
    16411741    /** 
    16421742    */ 
    1643     public this(CompileLoc location, CompileLoc endLocation, Expression exp) 
    1644     { 
    1645         super(location, endLocation, AstTag.DecStmt); 
     1743    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression exp) 
     1744    { 
     1745        super(c, location, endLocation, AstTag.DecStmt); 
    16461746        this.exp = exp; 
    16471747    } 
     
    16551755    /** 
    16561756    */ 
    1657     public this(CompileLoc location, CompileLoc endLocation, AstTag type) 
    1658     { 
    1659         super(location, endLocation, type); 
     1757    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type) 
     1758    { 
     1759        super(c, location, endLocation, type); 
    16601760    } 
    16611761 
     
    18501950    /** 
    18511951    */ 
    1852     public this(CompileLoc location, CompileLoc endLocation, Expression cond, Expression op1, Expression op2) 
    1853     { 
    1854         super(location, endLocation, AstTag.CondExp); 
     1952    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression cond, Expression op1, Expression op2) 
     1953    { 
     1954        super(c, location, endLocation, AstTag.CondExp); 
    18551955        this.cond = cond; 
    18561956        this.op1 = op1; 
     
    18821982    /** 
    18831983    */ 
    1884     public this(CompileLoc location, CompileLoc endLocation, AstTag type, Expression op1, Expression op2) 
    1885     { 
    1886         super(location, endLocation, type); 
     1984    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Expression op1, Expression op2) 
     1985    { 
     1986        super(c, location, endLocation, type); 
    18871987        this.op1 = op1; 
    18881988        this.op2 = op2; 
     
    18911991 
    18921992private const BinExpMixin = 
    1893 "public this(CompileLoc location, CompileLoc endLocation, Expression left, Expression right)" 
     1993"public this(ICompiler c, CompileLoc location, CompileLoc endLocation, Expression left, Expression right)" 
    18941994"{" 
    1895     "super(location, endLocation, mixin(\"AstTag.\" ~ typeof(this).stringof), left, right);" 
     1995    "super(c, location, endLocation, mixin(\"AstTag.\" ~ typeof(this).stringof), left, right);" 
    18961996"}"; 
    18971997 
     
    19472047 
    19482048/** 
     2049This class serves as a base class for all equality expressions. 
     2050*/ 
     2051abstract class BaseEqualExp : BinaryExp 
     2052{ 
     2053    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Expression left, Expression right) 
     2054    { 
     2055        super(c, location, endLocation, type, left, right); 
     2056    } 
     2057} 
     2058 
     2059/** 
    19492060This node represents an equality (==) expression. 
    19502061*/ 
    1951 class EqualExp : BinaryExp 
     2062class EqualExp : BaseEqualExp 
    19522063{ 
    19532064    mixin(BinExpMixin); 
     
    19572068This node represents an inequality (!=) expression. 
    19582069*/ 
    1959 class NotEqualExp : BinaryExp 
     2070class NotEqualExp : BaseEqualExp 
    19602071{ 
    19612072    mixin(BinExpMixin); 
     
    19652076This node represents an identity (is) expression. 
    19662077*/ 
    1967 class IsExp : BinaryExp 
     2078class IsExp : BaseEqualExp 
    19682079{ 
    19692080    mixin(BinExpMixin); 
     
    19732084This node represents a nonidentity (!is) expression. 
    19742085*/ 
    1975 class NotIsExp : BinaryExp 
     2086class NotIsExp : BaseEqualExp 
    19762087{ 
    19772088    mixin(BinExpMixin); 
     
    19792090 
    19802091/** 
     2092This class serves as a base class for comparison expressions. 
     2093*/ 
     2094abstract class BaseCmpExp : BinaryExp 
     2095{ 
     2096    public this(ICompiler c, CompileLoc location, CompileLoc endLocation, AstTag type, Expression left, Expression right) 
     2097    { 
     2098        super(c, location, endLocation, type, left, right); 
     2099    } 
     2100} 
     2101 
     2102/** 
    19812103This node represents a less-than (<) comparison. 
    19822104*/