Changeset 1188
- Timestamp:
- 06/16/08 13:27:07 (6 months ago)
- Files:
-
- trunk/descent.building/META-INF/MANIFEST.MF (modified) (1 diff)
- trunk/descent.core/src/descent/core/Signature.java (modified) (4 diffs)
- trunk/descent.core/src/descent/core/compiler/IProblem.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/BE.java (added)
- trunk/descent.core/src/descent/internal/compiler/parser/BreakStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/CaseStatement.java (modified) (5 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/Catch.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/CompoundStatement.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ConditionalStatement.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/ContinueStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/DeclarationStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/DefaultStatement.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/DoStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ExpStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/Expression.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/ForStatement.java (modified) (5 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ForeachStatement.java (modified) (14 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/GotoCaseStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/GotoDefaultStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/GotoStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ISignatureConstants.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/IfStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/LabelStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/OnScopeStatement.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/PragmaStatement.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/Problem.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.properties (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/ReturnStatement.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ScopeStatement.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/Statement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/SwitchErrorStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/SwitchStatement.java (modified) (6 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/SynchronizedStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ThrowStatement.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/TryCatchStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/TryFinallyStatement.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/UnrolledLoopStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/VarDeclaration.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/VolatileStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/WhileStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/WithStatement.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/port.txt (modified) (1 diff)
- trunk/descent.core/template/problem.sh (added)
- trunk/descent.core/template/problem/problems.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.building/META-INF/MANIFEST.MF
r1184 r1188 12 12 descent.ui, 13 13 descent.launching, 14 org.eclipse.ui.forms 14 org.eclipse.ui.forms, 15 org.eclipse.core.resources 15 16 Eclipse-LazyStart: true trunk/descent.core/src/descent/core/Signature.java
r1165 r1188 96 96 * 97 97 * SliceTypeSignature ::= 98 * " ¬" TypeSignature "¬"99 * Number " ¬" Chars // Number == Chars.length --> lower100 * Number " ¬" Chars // Number == Chars.length --> upper98 * "" TypeSignature "" 99 * Number "" Chars // Number == Chars.length --> lower 100 * Number "" Chars // Number == Chars.length --> upper 101 101 * 102 102 * FunctionTypeSignature ::= … … 133 133 * | "|" // interface 134 134 * | "E" // enum 135 * | " ¡" // variable135 * | "" // variable 136 136 * | "=" // alias 137 137 * | "T" // typedef … … 398 398 /** 399 399 * 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 = '¬'; 403 403 404 404 /** … … 494 494 /** 495 495 * 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 = '¡'; 499 499 500 500 /** trunk/descent.core/src/descent/core/compiler/IProblem.java
r1176 r1188 673 673 int CannotHaveEDotTuple = 462; 674 674 int CannotCreateCppClasses = 463; 675 int SwitchAndCaseAreInDifferentFinallyBlocks = 464; 676 int SwitchAndDefaultAreInDifferentFinallyBlocks = 465; 675 677 676 678 } trunk/descent.core/src/descent/internal/compiler/parser/BreakStatement.java
r1160 r1188 1 1 package descent.internal.compiler.parser; 2 2 3 import static descent.internal.compiler.parser.BE.BEbreak; 4 import static descent.internal.compiler.parser.BE.BEgoto; 3 5 import melnorme.miscutil.tree.TreeVisitor; 4 6 import descent.core.compiler.IProblem; 5 7 import descent.internal.compiler.parser.ast.IASTVisitor; 6 7 8 8 9 public class BreakStatement extends Statement { … … 22 23 } 23 24 visitor.endVisit(this); 25 } 26 27 @Override 28 public int blockExit(SemanticContext context) { 29 return ident != null ? BEgoto : BEbreak; 24 30 } 25 31 trunk/descent.core/src/descent/internal/compiler/parser/CaseStatement.java
r1160 r1188 1 1 package descent.internal.compiler.parser; 2 2 3 import static descent.internal.compiler.parser.BE.BEany; 4 import static descent.internal.compiler.parser.TOK.TOKint64; 5 import static descent.internal.compiler.parser.TOK.TOKstring; 6 import static descent.internal.compiler.parser.TOK.TOKvar; 7 import static descent.internal.compiler.parser.TY.Tclass; 3 8 import melnorme.miscutil.tree.TreeVisitor; 4 9 import descent.core.compiler.IProblem; 5 10 import 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 9 11 10 12 public class CaseStatement extends Statement { … … 29 31 } 30 32 visitor.endVisit(this); 33 } 34 35 @Override 36 public int blockExit(SemanticContext context) { 37 // Assume the worst 38 return BEany; 31 39 } 32 40 … … 79 87 exp = exp.implicitCastTo(sc, sw.condition.type, context); 80 88 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 } 84 107 } 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 } 86 117 } 87 118 119 // L1: 88 120 for (i = 0; i < sw.cases.size(); i++) { 89 121 CaseStatement cs = (CaseStatement) sw.cases.get(i); 90 122 91 //printf("comparing '%s' with '%s'\n", exp.toChars(), cs.exp.toChars());92 123 if (cs.exp.equals(exp)) { 93 124 if (context.acceptsProblems()) { … … 108 139 gcs.cs = this; 109 140 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)); 110 149 } 111 150 } … … 140 179 141 180 @Override 142 public boolean usesEH( ) {143 return statement.usesEH( );181 public boolean usesEH(SemanticContext context) { 182 return statement.usesEH(context); 144 183 } 145 184 trunk/descent.core/src/descent/internal/compiler/parser/Catch.java
r1160 r1188 1 1 package descent.internal.compiler.parser; 2 2 3 import static descent.internal.compiler.parser.BE.BEfallthru; 3 4 import melnorme.miscutil.tree.TreeVisitor; 4 5 import descent.core.compiler.IProblem; … … 30 31 } 31 32 visitor.endVisit(this); 33 } 34 35 public int blockExit(SemanticContext context) { 36 return handler != null ? handler.blockExit(context) : BEfallthru; 32 37 } 33 38 … … 91 96 buf.writebyte('{'); 92 97 buf.writenl(); 93 handler.toCBuffer(buf, hgs, context); 98 if (handler != null) { 99 handler.toCBuffer(buf, hgs, context); 100 } 94 101 buf.writebyte('}'); 95 102 buf.writenl(); trunk/descent.core/src/descent/internal/compiler/parser/CompoundStatement.java
r1160 r1188 4 4 import descent.core.compiler.IProblem; 5 5 import descent.internal.compiler.parser.ast.IASTVisitor; 6 6 import static descent.internal.compiler.parser.BE.*; 7 7 8 8 public class CompoundStatement extends Statement { … … 37 37 visitor.endVisit(this); 38 38 } 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 } 39 60 40 61 @Override … … 150 171 Statement[] sfinally = { null }; 151 172 152 s.scopeCode(s entry, sexception, sfinally);173 s.scopeCode(sc, sentry, sexception, sfinally); 153 174 if (sentry[0] != null) { 154 175 sentry[0] = sentry[0].semantic(sc, context); … … 259 280 260 281 @Override 261 public boolean usesEH( ) {282 public boolean usesEH(SemanticContext context) { 262 283 for (int i = 0; i < statements.size(); i++) { 263 284 Statement s; 264 285 265 286 s = statements.get(i); 266 if (s != null && s.usesEH( )) {287 if (s != null && s.usesEH(context)) { 267 288 return true; 268 289 } trunk/descent.core/src/descent/internal/compiler/parser/ConditionalStatement.java
r1160 r1188 93 93 94 94 @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)); 98 98 } 99 99 trunk/descent.core/src/descent/internal/compiler/parser/ContinueStatement.java
r1160 r1188 1 1 package descent.internal.compiler.parser; 2 2 3 import static descent.internal.compiler.parser.BE.BEcontinue; 4 import static descent.internal.compiler.parser.BE.BEgoto; 3 5 import melnorme.miscutil.tree.TreeVisitor; 4 6 import descent.core.compiler.IProblem; 5 7 import descent.internal.compiler.parser.ast.IASTVisitor; 6 7 8 8 9 public class ContinueStatement extends Statement { … … 22 23 } 23 24 visitor.endVisit(this); 25 } 26 27 @Override 28 public int blockExit(SemanticContext context) { 29 return ident != null ? BEgoto : BEcontinue; 24 30 } 25 31 trunk/descent.core/src/descent/internal/compiler/parser/DeclarationStatement.java
r1160 r1188 32 32 33 33 @Override 34 public void scopeCode(S tatement[] sentry, Statement[] sexception,34 public void scopeCode(Scope sc, Statement[] sentry, Statement[] sexception, 35 35 Statement[] sfinally) { 36 36 sentry[0] = null; … … 45 45 Expression e; 46 46 47 e = v.callAutoDtor( );47 e = v.callAutoDtor(sc); 48 48 if (e != null) { 49 49 sfinally[0] = new ExpStatement(loc, e); trunk/descent.core/src/descent/internal/compiler/parser/DefaultStatement.java
r1160 r1188 1 1 package descent.internal.compiler.parser; 2 2 3 import static descent.internal.compiler.parser.BE.BEany; 3 4 import melnorme.miscutil.tree.TreeVisitor; 4 5 import descent.core.compiler.IProblem; 5 6 import descent.internal.compiler.parser.ast.IASTVisitor; 6 7 7 8 8 public class DefaultStatement extends Statement { … … 24 24 } 25 25 visitor.endVisit(this); 26 } 27 28 @Override 29 public int blockExit(SemanticContext context) { 30 // Assume the worst 31 return BEany; 26 32 } 27 33 … … 62 68 } 63 69 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 } 64 78 } else { 65 79 if (context.acceptsProblems()) { … … 86 100 87 101 @Override 88 public boolean usesEH( ) {89 return statement.usesEH( );102 public boolean usesEH(SemanticContext context) { 103 return statement.usesEH(context); 90 104 } 91 105 trunk/descent.core/src/descent/internal/compiler/parser/DoStatement.java
r1160 r1188 3 3 import melnorme.miscutil.tree.TreeVisitor; 4 4 import descent.internal.compiler.parser.ast.IASTVisitor; 5 5 import static descent.internal.compiler.parser.BE.*; 6 6 7 7 public class DoStatement extends Statement { … … 24 24 } 25 25 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; 26 51 } 27 52 … … 158 183 159 184 @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; 162 187 } 163 188 trunk/descent.core/src/descent/internal/compiler/parser/ExpStatement.java
r1160 r1188 5 5 import static descent.internal.compiler.parser.TOK.TOKassert; 6 6 import static descent.internal.compiler.parser.TOK.TOKhalt; 7 import static descent.internal.compiler.parser.BE.*; 7 8 8 9 … … 24 25 } 25 26 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; 26 50 } 27 51 trunk/descent.core/src/descent/internal/compiler/parser/Expression.java
r1176 r1188 124 124 e.type = type.pointerTo(context); 125 125 return e; 126 } 127 128 public boolean canThrow() { 129 return false; 126 130 } 127 131 trunk/descent.core/src/descent/internal/compiler/parser/ForStatement.java
r1160 r1188 3 3 import melnorme.miscutil.tree.TreeVisitor; 4 4 import descent.internal.compiler.parser.ast.IASTVisitor; 5 5 import static descent.internal.compiler.parser.BE.*; 6 6 7 7 public class ForStatement extends Statement { … … 32 32 visitor.endVisit(this); 33 33 } 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 } 34 63 35 64 @Override … … 144 173 145 174 @Override 146 public void scopeCode(S tatement[] sentry, Statement[] sexception,175 public void scopeCode(Scope sc, Statement[] sentry, Statement[] sexception, 147 176 Statement[] sfinally) { 148 177 if (init != null) { 149 init.scopeCode(s entry, sexception, sfinally);178 init.scopeCode(sc, sentry, sexception, sfinally); 150 179 } else { 151 super.scopeCode(s entry, sexception, sfinally);180 super.scopeCode(sc, sentry, sexception, sfinally); 152 181 } 153 182 } … … 166 195 } 167 196 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 173 212 if (increment != null) { 174 213 increment = increment.semantic(sc, context); … … 239 278 240 279 @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); 243 282 } 244 283 trunk/descent.core/src/descent/internal/compiler/parser/ForeachStatement.java
r1160 r1188 1 1 package descent.internal.compiler.parser; 2 2 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;11 3 import static descent.internal.compiler.parser.Constfold.ArrayLength; 12 4 import static descent.internal.compiler.parser.Constfold.Index; 13 5 import static descent.internal.compiler.parser.MATCH.MATCHconst; 14 6 import static descent.internal.compiler.parser.STC.STCconst; 7 import static descent.internal.compiler.parser.STC.STCfinal; 15 8 import static descent.internal.compiler.parser.STC.STCforeach; 16 9 import static descent.internal.compiler.parser.STC.STCin; 10 import static descent.internal.compiler.parser.STC.STCinvariant; 17 11 import static descent.internal.compiler.parser.STC.STClazy; 12 import static descent.internal.compiler.parser.STC.STCmanifest; 18 13 import static descent.internal.compiler.parser.STC.STCout; 19 14 import static descent.internal.compiler.parser.STC.STCref; 20 21 15 import static descent.internal.compiler.parser.TOK.TOKdelegate; 22 16 import static descent.internal.compiler.parser.TOK.TOKforeach; … … 26 20 import static descent.internal.compiler.parser.TOK.TOKtype; 27 21 import static descent.internal.compiler.parser.TOK.TOKvar; 28 29 22 import static descent.internal.compiler.parser.TY.Taarray; 30 23 import static descent.internal.compiler.parser.TY.Tarray; … … 40 33 import static descent.internal.compiler.parser.TY.Tuns64; 41 34 import static descent.internal.compiler.parser.TY.Twchar; 35 import static descent.internal.compiler.parser.BE.*; 36 37 import java.util.List; 38 39 import melnorme.miscutil.tree.TreeVisitor; 40 41 import org.eclipse.core.runtime.Assert; 42 43 import descent.core.compiler.IProblem; 44 import descent.internal.compiler.parser.ast.IASTVisitor; 42 45 43 46 … … 83 86 } 84 87 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; 85 102 } 86 103 … … 231 248 aggr = aggr.semantic(sc, context); 232 249 aggr = resolveProperties(sc, aggr, context); 250 251 if (context.isD2()) { 252 aggr = aggr.optimize(WANTvalue, context); 253 } 254 233 255 if (aggr.type == null) { 234 256 if (context.acceptsProblems()) { … … 310 332 arg.var = var; 311 333 312 var.storage_class |= STCconst; 334 if (context.isD2()) { 335 var.storage_class |= STCmanifest; 336 } else { 337 var.storage_class |= STCconst; 338 } 339 313 340 DeclarationExp de = new DeclarationExp(loc, var); 314 341 st.add(new ExpStatement(loc, de)); … … 323 350 Dsymbol var = null; 324 351 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) { 327 362 VarExp ve = (VarExp) e; 328 363 var = new AliasDeclaration(loc, arg.ident, ve.var); … … 334 369 if (e.isConst()) { 335 370 v.storage_class |= STCconst; 371 } else if (context.isD2()) { 372 v.storage_class |= STCfinal; 336 373 } 337 // #if V2338 // else339 // v.storage_class |= STCfinal;340 // #endif341 374 var = v; 342 375 } … … 433 466 var.copySourceRange(arg); 434 467 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 } 437 481 438 482 // Descent: for binding resolution … … 444 488 DeclarationExp de = new DeclarationExp(loc, var); 445 489 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 } 450 497 } 451 498 } … … 455 502 body = body.semantic(sc, context); 456 503 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) { 458 512 if (aggr.op == TOKstring) { 459 513 aggr = aggr.implicitCastTo(sc, value.type.arrayOf(context), … … 589 643 flde = new FuncExp(loc, fld); 590 644 flde = flde.semantic(sc, context); 645 646 if (context.isD2()) { 647 fld.tookAddressOf = 0; 648 } 591 649 592 650 // Resolve any forward referenced goto's … … 641 699 Expressions exps = new Expressions(); 642 700 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 } 644 708 keysize = (keysize + 3) & ~3; 645 709 exps.add(new IntegerExp(loc, keysize, Type.tint32)); … … 804 868 805 869 @Override 806 public boolean usesEH( ) {807 return bo
