Changeset 1188

Show
Ignore:
Timestamp:
06/16/08 13:27:07 (6 months ago)
Author:
asterite
Message:

statement.c and statement.h ported to DMD 2.013

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.building/META-INF/MANIFEST.MF

    r1184 r1188  
    1212 descent.ui, 
    1313 descent.launching, 
    14  org.eclipse.ui.forms 
     14 org.eclipse.ui.forms, 
     15 org.eclipse.core.resources 
    1516Eclipse-LazyStart: true 
  • trunk/descent.core/src/descent/core/Signature.java

    r1165 r1188  
    9696 *    
    9797 * SliceTypeSignature ::= 
    98  *   "¬" TypeSignature "¬
    99  *   Number "¬" Chars // Number == Chars.length --> lower 
    100  *   Number "¬" Chars // Number == Chars.length --> upper 
     98 *   "" TypeSignature "
     99 *   Number "" Chars // Number == Chars.length --> lower 
     100 *   Number "" Chars // Number == Chars.length --> upper 
    101101 *    
    102102 * FunctionTypeSignature ::= 
     
    133133 *     | "|"  // interface 
    134134 *     | "E"  // enum 
    135  *     | "¡"  // variable 
     135 *     | ""  // variable 
    136136 *     | "="  // alias 
    137137 *     | "T"  // typedef 
     
    398398    /** 
    399399     * Character constant indicating a slice type in a signature. 
    400      * Value is <code>'¬'</code>. 
    401      */ 
    402     public static final char C_SLICE                                    = '¬'; 
     400     * Value is <code>''</code>. 
     401     */ 
     402    public static final char C_SLICE                                    = '¬'; 
    403403     
    404404    /** 
     
    494494    /** 
    495495     * Character constant indicating a variable in a signature. 
    496      * Value is <code>'¡'</code>. 
    497      */ 
    498     public static final char C_VARIABLE                                 = '¡'; 
     496     * Value is <code>''</code>. 
     497     */ 
     498    public static final char C_VARIABLE                                 = '¡'; 
    499499     
    500500    /** 
  • trunk/descent.core/src/descent/core/compiler/IProblem.java

    r1176 r1188  
    673673    int CannotHaveEDotTuple = 462; 
    674674    int CannotCreateCppClasses = 463; 
     675    int SwitchAndCaseAreInDifferentFinallyBlocks = 464; 
     676    int SwitchAndDefaultAreInDifferentFinallyBlocks = 465; 
    675677 
    676678} 
  • trunk/descent.core/src/descent/internal/compiler/parser/BreakStatement.java

    r1160 r1188  
    11package descent.internal.compiler.parser; 
    22 
     3import static descent.internal.compiler.parser.BE.BEbreak; 
     4import static descent.internal.compiler.parser.BE.BEgoto; 
    35import melnorme.miscutil.tree.TreeVisitor; 
    46import descent.core.compiler.IProblem; 
    57import descent.internal.compiler.parser.ast.IASTVisitor; 
    6  
    78 
    89public class BreakStatement extends Statement { 
     
    2223        } 
    2324        visitor.endVisit(this); 
     25    } 
     26     
     27    @Override 
     28    public int blockExit(SemanticContext context) { 
     29        return ident != null ? BEgoto : BEbreak; 
    2430    } 
    2531 
  • trunk/descent.core/src/descent/internal/compiler/parser/CaseStatement.java

    r1160 r1188  
    11package descent.internal.compiler.parser; 
    22 
     3import static descent.internal.compiler.parser.BE.BEany; 
     4import static descent.internal.compiler.parser.TOK.TOKint64; 
     5import static descent.internal.compiler.parser.TOK.TOKstring; 
     6import static descent.internal.compiler.parser.TOK.TOKvar; 
     7import static descent.internal.compiler.parser.TY.Tclass; 
    38import melnorme.miscutil.tree.TreeVisitor; 
    49import descent.core.compiler.IProblem; 
    510import descent.internal.compiler.parser.ast.IASTVisitor; 
    6 import static descent.internal.compiler.parser.TOK.TOKint64; 
    7 import static descent.internal.compiler.parser.TOK.TOKstring; 
    8  
    911 
    1012public class CaseStatement extends Statement { 
     
    2931        } 
    3032        visitor.endVisit(this); 
     33    } 
     34     
     35    @Override 
     36    public int blockExit(SemanticContext context) { 
     37        // Assume the worst 
     38        return BEany; 
    3139    } 
    3240 
     
    7987            exp = exp.implicitCastTo(sc, sw.condition.type, context); 
    8088            exp = exp.optimize(WANTvalue | WANTinterpret, context); 
    81             if (exp.op != TOKstring && exp.op != TOKint64) { 
    82                 if (context.acceptsProblems()) { 
    83                     context.acceptProblem(Problem.newSemanticTypeError(IProblem.CaseMustBeAnIntegralOrStringConstant, sourceExp, new String[] { exp.toChars(context) })); 
     89             
     90            boolean gotoL1 = false; 
     91             
     92            if (context.isD2()) { 
     93                /* This is where variables are allowed as case expressions. 
     94                 */ 
     95                if (exp.op == TOKvar) 
     96                {   VarExp ve = (VarExp) exp; 
     97                    VarDeclaration v = ve.var.isVarDeclaration(); 
     98                    Type t = exp.type.toBasetype(context); 
     99                    if (v != null && (t.isintegral() || t.ty == Tclass)) 
     100                    {   /* Flag that we need to do special code generation 
     101                     * for this, i.e. generate a sequence of if-then-else 
     102                     */ 
     103                    sw.hasVars = 1; 
     104                    // goto L1; 
     105                    gotoL1 = true; 
     106                    } 
    84107                } 
    85                 exp = new IntegerExp(0); 
     108            } 
     109             
     110            if (!gotoL1) { 
     111                if (exp.op != TOKstring && exp.op != TOKint64) { 
     112                    if (context.acceptsProblems()) { 
     113                        context.acceptProblem(Problem.newSemanticTypeError(IProblem.CaseMustBeAnIntegralOrStringConstant, sourceExp, new String[] { exp.toChars(context) })); 
     114                    } 
     115                    exp = new IntegerExp(0); 
     116                } 
    86117            } 
    87118 
     119            // L1: 
    88120            for (i = 0; i < sw.cases.size(); i++) { 
    89121                CaseStatement cs = (CaseStatement) sw.cases.get(i); 
    90122 
    91                 //printf("comparing '%s' with '%s'\n", exp.toChars(), cs.exp.toChars()); 
    92123                if (cs.exp.equals(exp)) { 
    93124                    if (context.acceptsProblems()) { 
     
    108139                        gcs.cs = this; 
    109140                        sw.gotoCases.remove(i); // remove from array 
     141                    } 
     142                } 
     143            } 
     144             
     145            if (context.isD2()) { 
     146                if (sc.sw.tf != sc.tf) { 
     147                    if (context.acceptsProblems()) { 
     148                        context.acceptProblem(Problem.newSemanticTypeErrorLoc(IProblem.SwitchAndCaseAreInDifferentFinallyBlocks, this)); 
    110149                    } 
    111150                } 
     
    140179     
    141180    @Override 
    142     public boolean usesEH() { 
    143         return statement.usesEH(); 
     181    public boolean usesEH(SemanticContext context) { 
     182        return statement.usesEH(context); 
    144183    } 
    145184     
  • trunk/descent.core/src/descent/internal/compiler/parser/Catch.java

    r1160 r1188  
    11package descent.internal.compiler.parser; 
    22 
     3import static descent.internal.compiler.parser.BE.BEfallthru; 
    34import melnorme.miscutil.tree.TreeVisitor; 
    45import descent.core.compiler.IProblem; 
     
    3031        } 
    3132        visitor.endVisit(this); 
     33    } 
     34     
     35    public int blockExit(SemanticContext context) { 
     36        return handler != null ? handler.blockExit(context) : BEfallthru; 
    3237    } 
    3338 
     
    9196        buf.writebyte('{'); 
    9297        buf.writenl(); 
    93         handler.toCBuffer(buf, hgs, context); 
     98        if (handler != null) { 
     99            handler.toCBuffer(buf, hgs, context); 
     100        } 
    94101        buf.writebyte('}'); 
    95102        buf.writenl(); 
  • trunk/descent.core/src/descent/internal/compiler/parser/CompoundStatement.java

    r1160 r1188  
    44import descent.core.compiler.IProblem; 
    55import descent.internal.compiler.parser.ast.IASTVisitor; 
    6  
     6import static descent.internal.compiler.parser.BE.*; 
    77 
    88public class CompoundStatement extends Statement {   
     
    3737        visitor.endVisit(this); 
    3838    } 
     39     
     40    @Override 
     41    public int blockExit(SemanticContext context) { 
     42        int result = BEfallthru; 
     43        for (int i = 0; i < size(statements); i++) { 
     44            Statement s = (Statement) statements.get(i); 
     45            if (s != null) { 
     46                if (0 == (result & BEfallthru) && !s.comeFrom()) { 
     47                    if (context.global.params.warnings) { 
     48                        if (context.acceptsProblems()) { 
     49                            context.acceptProblem(Problem.newSemanticTypeError(IProblem.StatementIsNotReachable, this)); 
     50                        } 
     51                    } 
     52                } 
     53 
     54                result &= ~BEfallthru; 
     55                result |= s.blockExit(context); 
     56            } 
     57        } 
     58        return result; 
     59    } 
    3960 
    4061    @Override 
     
    150171                        Statement[] sfinally = { null }; 
    151172 
    152                         s.scopeCode(sentry, sexception, sfinally); 
     173                        s.scopeCode(sc, sentry, sexception, sfinally); 
    153174                        if (sentry[0] != null) { 
    154175                            sentry[0] = sentry[0].semantic(sc, context); 
     
    259280 
    260281    @Override 
    261     public boolean usesEH() { 
     282    public boolean usesEH(SemanticContext context) { 
    262283        for (int i = 0; i < statements.size(); i++) { 
    263284            Statement s; 
    264285 
    265286            s = statements.get(i); 
    266             if (s != null && s.usesEH()) { 
     287            if (s != null && s.usesEH(context)) { 
    267288                return true; 
    268289            } 
  • trunk/descent.core/src/descent/internal/compiler/parser/ConditionalStatement.java

    r1160 r1188  
    9393 
    9494    @Override 
    95     public boolean usesEH() { 
    96         return (ifbody != null && ifbody.usesEH()) 
    97                 || (elsebody != null && elsebody.usesEH()); 
     95    public boolean usesEH(SemanticContext context) { 
     96        return (ifbody != null && ifbody.usesEH(context)) 
     97                || (elsebody != null && elsebody.usesEH(context)); 
    9898    } 
    9999 
  • trunk/descent.core/src/descent/internal/compiler/parser/ContinueStatement.java

    r1160 r1188  
    11package descent.internal.compiler.parser; 
    22 
     3import static descent.internal.compiler.parser.BE.BEcontinue; 
     4import static descent.internal.compiler.parser.BE.BEgoto; 
    35import melnorme.miscutil.tree.TreeVisitor; 
    46import descent.core.compiler.IProblem; 
    57import descent.internal.compiler.parser.ast.IASTVisitor; 
    6  
    78 
    89public class ContinueStatement extends Statement { 
     
    2223        } 
    2324        visitor.endVisit(this); 
     25    } 
     26     
     27    @Override 
     28    public int blockExit(SemanticContext context) { 
     29        return ident != null ? BEgoto : BEcontinue; 
    2430    } 
    2531 
  • trunk/descent.core/src/descent/internal/compiler/parser/DeclarationStatement.java

    r1160 r1188  
    3232 
    3333    @Override 
    34     public void scopeCode(Statement[] sentry, Statement[] sexception, 
     34    public void scopeCode(Scope sc, Statement[] sentry, Statement[] sexception, 
    3535            Statement[] sfinally) { 
    3636        sentry[0] = null; 
     
    4545                    Expression e; 
    4646 
    47                     e = v.callAutoDtor(); 
     47                    e = v.callAutoDtor(sc); 
    4848                    if (e != null) { 
    4949                        sfinally[0] = new ExpStatement(loc, e); 
  • trunk/descent.core/src/descent/internal/compiler/parser/DefaultStatement.java

    r1160 r1188  
    11package descent.internal.compiler.parser; 
    22 
     3import static descent.internal.compiler.parser.BE.BEany; 
    34import melnorme.miscutil.tree.TreeVisitor; 
    45import descent.core.compiler.IProblem; 
    56import descent.internal.compiler.parser.ast.IASTVisitor; 
    6  
    77 
    88public class DefaultStatement extends Statement { 
     
    2424        } 
    2525        visitor.endVisit(this); 
     26    } 
     27     
     28    @Override 
     29    public int blockExit(SemanticContext context) { 
     30        // Assume the worst 
     31        return BEany; 
    2632    } 
    2733 
     
    6268            } 
    6369            sc.sw.sdefault = this; 
     70             
     71            if (context.isD2()) { 
     72                if (sc.sw.tf != sc.tf) { 
     73                    if (context.acceptsProblems()) { 
     74                        context.acceptProblem(Problem.newSemanticTypeError(IProblem.SwitchAndDefaultAreInDifferentFinallyBlocks, this));     
     75                    } 
     76                } 
     77            } 
    6478        } else { 
    6579            if (context.acceptsProblems()) { 
     
    86100 
    87101    @Override 
    88     public boolean usesEH() { 
    89         return statement.usesEH(); 
     102    public boolean usesEH(SemanticContext context) { 
     103        return statement.usesEH(context); 
    90104    } 
    91105 
  • trunk/descent.core/src/descent/internal/compiler/parser/DoStatement.java

    r1160 r1188  
    33import melnorme.miscutil.tree.TreeVisitor; 
    44import descent.internal.compiler.parser.ast.IASTVisitor; 
    5  
     5import static descent.internal.compiler.parser.BE.*; 
    66 
    77public class DoStatement extends Statement { 
     
    2424        } 
    2525        visitor.endVisit(this); 
     26    } 
     27     
     28    @Override 
     29    public int blockExit(SemanticContext context) { 
     30        int result; 
     31 
     32        if (body != null) { 
     33            result = body.blockExit(context); 
     34            if ((result & BEbreak) != 0) { 
     35                if (result == BEbreak) { 
     36                    return BEfallthru; 
     37                } 
     38                result |= BEfallthru; 
     39            } 
     40            if ((result & BEcontinue) != 0) { 
     41                result |= BEfallthru; 
     42            } 
     43            result &= ~(BEbreak | BEcontinue); 
     44        } else { 
     45            result = BEfallthru; 
     46        } 
     47        if ((result & BEfallthru) != 0 && condition.canThrow()) { 
     48            result |= BEthrow; 
     49        } 
     50        return result; 
    2651    } 
    2752 
     
    158183 
    159184    @Override 
    160     public boolean usesEH() { 
    161         return body != null ? body.usesEH() : false; 
     185    public boolean usesEH(SemanticContext context) { 
     186        return body != null ? body.usesEH(context) : false; 
    162187    } 
    163188 
  • trunk/descent.core/src/descent/internal/compiler/parser/ExpStatement.java

    r1160 r1188  
    55import static descent.internal.compiler.parser.TOK.TOKassert; 
    66import static descent.internal.compiler.parser.TOK.TOKhalt; 
     7import static descent.internal.compiler.parser.BE.*; 
    78 
    89 
     
    2425        } 
    2526        visitor.endVisit(this); 
     27    } 
     28     
     29    @Override 
     30    public int blockExit(SemanticContext context) { 
     31        int result = BEfallthru; 
     32 
     33        if (exp != null) { 
     34            if (exp.op == TOKhalt) { 
     35                return BEhalt; 
     36            } 
     37             
     38            if (exp.op == TOKassert) { 
     39                AssertExp a = (AssertExp) exp; 
     40 
     41                if (a.e1.isBool(false)) {// if it's an assert(0) 
     42                    return BEhalt; 
     43                } 
     44            } 
     45            if (exp.canThrow()) { 
     46                result |= BEthrow; 
     47            } 
     48        } 
     49        return result; 
    2650    } 
    2751 
  • trunk/descent.core/src/descent/internal/compiler/parser/Expression.java

    r1176 r1188  
    124124        e.type = type.pointerTo(context); 
    125125        return e; 
     126    } 
     127     
     128    public boolean canThrow() { 
     129        return false; 
    126130    } 
    127131 
  • trunk/descent.core/src/descent/internal/compiler/parser/ForStatement.java

    r1160 r1188  
    33import melnorme.miscutil.tree.TreeVisitor; 
    44import descent.internal.compiler.parser.ast.IASTVisitor; 
    5  
     5import static descent.internal.compiler.parser.BE.*; 
    66 
    77public class ForStatement extends Statement { 
     
    3232        visitor.endVisit(this); 
    3333    } 
     34     
     35    @Override 
     36    public int blockExit(SemanticContext context) { 
     37        int result = BEfallthru; 
     38 
     39        if (init != null) { 
     40            result = init.blockExit(context); 
     41            if (0 == (result & BEfallthru)) { 
     42                return result; 
     43            } 
     44        } 
     45        if (condition != null) { 
     46            if (condition.canThrow()) { 
     47                result |= BEthrow; 
     48            } 
     49        } else 
     50            result &= ~BEfallthru; // the body must do the exiting 
     51        if (body != null) { 
     52            int r = body.blockExit(context); 
     53            if ((r & BEbreak) != 0) { 
     54                result |= BEfallthru; 
     55            } 
     56            result |= r & ~(BEbreak | BEcontinue); 
     57        } 
     58        if (increment != null && increment.canThrow()) { 
     59            result |= BEthrow; 
     60        } 
     61        return result; 
     62    } 
    3463 
    3564    @Override 
     
    144173 
    145174    @Override 
    146     public void scopeCode(Statement[] sentry, Statement[] sexception, 
     175    public void scopeCode(Scope sc, Statement[] sentry, Statement[] sexception, 
    147176            Statement[] sfinally) { 
    148177        if (init != null) { 
    149             init.scopeCode(sentry, sexception, sfinally); 
     178            init.scopeCode(sc, sentry, sexception, sfinally); 
    150179        } else { 
    151             super.scopeCode(sentry, sexception, sfinally); 
     180            super.scopeCode(sc, sentry, sexception, sfinally); 
    152181        } 
    153182    } 
     
    166195        } 
    167196        sc.noctor++; 
    168         condition = condition.semantic(sc, context); 
    169         condition = resolveProperties(sc, condition, context); 
    170         condition = condition.optimize(WANTvalue, context); 
    171  
    172         condition = condition.checkToBoolean(context); 
     197         
     198        boolean check; 
     199        if (context.isD2()) { 
     200            check = context != null; 
     201        } else { 
     202            check = true; 
     203        } 
     204         
     205        if (check) { 
     206            condition = condition.semantic(sc, context); 
     207            condition = resolveProperties(sc, condition, context); 
     208            condition = condition.optimize(WANTvalue, context); 
     209            condition = condition.checkToBoolean(context); 
     210        } 
     211         
    173212        if (increment != null) { 
    174213            increment = increment.semantic(sc, context); 
     
    239278 
    240279    @Override 
    241     public boolean usesEH() { 
    242         return (init != null && init.usesEH()) || body.usesEH(); 
     280    public boolean usesEH(SemanticContext context) { 
     281        return (init != null && init.usesEH(context)) || body.usesEH(context); 
    243282    } 
    244283 
  • trunk/descent.core/src/descent/internal/compiler/parser/ForeachStatement.java

    r1160 r1188  
    11package descent.internal.compiler.parser; 
    22 
    3 import java.util.List; 
    4  
    5 import melnorme.miscutil.tree.TreeVisitor; 
    6  
    7 import org.eclipse.core.runtime.Assert; 
    8  
    9 import descent.core.compiler.IProblem; 
    10 import descent.internal.compiler.parser.ast.IASTVisitor; 
    113import static descent.internal.compiler.parser.Constfold.ArrayLength; 
    124import static descent.internal.compiler.parser.Constfold.Index; 
    13  
     5import static descent.internal.compiler.parser.MATCH.MATCHconst; 
    146import static descent.internal.compiler.parser.STC.STCconst; 
     7import static descent.internal.compiler.parser.STC.STCfinal; 
    158import static descent.internal.compiler.parser.STC.STCforeach; 
    169import static descent.internal.compiler.parser.STC.STCin; 
     10import static descent.internal.compiler.parser.STC.STCinvariant; 
    1711import static descent.internal.compiler.parser.STC.STClazy; 
     12import static descent.internal.compiler.parser.STC.STCmanifest; 
    1813import static descent.internal.compiler.parser.STC.STCout; 
    1914import static descent.internal.compiler.parser.STC.STCref; 
    20  
    2115import static descent.internal.compiler.parser.TOK.TOKdelegate; 
    2216import static descent.internal.compiler.parser.TOK.TOKforeach; 
     
    2620import static descent.internal.compiler.parser.TOK.TOKtype; 
    2721import static descent.internal.compiler.parser.TOK.TOKvar; 
    28  
    2922import static descent.internal.compiler.parser.TY.Taarray; 
    3023import static descent.internal.compiler.parser.TY.Tarray; 
     
    4033import static descent.internal.compiler.parser.TY.Tuns64; 
    4134import static descent.internal.compiler.parser.TY.Twchar; 
     35import static descent.internal.compiler.parser.BE.*; 
     36 
     37import java.util.List; 
     38 
     39import melnorme.miscutil.tree.TreeVisitor; 
     40 
     41import org.eclipse.core.runtime.Assert; 
     42 
     43import descent.core.compiler.IProblem; 
     44import descent.internal.compiler.parser.ast.IASTVisitor; 
    4245 
    4346 
     
    8386        } 
    8487        visitor.endVisit(this); 
     88    } 
     89     
     90    @Override 
     91    public int blockExit(SemanticContext context) { 
     92        int result = BEfallthru; 
     93 
     94        if (aggr.canThrow()) { 
     95            result |= BEthrow; 
     96        } 
     97 
     98        if (body != null) { 
     99            result |= body.blockExit(context) & ~(BEbreak | BEcontinue); 
     100        } 
     101        return result; 
    85102    } 
    86103 
     
    231248        aggr = aggr.semantic(sc, context); 
    232249        aggr = resolveProperties(sc, aggr, context); 
     250         
     251        if (context.isD2()) { 
     252            aggr = aggr.optimize(WANTvalue, context); 
     253        } 
     254         
    233255        if (aggr.type == null) { 
    234256            if (context.acceptsProblems()) { 
     
    310332                    arg.var = var; 
    311333                     
    312                     var.storage_class |= STCconst; 
     334                    if (context.isD2()) { 
     335                        var.storage_class |= STCmanifest; 
     336                    } else { 
     337                        var.storage_class |= STCconst; 
     338                    } 
     339                     
    313340                    DeclarationExp de = new DeclarationExp(loc, var); 
    314341                    st.add(new ExpStatement(loc, de)); 
     
    323350                Dsymbol var = null; 
    324351                if (te != null) { 
    325                     if (e.type.toBasetype(context).ty == Tfunction 
    326                             && e.op == TOKvar) { 
     352                    Type tb = e.type.toBasetype(context); 
     353                     
     354                    boolean condition; 
     355                    if (context.isD2()) { 
     356                        condition = (tb.ty == Tfunction || tb.ty == Tsarray) && e.op == TOKvar; 
     357                    } else { 
     358                        condition = tb.ty == Tfunction && e.op == TOKvar; 
     359                    } 
     360                     
     361                    if (condition) { 
    327362                        VarExp ve = (VarExp) e; 
    328363                        var = new AliasDeclaration(loc, arg.ident, ve.var); 
     
    334369                        if (e.isConst()) { 
    335370                            v.storage_class |= STCconst; 
     371                        } else if (context.isD2()) { 
     372                            v.storage_class |= STCfinal; 
    336373                        } 
    337                         //              #if V2 
    338                         //                          else 
    339                         //                          v.storage_class |= STCfinal; 
    340                         //              #endif 
    341374                        var = v; 
    342375                    } 
     
    433466                var.copySourceRange(arg); 
    434467                var.storage_class |= STCforeach; 
    435                 var.storage_class |= arg.storageClass 
    436                         & (STCin | STCout | STCref); 
     468                 
     469                if (context.isD2()) { 
     470                    var.storage_class |= arg.storageClass & (STCin | STCout | STCref | STCconst | STCinvariant); 
     471                    if (dim == 2 && i == 0) { 
     472                        key = var; 
     473                        // var.storage_class |= STCfinal; 
     474                    } else { // if (!(arg.storageClass & STCref)) 
     475                        // var.storage_class |= STCfinal; 
     476                        value = var; 
     477                    } 
     478                } else { 
     479                    var.storage_class |= arg.storageClass & (STCin | STCout | STCref); 
     480                } 
    437481                 
    438482                // Descent: for binding resolution 
     
    444488                DeclarationExp de = new DeclarationExp(loc, var); 
    445489                de.semantic(sc, context); 
    446                 if (dim == 2 && i == 0) { 
    447                     key = var; 
    448                 } else { 
    449                     value = var; 
     490                 
     491                if (!context.isD2()) { 
     492                    if (dim == 2 && i == 0) { 
     493                        key = var; 
     494                    } else { 
     495                        value = var; 
     496                    } 
    450497                } 
    451498            } 
     
    455502            body = body.semantic(sc, context); 
    456503 
    457             if (!value.type.equals(tab.next)) { 
     504            boolean condition; 
     505            if (context.isD2()) { 
     506                condition = tab.nextOf().implicitConvTo(value.type, context).ordinal() < MATCHconst.ordinal(); 
     507            } else { 
     508                condition = !value.type.equals(tab.next); 
     509            } 
     510             
     511            if (condition) { 
    458512                if (aggr.op == TOKstring) { 
    459513                    aggr = aggr.implicitCastTo(sc, value.type.arrayOf(context), 
     
    589643        flde = new FuncExp(loc, fld); 
    590644        flde = flde.semantic(sc, context); 
     645         
     646        if (context.isD2()) { 
     647            fld.tookAddressOf = 0; 
     648        } 
    591649 
    592650        // Resolve any forward referenced goto's 
     
    641699            Expressions exps = new Expressions(); 
    642700            exps.add(aggr); 
    643             int keysize = taa.key.size(loc, context); 
     701            int keysize; 
     702             
     703            if (context.isD2()) { 
     704                keysize = taa.index.size(loc, context); 
     705            } else { 
     706                keysize = taa.key.size(loc, context); 
     707            } 
    644708            keysize = (keysize + 3) & ~3; 
    645709            exps.add(new IntegerExp(loc, keysize, Type.tint32)); 
     
    804868 
    805869    @Override 
    806     public boolean usesEH() { 
    807         return bo