Changeset 1154

Show
Ignore:
Timestamp:
05/03/08 00:08:26 (2 months ago)
Author:
asterite
Message:

Optimizations... but still about 0.5 ~ 1 second in a DWT-example. Is DWT cursed? In every other library it works quite well... :-(

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java

    r1149 r1154  
    22152215                    proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); 
    22162216                    proposal.isAlias = isAliased; 
     2217                     
    22172218                    CompletionEngine.this.requestor.accept(proposal); 
    22182219                     
  • trunk/descent.core/src/descent/internal/compiler/lookup/ModuleBuilder.java

    r1141 r1154  
    8787     
    8888    /* 
     89     * Wether to make surface Module semantic. 
     90     */ 
     91    public boolean LAZY_MODULES = LAZY & true; 
     92     
     93    /* 
    8994     * Wether to make surface ClassDeclaration semantic lazy. 
    9095     */ 
     
    130135     * Currently doesn't work. 
    131136     */ 
    132     private final static boolean LAZY_VARS = LAZY & true; 
     137    public boolean LAZY_VARS = LAZY & true; 
    133138     
    134139    /* 
     
    174179        this.config = config; 
    175180        this.encoder = encoder; 
     181         
     182        switch(config.semanticAnalysisLevel) { 
     183        case 0: // None 
     184            LAZY_MODULES = LAZY & true; 
     185            LAZY_VARS = LAZY & true; 
     186            break; 
     187        case 1: // Some 
     188        case 2: // All 
     189            LAZY_MODULES = false; 
     190            LAZY_VARS = false; 
     191            break; 
     192        } 
    176193    } 
    177194     
     
    186203        module.moduleName = unit.getFullyQualifiedName(); 
    187204         
    188         try { 
    189             IPackageDeclaration[] packageDeclarations = unit.getPackageDeclarations(); 
    190             if (packageDeclarations.length == 1) { 
    191                 String elementName = packageDeclarations[0].getElementName(); 
    192                 Identifiers packages = new Identifiers(); 
    193                 IdentifierExp name = splitName(elementName, packages);   
    194                 module.md = new ModuleDeclaration(packages, name); 
    195             } 
    196              
    197             State state = new State(); 
    198              
    199             module.members = new Dsymbols(); 
    200             fill(module, module.members, unit.getChildren(), state); 
    201              
    202             state.surface = false; 
    203         } catch (JavaModelException e) { 
    204             e.printStackTrace(); 
    205             Util.log(e); 
    206             return null; 
     205        if (LAZY_MODULES) { 
     206            module.setJavaElement(unit); 
     207            module.rest = new SemanticRest(new Runnable() { 
     208                public void run() { 
     209                    try { 
     210                        IPackageDeclaration[] packageDeclarations = unit.getPackageDeclarations(); 
     211                        if (packageDeclarations.length == 1) { 
     212                            String elementName = packageDeclarations[0].getElementName(); 
     213                            Identifiers packages = new Identifiers(); 
     214                            IdentifierExp name = splitName(elementName, packages);   
     215                            module.md = new ModuleDeclaration(packages, name); 
     216                        } 
     217                         
     218                        State state = new State(); 
     219                         
     220                        module.members = new Dsymbols(); 
     221                        fill(module, module.members, unit.getChildren(), state); 
     222                         
     223                        state.surface = false; 
     224                    } catch (JavaModelException e) { 
     225                        Util.log(e); 
     226                    } 
     227                } 
     228            }); 
     229            module.rest.skipScopeCheck = true; 
     230        } else { 
     231            try { 
     232                IPackageDeclaration[] packageDeclarations = unit.getPackageDeclarations(); 
     233                if (packageDeclarations.length == 1) { 
     234                    String elementName = packageDeclarations[0].getElementName(); 
     235                    Identifiers packages = new Identifiers(); 
     236                    IdentifierExp name = splitName(elementName, packages);   
     237                    module.md = new ModuleDeclaration(packages, name); 
     238                } 
     239                 
     240                State state = new State(); 
     241                 
     242                module.members = new Dsymbols(); 
     243                fill(module, module.members, unit.getChildren(), state); 
     244                 
     245                state.surface = false; 
     246            } catch (JavaModelException e) { 
     247                Util.log(e); 
     248                return null; 
     249            } 
    207250        } 
    208251         
  • trunk/descent.core/src/descent/internal/compiler/lookup/SemanticRest.java

    r1124 r1154  
    1212    private boolean structureKnown; 
    1313    private final Runnable runnable; 
     14     
     15    public boolean skipScopeCheck; 
    1416     
    1517    public SemanticRest(Runnable runnable) { 
     
    4244     
    4345    public void consume(Dsymbol symbol) { 
    44         if (sc == null) { 
     46        if (sc == null && !skipScopeCheck) { 
    4547            return; 
    4648        } 
  • trunk/descent.core/src/descent/internal/compiler/parser/ASTDmdNode.java

    r1141 r1154  
    482482                } 
    483483            } else { 
    484                 context.acceptProblem(Problem.newSemanticTypeError( 
    485                         IProblem.DivisionByZero, d)); 
     484                if (context.acceptsProblems()) { 
     485                    context.acceptProblem(Problem.newSemanticTypeError( 
     486                            IProblem.DivisionByZero, d)); 
     487                } 
    486488                break; 
    487489            } 
     
    558560 
    559561            else if (e.op == TOKdotexp) { 
    560                 context.acceptProblem(Problem.newSemanticTypeError( 
    561                         IProblem.SymbolHasNoValue, e, 
    562                         new String[] { e.toChars(context) })); 
     562                if (context.acceptsProblems()) { 
     563                    context.acceptProblem(Problem.newSemanticTypeError( 
     564                            IProblem.SymbolHasNoValue, e, 
     565                            new String[] { e.toChars(context) })); 
     566                } 
    563567            } 
    564568        } 
     
    618622            if (d.prot() == PROTprivate && d.getModule() != sc.module 
    619623                    || d.prot() == PROTpackage && !hasPackageAccess(sc, d)) { 
    620                 context.acceptProblem(Problem.newSemanticTypeError(IProblem.SymbolIsNotAccessible, this, new String[] { d.kind(), d 
    621                         .getModule().toChars(context), d.toChars(context), 
    622                         sc.module.toChars(context) })); 
     624                if (context.acceptsProblems()) { 
     625                    context.acceptProblem(Problem.newSemanticTypeError(IProblem.SymbolIsNotAccessible, this, new String[] { d.kind(), d 
     626                            .getModule().toChars(context), d.toChars(context), 
     627                            sc.module.toChars(context) })); 
     628                } 
    623629            } 
    624630        } else if (e.type.ty == Tclass) { // Do access check 
     
    759765 
    760766        if (nargs > nparams && tf.varargs == 0) { 
    761             context.acceptProblem(Problem.newSemanticTypeError( 
    762                     IProblem.ExpectedNumberArguments, this, new String[] { String.valueOf(nparams), String.valueOf(nargs) })); 
     767            if (context.acceptsProblems()) { 
     768                context.acceptProblem(Problem.newSemanticTypeError( 
     769                        IProblem.ExpectedNumberArguments, this, new String[] { String.valueOf(nparams), String.valueOf(nargs) })); 
     770            } 
    763771        } 
    764772 
     
    786794                        } 
    787795                        if (!gotoL2) { 
    788                             context.acceptProblem(Problem.newSemanticTypeError( 
    789                                     IProblem.ExpectedNumberArguments, this, new String[] { String.valueOf(nparams), String.valueOf(nargs) })); 
     796                            if (context.acceptsProblems()) { 
     797                                context.acceptProblem(Problem.newSemanticTypeError( 
     798                                        IProblem.ExpectedNumberArguments, this, new String[] { String.valueOf(nparams), String.valueOf(nargs) })); 
     799                            } 
    790800                        } 
    791801                        break; 
     
    870880                        default: 
    871881                            if (arg == null) { 
    872                                 context.acceptProblem(Problem.newSemanticTypeError(IProblem.NotEnoughArguments, this)); 
     882                                if (context.acceptsProblems()) { 
     883                                    context.acceptProblem(Problem.newSemanticTypeError(IProblem.NotEnoughArguments, this)); 
     884                                } 
    873885                                return; 
    874886                            } 
     
    897909                    if (arg.op == TOKarray 
    898910                            && arg.type.toBasetype(context).ty == Tbit) { 
    899                         context.acceptProblem(Problem.newSemanticTypeError( 
    900                                 IProblem.CannotHaveOutOrInoutArgumentOfBitInArray, this)); 
     911                        if (context.acceptsProblems()) { 
     912                            context.acceptProblem(Problem.newSemanticTypeError( 
     913                                    IProblem.CannotHaveOutOrInoutArgumentOfBitInArray, this)); 
     914                        } 
    901915                    } 
    902916                } 
     
    10351049 
    10361050                if (arg.type == null) { 
    1037                     context.acceptProblem(Problem.newSemanticTypeWarning( 
    1038                             IProblem.SymbolNotAnExpression, 0, arg.start, 
    1039                             arg.length, new String[] { arg.toChars(context) })); 
     1051                    if (context.acceptsProblems()) { 
     1052                        context.acceptProblem(Problem.newSemanticTypeWarning( 
     1053                                IProblem.SymbolNotAnExpression, 0, arg.start, 
     1054                                arg.length, new String[] { arg.toChars(context) })); 
     1055                    } 
    10401056                    arg = new IntegerExp(arg.loc, 0, Type.tint32); 
    10411057                } 
     
    13921408                    f = d.isFuncDeclaration(); 
    13931409                    if (null == f) { 
    1394                         context.acceptProblem(Problem.newSemanticTypeError( 
    1395                                 IProblem.SymbolIsAliasedToAFunction, a, new String[] { a.toChars(context) })); 
     1410                        if (context.acceptsProblems()) { 
     1411                            context.acceptProblem(Problem.newSemanticTypeError( 
     1412                                    IProblem.SymbolIsAliasedToAFunction, a, new String[] { a.toChars(context) })); 
     1413                        } 
    13961414                        break; // BUG: should print error message? 
    13971415                    } 
     
    15251543                e = v.value(); 
    15261544                if (null == e) { 
    1527                     context.acceptProblem(Problem.newSemanticTypeError( 
    1528                             IProblem.VariableIsUsedBeforeInitialization, v, new String[] { v.toChars(context) })); 
     1545                    if (context.acceptsProblems()) { 
     1546                        context.acceptProblem(Problem.newSemanticTypeError( 
     1547                                IProblem.VariableIsUsedBeforeInitialization, v, new String[] { v.toChars(context) })); 
     1548                    } 
    15291549                } 
    15301550                else if (e != EXP_CANT_INTERPRET) 
     
    16201640                    for (Scope sc1 = sc; sc1 != null; sc1 = sc1.enclosing) { 
    16211641                        if (sc1.scopesym == ti1) { 
    1622                             context.acceptProblem(Problem.newSemanticTypeError( 
    1623                                     IProblem.RecursiveTemplateExpansionForTemplateArgument, t1, new String[] { t1.toChars(context) })); 
     1642                            if (context.acceptsProblems()) { 
     1643                                context.acceptProblem(Problem.newSemanticTypeError( 
     1644                                        IProblem.RecursiveTemplateExpansionForTemplateArgument, t1, new String[] { t1.toChars(context) })); 
     1645                            } 
    16241646                            return true; // fake a match 
    16251647                        } 
     
    18271849            for (Modifier modifier : modifiers) { 
    18281850                if (modifier.tok == tok) { 
    1829                     context.acceptProblem(Problem.newSemanticTypeError( 
    1830                             problemId, modifier)); 
     1851                    if (context.acceptsProblems()) { 
     1852                        context.acceptProblem(Problem.newSemanticTypeError( 
     1853                                problemId, modifier)); 
     1854                    } 
    18311855                    reported = true; 
    18321856                } 
     
    18371861            for (Modifier modifier : extraModifiers) { 
    18381862                if (modifier.tok == tok) { 
    1839                     context.acceptProblem(Problem.newSemanticTypeError( 
    1840                             problemId, modifier)); 
     1863                    if (context.acceptsProblems()) { 
     1864                        context.acceptProblem(Problem.newSemanticTypeError( 
     1865                                problemId, modifier)); 
     1866                    } 
    18411867                    reported = true; 
    18421868                } 
     
    18451871         
    18461872        if (!reported) { 
    1847             context.acceptProblem(Problem.newSemanticTypeErrorLoc( 
    1848                     problemId, this)); 
     1873            if (context.acceptsProblems()) { 
     1874                context.acceptProblem(Problem.newSemanticTypeErrorLoc( 
     1875                        problemId, this)); 
     1876            } 
    18491877        } 
    18501878    } 
  • trunk/descent.core/src/descent/internal/compiler/parser/AddrExp.java

    r1116 r1154  
    139139                    if (index.compareTo(0) < 0 || index.compareTo(dim) >= 0) { 
    140140                        // PERHAPS test this error 
    141                         context.acceptProblem(Problem.newSemanticTypeError( 
    142                                 IProblem.ArrayIndexOutOfBounds, 
    143                                 this, 
    144                                 new String[] { 
    145                                     String.valueOf(index), 
    146                                     String.valueOf(dim), 
    147                                 })); 
     141                        if (context.acceptsProblems()) { 
     142                            context.acceptProblem(Problem.newSemanticTypeError( 
     143                                    IProblem.ArrayIndexOutOfBounds, 
     144                                    this, 
     145                                    new String[] { 
     146                                        String.valueOf(index), 
     147                                        String.valueOf(dim), 
     148                                    })); 
     149                        } 
    148150                    } 
    149151                    e = new SymOffExp(loc, ve.var, index.multiply(ts.next 
     
    163165            e1 = e1.toLvalue(sc, null, context); 
    164166            if (e1.type == null) { 
    165                 context.acceptProblem(Problem.newSemanticTypeError( 
    166                         IProblem.CannotTakeAddressOf, e1, new String[] { e1.toChars(context) })); 
     167                if (context.acceptsProblems()) { 
     168                    context.acceptProblem(Problem.newSemanticTypeError( 
     169                            IProblem.CannotTakeAddressOf, e1, new String[] { e1.toChars(context) })); 
     170                } 
    167171                type = Type.tint32; 
    168172                return this; 
  • trunk/descent.core/src/descent/internal/compiler/parser/AggregateDeclaration.java

    r1126 r1154  
    9090        } 
    9191        if (!result) { 
    92             context.acceptProblem(Problem.newSemanticTypeError(IProblem.MemberIsNotAccessible, reference, new String[] { smember.toChars(context) })); 
     92            if (context.acceptsProblems()) { 
     93                context.acceptProblem(Problem.newSemanticTypeError(IProblem.MemberIsNotAccessible, reference, new String[] { smember.toChars(context) })); 
     94            } 
    9395        } 
    9496    } 
     
    250252    public void semantic2(Scope sc, SemanticContext context) { 
    251253        if (scope != null) { 
    252             context.acceptProblem(Problem.newSemanticTypeError(IProblem.SymbolHasForwardReferences, this, new String[] { toChars(context) })); 
     254            if (context.acceptsProblems()) { 
     255                context.acceptProblem(Problem.newSemanticTypeError(IProblem.SymbolHasForwardReferences, this, new String[] { toChars(context) })); 
     256            } 
    253257        } 
    254258        if (members != null) { 
     
    281285         
    282286        if (null == members) { 
    283             context.acceptProblem(Problem.newSemanticTypeError( 
    284                     IProblem.UnknownSize, this)); 
     287            if (context.acceptsProblems()) { 
     288                context.acceptProblem(Problem.newSemanticTypeError( 
     289                        IProblem.UnknownSize, this)); 
     290            } 
    285291        } 
    286292        if (sizeok != 1) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/AliasDeclaration.java

    r1141 r1154  
    178178                return; 
    179179            } else { 
    180                 context.acceptProblem(Problem.newSemanticTypeError(IProblem.CannotAliasAnExpression, sourceType, new String[] { e[0].toChars(context) })); 
     180                if (context.acceptsProblems()) { 
     181                    context.acceptProblem(Problem.newSemanticTypeError(IProblem.CannotAliasAnExpression, sourceType, new String[] { e[0].toChars(context) })); 
     182                } 
    181183                t[0] = e[0].type; 
    182184            } 
     
    205207        VarDeclaration v = s.isVarDeclaration(); 
    206208        if (v != null && v.linkage == LINK.LINKdefault) { 
    207             context.acceptProblem(Problem.newSemanticTypeError( 
    208                     IProblem.ForwardReferenceOfSymbol, tempType, new String[] { tempType.toString() })); 
    209             context 
    210                     .acceptProblem(Problem.newSemanticTypeError( 
    211                             IProblem.ForwardReferenceOfSymbol, v.ident, new String[] { new String( 
    212                                     v.ident.ident) })); 
     209            if (context.acceptsProblems()) { 
     210                context.acceptProblem(Problem.newSemanticTypeError( 
     211                        IProblem.ForwardReferenceOfSymbol, tempType, new String[] { tempType.toString() })); 
     212                context 
     213                        .acceptProblem(Problem.newSemanticTypeError( 
     214                                IProblem.ForwardReferenceOfSymbol, v.ident, new String[] { new String( 
     215                                        v.ident.ident) })); 
     216            } 
    213217            s = null; 
    214218        } else { 
     
    276280        Assert.isTrue(this != aliassym); 
    277281        if (inSemantic != 0) { 
    278             context.acceptProblem(Problem.newSemanticTypeError( 
    279                     IProblem.CircularDefinition, ident, new String[] { toChars(context) })); 
     282            if (context.acceptsProblems()) { 
     283                context.acceptProblem(Problem.newSemanticTypeError( 
     284                        IProblem.CircularDefinition, ident, new String[] { toChars(context) })); 
     285            } 
    280286        } 
    281287        Dsymbol s = aliassym != null ? aliassym.toAlias(context) : this; 
  • trunk/descent.core/src/descent/internal/compiler/parser/AndAndExp.java

    r964 r1154  
    5555        } 
    5656        if (e2.op == TOK.TOKtype || e2.op == TOK.TOKimport) { 
    57             context.acceptProblem(Problem.newSemanticTypeWarning( 
    58                     IProblem.SymbolNotAnExpression, 0, e2.start, e2.length, 
    59                     new String[] { e2.toChars(context) })); 
     57            if (context.acceptsProblems()) { 
     58                context.acceptProblem(Problem.newSemanticTypeWarning( 
     59                        IProblem.SymbolNotAnExpression, 0, e2.start, e2.length, 
     60                        new String[] { e2.toChars(context) })); 
     61            } 
    6062        } 
    6163 
     
    123125            if (result > 0 && e2.type.toBasetype(context).ty == Tvoid 
    124126                    && context.global.errors <= 0) { 
    125                 context.acceptProblem(Problem.newSemanticTypeError( 
    126                         IProblem.SymbolHasNoValue, this, 
    127                         new String[] { "void" })); 
     127                if (context.acceptsProblems()) { 
     128                    context.acceptProblem(Problem.newSemanticTypeError( 
     129                            IProblem.SymbolHasNoValue, this, 
     130                            new String[] { "void" })); 
     131                } 
    128132            } 
    129133            if (e1.isConst()) { 
  • trunk/descent.core/src/descent/internal/compiler/parser/AnonDeclaration.java