Changeset 762

Show
Ignore:
Timestamp:
09/18/07 07:37:03 (1 year ago)
Author:
asterite
Message:

80 to go!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.core/src/descent/internal/compiler/parser/CompoundStatement.java

    r755 r762  
    114114 
    115115    @Override 
    116     public Statements flatten(Scope sc) { 
     116    public Statements flatten(Scope sc, SemanticContext context) { 
    117117        return statements; 
    118118    } 
     
    199199                s = statements.get(i); 
    200200                if (s != null) { 
    201                     Statements a = s.flatten(sc); 
     201                    Statements a = s.flatten(sc, context); 
    202202 
    203203                    if (a != null) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/ConditionalDeclaration.java

    r748 r762  
    77import descent.internal.compiler.parser.ast.IASTVisitor; 
    88 
     9// DMD 1.020 
    910public class ConditionalDeclaration extends AttribDeclaration { 
    1011 
     
    2021 
    2122    @Override 
    22     public int getNodeType() { 
    23         return CONDITIONAL_DECLARATION; 
    24     } 
    25      
    26     @Override 
    2723    public void accept0(IASTVisitor visitor) { 
    2824        boolean children = visitor.visit(this); 
     
    3632 
    3733    @Override 
     34    public int getNodeType() { 
     35        return CONDITIONAL_DECLARATION; 
     36    } 
     37 
     38    @Override 
    3839    public Dsymbols include(Scope sc, ScopeDsymbol sd, SemanticContext context) { 
    3940        Assert.isNotNull(condition); 
     
    4344    @Override 
    4445    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; 
    4749            return Dsymbol.oneMembers(d, ps, context); 
    4850        } 
     
    6264 
    6365    @Override 
    64     public void toCBuffer(OutBuffer buf, HdrGenState hgs, SemanticContext context) { 
     66    public void toCBuffer(OutBuffer buf, HdrGenState hgs, 
     67            SemanticContext context) { 
    6568        condition.toCBuffer(buf, hgs, context); 
    6669        if (decl != null || elsedecl != null) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/ConditionalStatement.java

    r748 r762  
    44import descent.internal.compiler.parser.ast.IASTVisitor; 
    55 
     6// DMD 1.020 
    67public class ConditionalStatement extends Statement { 
    7      
    8     public final Condition condition; 
    9     public final Statement ifbody; 
    10     public final Statement elsebody; 
    118 
    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) { 
    1315        super(loc); 
    1416        this.condition = condition; 
    1517        this.ifbody = ifbody; 
    16         this.elsebody = elsebody;       
     18        this.elsebody = elsebody; 
    1719    } 
    18      
    19     @Override 
    20     public int getNodeType() { 
    21         return CONDITIONAL_STATEMENT; 
    22     } 
    23      
     20 
    2421    @Override 
    2522    public void accept0(IASTVisitor visitor) { 
     
    3330    } 
    3431 
     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    } 
    3597 
    3698} 
  • trunk/descent.core/src/descent/internal/compiler/parser/DVCondition.java

    r761 r762  
    11package descent.internal.compiler.parser; 
    22 
     3// DMD 1.020 
    34public abstract class DVCondition extends Condition { 
    45     
     6    public Module mod; 
    57    public char[] ident; 
    68    public long level; 
     
    810    public int length; 
    911     
    10     public DVCondition(Loc loc, long level, char[] id) { 
     12    public DVCondition(Module mod, Loc loc, long level, char[] id) { 
    1113        super(loc); 
     14        this.mod = mod; 
    1215        this.level = level; 
    1316        this.ident = id; 
    1417    } 
     18     
     19    @Override 
     20    public Condition syntaxCopy() { 
     21        return this; // don't need to copy 
     22    } 
    1523 
    1624} 
  • trunk/descent.core/src/descent/internal/compiler/parser/DebugCondition.java

    r761 r762  
    11package descent.internal.compiler.parser; 
     2 
     3import java.util.ArrayList; 
    24 
    35import descent.internal.compiler.parser.ast.IASTVisitor; 
    46 
     7// DMD 1.020 
    58public class DebugCondition extends DVCondition { 
    69 
    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); 
    927    } 
    1028 
     
    1533 
    1634    @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            } 
    2053        } 
    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        } 
    2273    } 
    2374 
     
    3182    } 
    3283 
    33     @Override 
    34     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  
    4684} 
  • trunk/descent.core/src/descent/internal/compiler/parser/DelegateExp.java

    r748 r762  
    11package descent.internal.compiler.parser; 
     2 
     3import melnorme.miscutil.tree.TreeVisitor; 
     4import descent.internal.compiler.parser.ast.IASTVisitor; 
    25 
    36import static descent.internal.compiler.parser.TY.Tdelegate; 
     
    58import static descent.internal.compiler.parser.TY.Tpointer; 
    69import static descent.internal.compiler.parser.TY.Tstruct; 
    7 import melnorme.miscutil.tree.TreeVisitor; 
    8 import descent.internal.compiler.parser.ast.IASTVisitor; 
    910 
     11// DMD 1.020 
    1012public class DelegateExp extends UnaExp { 
    1113 
     
    1618        this.func = f; 
    1719    } 
    18      
    19     @Override 
    20     public int getNodeType() { 
    21         return DELEGATE_EXP; 
    22     } 
    23      
     20 
    2421    @Override 
    2522    public void accept0(IASTVisitor visitor) { 
     
    5047                        int[] offset = { 0 }; 
    5148                        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) { 
    5451                            error("cannot form delegate due to covariant return type"); 
    5552                        } 
     
    6865 
    6966            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) { 
    7269                error("cannot form delegate due to covariant return type"); 
    7370            } 
     
    7572        e.type = t; 
    7673        return e; 
     74    } 
     75 
     76    @Override 
     77    public int getNodeType() { 
     78        return DELEGATE_EXP; 
    7779    } 
    7880 
     
    9799        } 
    98100        return result; 
     101    } 
     102 
     103    @Override 
     104    public int inlineCost(InlineCostState ics, SemanticContext context) { 
     105        return COST_MAX; 
    99106    } 
    100107 
     
    136143                        } 
    137144                        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)); 
    139147                    } 
    140148                } 
  • trunk/descent.core/src/descent/internal/compiler/parser/DeleteExp.java

    r756 r762  
    11package descent.internal.compiler.parser; 
    22 
    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; 
    63import melnorme.miscutil.tree.TreeVisitor; 
    74import descent.core.compiler.IProblem; 
    85import descent.internal.compiler.parser.ast.IASTVisitor; 
     6import static descent.internal.compiler.parser.TOK.TOKindex; 
    97 
     8import static descent.internal.compiler.parser.TY.Taarray; 
     9import static descent.internal.compiler.parser.TY.Tstruct; 
     10 
     11// DMD 1.020 
    1012public class DeleteExp extends UnaExp { 
    1113 
     
    1315        super(loc, TOK.TOKdelete, e1); 
    1416    } 
    15      
    16     @Override 
    17     public int getNodeType() { 
    18         return DELETE_EXP; 
    19     } 
    20      
     17 
    2118    @Override 
    2219    public void accept0(IASTVisitor visitor) { 
     
    2724        visitor.endVisit(this); 
    2825    } 
    29      
     26 
    3027    @Override 
    3128    public int checkSideEffect(int flag, SemanticContext context) { 
    3229        return 1; 
    3330    } 
    34      
     31 
    3532    @Override 
    3633    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; 
    3944    } 
    4045 
     
    108113        return this; 
    109114    } 
    110      
     115 
    111116    @Override 
    112     public void toCBuffer(OutBuffer buf, HdrGenState hgs, SemanticContext context) { 
     117    public void toCBuffer(OutBuffer buf, HdrGenState hgs, 
     118            SemanticContext context) { 
    113119        buf.writestring("delete "); 
    114         expToCBuffer(buf, hgs, e1, op.precedence, context); 
     120       expToCBuffer(buf, hgs, e1, op.precedence, context); 
    115121    } 
    116122 
  • trunk/descent.core/src/descent/internal/compiler/parser/FuncExp.java

    r748 r762  
    44import descent.internal.compiler.parser.ast.IASTVisitor; 
    55 
     6// DMD 1.020 
    67public class FuncExp extends Expression { 
    78 
     
    1415 
    1516    @Override 
    16     public int getNodeType() { 
    17         return FUNC_EXP; 
    18     } 
    19      
    20     @Override 
    2117    public void accept0(IASTVisitor visitor) { 
    2218        boolean children = visitor.visit(this); 
     
    2521        } 
    2622        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 
    2739    } 
    2840 
     
    5870        return this; 
    5971    } 
    60      
     72 
    6173    @Override 
    6274    public Expression syntaxCopy() { 
    6375        return new FuncExp(loc, (FuncLiteralDeclaration) fd.syntaxCopy(null)); 
    6476    } 
    65      
     77 
    6678    @Override 
    67     public void toCBuffer(OutBuffer buf, HdrGenState hgs, SemanticContext context) { 
     79    public void toCBuffer(OutBuffer buf, HdrGenState hgs, 
     80            SemanticContext context) { 
    6881        buf.writestring(fd.toChars(context)); 
    6982    } 
  • trunk/descent.core/src/descent/internal/compiler/parser/FuncLiteralDeclaration.java

    r748 r762  
    33import melnorme.miscutil.tree.TreeVisitor; 
    44import descent.internal.compiler.parser.ast.IASTVisitor; 
     5import static descent.internal.compiler.parser.TOK.TOKdelegate; 
    56 
     7// DMD 1.020 
    68public 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 
    821    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) { 
    1125        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)); 
    1236        this.tok = tok; 
    13         // TODO semantic 
     37        this.fes = fes; 
    1438    } 
    1539 
    16     @Override 
    17     public int getNodeType() { 
    18         return FUNC_LITERAL_DECLARATION; 
    19     } 
    20      
    2140    @Override 
    2241    public void accept0(IASTVisitor visitor) { 
     
    3352        visitor.endVisit(this); 
    3453    } 
    35      
     54 
     55    @Override 
     56    public int getNodeType() { 
     57        return FUNC_LITERAL_DECLARATION; 
     58    } 
     59 
    3660    @Override 
    3761    public FuncLiteralDeclaration isFuncLiteralDeclaration() { 
    3862        return this; 
    3963    } 
    40      
     64 
    4165    @Override 
    4266    public boolean isNested() { 
    4367        return (tok == TOK.TOKdelegate); 
    4468    } 
    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    } 
    4695 
    4796} 
  • trunk/descent.core/src/descent/internal/compiler/parser/Global.java

    r713 r762  
    88    public int errors; 
    99    public Param params = new Param(); 
     10    public long debugLevel; 
    1011 
    1112} 
  • trunk/descent.core/src/descent/internal/compiler/parser/IdentifierExp.java

    r754 r762  
    77// DMD 1.020 
    88public 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    } 
    921 
    1022    public char[] ident; 
  • trunk/descent.core/src/descent/internal/compiler/parser/LabelStatement.java

    r754 r762  
    4242 
    4343    @Override 
    44     public Statements flatten(Scope sc) { 
     44    public Statements flatten(Scope sc, SemanticContext context) { 
    4545        Statements a = null; 
    4646 
    4747        if (statement != null) { 
    48             a = statement.flatten(sc); 
     48            a = statement.flatten(sc, context); 
    4949            if (a != null) { 
    5050                if (0 == a.size()) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/Param.java

    r753 r762  
    4949    String hdrname;     // write 'header' file to docname 
    5050 
    51     int debuglevel;   // debug level 
    52     List<String> debugids;        // debug identifiers 
     51    long debuglevel;  // debug level 
     52    List<char[]> debugids;        // debug identifiers 
    5353 
    54     int versionlevel; // version level 
    55     List<String> versionids;      // version identifiers 
     54    long versionlevel;    // version level 
     55    List<char[]> versionids;      // version identifiers 
    5656 
    5757    boolean dump_source; 
  • trunk/descent.core/src/descent/internal/compiler/parser/Parser.java

    r761 r762  
    111111    private final static int PScurlyscope = 8;  // { } starts a new scope 
    112112 
     113    private Module module; 
    113114    private ModuleDeclaration md; 
    114115    private int inBrackets;  
     
    157158     
    158159    public Module parseModuleObj() { 
    159         Module module = new Module(loc); 
     160        module = new Module(loc); 
    160161        module.members = parseModule(); 
    161162        module.md = md; 
     
    939940            nextToken(); 
    940941            check(TOKrparen); 
    941             c = new DebugCondition(loc, level, id); 
     942            c = new DebugCondition(module, loc, level, id); 
    942943        } else { 
    943             c = new DebugCondition(loc, 1, null); 
     944            c = new DebugCondition(module, loc, 1, null); 
    944945        } 
    945946        c.startPosition = idTokenStart; 
     
    975976            parsingErrorInsertToComplete(prevToken, "(condition)", "VersionDeclaration"); 
    976977        } 
    977         c = new VersionCondition(loc, level, id); 
     978        c = new VersionCondition(module, loc, level, id); 
    978979        c.startPosition = idTokenStart; 
    979980        c.length = idTokenLength; 
     
    19621963             
    19631964            if (tiargs != null) { 
    1964                 TemplateInstance tempinst = new TemplateInstance(id); 
     1965                TemplateInstance tempinst = new TemplateInstance(loc, id); 
    19651966                tempinst.tiargs = tiargs; 
    19661967                tempinst.start = thisStart; 
     
    19901991        } 
    19911992         
    1992         tm = new TemplateMixin(id, tqual, idents, tiargs); 
     1993        tm = new TemplateMixin(loc, id, tqual, idents, tiargs); 
    19931994        tm.setTypeSourceRange(typeStart, typeLength); 
    19941995 
     
    22182219            if (token.value == TOKnot) { 
    22192220                nextToken(); 
    2220                 tempinst = new TemplateInstance(id); 
     2221                tempinst = new TemplateInstance(loc, id); 
    22212222                tempinst.tiargs = parseTemplateArgumentList(); 
    22222223                tempinst.setSourceRange(id.start, prevToken.ptr + prevToken.len - id.start); 
     
    23442345            if (token.value == TOKnot) { 
    23452346                nextToken(); 
    2346                 tempinst[0] = new TemplateInstance(id[0]); 
     2347                tempinst[0] = new TemplateInstance(loc, id[0]); 
    23472348                tempinst[0].tiargs = parseTemplateArgumentList(); 
    23482349                tempinst[0].setSourceRange(tempinstStart, prevToken.ptr + prevToken.len - tempinstStart); 
     
    51715172                TemplateInstance tempinst; 
    51725173                 
    5173                 tempinst = new TemplateInstance(id);               
     5174                tempinst = new TemplateInstance(loc, id);              
    51745175                nextToken(); 
    51755176                tempinst.tiargs = parseTemplateArgumentList(); 
     
    56165617                        TemplateInstance tempinst; 
    56175618                         
    5618                         tempinst = new TemplateInstance(id);                       
     5619                        tempinst = new TemplateInstance(loc, id);                      
    56195620                        nextToken(); 
    56205621                         
  • trunk/descent.core/src/descent/internal/compiler/parser/ScopeStatement.java

    r741 r762  
    8080            sc = sc.push(sym); 
    8181 
    82             a = statement.flatten(sc); 
     82            a = statement.flatten(sc, context); 
    8383            if (a != null) { 
    8484                statement = new CompoundStatement(loc, a); 
  • trunk/descent.core/src/descent/internal/compiler/parser/Statement.java

    r741 r762  
    2424    } 
    2525 
    26     public Statements flatten(Scope sc) { 
     26    public Statements flatten(Scope sc, SemanticContext context) { 
    2727        return null; 
    2828    } 
  • trunk/descent.core/src/descent/internal/compiler/parser/TemplateInstance.java

    r753 r762  
    1515    public IdentifierExp name; 
    1616 
    17     public TemplateInstance(IdentifierExp id) { 
    18         super(null); 
     17    public TemplateInstance(Loc loc, IdentifierExp id) { 
     18        super(loc); 
    1919        this.name = id; 
    2020    } 
  • trunk/descent.core/src/descent/internal/compiler/parser/TemplateMixin.java

    r753 r762  
    1212    public int typeLength; 
    1313 
    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)); 
    1717        this.ident = ident; 
    1818        this.tqual = tqual; 
     
    5757        return s; 
    5858    } 
     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 
    5982} 
  • trunk/descent.core/src/descent/internal/compiler/parser/VersionCondition.java

    r761 r762  
    11package descent.internal.compiler.parser; 
     2 
     3import java.util.ArrayList; 
    24 
    35import descent.core.compiler.CharOperation; 
     
    57import descent.internal.compiler.parser.ast.IASTVisitor; 
    68 
     9// DMD 1.020 
    710public class VersionCondition extends DVCondition { 
    811 
     
    1619            { 'n', 'o', 'n', 'e' }, }; 
    1720 
    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