Changeset 1201

Show
Ignore:
Timestamp:
07/01/08 20:18:15 (2 months ago)
Author:
asterite
Message:

Some bug fixes relating to DMD's front end porting. More optimization

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.core/src/descent/core/dom/ASTConverter.java

    r1195 r1201  
    23312331            } 
    23322332        } 
    2333         if (a.ifbody != null) { 
    2334             descent.core.dom.Statement convertedBody = convert(a.ifbody); 
     2333        if (a.sourceIfbody != null) { 
     2334            descent.core.dom.Statement convertedBody = convert(a.sourceIfbody); 
    23352335            if (convertedBody != null) { 
    23362336                ret.setThenBody(convertedBody); 
     
    31353135            } 
    31363136        } 
     3137         
    31373138        if (a.tempinst.sourceTiargs != null) { 
    31383139            for(ASTDmdNode node : a.tempinst.sourceTiargs) { 
  • trunk/descent.core/src/descent/core/dom/ASTNode.java

    r1165 r1201  
    30233023        } 
    30243024        if (startPosition < 0 && length != 0) { 
    3025             System.out.println(this.toString()); 
    30263025            throw new IllegalArgumentException(this.toString()); 
    30273026        } 
  • trunk/descent.core/src/descent/core/dom/DefaultBindingResolver.java

    r1189 r1201  
    738738     
    739739    IBinding resolveType(Type type) { 
     740        if (type.alias != null) { 
     741            return resolveDsymbol(type.alias); 
     742        } 
     743         
    740744        String key = type.getSignature(); 
    741745        if (key == null) { 
     
    794798         
    795799        if (binding != null) { 
     800            if ("@5tango3sys5win325Types=6HANDLE".equals(binding)) { 
     801                System.out.println(123456); 
     802            } 
    796803            bindingTables.bindingKeysToBindings.put(key, binding); 
    797804        } 
  • trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java

    r1198 r1201  
    389389             
    390390            // If there's an expected type, doSemantic to find it out 
    391             if (parser.expectedTypeNode != null) { 
    392                 doSemantic(); 
    393                 computeExpectedType(); 
    394             } 
    395              
    396             // First the assist node 
    397             completeNode(assistNode); 
    398              
    399             // For new |, don't suggest keywords or ddoc 
    400             if (parser.inNewExp) { 
    401                 return; 
     391            if (parser.wantAssitNode()) { 
     392                if (parser.expectedTypeNode != null) { 
     393                    doSemantic(); 
     394                    computeExpectedType(); 
     395                } 
     396                 
     397                // First the assist node 
     398                completeNode(assistNode); 
     399                 
     400                // For new |, don't suggest keywords or ddoc 
     401                if (parser.inNewExp) { 
     402                    return; 
     403                } 
    402404            } 
    403405             
  • trunk/descent.core/src/descent/internal/codeassist/EvaluationASTConverter.java

    r1168 r1201  
    2626import descent.internal.compiler.parser.TypeClass; 
    2727import descent.internal.compiler.parser.TypeIdentifier; 
     28import descent.internal.compiler.parser.TypeInstance; 
    2829import descent.internal.compiler.parser.TypeStruct; 
    2930import descent.internal.compiler.parser.TypeTypedef; 
     
    169170     
    170171    @Override 
     172    public Type convert(TypeInstance a) { 
     173        if (a.tempinst.sourceTiargs == null && a.tempinst.tiargs != null) { 
     174            a.tempinst.sourceTiargs = a.tempinst.tiargs; 
     175        } 
     176        return super.convert(a); 
     177    } 
     178     
     179    @Override 
    171180    protected void setSourceRange(ASTNode node, int start, int length) { 
    172181        // Do nothing 
  • trunk/descent.core/src/descent/internal/codeassist/EvaluationEngine.java

    r1199 r1201  
    2121import descent.internal.compiler.parser.ComplexExp; 
    2222import descent.internal.compiler.parser.Declaration; 
     23import descent.internal.compiler.parser.Dsymbol; 
     24import descent.internal.compiler.parser.Dsymbols; 
    2325import descent.internal.compiler.parser.EnumDeclaration; 
    2426import descent.internal.compiler.parser.EnumMember; 
     
    3537import descent.internal.compiler.parser.StructInitializer; 
    3638import descent.internal.compiler.parser.StructLiteralExp; 
     39import descent.internal.compiler.parser.TemplateInstance; 
     40import descent.internal.compiler.parser.TemplateMixin; 
    3741import descent.internal.compiler.parser.Type; 
    3842import descent.internal.compiler.parser.TypeEnum; 
     
    129133                converter.init(javaProject, context, null); 
    130134                 
     135                 
     136                 
    131137                Module module = new Module(null, null); 
    132                 module.members = node.templateInstance.members; 
    133                 module.sourceMembers = node.templateInstance.members; 
     138                module.members = new Dsymbols(); 
     139                for(Dsymbol sym : node.templateInstance.members) { 
     140                    if (sym instanceof TemplateInstance && !(sym instanceof TemplateMixin)) { 
     141                        continue; 
     142                    } 
     143                    module.members.add(sym); 
     144                } 
     145                 
     146                module.sourceMembers = module.members; 
    134147                 
    135148                CompilationUnit unit = converter.convert(module, null); 
  • trunk/descent.core/src/descent/internal/codeassist/complete/CompletionParser.java

    r1198 r1201  
    6363    private boolean wantAssist = true; 
    6464    private boolean wantOnlyType = false; 
     65    private boolean wantAssitNode = true; 
    6566     
    6667    // Javadoc completion, and other ddocs found, in order to 
     
    143144    public boolean wantOnlyType() { 
    144145        return wantOnlyType; 
     146    } 
     147     
     148    public boolean wantAssitNode() { 
     149        return wantAssitNode; 
    145150    } 
    146151     
     
    380385            if (toks == contractsExpectations) { 
    381386                acceptMoreKeywords = false; 
     387            } 
     388            if (toks == scopeArgsExpectations) { 
     389                acceptMoreKeywords = false; 
     390                wantAssitNode = false; 
    382391            } 
    383392        } 
  • trunk/descent.core/src/descent/internal/compiler/lookup/ModuleBuilder.java

    r1199 r1201  
    8686     * One ring to rule them all.  
    8787     */ 
    88     private final static boolean LAZY = false; 
     88    private final static boolean LAZY = true; 
    8989     
    9090    /* 
    9191     * Whether to make surface Module semantic. 
    9292     */ 
    93     public boolean LAZY_MODULES = false; 
     93    public boolean LAZY_MODULES = true; 
    9494     
    9595    /* 
     
    137137     * Currently doesn't work. 
    138138     */ 
    139     public boolean LAZY_VARS = LAZY & true; 
     139    public boolean LAZY_VARS = LAZY & false; 
    140140     
    141141    /* 
     
    201201     */ 
    202202    public Module build(final ICompilationUnit unit) { 
    203 //        long time = System.currentTimeMillis(); 
     203      long time = System.currentTimeMillis(); 
    204204         
    205205        final Module module = new Module(unit.getElementName(), new IdentifierExp(unit.getModuleName().toCharArray())); 
     
    271271//      } 
    272272//       
    273 //        time = System.currentTimeMillis() - time; 
     273      time = System.currentTimeMillis() - time; 
    274274//      if (time > 10) { 
    275275//          System.out.println("ModuleBuilder#build(" + module.moduleName + ") = " + time); 
     
    490490        } else {  
    491491            final FuncDeclaration member; 
    492             if (LAZY_FUNCTIONS && surface) { 
     492            if (LAZY_FUNCTIONS && surface && module.builder == null) { 
    493493                member = new FuncDeclaration(getLoc(module, method), getIdent(method), getStorageClass(method), null); 
    494494                member.rest = new SemanticRest(new Runnable() { 
     
    518518            final ClassDeclaration member; 
    519519             
    520             if (LAZY_CLASSES && surface) { 
     520            if (LAZY_CLASSES && surface && module.builder == null) { 
    521521                member = new ClassDeclaration(getLoc(module, type), getIdent(type)); 
    522522                member.rest = new SemanticRest(new Runnable() { 
     
    553553            final InterfaceDeclaration member; 
    554554             
    555             if (LAZY_INTERFACES && surface) { 
     555            if (LAZY_INTERFACES && surface && module.builder == null) { 
    556556                member = new InterfaceDeclaration(getLoc(module, type), getIdent(type), null); 
    557557                member.rest = new SemanticRest(new Runnable() { 
     
    593593                final StructDeclaration member; 
    594594                 
    595                 if (LAZY_STRUCTS && surface) { 
     595                if (LAZY_STRUCTS && surface && module.builder == null) { 
    596596                    member = new StructDeclaration(getLoc(module, type), id); 
    597597                    member.rest = new SemanticRest(new Runnable() { 
     
    630630                final UnionDeclaration member; 
    631631                 
    632                 if (LAZY_UNIONS && surface) { 
     632                if (LAZY_UNIONS && surface && module.builder == null) { 
    633633                    member = new UnionDeclaration(getLoc(module, type), id); 
    634634                    member.rest = new SemanticRest(new Runnable() { 
     
    665665            final TemplateDeclaration member; 
    666666             
    667             if (LAZY_TEMPLATES && surface) { 
     667            if (LAZY_TEMPLATES && surface && module.builder == null) { 
    668668                member = new TemplateDeclaration(getLoc(module, type), getIdent(type), null, null); 
    669669                member.rest = new SemanticRest(new Runnable() { 
     
    701701         
    702702        // For anonymous enums we can do it lazily  
    703         if (LAZY_ENUMS && surface && ident != null) { 
     703        if (LAZY_ENUMS && surface && ident != null && module.builder == null) { 
    704704            member = new EnumDeclaration(getLoc(module, type), ident, null); 
    705705            member.rest = new SemanticRest(new Runnable() { 
     
    760760        if (field.isVariable()) { 
    761761            final VarDeclaration member; 
    762             if (LAZY_VARS && state.surface) { 
     762            if (LAZY_VARS && state.surface && module.builder == null) { 
    763763                member = new VarDeclaration(getLoc(module, field), null, getIdent(field), null); 
    764764                member.rest = new SemanticRest(new Runnable() { 
     
    780780        } else if (field.isAlias()) { 
    781781            final AliasDeclaration member; 
    782             if (LAZY_ALIASES && state.surface) { 
     782            if (LAZY_ALIASES && state.surface && module.builder == null) { 
    783783                member = new AliasDeclaration(getLoc(module, field), getIdent(field), (Type) null); 
    784784                member.rest = new SemanticRest(new Runnable() { 
     
    872872            final TemplateDeclaration temp; 
    873873             
    874             if (LAZY_TEMPLATES && surface) { 
     874            if (LAZY_TEMPLATES && surface && module.builder == null) { 
    875875                temp = new TemplateDeclaration(getLoc(module, (ISourceReference) templated), getIdent((IJavaElement) templated), null, toDsymbols(symbol)); 
    876876                temp.wrapper = true; 
  • trunk/descent.core/src/descent/internal/compiler/parser/ASTDmdNode.java

    r1200 r1201  
    489489                } 
    490490            } else { 
    491                 if (context.acceptsProblems()) { 
     491                if (context.acceptsErrors()) { 
    492492                    context.acceptProblem(Problem.newSemanticTypeError( 
    493493                            IProblem.DivisionByZero, d)); 
     
    567567 
    568568            else if (e.op == TOKdotexp) { 
    569                 if (context.acceptsProblems()) { 
     569                if (context.acceptsErrors()) { 
    570570                    context.acceptProblem(Problem.newSemanticTypeError( 
    571571                            IProblem.SymbolHasNoValue, e, 
     
    634634            if ((d.prot() == PROTprivate && d.getModule() != sc.module 
    635635                    || d.prot() == PROTpackage && !hasPackageAccess(sc, d))) { 
    636                 if (context.acceptsProblems()) { 
     636                if (context.acceptsErrors()) { 
    637637                    context.acceptProblem(Problem.newSemanticTypeError(IProblem.SymbolIsNotAccessible, this, d.kind(), d 
    638638                            .getModule().toChars(context), d.toChars(context), 
     
    779779 
    780780        if (nargs > nparams && tf.varargs == 0) { 
    781             if (context.acceptsProblems()) { 
     781            if (context.acceptsErrors()) { 
    782782                context.acceptProblem(Problem.newSemanticTypeError( 
    783783                        IProblem.ExpectedNumberArguments, this, String.valueOf(nparams), String.valueOf(nargs))); 
     
    808808                        } 
    809809                        if (!gotoL2) { 
    810                             if (context.acceptsProblems()) { 
     810                            if (context.acceptsErrors()) { 
    811811                                context.acceptProblem(Problem.newSemanticTypeError( 
    812812                                        IProblem.ExpectedNumberArguments, this, String.valueOf(nparams), String.valueOf(nargs))); 
     
    894894                        default: 
    895895                            if (arg == null) { 
    896                                 if (context.acceptsProblems()) { 
     896                                if (context.acceptsErrors()) { 
    897897                                    context.acceptProblem(Problem.newSemanticTypeError(IProblem.NotEnoughArguments, this)); 
    898898                                } 
     
    923923                    if (arg.op == TOKarray &&  
    924924                            arg.type.toBasetype(context).ty == Tbit) { 
    925                         if (context.acceptsProblems()) { 
     925                        if (context.acceptsErrors()) { 
    926926                            context.acceptProblem(Problem.newSemanticTypeError( 
    927927                                    IProblem.CannotHaveOutOrInoutArgumentOfBitInArray, this)); 
     
    10631063 
    10641064                if (arg.type == null) { 
    1065                     if (context.acceptsProblems()) { 
     1065                    if (context.acceptsWarnings()) { 
    10661066                        context.acceptProblem(Problem.newSemanticTypeWarning( 
    10671067                                IProblem.SymbolNotAnExpression, 0, arg.start, 
     
    14911491                    f = d.isFuncDeclaration(); 
    14921492                    if (null == f) { 
    1493                         if (context.acceptsProblems()) { 
     1493                        if (context.acceptsErrors()) { 
    14941494                            context.acceptProblem(Problem.newSemanticTypeError( 
    14951495                                    IProblem.SymbolIsAliasedToAFunction, a, a.toChars(context))); 
     
    16371637                e = v.value(); 
    16381638                if (null == e) { 
    1639                     if (context.acceptsProblems()) { 
     1639                    if (context.acceptsErrors()) { 
    16401640                        context.acceptProblem(Problem.newSemanticTypeError( 
    16411641                                IProblem.VariableIsUsedBeforeInitialization, v, v.toChars(context))); 
     
    17381738                    for (Scope sc1 = sc; sc1 != null; sc1 = sc1.enclosing) { 
    17391739                        if (sc1.scopesym == ti1) { 
    1740                             if (context.acceptsProblems()) { 
     1740                            if (context.acceptsErrors()) { 
    17411741                                context.acceptProblem(Problem.newSemanticTypeError( 
    17421742                                        IProblem.RecursiveTemplateExpansionForTemplateArgument, t1, t1.toChars(context))); 
     
    20612061                        continue L1; 
    20622062                    } 
    2063                     if (context.acceptsProblems()) { 
     2063                    if (context.acceptsErrors()) { 
    20642064                        context.acceptProblem(Problem.newSemanticTypeError(IProblem.ThisForSymbolNeedsToBeType, var, var 
    20652065                                .toChars(context), ad.toChars(context), t.toChars(context))); 
     
    20772077            for (Modifier modifier : modifiers) { 
    20782078                if (modifier.tok == tok) { 
    2079                     if (context.acceptsProblems()) { 
     2079                    if (context.acceptsErrors()) { 
    20802080                        context.acceptProblem(Problem.newSemanticTypeError( 
    20812081                                problemId, modifier)); 
     
    20892089            for (Modifier modifier : extraModifiers) { 
    20902090                if (modifier.tok == tok) { 
    2091                     if (context.acceptsProblems()) { 
     2091                    if (context.acceptsErrors()) { 
    20922092                        context.acceptProblem(Problem.newSemanticTypeError( 
    20932093                                problemId, modifier)); 
     
    20992099         
    21002100        if (!reported) { 
    2101             if (context.acceptsProblems()) { 
     2101            if (context.acceptsErrors()) { 
    21022102                context.acceptProblem(Problem.newSemanticTypeErrorLoc( 
    21032103                        problemId, this)); 
  • trunk/descent.core/src/descent/internal/compiler/parser/AddrExp.java

    r1189 r1201  
    177177                    if ((index.compareTo(0) < 0 || index.compareTo(dim) >= 0)) { 
    178178                        // PERHAPS test this error 
    179                         if (context.acceptsProblems()) { 
     179                        if (context.acceptsErrors()) { 
    180180                            context.acceptProblem(Problem.newSemanticTypeError( 
    181181                                    IProblem.ArrayIndexOutOfBounds, 
     
    207207            e1 = e1.toLvalue(sc, null, context); 
    208208            if (e1.type == null) { 
    209                 if (context.acceptsProblems()) { 
     209                if (context.acceptsErrors()) { 
    210210                    context.acceptProblem(Problem.newSemanticTypeError( 
    211211                            IProblem.CannotTakeAddressOf, e1, e1.toChars(context))); 
  • trunk/descent.core/src/descent/internal/compiler/parser/AggregateDeclaration.java

    <
    r1198 r1201  
    9090        } 
    9191        if (!result) { 
    92             if (context.acceptsProblems()) { 
     92            if (context.acceptsErrors()) { 
    9393                context.acceptProblem(Problem.newSemanticTypeError(IProblem.MemberIsNotAccessible, reference, smember.toChars(context))); 
    9494            } 
     
    108108            if (context.isD2()) { 
    109109                if (ts.sym == this) { 
    110                     if (context.acceptsProblems()) { 
     110                    if (context.acceptsErrors()) { 
    111111                        context.acceptProblem(Problem.newSemanticTypeErrorLoc(IProblem.CannotHaveFieldWithSameStructType, v)); 
    112112                    } 
     
    360360    public void semantic2(Scope sc, SemanticContext context) { 
    361361        if (scope != null) { 
    362             if (context.acceptsProblems()) { 
     362            if (context.acceptsErrors()) { 
    363363                context.acceptProblem(Problem.newSemanticTypeError(IProblem.SymbolHasForwardReferences, this, toChars(context))); 
    364364            } 
     
    393393         
    394