Changeset 1167

Show
Ignore:
Timestamp:
05/17/08 10:22:56 (2 months ago)
Author:
asterite
Message:

Updated to DMD 1.030.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.core/src/descent/core/compiler/IProblem.java

    r1165 r1167  
    671671    int TypeofReturnMustBeInsideFunction = 460; 
    672672    int PostBlitsAreOnlyForStructUnionDefinitions = 461; 
     673    int CannotHaveEDotTuple = 462; 
    673674 
    674675} 
  • trunk/descent.core/src/descent/core/dom/ASTConverter.java

    r1166 r1167  
    544544     
    545545    public void convert(StorageClassDeclaration a, List<Declaration> toAdd) { 
    546         descent.core.dom.Modifier modifier = convert(a.modifier); 
     546        descent.core.dom.Modifier modifier = null; 
     547         
     548        if (a.modifier != null) { 
     549            convert(a.modifier); 
     550        } 
    547551         
    548552        if (a.single && a.decl != null && a.decl.size() >= 1) { 
     
    585589        } 
    586590         
    587         descent.core.dom.ModifierDeclaration b = new descent.core.dom.ModifierDeclaration(ast);          
    588         b.setModifier(modifier); 
     591        descent.core.dom.ModifierDeclaration b = new descent.core.dom.ModifierDeclaration(ast); 
     592        if (modifier != null) { 
     593            b.setModifier(modifier); 
     594        } 
    589595        convertDeclarations(b.declarations(), a.decl); 
    590596        b.setSourceRange(a.start, a.length); 
     
    615621 
    616622    public void convert(ProtDeclaration a, List<Declaration> toAdd) { 
    617         descent.core.dom.Modifier modifier = convert(a.modifier); 
     623        descent.core.dom.Modifier modifier = null; 
     624        if (a.modifier != null) { 
     625            modifier = convert(a.modifier); 
     626        } 
    618627         
    619628        if (a.single && a.decl != null && a.decl.size() > 0) { 
     
    646655        } 
    647656         
    648         descent.core.dom.ModifierDeclaration b = new descent.core.dom.ModifierDeclaration(ast);          
    649         b.setModifier(modifier); 
     657        descent.core.dom.ModifierDeclaration b = new descent.core.dom.ModifierDeclaration(ast); 
     658        if (modifier != null) { 
     659            b.setModifier(modifier); 
     660        } 
    650661        convertDeclarations(b.declarations(), a.decl); 
    651662        b.setSourceRange(a.start, a.length); 
  • trunk/descent.core/src/descent/internal/compiler/parser/ASTDmdNode.java

    r1165 r1167  
    4444import static descent.internal.compiler.parser.TY.Tfunction; 
    4545import static descent.internal.compiler.parser.TY.Tident; 
     46import static descent.internal.compiler.parser.TY.Tpointer; 
    4647import static descent.internal.compiler.parser.TY.Tsarray; 
    4748import static descent.internal.compiler.parser.TY.Tstruct; 
     
    18941895    } 
    18951896     
     1897    /************************************************************* 
     1898     * Now that we have the right function f, we need to get the 
     1899     * right 'this' pointer if f is in an outer class, but our 
     1900     * existing 'this' pointer is in an inner class. 
     1901     * This code is analogous to that used for variables 
     1902     * in DotVarExp::semantic(). 
     1903     */ 
     1904    public static Expression getRightThis(Loc loc, Scope sc, 
     1905            AggregateDeclaration ad, Expression e1, Declaration var, 
     1906            SemanticContext context) { 
     1907        boolean gotoL1 = true; 
     1908    L1: 
     1909        while(gotoL1) { 
     1910            gotoL1 = false; 
     1911             
     1912            Type t = e1.type.toBasetype(context); 
     1913     
     1914            if (ad != null 
     1915                    && !(t.ty == Tpointer && t.next.ty == Tstruct && ((TypeStruct) t.next).sym == ad) 
     1916                    && !(t.ty == Tstruct && ((TypeStruct) t).sym == ad)) { 
     1917                ClassDeclaration cd = ad.isClassDeclaration(); 
     1918                ClassDeclaration tcd = t.isClassHandle(); 
     1919     
     1920                if (null == cd || null == tcd 
     1921                        || !(tcd == cd || cd.isBaseOf(tcd, null, context))) { 
     1922                    if (tcd != null && tcd.isNested()) { // Try again with outer scope 
     1923     
     1924                        e1 = new DotVarExp(loc, e1, tcd.vthis); 
     1925                        e1 = e1.semantic(sc, context); 
     1926     
     1927                        // Skip over nested functions, and get the enclosing 
     1928                        // class type. 
     1929                        Dsymbol s = tcd.toParent(); 
     1930                        while (s != null && s.isFuncDeclaration() != null) { 
     1931                            FuncDeclaration f = s.isFuncDeclaration(); 
     1932                            if (f.vthis != null) { 
     1933                                e1 = new VarExp(loc, f.vthis); 
     1934                            } 
     1935                            s = s.toParent(); 
     1936                        } 
     1937                        if (s != null && s.isClassDeclaration() != null) { 
     1938                            e1.type = s.isClassDeclaration().type; 
     1939                        } 
     1940                        e1 = e1.semantic(sc, context); 
     1941                        // goto L1; 
     1942                        gotoL1 = true; 
     1943                        continue L1; 
     1944                    } 
     1945                    if (context.acceptsProblems()) { 
     1946                        context.acceptProblem(Problem.newSemanticTypeError(IProblem.ThisForSymbolNeedsToBeType, var, new String[] { var 
     1947                                .toChars(context), ad.toChars(context), t 
     1948                                .toChars(context) })); 
     1949                    } 
     1950                } 
     1951            } 
     1952        } 
     1953        return e1; 
     1954    } 
     1955     
    18961956    public void errorOnModifier(int problemId, TOK tok, SemanticContext context) { 
    18971957        boolean reported = false; 
  • trunk/descent.core/src/descent/internal/compiler/parser/BinExp.java

    r1161 r1167  
    474474            return this; 
    475475        } else if (t1.ty == Tclass || t2.ty == Tclass) { 
    476             MATCH i1; 
    477             MATCH i2; 
    478  
    479             i1 = e2.implicitConvTo(t1, context); 
    480             i2 = e1.implicitConvTo(t2, context); 
    481  
    482             if (i1 != MATCHnomatch && i2 != MATCHnomatch) { 
    483                 // We have the case of class vs. void*, so pick class 
    484                 if (t1.ty == Tpointer) { 
    485                     i1 = MATCHnomatch; 
    486                 } else if (t2.ty == Tpointer) { 
    487                     i2 = MATCHnomatch; 
    488                 } 
    489             } 
    490  
    491             if (i2 != MATCHnomatch) { 
    492                 // goto Lt2; 
    493                 e1 = e1.castTo(sc, t2, context); 
    494                 t = t2; 
    495                 if (type == null) { 
    496                     type = t; 
    497                 } 
    498                 return this; 
    499             } else if (i1 != MATCHnomatch) { 
    500                 // goto Lt1; 
    501                 e2 = e2.castTo(sc, t1, context); 
    502                 t = t1; 
    503                 if (type == null) { 
    504                     type = t; 
    505                 } 
    506                 return this; 
    507             } else { 
    508                 return typeCombine_Lincompatible_End(t, context); 
     476 
     477            while(true) { 
     478                MATCH i1 = e2.implicitConvTo(t1, context); 
     479                MATCH i2 = e1.implicitConvTo(t2, context); 
     480     
     481                if (i1 != MATCHnomatch && i2 != MATCHnomatch) { 
     482                    // We have the case of class vs. void*, so pick class 
     483                    if (t1.ty == Tpointer) { 
     484                        i1 = MATCHnomatch; 
     485                    } else if (t2.ty == Tpointer) { 
     486                        i2 = MATCHnomatch; 
     487                    } 
     488                } 
     489     
     490                if (i2 != MATCHnomatch) { 
     491                    // goto Lt2; 
     492                    e1 = e1.castTo(sc, t2, context); 
     493                    t = t2; 
     494                    if (type == null) { 
     495                        type = t; 
     496                    } 
     497                    return this; 
     498                } else if (i1 != MATCHnomatch) { 
     499                    // goto Lt1; 
     500                    e2 = e2.castTo(sc, t1, context); 
     501                    t = t1; 
     502                    if (type == null) { 
     503                        type = t; 
     504                    } 
     505                    return this; 
     506                } else if (t1.ty == Tclass && t2.ty == Tclass) { 
     507                    TypeClass tc1 = (TypeClass) t1; 
     508                    TypeClass tc2 = (TypeClass) t2; 
     509 
     510                    /* Pick 'tightest' type 
     511                     */ 
     512                    ClassDeclaration cd1 = tc1.sym.baseClass; 
     513                    ClassDeclaration cd2 = tc2.sym.baseClass; 
     514 
     515                    if (cd1 != null && cd2 != null) { 
     516                        t1 = cd1.type; 
     517                        t2 = cd2.type; 
     518                    } else if (cd1 != null) 
     519                        t1 = cd1.type; 
     520                    else if (cd2 != null) 
     521                        t2 = cd2.type; 
     522                    else { 
     523                        // goto Lincompatible; 
     524                        return typeCombine_Lincompatible_End(t, context); 
     525                    } 
     526                } else { 
     527                    return typeCombine_Lincompatible_End(t, context); 
     528                } 
    509529            } 
    510530        } else if ((e1.op == TOKstring || e1.op == TOKnull) 
  • trunk/descent.core/src/descent/internal/compiler/parser/CallExp.java

    r1165 r1167  
    391391                    ad = td.toParent().isAggregateDeclaration(); 
    392392                } 
    393                 /* Now that we have the right function f, we need to get the 
    394                  * right 'this' pointer if f is in an outer class, but our 
    395                  * existing 'this' pointer is in an inner class. 
    396                  * This code is analogous to that used for variables 
    397                  * in DotVarExp.semantic(). 
    398                  */ 
    399                 boolean loopL10 = true; 
    400                 L10: while (loopL10) { 
    401                     loopL10 = false; 
    402                     Type t = ue.e1.type.toBasetype(context); 
    403                     if (f.needThis() 
    404                             && ad != null 
    405                             && !(t.ty == Tpointer && t.next.ty == Tstruct && ((TypeStruct) t.next).sym == ad) 
    406                             && !(t.ty == Tstruct && ((TypeStruct) t).sym == ad)) { 
    407                         ClassDeclaration cd = ad.isClassDeclaration(); 
    408                         ClassDeclaration tcd = t.isClassHandle(); 
    409  
    410                         if (cd == null 
    411                                 || tcd == null 
    412                                 || !(tcd == cd || cd.isBaseOf(tcd, null, 
    413                                         context))) { 
    414                             if (tcd != null && tcd.isNested()) { // Try again with outer scope 
    415  
    416                                 ue.e1 = new DotVarExp(loc, ue.e1, tcd.vthis); 
    417                                 ue.e1 = ue.e1.semantic(sc, context); 
    418                                 // goto L10; 
    419                                 loopL10 = true; 
    420                                 continue L10; 
    421                             } 
    422                             if (context.acceptsProblems()) { 
    423                                 context.acceptProblem(Problem.newSemanticTypeError(IProblem.ThisForSymbolNeedsToBeType, this, new String[] { f.toChars(context), ad.toChars(context), t 
    424                                                 .toChars(context) })); 
    425                             } 
    426                         } 
    427                     } 
     393                 
     394                if (f.needThis()) { 
     395                    ue.e1 = getRightThis(loc, sc, ad, ue.e1, f, context); 
    428396                } 
    429397 
  • trunk/descent.core/src/descent/internal/compiler/parser/DelegateExp.java

    r1160 r1167  
    66import static descent.internal.compiler.parser.TY.Tdelegate; 
    77import static descent.internal.compiler.parser.TY.Tfunction; 
    8 import static descent.internal.compiler.parser.TY.Tpointer; 
    9 import static descent.internal.compiler.parser.TY.Tstruct; 
    108 
    119 
     
    113111            type = new TypeDelegate(func.type); 
    114112            type = type.semantic(loc, sc, context); 
    115             //  ----------------- 
    116             /* For func, we need to get the 
    117              * right 'this' pointer if func is in an outer class, but our 
    118              * existing 'this' pointer is in an inner class. 
    119              * This code is analogous to that used for variables 
    120              * in DotVarExp::semantic(). 
    121              */ 
    122113            AggregateDeclaration ad = func.toParent().isAggregateDeclaration(); 
    123  
    124             boolean loop = true; 
    125             L10: while (loop) { 
    126                 loop = false; 
    127                 Type t = e1.type; 
    128                 if (func.needThis() 
    129                         && ad != null 
    130                         && !(t.ty == Tpointer && t.next.ty == Tstruct && ((TypeStruct) t.next).sym == ad) 
    131                         && !(t.ty == Tstruct && ((TypeStruct) t).sym == ad)) { 
    132                     ClassDeclaration cd = ad.isClassDeclaration(); 
    133                     ClassDeclaration tcd = t.isClassHandle(); 
    134  
    135                     if (cd == null || tcd == null 
    136                             || !(tcd == cd || cd.isBaseOf(tcd, null, context))) { 
    137                         if (tcd != null && tcd.isNested()) { // Try again with outer scope 
    138  
    139                             e1 = new DotVarExp(loc, e1, tcd.vthis); 
    140                             e1 = e1.semantic(sc, context); 
    141                             // goto L10; 
    142                             loop = true; 
    143                             continue L10; 
    144                         } 
    145                         if (context.acceptsProblems()) { 
    146                             context.acceptProblem(Problem.newSemanticTypeError(IProblem.ThisForSymbolNeedsToBeType, this, new String[] { func.toChars(context), ad.toChars(context), t 
    147                                     .toChars(context) })); 
    148                         } 
    149                     } 
    150                 } 
     114            if (func.needThis()) { 
     115                e1 = getRightThis(loc, sc, ad, e1, func, context); 
    151116            } 
    152             //  ----------------- 
    153117        } 
    154118        return this; 
  • trunk/descent.core/src/descent/internal/compiler/parser/DotIdExp.java

    r1160 r1167  
    199199                    return new TypeExp(loc, t); 
    200200                } 
     201                 
     202                TupleDeclaration tup = s.isTupleDeclaration(); 
     203                if (tup != null) 
     204                { 
     205                if (eleft != null) { 
     206                    if (context.acceptsProblems()) { 
     207                        context.acceptProblem(Problem.newSemanticTypeError(IProblem.CannotHaveEDotTuple, this)); 
     208                    } 
     209                } 
     210                e = new TupleExp(loc, tup, context); 
     211                e = e.semantic(sc, context); 
     212                return e; 
     213                } 
    201214 
    202215                ScopeDsymbol sds = s.isScopeDsymbol(); 
  • trunk/descent.core/src/descent/internal/compiler/parser/DotVarExp.java

    r1160 r1167  
    1010import static descent.internal.compiler.parser.TOK.TOKdsymbol; 
    1111import static descent.internal.compiler.parser.TOK.TOKthis; 
    12  
    13 import static descent.internal.compiler.parser.TY.Tpointer; 
    14 import static descent.internal.compiler.parser.TY.Tstruct; 
    1512 
    1613 
     
    125122                AggregateDeclaration ad = var.toParent() 
    126123                        .isAggregateDeclaration(); 
    127  
    128                 boolean loop = true; 
    129                 L1: while (loop) { 
    130                     loop = false; 
    131  
    132                     Type t = e1.type.toBasetype(context); 
    133  
    134                     if (ad != null 
    135                             && !(t.ty == Tpointer && t.next.ty == Tstruct && ((TypeStruct) t.next).sym == ad) 
    136                             && !(t.ty == Tstruct && ((TypeStruct) t).sym == ad)) { 
    137                         ClassDeclaration cd = ad.isClassDeclaration(); 
    138                         ClassDeclaration tcd = t.isClassHandle(); 
    139  
    140                         if (cd == null 
    141                                 || tcd == null 
    142                                 || !(tcd == cd || cd.isBaseOf(tcd, null, 
    143                                         context))) { 
    144                             if (tcd != null && tcd.isNested()) { // Try again with outer scope 
    145  
    146                                 e1 = new DotVarExp(loc, e1, tcd.vthis); 
    147                                 e1 = e1.semantic(sc, context); 
    148  
    149                                 // Skip over nested functions, and get the enclosing 
    150                                 // class type. 
    151                                 Dsymbol s = tcd.toParent(); 
    152                                 while (s != null 
    153                                         && s.isFuncDeclaration() != null) { 
    154                                     FuncDeclaration f = s.isFuncDeclaration(); 
    155                                     if (f.vthis() != null) { 
    156                                         e1 = new VarExp(loc, f.vthis()); 
    157                                     } 
    158                                     s = s.toParent(); 
    159                                 } 
    160                                 if (s != null && s.isClassDeclaration() != null) { 
    161                                     e1.type = s.isClassDeclaration().type; 
    162                                 } 
    163  
    164                                 // goto L1; 
    165                                 loop = true; 
    166                                 continue L1; 
    167                             } 
    168                             if (context.acceptsProblems()) { 
    169                                 context.acceptProblem(Problem.newSemanticTypeError(IProblem.ThisForSymbolNeedsToBeType, this, new String[] { var.toChars(context), ad.toChars(context), 
    170                                         t.toChars(context) })); 
    171                             } 
    172                         } 
    173                     } 
    174                 } 
     124                e1 = getRightThis(loc, sc, ad, e1, var, context); 
    175125                accessCheck(sc, e1, var, context); 
    176126            } 
  • trunk/descent.core/src/descent/internal/compiler/parser/Problem.java

    r1165 r1167  
    10501050        case PostBlitsAreOnlyForStructUnionDefinitions: 
    10511051            return String.format(ProblemMessages.PostBlitsAreOnlyForStructUnionDefinitions); 
     1052        case CannotHaveEDotTuple: 
     1053            return String.format(ProblemMessages.CannotHaveEDotTuple); 
    10521054        default: 
    10531055            return ""; 
  • trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.java

    r1165 r1167  
    472472    public static String TypeofReturnMustBeInsideFunction; 
    473473    public static String PostBlitsAreOnlyForStructUnionDefinitions; 
     474    public static String CannotHaveEDotTuple; 
    474475     
    475476    static { 
  • trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.properties

    r1165 r1167  
    460460TypeofReturnMustBeInsideFunction=typeof(return) must be inside function 
    461461PostBlitsAreOnlyForStructUnionDefinitions=Post blits are only for struct/union definitions 
     462CannotHaveEDotTuple=Cannot have e.tuple 
  • trunk/descent.core/src/descent/internal/compiler/parser/StructInitializer.java

    r1160 r1167  
    8383                            context.acceptProblem(Problem.newSemanticTypeError(IProblem.TooManyInitializers, this, new String[] { ad.toChars(context) })); 
    8484                        } 
     85                        field.remove(i); 
     86                        i--; 
    8587                        continue; 
    8688                    } else { 
  • trunk/descent.core/src/descent/internal/compiler/parser/TemplateDeclaration.java

    r1160 r1167  
    66import melnorme.miscutil.tree.TreeVisitor; 
    77import descent.core.IJavaElement; 
    8 import descent.core.compiler.CharOperation; 
    98import descent.core.compiler.IProblem; 
    109import descent.internal.compiler.lookup.SemanticRest; 
     
    102101            } 
    103102 
    104             VarDeclaration v = new VarDeclaration(Loc.ZERO, tvp.valType, 
     103            VarDeclaration v = new VarDeclaration(loc, tvp.valType, 
    105104                    tp.ident, init); 
    106105            v.storage_class = STCconst; 
     
    655654            Declaration[] sparam = { null }; 
    656655 
    657             m2 = tp.matchArg(paramscope, ti.tiargs, i, parameters, dedtypes, 
    658                     sparam, context); 
     656            if (context.apiLevel == Parser.D2) { 
     657                // TODO Semantic fix this 
     658                // m2 = tp.matchArg(paramscope, ti.tiargs, i, parameters, dedtypes, sparam, (flag & 2) != 0 ? 1 : 0, context); 
     659                m2 = tp.matchArg(paramscope, ti.tiargs, i, parameters, dedtypes, sparam, context); 
     660            } else { 
     661                m2 = tp.matchArg(paramscope, ti.tiargs, i, parameters, dedtypes, sparam, context); 
     662            } 
    659663 
    660664            if (m2 == MATCHnomatch) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/TemplateParameter.java

    r1160 r1167  
    3939        return null; 
    4040    } 
     41     
     42    public TemplateThisParameter isTemplateThisParameter() { 
     43        return null; 
     44    } 
    4145 
    4246    /** 
  • trunk/descent.core/src/descent/internal/compiler/parser/TemplateThisParameter.java

    r1165 r1167  
    11package descent.internal.compiler.parser; 
    2  
    32 
    43public class TemplateThisParameter extends TemplateTypeParameter { 
    54 
    6     public TemplateThisParameter(Loc loc, IdentifierExp ident, Type specType, Type defaultType) { 
     5    public TemplateThisParameter(Loc loc, IdentifierExp ident, Type specType, 
     6            Type defaultType) { 
    77        super(loc, ident, specType, defaultType); 
    88    } 
    99 
     10    @Override 
     11    public TemplateThisParameter isTemplateThisParameter() { 
     12        return this; 
     13    } 
     14 
     15    @Override 
     16    public TemplateParameter syntaxCopy(SemanticContext context) { 
     17        TemplateThisParameter tp = new TemplateThisParameter(loc, ident, 
     18                specType, defaultType); 
     19        if (tp.specType != null) 
     20            tp.specType = specType.syntaxCopy(context); 
     21        if (defaultType != null) 
     22            tp.defaultType = defaultType.syntaxCopy(context); 
     23        tp.copySourceRange(this); 
     24        return tp; 
     25    } 
     26     
     27    @Override 
     28    public void toCBuffer(OutBuffer buf, HdrGenState hgs, SemanticContext context) { 
     29        buf.writestring("this "); 
     30        super.toCBuffer(buf, hgs, context); 
     31    } 
     32 
    1033} 
  • trunk/descent.core/src/descent/internal/compiler/parser/TemplateValueParameter.java

    r1160 r1167  
    6969            e = e.syntaxCopy(context); 
    7070            e = e.semantic(sc, context); 
     71            if (context.apiLevel == Parser.D2) { 
     72                // TODO Semantic D2 
     73//              if (e.op == TOKdefault) 
     74//              {   DefaultInitExp de = (DefaultInitExp) e; 
     75//                  e = de.resolve(loc, sc, context); 
     76//              } 
     77            } 
    7178        } 
    7279        return e; 
  • trunk/descent.core/src/descent/internal/compiler/parser/TypeAArray.java

    r1165 r1167  
    241241     
    242242    @Override 
     243    public void resolve(Loc loc, Scope sc, Expression[] pe, Type[] pt, Dsymbol[] ps, SemanticContext context) { 
     244        // Deal with the case where we thought the index was a type, but 
     245        // in reality it was an expression. 
     246        if (index.ty == Tident || index.ty == Tinstance || index.ty == Tsarray) { 
     247            Expression[] e = { null }; 
     248            Type[] t = { null }; 
     249            Dsymbol[] s = { null }; 
     250 
     251            index.resolve(loc, sc, e, t, s, context); 
     252            if (e[0] != null) { // It was an expression - 
     253                // Rewrite as a static array 
     254 
     255                TypeSArray tsa = new TypeSArray(next, e[0], context.encoder); 
     256                tsa.resolve(loc, sc, pe, pt, ps, context); 
     257                return; 
     258            } else if (t != null) { 
     259                index = t[0]; 
     260            } else { 
     261                if (context.acceptsProblems()) { 
     262                    context.acceptProblem(Problem.newSemanticTypeError(IProblem.IndexIsNotATypeOrExpression, index)); 
     263                } 
     264            } 
     265        } 
     266        super.resolve(loc, sc, pe, pt, ps, context); 
     267    } 
     268     
     269    @Override 
    243270    protected void appendSignature0(StringBuilder sb) { 
    244271        sb.append('H'); 
  • trunk/descent.core/template/problem/problems.txt

    r1165 r1167  
    13811381PostBlitsAreOnlyForStructUnionDefinitions 
    13821382    formatString=Post blits are only for struct/union definitions 
     1383    numArgs=0 
     1384CannotHaveEDotTuple 
     1385    formatString=Cannot have e.tuple 
    13831386    numArgs=0 
    13841387 
     
    13911394 
    13921395 
    1393  
    1394