Changeset 1176

Show
Ignore:
Timestamp:
05/25/08 12:09:14 (3 months ago)
Author:
asterite
Message:

More D2 porting. Also started implementing quick fixes and quick assists.

Files:

Legend:

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

    r1167 r1176  
    672672    int PostBlitsAreOnlyForStructUnionDefinitions = 461; 
    673673    int CannotHaveEDotTuple = 462; 
     674    int CannotCreateCppClasses = 463; 
    674675 
    675676} 
  • trunk/descent.core/src/descent/internal/compiler/parser/ASTDmdNode.java

    r1171 r1176  
    13461346     */ 
    13471347 
    1348     public static int overloadApply(FuncDeclaration fstart, 
     1348    public static boolean overloadApply(FuncDeclaration fstart, 
    13491349            OverloadApply_fp fp, Object param, SemanticContext context) { 
    13501350        FuncDeclaration f; 
     
    13561356 
    13571357            if (fa != null) { 
    1358                 if (overloadApply(fa.funcalias, fp, param, context) != 0) { 
    1359                     return 1
     1358                if (overloadApply(fa.funcalias, fp, param, context)) { 
     1359                    return false
    13601360                } 
    13611361                next = fa.overnext; 
     
    13821382                    } 
    13831383                    if (fp.call(param, f, context) != 0) { 
    1384                         return 1
     1384                        return true
    13851385                    } 
    13861386 
     
    13891389            } 
    13901390        } 
    1391         return 0
     1391        return false
    13921392    } 
    13931393 
     
    15041504        { 
    15051505            boolean condition; 
    1506             if (context.apiLevel == Lexer.D2) { 
     1506            if (context.isD2()) { 
    15071507                condition = (v.isConst() || v.isInvariant()) && v.init != null && null == v.value; 
    15081508            } else { 
  • trunk/descent.core/src/descent/internal/compiler/parser/AnonDeclaration.java

    r1163 r1176  
    8989            sc = sc.push(); 
    9090             
    91             if (context.apiLevel == Parser.D2) { 
     91            if (context.isD2()) { 
    9292                sc.stc &= ~(STCauto | STCscope | STCstatic | STCtls);    
    9393            } else { 
  • trunk/descent.core/src/descent/internal/compiler/parser/CallExp.java

    r1167 r1176  
    101101            if (fd != null) { 
    102102                boolean doInlineDup = true; 
    103                 if (context.apiLevel == Parser.D2) { 
     103                if (context.isD2()) { 
    104104                    doInlineDup = false; 
    105105 
  • trunk/descent.core/src/descent/internal/compiler/parser/ClassDeclaration.java

    r1173 r1176  
    1414import static descent.internal.compiler.parser.STC.STCabstract; 
    1515import static descent.internal.compiler.parser.STC.STCauto; 
     16import static descent.internal.compiler.parser.STC.STCconst; 
    1617import static descent.internal.compiler.parser.STC.STCdeprecated; 
    1718import static descent.internal.compiler.parser.STC.STCfinal; 
     19import static descent.internal.compiler.parser.STC.STCinvariant; 
    1820import static descent.internal.compiler.parser.STC.STCscope; 
    1921import static descent.internal.compiler.parser.STC.STCstatic; 
     22import static descent.internal.compiler.parser.STC.STCtls; 
    2023 
    2124import static descent.internal.compiler.parser.TY.Tclass; 
     
    4952    public List vtbl; // Array of FuncDeclaration's making up the vtbl[] 
    5053    public List vtblFinal; // More FuncDeclaration's that aren't in vtbl[] 
     54    public boolean cpp;             // !=0 if this is a C++ interface 
    5155 
    5256    public ClassDeclaration(Loc loc, char[] id) {  
     
    180184 
    181185    public void interfaceSemantic(Scope sc, SemanticContext context) { 
    182        int i
    183  
     186        InterfaceDeclaration id = isInterfaceDeclaration()
     187         
    184188        vtblInterfaces = new BaseClasses(interfaces.size()); 
    185189 
    186         for (i = 0; i < interfaces.size(); i++) { 
     190        for (int i = 0; i < interfaces.size(); i++) { 
    187191            BaseClass b = interfaces.get(i); 
    188192 
     
    191195            if (b.base.isCOMinterface()) { 
    192196                com = true; 
     197            } 
     198 
     199            if (context.isD2()) { 
     200                if (b.base.isCPPinterface() && id != null) { 
     201                    id.cpp = true; 
     202                } 
    193203            } 
    194204 
     
    265275     
    266276    public boolean isCOMinterface() { 
     277        return false; 
     278    } 
     279     
     280    public boolean isCPPinterface() { 
    267281        return false; 
    268282    } 
     
    381395            isdeprecated = true; 
    382396        } 
    383  
     397         
     398        if (sc.linkage == LINK.LINKcpp) { 
     399            if (context.acceptsProblems()) { 
     400                context.acceptProblem(Problem.newSemanticTypeErrorLoc(IProblem.CannotCreateCppClasses, this)); 
     401            } 
     402        } 
    384403 
    385404        // Expand any tuples in baseclasses[] 
     
    403422            } 
    404423        } 
     424 
     425        if (context.isD2()) { 
     426            if (0 == size(baseclasses) && sc.linkage == LINK.LINKcpp) { 
     427                cpp = true; 
     428            } 
     429        } 
     430 
    405431 
    406432        // See if there's a base class as first in baseclasses[] 
     
    575601            if (baseClass.isInterfaceDeclaration() != null) { 
    576602                throw new IllegalStateException( 
    577                         "assert(!baseClass->isInterfaceDeclaration());"); 
     603                        "assert(!baseClass.isInterfaceDeclaration());"); 
    578604            } 
    579605            b.base = baseClass; 
     
    604630            isauto = baseClass.isauto; 
    605631            vthis = baseClass.vthis; 
     632             
     633            if (context.isD2()) { 
     634                storage_class |= baseClass.storage_class & (STCconst | STCinvariant); 
     635            } 
    606636        } else { 
    607637            // No base class, so this is the root of the class hierarchy 
     
    677707            isabstract = true; 
    678708        } 
     709         
     710        if (context.isD2()) { 
     711            if ((storage_class & STCinvariant) != 0) { 
     712                type = type.invariantOf(context); 
     713            } else if ((storage_class & STCconst) != 0) { 
     714                type = type.constOf(context); 
     715            } 
     716        } 
    679717 
    680718        sc = sc.push(this); 
    681         sc.stc &= ~(STCfinal | STCauto | STCscope | STCstatic | STCabstract | STCdeprecated); 
     719         
     720        if (context.isD2()) { 
     721            sc.stc &= ~(STCfinal | STCauto | STCscope | STCstatic | 
     722                 STCabstract | STCdeprecated | STCconst | STCinvariant | STCtls); 
     723            sc.stc |= storage_class & (STCconst | STCinvariant); 
     724        } else { 
     725            sc.stc &= ~(STCfinal | STCauto | STCscope | STCstatic | STCabstract | STCdeprecated); 
     726        } 
    682727 
    683728        sc.parent = this; 
     
    768813            members.add(ctor); 
    769814            ctor.addMember(sc, this, 1, context); 
    770             sc = scsave; // why? What about sc->nofree? 
     815            sc = scsave; // why? What about sc.nofree? 
    771816            sc.offset = structsize; 
    772817            ctor.semantic(sc, context); 
     
    777822        for (i = 0; i < vtblInterfaces.size(); i++) 
    778823        { 
    779             BaseClass b = (BaseClass) vtblInterfaces.get(i); 
     824            BaseClass b = vtblInterfaces.get(i); 
    780825            int thissize = Type.PTRSIZE; 
    781826             
     
    797842             
    798843            sc.offset += thissize; 
    799             if (alignsize < thissize) 
    800                 alignsize = thissize; 
     844            if (alignsize < thissize) { 
     845                alignsize = thissize; 
     846            } 
    801847        } 
    802848 
     
    836882            return false; 
    837883        } 
    838         FuncDeclaration fdstart = s.toAlias(context).isFuncDeclaration(); 
    839         return !(overloadApply(fdstart, isf, fd, context) == 1 ? true : false); 
     884         
     885        if (context.isD2()) { 
     886            s = s.toAlias(context); 
     887            OverloadSet os = s.isOverloadSet(); 
     888            if (os != null) { 
     889                for (int i = 0; i < size(os.a); i++) { 
     890                    Dsymbol s2 = (Dsymbol) os.a.get(i); 
     891                    FuncDeclaration f2 = s2.isFuncDeclaration(); 
     892                    if (f2 != null && overloadApply(f2, isf, fd, context)) 
     893                        return false; 
     894                } 
     895                return true; 
     896            } else { 
     897                FuncDeclaration fdstart = s.isFuncDeclaration(); 
     898                return !overloadApply(fdstart, isf, fd, context); 
     899            } 
     900        } else { 
     901            FuncDeclaration fdstart = s.toAlias(context).isFuncDeclaration(); 
     902            return !overloadApply(fdstart, isf, fd, context); 
     903        } 
    840904    } 
    841905 
     
    9421006    } 
    9431007     
     1008    @Override 
    9441009    public char getSignaturePrefix() { 
    9451010        if (templated) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/DeclarationExp.java

    r1160 r1176  
    4646            } else {  
    4747                boolean condition; 
    48                 if (context.apiLevel == Parser.D2) { 
     48                if (context.isD2()) { 
    4949                    condition = s == v && (v.isConst() || v.isInvariant()) && v.init != null; 
    5050                } else { 
  • trunk/descent.core/src/descent/internal/compiler/parser/Dsymbol.java

    r1160 r1176  
    318318 
    319319    public NewDeclaration isNewDeclaration() { 
     320        return null; 
     321    } 
     322     
     323    public OverloadSet isOverloadSet() { 
    320324        return null; 
    321325    } 
  • trunk/descent.core/src/descent/internal/compiler/parser/Expression.java

    r1160 r1176  
    88import static descent.internal.compiler.parser.LINK.LINKd; 
    99 
     10import static descent.internal.compiler.parser.MATCH.MATCHconst; 
    1011import static descent.internal.compiler.parser.MATCH.MATCHconvert; 
     12import static descent.internal.compiler.parser.MATCH.MATCHexact; 
    1113import static descent.internal.compiler.parser.MATCH.MATCHnomatch; 
    1214 
     
    259261    public Expression copy() { 
    260262        try { 
    261             return (Expression) clone(); 
     263            Expression exp = (Expression) clone(); 
     264            exp.copySourceRange(this); 
     265            return exp; 
    262266        } catch (CloneNotSupportedException e) { 
    263267            throw new RuntimeException(e); 
     
    282286 
    283287    public Expression implicitCastTo(Scope sc, Type t, SemanticContext context) { 
    284         if (implicitConvTo(t, context) != MATCHnomatch) { 
     288        MATCH match = implicitConvTo(t, context); 
     289        if (match != MATCHnomatch) { 
    285290            if (context.global.params.warnings 
    286291                    && Type.impcnvWarn[type.toBasetype(context).ty.ordinal()][t 
     
    300305                } 
    301306            } 
     307            if (context.isD2()) { 
     308                if (match == MATCHconst && t == type.constOf(context)) { 
     309                    Expression e = copy(); 
     310                    e.type = t; 
     311                    return e; 
     312                } 
     313            } 
    302314            return castTo(sc, t, context); 
    303315        } 
     
    347359        } 
    348360 
    349         if (t.ty == Tbit && isBit()) { 
    350             return MATCHconvert; 
     361        if (!context.isD2()) { 
     362            if (t.ty == Tbit && isBit()) { 
     363                return MATCHconvert; 
     364            } 
    351365        } 
    352366        Expression e = optimize(WANTvalue | WANTflags, context); 
     367        if (context.isD2()) { 
     368            if (e.type == t) { 
     369                return MATCHexact; 
     370            } 
     371        } 
     372         
    353373        if (e != this) { 
    354374            return e.implicitConvTo(t, context); 
  • trunk/descent.core/src/descent/internal/compiler/parser/IntegerExp.java

    r1160 r1176  
    77import descent.internal.compiler.parser.ast.IASTVisitor; 
    88 
     9import static descent.internal.compiler.parser.MATCH.MATCHconst; 
    910import static descent.internal.compiler.parser.MATCH.MATCHconvert; 
    1011import static descent.internal.compiler.parser.MATCH.MATCHexact; 
     
    1314import static descent.internal.compiler.parser.TY.Tenum; 
    1415import static descent.internal.compiler.parser.TY.Tint32; 
     16import static descent.internal.compiler.parser.TY.Tpointer; 
    1517import static descent.internal.compiler.parser.TY.Tuns32; 
    1618import static descent.internal.compiler.parser.TY.Tuns64; 
     
    101103    @Override 
    102104    public MATCH implicitConvTo(Type t, SemanticContext context) { 
    103         if (type.equals(t)) { 
    104             return MATCHexact; 
    105         } 
    106  
    107         TY ty = type.toBasetype(context).ty; 
    108         TY toty = t.toBasetype(context).ty; 
    109  
    110         if (type.implicitConvTo(t, context) == MATCHnomatch && t.ty == Tenum) { 
    111             return MATCHnomatch; 
     105        TY ty; 
     106        TY toty; 
     107 
     108        if (context.isD2()) { 
     109            MATCH m = type.implicitConvTo(t, context); 
     110            if (m.ordinal() >= MATCHconst.ordinal()) { 
     111                return m; 
     112            } 
     113 
     114            ty = type.toBasetype(context).ty; 
     115            toty = t.toBasetype(context).ty; 
     116 
     117            if (m == MATCHnomatch && t.ty == Tenum) { 
     118                // goto Lno; 
     119                return MATCHnomatch; 
     120            } 
     121        } else { 
     122            if (type.equals(t)) { 
     123                return MATCHexact; 
     124            } 
     125 
     126            ty = type.toBasetype(context).ty; 
     127            toty = t.toBasetype(context).ty; 
     128 
     129            if (type.implicitConvTo(t, context) == MATCHnomatch 
     130                    && t.ty == Tenum) { 
     131                return MATCHnomatch; 
     132            } 
    112133        } 
    113134 
     
    215236            return MATCHconvert; 
    216237 
    217              
    218238        case Tfloat32: 
    219239            float f; 
     
    222242                return MATCHnomatch; 
    223243            return MATCHconvert; 
    224               
    225          case Tfloat64: 
    226              double d; 
    227              d = value.floatValue(); 
    228              if (!value.isExactly(d)) 
    229                  return MATCHnomatch; 
    230             return MATCHconvert; 
    231          
    232         // TODO this isn't right, make sure th integer can fit in 80 bits. 
    233         // in practice, since there' no cent types yet, any 64-bit integer 
    234         // will fit in an 80-bit real 
    235          case Tfloat80: 
    236              return MATCHconvert; 
    237               
     244 
     245        case Tfloat64: 
     246            double d; 
     247            d = value.floatValue(); 
     248            if (!value.isExactly(d)) 
     249                return MATCHnomatch; 
     250            return MATCHconvert; 
     251 
     252            // TODO this isn't right, make sure th integer can fit in 80 bits. 
     253            // in practice, since there' no cent types yet, any 64-bit integer 
     254            // will fit in an 80-bit real 
     255        case Tfloat80: 
     256            return MATCHconvert; 
     257 
     258        case Tpointer: 
     259            if (context.isD2()) { 
     260                if (ty == Tpointer 
     261                        && type.toBasetype(context).nextOf().ty == t 
     262                                .toBasetype(context).nextOf().ty) { 
     263                    /* Allow things like: 
     264                     *  const char* P = cast(char *)3; 
     265                     *  char* q = P; 
     266                     */ 
     267                    // goto Lyes; 
     268                    return MATCHconvert; 
     269                } 
     270            } 
     271            break; 
     272 
    238273        } 
    239274        return super.implicitConvTo(t, context); 
  • trunk/descent.core/src/descent/internal/compiler/parser/InterfaceDeclaration.java

    r1173 r1176  
    1010import static descent.internal.compiler.parser.LINK.LINKwindows; 
    1111 
     12import static descent.internal.compiler.parser.STC.STCabstract; 
     13import static descent.internal.compiler.parser.STC.STCauto; 
     14import static descent.internal.compiler.parser.STC.STCconst; 
     15import static descent.internal.compiler.parser.STC.STCdeprecated; 
     16import static descent.internal.compiler.parser.STC.STCfinal; 
     17import static descent.internal.compiler.parser.STC.STCinvariant; 
     18import static descent.internal.compiler.parser.STC.STCscope; 
     19import static descent.internal.compiler.parser.STC.STCstatic; 
     20import static descent.internal.compiler.parser.STC.STCtls; 
     21 
    1222import static descent.internal.compiler.parser.TY.Tclass; 
    1323import static descent.internal.compiler.parser.TY.Ttuple; 
     
    1626public class InterfaceDeclaration extends ClassDeclaration { 
    1727     
    18     int cpp;                // !=0 if this is a C++ interface 
    19  
    2028    public InterfaceDeclaration(Loc loc, IdentifierExp id, 
    2129            BaseClasses baseclasses) { 
     
    2634            // objects 
    2735            com = true; 
     36            cpp = true; 
    2837        } 
    2938    } 
     
    268277            // Lcontinue: ; 
    269278        } 
     279         
     280        if (context.isD2()) { 
     281            protection = sc.protection; 
     282            storage_class |= sc.stc & (STCconst | STCinvariant); 
     283        } 
    270284 
    271285        for (Dsymbol s : members) { 
     
    274288 
    275289        sc = sc.push(this); 
     290         
     291        if (context.isD2()) { 
     292            sc.stc &= ~(STCfinal | STCauto | STCscope | STCstatic | 
     293                     STCabstract | STCdeprecated | STCconst | STCinvariant | STCtls); 
     294            sc.stc |= storage_class & (STCconst | STCinvariant); 
     295        } 
     296         
    276297        sc.parent = this; 
    277298        if (isCOMinterface()) { 
    278299            sc.linkage = LINKwindows; 
     300        } else if (context.isD2() && isCPPinterface()) { 
     301            sc.linkage = LINK.LINKcpp; 
    279302        } 
    280303        sc.structalign = 8; 
     
    315338    @Override 
    316339    public int vtblOffset() { 
    317         if (isCOMinterface()) { 
     340        if (isCOMinterface() || isCPPinterface()) { 
    318341            return 0; 
    319342        } 
     
    324347    public boolean isCOMinterface() { 
    325348        return com; 
     349    } 
     350     
     351    @Override 
     352    public boolean isCPPinterface() { 
     353        return cpp; 
    326354    } 
    327355     
  • trunk/descent.core/src/descent/internal/compiler/parser/IsExp.java

    r1173 r1176  
    267267        } 
    268268 
    269         if (context.apiLevel == Parser.D2) { 
     269        if (context.isD2()) { 
    270270            if (parameters != null) {  
    271271                // First parameter is already output, so start with second 
  • trunk/descent.core/src/descent/internal/compiler/parser/Lexer.java

    r1165 r1176  
    46564656        int c; 
    46574657        //Loc start = loc; 
     4658         
     4659        int firstLineBreak = -1; 
    46584660 
    46594661        p++; 
     
    46794681            case '\n': 
    46804682                newline(NOT_IN_COMMENT); 
    4681                 break; 
     4683                 
     4684                // Changed from DMD to allow better error reporting 
     4685                error(IProblem.UnterminatedStringConstant, token.lineNumber, 
     4686                        token.ptr, p - token.ptr); 
     4687                t.ustring = CharOperation.NO_CHAR; 
     4688                t.len = 0; 
     4689                t.postfix = 0; 
     4690                 
     4691                t.sourceLen = 0; 
     4692                return TOKstring; 
    46824693 
    46834694            case '\r': 
     
    46874698                c = '\n'; // treat EndOfLine as \n character 
    46884699                newline(NOT_IN_COMMENT); 
    4689                 break; 
     4700                 
     4701                // Changed from DMD to allow better error reporting 
     4702                error(IProblem.UnterminatedStringConstant, token.lineNumber, 
     4703                        token.ptr, p - token.ptr); 
     4704                t.ustring = CharOperation.NO_CHAR; 
     4705                t.len = 0; 
     4706                t.postfix = 0; 
     4707                 
     4708                t.sourceLen = 0; 
     4709                return TOKstring; 
    46904710 
    46914711            case '"': 
  • trunk/descent.core/src/descent/internal/compiler/parser/MATCH.java

    r1160 r1176  
    66     MATCHnomatch,  // no match 
    77     MATCHconvert,  // match with conversions 
     8     MATCHconst,    // match with conversions to const 
    89     MATCHexact     // exact match 
    910 
  • trunk/descent.core/src/descent/internal/compiler/parser/NullExp.java

    r1160 r1176  
    11package descent.internal.compiler.parser; 
    22 
     3import descent.internal.compiler.parser.ast.IASTVisitor; 
     4 
     5import static descent.internal.compiler.parser.MATCH.MATCHconst; 
    36import static descent.internal.compiler.parser.MATCH.MATCHconvert; 
    47import static descent.internal.compiler.parser.MATCH.MATCHexact; 
     8 
    59import static descent.internal.compiler.parser.TY.Taarray; 
    610import static descent.internal.compiler.parser.TY.Tarray; 
     
    1014import static descent.internal.compiler.parser.TY.Ttypedef; 
    1115import static descent.internal.compiler.parser.TY.Tvoid; 
    12 import descent.internal.compiler.parser.ast.IASTVisitor; 
    1316 
    1417 
     
    7073            return MATCHexact; 
    7174        } 
     75         
     76        if (context.isD2()) { 
     77            /* Allow implicit conversions from invariant to mutable|const, 
     78             * and mutable to invariant. It works because, after all, a null 
     79             * doesn't actually point to anything. 
     80             */ 
     81            if (t.invariantOf(context).equals(type.invariantOf(context))) { 
     82                return MATCHconst; 
     83            } 
     84        } 
     85         
    7286        // NULL implicitly converts to any pointer type or dynamic array 
    7387        if (type.ty == Tpointer && type.next.ty == Tvoid) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/PragmaDeclaration.java

    r1163 r1176  
    9696            semantic_Lnodecl(context); 
    9797            return; 
    98         } else if (context.apiLevel == Parser.D2 && equals(ident, Id.startaddress)) { 
     98        } else if (context.isD2() && equals(ident, Id.startaddress)) { 
    9999            if (args == null || args.size() != 1) { 
    100100                if (context.acceptsProblems()) { 
     
    159159        buf.writestring(ident.toChars()); 
    160160        if (args != null && args.size() != 0) { 
    161             if (context.apiLevel == Parser.D2) { 
     161            if (context.isD2()) { 
    162162                buf.writestring(", "); 
    163163                argsToCBuffer(buf, args, hgs, context); 
  • trunk/descent.core/src/descent/internal/compiler/parser/Problem.java

    r1167 r1176  
    10521052        case CannotHaveEDotTuple: 
    10531053            return String.format(ProblemMessages.CannotHaveEDotTuple); 
     1054        case CannotCreateCppClasses: 
     1055            return String.format(ProblemMessages.CannotCreateCppClasses); 
    10541056        default: 
    10551057            return ""; 
  • trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.java

    r1167 r1176  
    473473    public static String PostBlitsAreOnlyForStructUnionDefinitions; 
    474474    public static String CannotHaveEDotTuple; 
     475    public static String CannotCreateCppClasses; 
    475476     
    476477    static { 
  • trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.properties

    r1167 r1176  
    461461PostBlitsAreOnlyForStructUnionDefinitions=Post blits are only for struct/union definitions 
    462462CannotHaveEDotTuple=Cannot have e.tuple 
     463CannotCreateCppClasses=Cannot create C++ classes 
  • trunk/descent.core/src/descent/internal/compiler/parser/SemanticContext.java

    r1173 r1176  
    324324        } 
    325325         
    326         if (apiLevel == Lexer.D2) { 
     326        if (isD2()) { 
    327327            if (ASTDmdNode.equals(s.ident, Id.TypeInfo_Const)) { 
    328328                Type_typeinfoconst = (ClassDeclaration) s; 
     
    341341        typeInfoDeclarations.put(t, vtinfo); 
    342342    } 
     343     
     344    public boolean isD2() { 
     345        return apiLevel == Parser.D2; 
     346    } 
    343347 
    344348} 
  • trunk/descent.core/src/descent/internal/compiler/parser/StorageClassDeclaration.java

    r1163 r1176  
    112112            int stc_save = sc.stc; 
    113113 
    114             if (context.apiLevel == Parser.D2) { 
     114            if (context.isD2()) { 
    115115                /* These sets of storage classes are mutually exclusive, 
    116116                 * so choose the innermost or most recent one. 
     
    170170        boolean written = false; 
    171171 
    172         SCstring[] theTable = context.apiLevel == Parser.D2 ? table2 : table1; 
     172        SCstring[] theTable = context.isD2() ? table2 : table1; 
    173173 
    174174        for (SCstring sc : theTable) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/StringExp.java

    r1160 r1176  
    179179    public MATCH implicitConvTo(Type t, SemanticContext context) { 
    180180        if (!committed) { 
    181             if (!committed && t.ty == Tpointer && t.next.ty == Tvoid) { 
     181            boolean comparison = context.isD2() ? t.nextOf().ty == Tvoid : t.next.ty == Tvoid; 
     182            if (!committed && t.ty == Tpointer && comparison) { 
    182183                return MATCHnomatch; 
    183184            } 
     
    241242        if (!committed) { 
    242243            se = (StringExp) copy(); 
    243  
    244             // Descent 
    245             se.copySourceRange(this); 
    246  
    247244            se.committed = true; 
    248  
    249245            copied = 1; // this is the only instance 
    250246        } 
     
    262258            if (0 == copied) { 
    263259                se = (StringExp) copy(); 
    264                 // Descent 
    265                 se.copySourceRange(this); 
    266  
    267260                copied = 1; 
    268261            } 
     
    274267            if (0 == copied) { 
    275268                se = (StringExp) copy(); 
    276                 //       Descent 
    277                 se.copySourceRange(this); 
    278269                copied = 1; 
    279270            } 
     
    284275            if (0 == copied) { 
    285276                se = (StringExp) copy(); 
    286                 //       Descent 
    287                 se.copySourceRange(this); 
    288  
    289277                copied = 1; 
    290278            } 
     
    298286            if (0 == copied) { 
    299287                se = (StringExp) copy(); 
    300                 //       Descent 
    301                 se.copySourceRange(this); 
    302  
    303288                copied = 1; 
    304289            } 
     
    352337                    if (0 == copied) { 
    353338                        se = (StringExp) copy(); 
    354                         // Descent 
    355                         se.copySourceRange(this); 
    356339                    } 
    357340                    buffer.data.getChars(0, buffer.offset(), 
     
    375358                    if (0 == copied) { 
    376359                        se = (StringExp) copy(); 
    377                         // Descent 
    378                         se.copySourceRange(this); 
    379360              &nb