Changeset 762
- Timestamp:
- 09/18/07 07:37:03 (1 year ago)
- Files:
-
- trunk/descent.core/src/descent/internal/compiler/parser/CompoundStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ConditionalDeclaration.java (modified) (5 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ConditionalStatement.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/DVCondition.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/DebugCondition.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/DelegateExp.java (modified) (8 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/DeleteExp.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/FuncExp.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/FuncLiteralDeclaration.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/Global.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/IdentifierExp.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/LabelStatement.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/Param.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/Parser.java (modified) (10 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ScopeStatement.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/Statement.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/TemplateInstance.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/TemplateMixin.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/VersionCondition.java (modified) (5 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/VolatileStatement.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/pending.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.core/src/descent/internal/compiler/parser/CompoundStatement.java
r755 r762 114 114 115 115 @Override 116 public Statements flatten(Scope sc ) {116 public Statements flatten(Scope sc, SemanticContext context) { 117 117 return statements; 118 118 } … … 199 199 s = statements.get(i); 200 200 if (s != null) { 201 Statements a = s.flatten(sc );201 Statements a = s.flatten(sc, context); 202 202 203 203 if (a != null) { trunk/descent.core/src/descent/internal/compiler/parser/ConditionalDeclaration.java
r748 r762 7 7 import descent.internal.compiler.parser.ast.IASTVisitor; 8 8 9 // DMD 1.020 9 10 public class ConditionalDeclaration extends AttribDeclaration { 10 11 … … 20 21 21 22 @Override 22 public int getNodeType() {23 return CONDITIONAL_DECLARATION;24 }25 26 @Override27 23 public void accept0(IASTVisitor visitor) { 28 24 boolean children = visitor.visit(this); … … 36 32 37 33 @Override 34 public int getNodeType() { 35 return CONDITIONAL_DECLARATION; 36 } 37 38 @Override 38 39 public Dsymbols include(Scope sc, ScopeDsymbol sd, SemanticContext context) { 39 40 Assert.isNotNull(condition); … … 43 44 @Override 44 45 public boolean oneMember(Dsymbol[] ps, SemanticContext context) { 45 if (condition.inc) { 46 Dsymbols d = condition.include(null, null, context) ? decl : elsedecl; 46 if (condition.inc != 0) { 47 Dsymbols d = condition.include(null, null, context) ? decl 48 : elsedecl; 47 49 return Dsymbol.oneMembers(d, ps, context); 48 50 } … … 62 64 63 65 @Override 64 public void toCBuffer(OutBuffer buf, HdrGenState hgs, SemanticContext context) { 66 public void toCBuffer(OutBuffer buf, HdrGenState hgs, 67 SemanticContext context) { 65 68 condition.toCBuffer(buf, hgs, context); 66 69 if (decl != null || elsedecl != null) { trunk/descent.core/src/descent/internal/compiler/parser/ConditionalStatement.java
r748 r762 4 4 import descent.internal.compiler.parser.ast.IASTVisitor; 5 5 6 // DMD 1.020 6 7 public class ConditionalStatement extends Statement { 7 8 public final Condition condition;9 public final Statement ifbody;10 public final Statement elsebody;11 8 12 public ConditionalStatement(Loc loc, Condition condition, Statement ifbody, Statement elsebody) { 9 public Condition condition; 10 public Statement ifbody; 11 public Statement elsebody; 12 13 public ConditionalStatement(Loc loc, Condition condition, Statement ifbody, 14 Statement elsebody) { 13 15 super(loc); 14 16 this.condition = condition; 15 17 this.ifbody = ifbody; 16 this.elsebody = elsebody; 18 this.elsebody = elsebody; 17 19 } 18 19 @Override 20 public int getNodeType() { 21 return CONDITIONAL_STATEMENT; 22 } 23 20 24 21 @Override 25 22 public void accept0(IASTVisitor visitor) { … … 33 30 } 34 31 32 @Override 33 public Statements flatten(Scope sc, SemanticContext context) { 34 Statement s; 35 36 if (condition.include(sc, null, context)) { 37 s = ifbody; 38 } else { 39 s = elsebody; 40 } 41 42 Statements a = new Statements(); 43 a.add(s); 44 return a; 45 } 46 47 @Override 48 public int getNodeType() { 49 return CONDITIONAL_STATEMENT; 50 } 51 52 @Override 53 public Statement semantic(Scope sc, SemanticContext context) { 54 if (condition.include(sc, null, context)) { 55 ifbody = ifbody.semantic(sc, context); 56 return ifbody; 57 } else { 58 if (elsebody != null) { 59 elsebody = elsebody.semantic(sc, context); 60 } 61 return elsebody; 62 } 63 } 64 65 @Override 66 public Statement syntaxCopy() { 67 Statement e = null; 68 if (elsebody != null) { 69 e = elsebody.syntaxCopy(); 70 } 71 ConditionalStatement s = new ConditionalStatement(loc, condition 72 .syntaxCopy(), ifbody.syntaxCopy(), e); 73 return s; 74 } 75 76 @Override 77 public void toCBuffer(OutBuffer buf, HdrGenState hgs, 78 SemanticContext context) { 79 condition.toCBuffer(buf, hgs, context); 80 buf.writenl(); 81 if (ifbody != null) { 82 ifbody.toCBuffer(buf, hgs, context); 83 } 84 if (elsebody != null) { 85 buf.writestring("else"); 86 buf.writenl(); 87 elsebody.toCBuffer(buf, hgs, context); 88 } 89 buf.writenl(); 90 } 91 92 @Override 93 public boolean usesEH() { 94 return (ifbody != null && ifbody.usesEH()) 95 || (elsebody != null && elsebody.usesEH()); 96 } 35 97 36 98 } trunk/descent.core/src/descent/internal/compiler/parser/DVCondition.java
r761 r762 1 1 package descent.internal.compiler.parser; 2 2 3 // DMD 1.020 3 4 public abstract class DVCondition extends Condition { 4 5 6 public Module mod; 5 7 public char[] ident; 6 8 public long level; … … 8 10 public int length; 9 11 10 public DVCondition( Loc loc, long level, char[] id) {12 public DVCondition(Module mod, Loc loc, long level, char[] id) { 11 13 super(loc); 14 this.mod = mod; 12 15 this.level = level; 13 16 this.ident = id; 14 17 } 18 19 @Override 20 public Condition syntaxCopy() { 21 return this; // don't need to copy 22 } 15 23 16 24 } trunk/descent.core/src/descent/internal/compiler/parser/DebugCondition.java
r761 r762 1 1 package descent.internal.compiler.parser; 2 3 import java.util.ArrayList; 2 4 3 5 import descent.internal.compiler.parser.ast.IASTVisitor; 4 6 7 // DMD 1.020 5 8 public class DebugCondition extends DVCondition { 6 9 7 public DebugCondition(Loc loc, long level, char[] id) { 8 super(loc, level, id); 10 public DebugCondition(Module mod, Loc loc, long level, char[] id) { 11 super(mod, loc, level, id); 12 } 13 14 @Override 15 public void accept0(IASTVisitor visitor) { 16 boolean children = visitor.visit(this); 17 if (children) { 18 } 19 visitor.endVisit(this); 20 } 21 22 public void addGlobalIdent(IdentifierExp ident, SemanticContext context) { 23 if (null == context.global.params.debugids) { 24 context.global.params.debugids = new ArrayList<char[]>(); 25 } 26 context.global.params.debugids.add(ident.ident); 9 27 } 10 28 … … 15 33 16 34 @Override 17 public void accept0(IASTVisitor visitor) { 18 boolean children = visitor.visit(this); 19 if (children) { 35 public boolean include(Scope sc, ScopeDsymbol s, SemanticContext context) { 36 if (inc == 0) { 37 inc = 2; 38 if (ident != null) { 39 if (findCondition(mod.debugids, ident)) { 40 inc = 1; 41 } else if (findCondition(context.global.params.debugids, ident)) { 42 inc = 1; 43 } else { 44 if (null == mod.debugidsNot) { 45 mod.debugidsNot = new ArrayList<char[]>(); 46 } 47 mod.debugidsNot.add(ident); 48 } 49 } else if (level <= context.global.params.debuglevel 50 || level <= mod.debuglevel) { 51 inc = 1; 52 } 20 53 } 21 visitor.endVisit(this); 54 return (inc == 1); 55 } 56 57 public void setGlobalLevel(long level, SemanticContext context) { 58 context.global.debugLevel = level; 59 } 60 61 @Override 62 public void toCBuffer(OutBuffer buf, HdrGenState hgs, 63 SemanticContext context) { 64 if (ident != null) { 65 buf.writestring("debug ("); 66 buf.writestring(ident); 67 buf.writestring(")"); 68 } else { 69 buf.writestring("debug ("); 70 buf.writestring(level); 71 buf.writestring(")"); 72 } 22 73 } 23 74 … … 31 82 } 32 83 33 @Override34 public void toCBuffer(OutBuffer buf, HdrGenState hgs, SemanticContext context) {35 if (ident != null) {36 buf.writestring("debug (");37 buf.writestring(ident);38 buf.writestring(")");39 } else {40 buf.writestring("debug (");41 buf.writestring(level);42 buf.writestring(")");43 }44 }45 46 84 } trunk/descent.core/src/descent/internal/compiler/parser/DelegateExp.java
r748 r762 1 1 package descent.internal.compiler.parser; 2 3 import melnorme.miscutil.tree.TreeVisitor; 4 import descent.internal.compiler.parser.ast.IASTVisitor; 2 5 3 6 import static descent.internal.compiler.parser.TY.Tdelegate; … … 5 8 import static descent.internal.compiler.parser.TY.Tpointer; 6 9 import static descent.internal.compiler.parser.TY.Tstruct; 7 import melnorme.miscutil.tree.TreeVisitor;8 import descent.internal.compiler.parser.ast.IASTVisitor;9 10 11 // DMD 1.020 10 12 public class DelegateExp extends UnaExp { 11 13 … … 16 18 this.func = f; 17 19 } 18 19 @Override 20 public int getNodeType() { 21 return DELEGATE_EXP; 22 } 23 20 24 21 @Override 25 22 public void accept0(IASTVisitor visitor) { … … 50 47 int[] offset = { 0 }; 51 48 if (f.tintro != null 52 && f.tintro.next.isBaseOf(f.type.next, offset, context)53 && offset[0] != 0) {49 && f.tintro.next.isBaseOf(f.type.next, offset, 50 context) && offset[0] != 0) { 54 51 error("cannot form delegate due to covariant return type"); 55 52 } … … 68 65 69 66 if (func.tintro != null 70 && func.tintro.next.isBaseOf(func.type.next, offset, context)71 && offset[0] != 0) {67 && func.tintro.next.isBaseOf(func.type.next, offset, 68 context) && offset[0] != 0) { 72 69 error("cannot form delegate due to covariant return type"); 73 70 } … … 75 72 e.type = t; 76 73 return e; 74 } 75 76 @Override 77 public int getNodeType() { 78 return DELEGATE_EXP; 77 79 } 78 80 … … 97 99 } 98 100 return result; 101 } 102 103 @Override 104 public int inlineCost(InlineCostState ics, SemanticContext context) { 105 return COST_MAX; 99 106 } 100 107 … … 136 143 } 137 144 error("this for %s needs to be type %s not type %s", 138 func.toChars(context), ad.toChars(context), t.toChars(context)); 145 func.toChars(context), ad.toChars(context), t 146 .toChars(context)); 139 147 } 140 148 } trunk/descent.core/src/descent/internal/compiler/parser/DeleteExp.java
r756 r762 1 1 package descent.internal.compiler.parser; 2 2 3 import static descent.internal.compiler.parser.TOK.TOKindex;4 import static descent.internal.compiler.parser.TY.Taarray;5 import static descent.internal.compiler.parser.TY.Tstruct;6 3 import melnorme.miscutil.tree.TreeVisitor; 7 4 import descent.core.compiler.IProblem; 8 5 import descent.internal.compiler.parser.ast.IASTVisitor; 6 import static descent.internal.compiler.parser.TOK.TOKindex; 9 7 8 import static descent.internal.compiler.parser.TY.Taarray; 9 import static descent.internal.compiler.parser.TY.Tstruct; 10 11 // DMD 1.020 10 12 public class DeleteExp extends UnaExp { 11 13 … … 13 15 super(loc, TOK.TOKdelete, e1); 14 16 } 15 16 @Override 17 public int getNodeType() { 18 return DELETE_EXP; 19 } 20 17 21 18 @Override 22 19 public void accept0(IASTVisitor visitor) { … … 27 24 visitor.endVisit(this); 28 25 } 29 26 30 27 @Override 31 28 public int checkSideEffect(int flag, SemanticContext context) { 32 29 return 1; 33 30 } 34 31 35 32 @Override 36 33 public Expression checkToBoolean(SemanticContext context) { 37 context.acceptProblem(Problem.newSemanticTypeError(IProblem.ExpressionDoesNotGiveABooleanResult, 0, start, length)); 38 return this; 34 context 35 .acceptProblem(Problem.newSemanticTypeError( 36 IProblem.ExpressionDoesNotGiveABooleanResult, 0, start, 37 length)); 38 return this; 39 } 40 41 @Override 42 public int getNodeType() { 43 return DELETE_EXP; 39 44 } 40 45 … … 108 113 return this; 109 114 } 110 115 111 116 @Override 112 public void toCBuffer(OutBuffer buf, HdrGenState hgs, SemanticContext context) { 117 public void toCBuffer(OutBuffer buf, HdrGenState hgs, 118 SemanticContext context) { 113 119 buf.writestring("delete "); 114 expToCBuffer(buf, hgs, e1, op.precedence, context);120 expToCBuffer(buf, hgs, e1, op.precedence, context); 115 121 } 116 122 trunk/descent.core/src/descent/internal/compiler/parser/FuncExp.java
r748 r762 4 4 import descent.internal.compiler.parser.ast.IASTVisitor; 5 5 6 // DMD 1.020 6 7 public class FuncExp extends Expression { 7 8 … … 14 15 15 16 @Override 16 public int getNodeType() {17 return FUNC_EXP;18 }19 20 @Override21 17 public void accept0(IASTVisitor visitor) { 22 18 boolean children = visitor.visit(this); … … 25 21 } 26 22 visitor.endVisit(this); 23 } 24 25 @Override 26 public int getNodeType() { 27 return FUNC_EXP; 28 } 29 30 @Override 31 public int inlineCost(InlineCostState ics, SemanticContext context) { 32 // Right now, this makes the function be output to the .obj file twice. 33 return COST_MAX; 34 } 35 36 @Override 37 public void scanForNestedRef(Scope sc, SemanticContext context) { 38 // empty 27 39 } 28 40 … … 58 70 return this; 59 71 } 60 72 61 73 @Override 62 74 public Expression syntaxCopy() { 63 75 return new FuncExp(loc, (FuncLiteralDeclaration) fd.syntaxCopy(null)); 64 76 } 65 77 66 78 @Override 67 public void toCBuffer(OutBuffer buf, HdrGenState hgs, SemanticContext context) { 79 public void toCBuffer(OutBuffer buf, HdrGenState hgs, 80 SemanticContext context) { 68 81 buf.writestring(fd.toChars(context)); 69 82 } trunk/descent.core/src/descent/internal/compiler/parser/FuncLiteralDeclaration.java
r748 r762 3 3 import melnorme.miscutil.tree.TreeVisitor; 4 4 import descent.internal.compiler.parser.ast.IASTVisitor; 5 import static descent.internal.compiler.parser.TOK.TOKdelegate; 5 6 7 // DMD 1.020 6 8 public class FuncLiteralDeclaration extends FuncDeclaration { 7 9 10 private final static char[] foreachBody = { '_', '_', 'f', 'o', 'r', 'e', 11 'a', 'c', 'h', 'b', 'o', 'd', 'y' }; 12 private final static char[] dgliteral = { '_', '_', 'd', 'g', 'l', 'i', 13 't', 'e', 'r', 'a', 'l' }; 14 private final static char[] funcliteral = { '_', '_', 'f', 'u', 'n', 'c', 15 'l', 'i', 't', 'e', 'r', 'a', 'l' }; 16 private final static IdentifierExp idfunc = new IdentifierExp(new char[] { 17 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n' }); 18 private final static IdentifierExp iddel = new IdentifierExp(new char[] { 19 'd', 'e', 'l', 'e', 'g', 'a', 't', 'e' }); 20 8 21 public TOK tok; // TOKfunction or TOKdelegate 9 10 public FuncLiteralDeclaration(Loc loc, Type type, TOK tok, ForeachStatement fes) { 22 23 public FuncLiteralDeclaration(Loc loc, Type type, TOK tok, 24 ForeachStatement fes) { 11 25 super(loc, null, STC.STCundefined, type); 26 char[] id; 27 28 if (fes != null) { 29 id = foreachBody; 30 } else if (tok == TOKdelegate) { 31 id = dgliteral; 32 } else { 33 id = funcliteral; 34 } 35 this.ident = new IdentifierExp(IdentifierExp.generateId(id)); 12 36 this.tok = tok; 13 // TODO semantic37 this.fes = fes; 14 38 } 15 39 16 @Override17 public int getNodeType() {18 return FUNC_LITERAL_DECLARATION;19 }20 21 40 @Override 22 41 public void accept0(IASTVisitor visitor) { … … 33 52 visitor.endVisit(this); 34 53 } 35 54 55 @Override 56 public int getNodeType() { 57 return FUNC_LITERAL_DECLARATION; 58 } 59 36 60 @Override 37 61 public FuncLiteralDeclaration isFuncLiteralDeclaration() { 38 62 return this; 39 63 } 40 64 41 65 @Override 42 66 public boolean isNested() { 43 67 return (tok == TOK.TOKdelegate); 44 68 } 45 69 70 @Override 71 public String kind() { 72 return (tok == TOKdelegate) ? "delegate" : "function"; 73 } 74 75 @Override 76 public Dsymbol syntaxCopy(Dsymbol s) { 77 FuncLiteralDeclaration f; 78 79 if (s != null) { 80 f = (FuncLiteralDeclaration) s; 81 } else { 82 f = new FuncLiteralDeclaration(loc, type.syntaxCopy(), tok, fes); 83 } 84 super.syntaxCopy(f); 85 return f; 86 } 87 88 @Override 89 public void toCBuffer(OutBuffer buf, HdrGenState hgs, 90 SemanticContext context) { 91 type.toCBuffer(buf, ((tok == TOKdelegate) ? iddel : idfunc), hgs, 92 context); 93 bodyToCBuffer(buf, hgs, context); 94 } 46 95 47 96 } trunk/descent.core/src/descent/internal/compiler/parser/Global.java
r713 r762 8 8 public int errors; 9 9 public Param params = new Param(); 10 public long debugLevel; 10 11 11 12 } trunk/descent.core/src/descent/internal/compiler/parser/IdentifierExp.java
r754 r762 7 7 // DMD 1.020 8 8 public class IdentifierExp extends Expression { 9 10 public static int count; 11 public static char[] generateId(char[] id) { 12 StringBuilder s = new StringBuilder(); 13 s.append(id); 14 s.append(count); 15 count++; 16 if (count < 0) { 17 count = 0; 18 } 19 return s.toString().toCharArray(); 20 } 9 21 10 22 public char[] ident; trunk/descent.core/src/descent/internal/compiler/parser/LabelStatement.java
r754 r762 42 42 43 43 @Override 44 public Statements flatten(Scope sc ) {44 public Statements flatten(Scope sc, SemanticContext context) { 45 45 Statements a = null; 46 46 47 47 if (statement != null) { 48 a = statement.flatten(sc );48 a = statement.flatten(sc, context); 49 49 if (a != null) { 50 50 if (0 == a.size()) { trunk/descent.core/src/descent/internal/compiler/parser/Param.java
r753 r762 49 49 String hdrname; // write 'header' file to docname 50 50 51 intdebuglevel; // debug level52 List< String> debugids; // debug identifiers51 long debuglevel; // debug level 52 List<char[]> debugids; // debug identifiers 53 53 54 intversionlevel; // version level55 List< String> versionids; // version identifiers54 long versionlevel; // version level 55 List<char[]> versionids; // version identifiers 56 56 57 57 boolean dump_source; trunk/descent.core/src/descent/internal/compiler/parser/Parser.java
r761 r762 111 111 private final static int PScurlyscope = 8; // { } starts a new scope 112 112 113 private Module module; 113 114 private ModuleDeclaration md; 114 115 private int inBrackets; … … 157 158 158 159 public Module parseModuleObj() { 159 Modulemodule = new Module(loc);160 module = new Module(loc); 160 161 module.members = parseModule(); 161 162 module.md = md; … … 939 940 nextToken(); 940 941 check(TOKrparen); 941 c = new DebugCondition( loc, level, id);942 c = new DebugCondition(module, loc, level, id); 942 943 } else { 943 c = new DebugCondition( loc, 1, null);944 c = new DebugCondition(module, loc, 1, null); 944 945 } 945 946 c.startPosition = idTokenStart; … … 975 976 parsingErrorInsertToComplete(prevToken, "(condition)", "VersionDeclaration"); 976 977 } 977 c = new VersionCondition( loc, level, id);978 c = new VersionCondition(module, loc, level, id); 978 979 c.startPosition = idTokenStart; 979 980 c.length = idTokenLength; … … 1962 1963 1963 1964 if (tiargs != null) { 1964 TemplateInstance tempinst = new TemplateInstance( id);1965 TemplateInstance tempinst = new TemplateInstance(loc, id); 1965 1966 tempinst.tiargs = tiargs; 1966 1967 tempinst.start = thisStart; … … 1990 1991 } 1991 1992 1992 tm = new TemplateMixin( id, tqual, idents, tiargs);1993 tm = new TemplateMixin(loc, id, tqual, idents, tiargs); 1993 1994 tm.setTypeSourceRange(typeStart, typeLength); 1994 1995 … … 2218 2219 if (token.value == TOKnot) { 2219 2220 nextToken(); 2220 tempinst = new TemplateInstance( id);2221 tempinst = new TemplateInstance(loc, id); 2221 2222 tempinst.tiargs = parseTemplateArgumentList(); 2222 2223 tempinst.setSourceRange(id.start, prevToken.ptr + prevToken.len - id.start); … … 2344 2345 if (token.value == TOKnot) { 2345 2346 nextToken(); 2346 tempinst[0] = new TemplateInstance( id[0]);2347 tempinst[0] = new TemplateInstance(loc, id[0]); 2347 2348 tempinst[0].tiargs = parseTemplateArgumentList(); 2348 2349 tempinst[0].setSourceRange(tempinstStart, prevToken.ptr + prevToken.len - tempinstStart); … … 5171 5172 TemplateInstance tempinst; 5172 5173 5173 tempinst = new TemplateInstance( id);5174 tempinst = new TemplateInstance(loc, id); 5174 5175 nextToken(); 5175 5176 tempinst.tiargs = parseTemplateArgumentList(); … … 5616 5617 TemplateInstance tempinst; 5617 5618 5618 tempinst = new TemplateInstance( id);5619 tempinst = new TemplateInstance(loc, id); 5619 5620 nextToken(); 5620 5621 trunk/descent.core/src/descent/internal/compiler/parser/ScopeStatement.java
r741 r762 80 80 sc = sc.push(sym); 81 81 82 a = statement.flatten(sc );82 a = statement.flatten(sc, context); 83 83 if (a != null) { 84 84 statement = new CompoundStatement(loc, a); trunk/descent.core/src/descent/internal/compiler/parser/Statement.java
r741 r762 24 24 } 25 25 26 public Statements flatten(Scope sc ) {26 public Statements flatten(Scope sc, SemanticContext context) { 27 27 return null; 28 28 } trunk/descent.core/src/descent/internal/compiler/parser/TemplateInstance.java
r753 r762 15 15 public IdentifierExp name; 16 16 17 public TemplateInstance( IdentifierExp id) {18 super( null);17 public TemplateInstance(Loc loc, IdentifierExp id) { 18 super(loc); 19 19 this.name = id; 20 20 } trunk/descent.core/src/descent/internal/compiler/parser/TemplateMixin.java
r753 r762 12 12 public int typeLength; 13 13 14 public TemplateMixin( IdentifierExp ident, Type tqual,15 Identifiers idents,Objects tiargs) {16 super( idents.get(idents.size() - 1));14 public TemplateMixin(Loc loc, IdentifierExp ident, Type tqual, Identifiers idents, 15 Objects tiargs) { 16 super(loc, idents.get(idents.size() - 1)); 17 17 this.ident = ident; 18 18 this.tqual = tqual; … … 57 57 return s; 58 58 } 59 60 @Override 61 public Dsymbol syntaxCopy(Dsymbol s) { 62 TemplateMixin tm; 63 64 Identifiers ids = new Identifiers(idents.size()); 65 for (int i = 0; i < idents.size(); i++) { // Matches TypeQualified::syntaxCopyHelper() 66 IdentifierExp id = (IdentifierExp) idents.get(i); 67 if (id.dyncast() == DYNCAST.DYNCAST_DSYMBOL) { 68 TemplateInstance ti = ((TemplateInstanceWrapper) id).tempinst; 69 70 ti = (TemplateInstance) ti.syntaxCopy(null); 71 id = new TemplateInstanceWrapper(Loc.ZERO, ti); 72 } 73 ids.set(i, id); 74 } 75 76 tm = new TemplateMixin(loc, ident, (Type) (tqual != null ? tqual 77 .syntaxCopy() : null), ids, tiargs); 78 super.syntaxCopy(tm); 79 return tm; 80 } 81 59 82 } trunk/descent.core/src/descent/internal/compiler/parser/VersionCondition.java
r761 r762 1 1 package descent.internal.compiler.parser; 2 3 import java.util.ArrayList; 2 4 3 5 import descent.core.compiler.CharOperation; … … 5 7 import descent.internal.compiler.parser.ast.IASTVisitor; 6 8 9 // DMD 1.020 7 10 public class VersionCondition extends DVCondition { 8 11 … … 16 19 { 'n', 'o', 'n', 'e' }, }; 17 20 18 public VersionCondition(Loc loc, long level, char[] id) { 19 super(loc, level, id); 21 public static void checkPredefined(Loc loc, IdentifierExp ident, 22 SemanticContext context) { 23 for (int i = 0; i < resevered.length; i++) { 24 if (ident.ident != null 25 && CharOperation.equals(ident.ident, resevered[i])) { 26 // goto Lerror; 27 context 28 .acceptProblem(Problem.newSemanticTypeError( 29 IProblem.VersionIdentifierReserved, 0, 30 ident.start, ident.length, 31 new String[] { new String(ident.ident) })); 32 } 33 } 34 35 if (ident.ident != null && ident.ident[0] == 'D' 36 && ident.ident[1] == '_') { 37 // goto Lerror; 38 context.acceptProblem(Problem.newSemanticTypeError( 39 IProblem.VersionIdentifierReserved, 0, ident.start, 40 ident.length, new String[] { new String(ident.ident) })); 41 } 42 } 43 44 public VersionCondition(Module mod, Loc loc, long level, char[] id) { 45 super(mod, loc, level, id); 46 } 47 48 @Override 49 public void accept0(IASTVisitor visitor) { 50 boolean
