Changeset 1203

Show
Ignore:
Timestamp:
07/04/08 22:14:03 (6 months ago)
Author:
asterite
Message:

Finally I came up with a big optimization. Now everything should work *fast*... or at least much, much faster than before. :-)

Files:

Legend:

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

    r1192 r1203  
    17141714                } 
    17151715                 
    1716                 func.consumeRestStructure(); 
    1717                  
    17181716                TypeFunction tf = (TypeFunction) func.type;  
    17191717                 
  • trunk/descent.core/src/descent/core/dom/CompilationUnitResolver.java

    r1198 r1203  
    1111package descent.core.dom; 
    1212 
    13 import java.util.List; 
    1413import java.util.Map; 
    1514 
     
    4544     
    4645    private final static boolean RESOLVE = true; 
    47     private final static boolean STATS = true; 
     46    private final static boolean STATS = false; 
    4847     
    4948    public static class ParseResult { 
     
    359358            module.semantic(context); 
    360359        } catch (Throwable t) { 
    361             Util.log(t); 
     360            Util.log(t, "In module " + module.moduleName + ": " + t.getClass().getName() + ":" + t.getMessage()); 
    362361        } 
    363362         
     
    400399    } 
    401400     
    402     private static void addIdentifiers(HashtableOfCharArrayAndObject hash, List<char[]> list) { 
     401    private static void addIdentifiers(HashtableOfCharArrayAndObject hash, HashtableOfCharArrayAndObject list) { 
    403402        for(char[] key : hash.keys()) { 
    404403            if (key != null) { 
    405                 list.add(key); 
     404                list.put(key, CompilationUnitResolver.class); 
    406405            } 
    407406        } 
  • trunk/descent.core/src/descent/core/dom/DefaultBindingResolver.java

    r1201 r1203  
    560560        if (id.resolvedSymbol != null) { 
    561561            Dsymbol sym = id.resolvedSymbol; 
     562             
     563            if (sym instanceof AliasDeclaration) { 
     564                AliasDeclaration alias = (AliasDeclaration) sym; 
     565                if (alias.isImportAlias) { 
     566                    sym = alias.aliassym; 
     567                } 
     568            } 
     569             
    562570            IBinding binding = resolveDsymbol(sym); 
    563571            if (binding != null) { 
     
    798806         
    799807        if (binding != null) { 
    800             if ("@5tango3sys5win325Types=6HANDLE".equals(binding)) { 
    801                 System.out.println(123456); 
    802             } 
    803808            bindingTables.bindingKeysToBindings.put(key, binding); 
    804809        } 
  • trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java

    r1201 r1203  
    337337        } 
    338338         
    339       long time = System.currentTimeMillis(); 
     339//        long time = System.currentTimeMillis(); 
    340340         
    341341        this.requestor.beginReporting(); 
     
    434434            this.requestor.endReporting(); 
    435435             
    436           time = System.currentTimeMillis() - time; 
    437           System.out.println("Completion took " + time + " milliseconds to complete."); 
     436//            time = System.currentTimeMillis() - time; 
     437//            System.out.println("Completion took " + time + " milliseconds to complete."); 
    438438        } 
    439439    } 
     
    720720         
    721721        node.semantic(Scope.createGlobal(node.mod, semanticContext), semanticContext); 
    722         node.mod.consumeRestStructure(); 
    723         node.mod.consumeRest(); 
    724722         
    725723        if (node.mod != null) { 
     
    10841082            } 
    10851083        } else if (node.ident != null) { 
     1084            isCompletingTypeIdentifier = false; 
    10861085            completeIdentDot(node.ident); 
    10871086        } 
     
    10971096        if (sym instanceof ClassDeclaration) { 
    10981097            ClassDeclaration cd = (ClassDeclaration) sym; 
     1098            cd = cd.unlazy(semanticContext); 
     1099             
    10991100            Declaration func = cd.ctor; 
    11001101             
     
    11271128            } 
    11281129        } else if (sym instanceof StructDeclaration) { 
    1129             suggestMembers(((StructDeclaration) sym).members, onlyStatics, 0, new HashtableOfCharArrayAndObject(), INCLUDE_OPCALL); 
    1130         } 
    1131     } 
    1132      
     1130            StructDeclaration struct = ((StructDeclaration) sym).unlazy(semanticContext); 
     1131            suggestMembers(struct.members, onlyStatics, 0, new HashtableOfCharArrayAndObject(), INCLUDE_OPCALL); 
     1132        } 
     1133    } 
     1134 
    11331135    private void completeExpStatement(CompletionOnExpStatement node) throws JavaModelException { 
    11341136        doSemantic(); 
     
    15431545        } else if (sd.members != null && !sd.members.isEmpty()) { 
    15441546            // If the members are from a Module, don't restrict to "static" symbols 
     1547            if (sd instanceof Module) { 
     1548                sd = ((Module) sd).unlazy(semanticContext); 
     1549            } 
     1550             
    15451551            suggestMembers(sd.members, sd instanceof Module ? false : onlyStatics, 0, new HashtableOfCharArrayAndObject(), includes); 
    15461552        } 
    15471553    } 
    1548      
     1554 
    15491555    private Dsymbol getScopeSymbol(Scope scope) { 
    15501556        if (scope.scopesym == null || scope.scopesym.members == null 
     
    15931599            if (se.sds instanceof Module) { 
    15941600                currentName = computePrefixAndSourceRange(ident); 
    1595                 suggestMembers(((Module) se.sds).members, false /* not only statics */,  
     1601                suggestMembers((((Module) se.sds)).unlazy(semanticContext).members,  
     1602                        false /* not only statics */,  
    15961603                        new HashtableOfCharArrayAndObject(), INCLUDE_ALL); 
    15971604            } else if (se.sds instanceof Package) { 
     
    16421649        } 
    16431650    } 
    1644  
     1651     
    16451652    private void completePackage(Package sds, char[] name, IdentifierExp ident) { 
    16461653        Stack<char[]> pieces = new Stack<char[]>(); 
     
    18701877     
    18711878    private void completeTypeClassRecursively(TypeClass type, boolean onlyStatics, HashtableOfCharArrayAndObject funcSignatures) { 
    1872         ClassDeclaration decl = type.sym
     1879        ClassDeclaration decl = type.sym == null ? null : type.sym.unlazy(semanticContext)
    18731880        if (decl == null) { 
    18741881            return; 
     
    18941901     
    18951902    private void completeTypeStruct(TypeStruct type, boolean onlyStatics) { 
    1896         StructDeclaration decl = type.sym
     1903        StructDeclaration decl = type.sym == null ? null : type.sym.unlazy(semanticContext)
    18971904        if (decl == null) { 
    18981905            return; 
     
    20202027        } 
    20212028         
    2022         // The member may not have it's semantic pass done 
    2023         member.consumeRestStructure(); 
    2024         member.consumeRest(); 
    2025          
    20262029        if (member instanceof Import /* && member.getModule() == module */) { 
    20272030            Import imp = ((Import) member); 
     
    20372040                if (!suggestedModules.containsKey(fqn)) { 
    20382041                    suggestedModules.put(fqn, this); 
     2042                     
     2043                    mod = mod.unlazy(semanticContext); 
    20392044                     
    20402045                    suggestMembers(mod.members, false, funcSignatures, includes & (~INCLUDE_IMPORTS)); 
     
    22272232                    if (parser.inNewExp) { 
    22282233                        if (type instanceof TypeClass) { 
    2229                             ClassDeclaration cd = ((TypeClass) type).sym
     2234                            ClassDeclaration cd = ((TypeClass) type).sym.unlazy(semanticContext)
    22302235                            if (cd.isClassDeclaration() != null && cd.isInterfaceDeclaration() == null) { 
    22312236                                // If it's abstract, skip 
     
    22912296            if (isType) { 
    22922297                if (currentName.length == 0 || match(currentName, ident)) { 
    2293                     if (member.getSignature() == null) { 
    2294                         member.consumeRest(); 
    2295                         member.getSignature(); 
    2296                     } 
    2297                      
    22982298                    char[] sigChars = member.getSignature().toCharArray(); 
    22992299                     
     
    25392539        // opCall 
    25402540        case ASTDmdNode.TYPE_STRUCT: { 
    2541             StructDeclaration sym = ((TypeStruct) type).sym; 
    2542             sym.consumeRestStructure(); 
    2543             sym.consumeRest(); 
     2541            StructDeclaration sym = (((TypeStruct) type).sym).unlazy(semanticContext); 
    25442542            currentName = ident; 
    25452543            suggestMembers(sym.members, onlyStatics, new HashtableOfCharArrayAndObject(), INCLUDE_OPCALL); 
     
    25472545        } 
    25482546        case ASTDmdNode.TYPE_CLASS: {            
    2549             ClassDeclaration sym = ((TypeClass) type).sym; 
    2550             sym.consumeRestStructure(); 
    2551             sym.consumeRest(); 
     2547            ClassDeclaration sym = (((TypeClass) type).sym).unlazy(semanticContext); 
    25522548            currentName = ident; 
    25532549            suggestMembers(sym.members, onlyStatics, new HashtableOfCharArrayAndObject(), INCLUDE_OPCALL); 
     
    34263422 
    34273423    private boolean isFunctionSignature(char[] signature) { 
    3428         return signature.length > 0 && signature[0] == Signature.C_D_LINKAGE || signature[0] == Signature.C_C_LINKAGE || 
     3424        return signature.length > 0 && (signature[0] == Signature.C_D_LINKAGE || signature[0] == Signature.C_C_LINKAGE || 
    34293425                signature[0] == Signature.C_CPP_LINKAGE || signature[0] == Signature.C_PASCAL_LINKAGE || 
    3430                 signature[0] == Signature.C_WINDOWS_LINKAGE
     3426                signature[0] == Signature.C_WINDOWS_LINKAGE)
    34313427    } 
    34323428 
  • trunk/descent.core/src/descent/internal/codeassist/SelectionEngine.java

    r1200 r1203  
    331331            sym = node.templateInstance.tempdecl; 
    332332        } 
    333  
     333         
    334334        if (sym != null) { 
    335335            // See if this symbols was created at compile-time 
    336336            while (sym.creator != null) { 
    337337                sym = sym.creator; 
     338            } 
     339             
     340            if (sym instanceof AliasDeclaration) { 
     341                AliasDeclaration alias = (AliasDeclaration) sym; 
     342                if (alias.isImportAlias) { 
     343                    sym = alias.aliassym; 
     344                } 
    338345            } 
    339346             
  • trunk/descent.core/src/descent/internal/codeassist/complete/CompletionOnTypeIdentifier.java

    r1131 r1203  
    4545        this.scope = ScopeCopy.copy(sc, context); 
    4646    } 
     47     
     48    @Override 
     49    public void addIdent(IdentifierExp ident) { 
     50         
     51    } 
    4752 
    4853} 
  • trunk/descent.core/src/descent/internal/codeassist/complete/CompletionParser.java

    r1201 r1203  
    1414import descent.internal.compiler.parser.CaseStatement; 
    1515import descent.internal.compiler.parser.Chars; 
    16 import descent.internal.compiler.parser.ClassDeclaration; 
    1716import descent.internal.compiler.parser.CompoundStatement; 
    1817import descent.internal.compiler.parser.ContinueStatement; 
     
    482481        } else if (token.ptr <= cursorLocation && cursorLocation <= token.ptr + token.sourceLen) { 
    483482            pivot = token; 
     483        } else if (e.start + e.length < cursorLocation && cursorLocation < id.start) { 
     484            assistNode = new CompletionOnDotIdExp(loc, e, new IdentifierExp(CharOperation.NO_CHAR)); 
     485            return (DotIdExp) assistNode; 
    484486        } else { 
    485487            return super.newDotIdExp(loc, e, id); 
     
    490492            return (DotIdExp) assistNode; 
    491493        } else { 
    492             completionTokenStart = pivot.ptr; 
    493             completionTokenEnd = pivot.ptr + pivot.sourceLen; 
    494             completionToken = CharOperation.subarray(input, completionTokenStart, cursorLocation); 
     494            if (pivot.value == TOK.TOKdot) { 
     495                completionTokenStart = pivot.ptr + pivot.sourceLen; 
     496                completionTokenEnd = pivot.ptr + pivot.sourceLen; 
     497                completionToken = CharOperation.subarray(input, completionTokenStart, cursorLocation); 
     498            } else { 
     499                completionTokenStart = pivot.ptr; 
     500                completionTokenEnd = pivot.ptr + pivot.sourceLen; 
     501                completionToken = CharOperation.subarray(input, completionTokenStart, cursorLocation); 
     502            } 
    495503             
    496504            assistNode = new CompletionOnDotIdExp(loc, e, id); 
  • trunk/descent.core/src/descent/internal/compiler/lookup/ModuleBuilder.java

    r1201 r1203  
    11package descent.internal.compiler.lookup; 
     2 
     3import java.util.ArrayList; 
     4import java.util.List; 
    25 
    36import descent.core.Flags; 
     
    1215import descent.core.IMethod; 
    1316import descent.core.IPackageDeclaration; 
     17import descent.core.IParent; 
     18import descent.core.ISourceRange; 
    1419import descent.core.ISourceReference; 
    1520import descent.core.ITemplated; 
     
    1823import descent.core.JavaModelException; 
    1924import descent.internal.compiler.parser.ASTNodeEncoder; 
    20 import descent.internal.compiler.parser.AggregateDeclaration; 
    2125import descent.internal.compiler.parser.AliasDeclaration; 
    2226import descent.internal.compiler.parser.AlignDeclaration; 
     
    5660import descent.internal.compiler.parser.ProtDeclaration; 
    5761import descent.internal.compiler.parser.STC; 
     62import descent.internal.compiler.parser.SemanticContext; 
    5863import descent.internal.compiler.parser.StaticIfCondition; 
    5964import descent.internal.compiler.parser.StaticIfDeclaration; 
     
    8388public class ModuleBuilder { 
    8489     
    85     /* 
    86      * One ring to rule them all.  
    87      */ 
    88     private final static boolean LAZY = true; 
    89      
    90     /* 
    91      * Whether to make surface Module semantic. 
    92      */ 
    93     public boolean LAZY_MODULES = true; 
    94      
    95     /* 
    96      * Whether to make surface ClassDeclaration semantic lazy. 
    97      */ 
    98     private final static boolean LAZY_CLASSES = LAZY & true; 
    99      
    100     /* 
    101      * Whether to make surface InterfaceDeclaration semantic lazy. 
    102      */ 
    103     private final static boolean LAZY_INTERFACES = LAZY & true; 
    104      
    105     /* 
    106      * Whether to make surface StructDeclaration semantic lazy. 
    107      */ 
    108     private final static boolean LAZY_STRUCTS = LAZY & true; 
    109      
    110     /* 
    111      * Whether to make surface UnionDeclaration semantic lazy. 
    112      */ 
    113     private final static boolean LAZY_UNIONS = LAZY & true; 
    114      
    115     /* 
    116      * Whether to make surface AliasDeclaration semantic lazy. 
    117      */ 
    118     private final static boolean LAZY_ALIASES = LAZY & true; 
    119      
    120     /* 
    121      * Whether to make surface EnumDeclaration semantic lazy. 
    122      */ 
    123     private final static boolean LAZY_ENUMS = LAZY & true; 
    124      
    125     /* 
    126      * Whether to make surface TemplateDeclaration semantic lazy. 
    127      */ 
    128     private final static boolean LAZY_TEMPLATES = LAZY & true; 
    129      
    130     /* 
    131      * Whether to make surface FuncDeclaration semantic lazy. 
    132      */ 
    133     private final static boolean LAZY_FUNCTIONS = LAZY & true; 
    134      
    135     /* 
    136      * Whether to make surface VarDeclaration semantic lazy. 
    137      * Currently doesn't work. 
    138      */ 
    139     public boolean LAZY_VARS = LAZY & false; 
     90    public boolean LAZY = true; 
    14091     
    14192    /* 
     
    167118        HashtableOfCharArrayAndObject versions = new HashtableOfCharArrayAndObject(); 
    168119        HashtableOfCharArrayAndObject debugs = new HashtableOfCharArrayAndObject(); 
    169         boolean surface = true; 
    170120    } 
    171121     
     
    181131        this.config = config; 
    182132        this.encoder = encoder; 
    183          
    184 //      switch(config.semanticAnalysisLevel) { 
    185 //      case 0: // None 
    186 //          LAZY_MODULES = LAZY & true; 
    187 //          LAZY_VARS = LAZY & true; 
    188 //          break; 
    189 //      case 1: // Some 
    190 //      case 2: // All 
    191 //          LAZY_MODULES = false; 
    192 //          LAZY_VARS = false; 
    193 //          break; 
    194 //      } 
    195133    } 
    196134     
     
    201139     */ 
    202140    public Module build(final ICompilationUnit unit) { 
    203         long time = System.currentTimeMillis(); 
     141        CompilationUnitElementInfo info = null; 
     142        try { 
     143            info = (CompilationUnitElementInfo) ((CompilationUnit) unit).getElementInfo(); 
     144        } catch (JavaModelException e) { 
     145            Util.log(e); 
     146        } 
     147         
     148        String moduleName = unit.getFullyQualifiedName(); 
     149         
     150        final Module module; 
     151        if (!LAZY || "object".equals(moduleName) || (info != null && info.hasTopLevelCompileTimeDifficulties())) { 
     152            module = new Module(unit.getElementName(), new IdentifierExp(unit.getModuleName().toCharArray())); 
     153            assignMembers(unit, moduleName, module); 
     154        } else { 
     155            module = new LazyModule(unit.getElementName(), new IdentifierExp(unit.getModuleName().toCharArray()), this, info.getTopLevelIdentifiers(), info.getLastImportLocation()); 
     156            module.moduleName = moduleName; 
     157        } 
     158        module.setJavaElement(unit); 
     159         
     160        assignPackageDeclaration(unit, module); 
     161         
     162        return module; 
     163    } 
     164     
     165    public Module buildNonLazyModule(ICompilationUnit unit) { 
     166        String moduleName = unit.getFullyQualifiedName(); 
    204167         
    205168        final Module module = new Module(unit.getElementName(), new IdentifierExp(unit.getModuleName().toCharArray())); 
     169        assignMembers(unit, moduleName, module); 
    206170        module.setJavaElement(unit); 
    207         module.moduleName = unit.getFullyQualifiedName(); 
    208          
    209 //      if (LAZY_MODULES) { 
    210 //          module.setJavaElement(unit); 
    211 //          module.rest = new SemanticRest(new Runnable() { 
    212 //              public void run() { 
    213 //                  try { 
    214 //                      IPackageDeclaration[] packageDeclarations = unit.getPackageDeclarations(); 
    215 //                      if (packageDeclarations.length == 1) { 
    216 //                          String elementName = packageDeclarations[0].getElementName(); 
    217 //                          Identifiers packages = new Identifiers(); 
    218 //                          IdentifierExp name = splitName(elementName, packages);   
    219 //                          module.md = new ModuleDeclaration(packages, name); 
    220 //                      } 
    221 //                       
    222 //                      State state = new State(); 
    223 //                       
    224 //                      module.members = new Dsymbols(); 
    225 ////                        fill(module, module.members, unit.getChildren(), state); 
    226 //                       
    227 //                      state.surface = false; 
    228 //                  } catch (JavaModelException e) { 
    229 //                      Util.log(e); 
    230 //                  } 
    231 //              } 
    232 //          }); 
    233 //          module.rest.skipScopeCheck = true; 
    234 //      } else { 
    235          
     171         
     172        assignPackageDeclaration(unit, module); 
     173         
     174        return module; 
     175    } 
     176 
     177    private void assignMembers(ICompilationUnit unit, String moduleName, final Module module) { 
     178        try { 
     179            State state = new State(); 
     180            module.moduleName = moduleName; 
     181            module.members = new Dsymbols(); 
     182            fill(module, module.members, unit.getChildren(), state); 
     183        } catch (JavaModelException e) { 
     184            Util.log(e); 
     185        } 
     186    } 
     187 
     188    private void assignPackageDeclaration(ICompilationUnit unit, final Module module) { 
    236189        IPackageDeclaration[] packageDeclarations; 
    237190        try { 
     
    246199            Util.log(e); 
    247200        } 
    248          
    249         CompilationUnitElementInfo info = null; 
    250         try { 
    251             info = (CompilationUnitElementInfo) ((CompilationUnit) unit).getElementInfo(); 
    252         } catch (JavaModelException e) { 
    253             Util.log(e); 
    254         } 
    255          
    256         if (!LAZY_MODULES || "object".equals(module.moduleName) || (info != null && info.hasTopLevelCompileTimeDifficulties())) { 
    257             try { 
    258                 State state = new State(); 
    259                  
    260                 module.members = new Dsymbols(); 
    261                 fill(module, module.members, unit.getChildren(), state); 
    262                  
    263                 state.surface = false; 
    264             } catch (JavaModelException e) { 
    265                 Util.log(e); 
    266             } 
    267         } else { 
    268             module.builder = this; 
    269         } 
    270          
    271 //      } 
    272 //       
    273         time = System.currentTimeMillis() - time; 
    274 //      if (time > 10) { 
    275 //          System.out.println("ModuleBuilder#build(" + module.moduleName + ") = " + time); 
    276 //      } 
    277          
    278         return module; 
    279201    } 
    280202     
     
    298220        case IJavaElement.FIELD: 
    299221            IField field = (IField) elem; 
    300             fillField(module, members, field, state); 
     222            fillField(module, members, field); 
    301223            break; 
    302224        case IJavaElement.TYPE: 
     
    306228        case IJavaElement.METHOD: 
    307229            IMethod method = (IMethod) elem; 
    308             fillMethod(module, members, method, state.surface); 
     230            fillMethod(module, members, method); 
    309231            break; 
    310232        case IJavaElement.INITIALIZER: 
     
    337259            char[] nameC = name.toCharArray(); 
    338260            try { 
    339                 long value = Long.parseLong(name); 
    340                  
    341                 if (state.versions.containsKey(nameC)) { 
     261                long value = Long.parseLong(name);               
     262                if ((state != null && state.versions.containsKey(nameC))) { 
    342263                    buildConditional(module, members, cond, state, nameC, value, false /* not debug */); 
    343264                } else { 
    344                     if (config.isVersionEnabled(value)) { 
     265                    if (config.isVersionEnabled(value) || value >= module.versionlevel) { 
    345266                        fill(module, members, cond.getThenChildren(), state); 
    346267                    } else { 
     
    349270                } 
    350271            } catch(NumberFormatException e) { 
    351                 if (state.versions.containsKey(nameC)) { 
     272                if ((state != null && state.versions.containsKey(nameC))) { 
    352273                    buildConditional(module, members, cond, state, nameC, 0, false /* not debug */); 
    353274                } else { 
    354                     if (config.isVersionEnabled(name.toCharArray())) { 
     275                    if (config.isVersionEnabled(name.toCharArray()) || (module.versionids != null && module.versionids.containsKey(nameC))) { 
    355276                        fill(module, members, cond.getThenChildren(), state); 
    356277                    } else { 
     
    364285            try { 
    365286                long value = Long.parseLong(name); 
    366                 if (state.debugs.containsKey(nameC)) { 
     287                if (state != null && state.debugs.containsKey(nameC)) { 
    367288                    buildConditional(module, members, cond, state, nameC, value, true /* debug */); 
    368289                } else {                     
    369                     if (config.isDebugEnabled(value)) { 
     290                    if (config.isDebugEnabled(value) || value >= module.debuglevel) { 
    370291                        fill(module, members, cond.getThenChildren(), state); 
    371292                    } else { 
     
    374295                } 
    375296            } catch(NumberFormatException e) { 
    376                 if (state.debugs.containsKey(nameC)) { 
     297                if (state != null && state.debugs.containsKey(nameC)) { 
    377298                    buildConditional(module, members, cond, state, nameC, 0, true /* debug */); 
    378299                } else {     
    379                     if (config.isDebugEnabled(name.toCharArray())) { 
     300                    if (config.isDebugEnabled(name.toCharArray()) || (module.debugids != null && module.debugids.containsKey(nameC))) { 
    380301                        fill(module, members, cond.getThenChildren(), state); 
    381302                    } else { 
     
    410331    private void fillInitializer(Module module, Dsymbols members, IInitializer init,  
    411332            State state) throws JavaModelException { 
    412         boolean surface = state.surface;         
    413         state.surface = false; 
    414          
    415333        if (init.isAlign()) { 
    416334            Dsymbols sub = new Dsymbols(); 
     
    420338            members.add(member); 
    421339        } else if (init.isDebugAssignment()) { 
    422             char[] ident = init.getElementName().toCharArray(); 
    423              
    424             state.debugs.put(ident, this); 
    425              
    426             Version version = new Version(getLoc(module, init), ident); 
    427             try { 
    428                 long level = Long.parseLong(init.getElementName()); 
    429                 DebugSymbol member = new DebugSymbol(getLoc(module, init), level, version); 
    430                 members.add(member); 
    431             } catch(NumberFormatException e) { 
    432                 DebugSymbol member = new DebugSymbol(getLoc(module, init), new IdentifierExp(ident), version); 
    433                 members.add(member); 
    434             } 
     340            fillDebugAssignment(module, members, init, state); 
    435341        } else if (init.isVersionAssignment()) { 
    436             char[] ident = init.getElementName().toCharArray(); 
    437              
    438             state.versions.put(ident, this); 
    439              
    440             Version version = new Version(getLoc(module, init), ident); 
    441             try { 
    442                 long level = Long.parseLong(init.getElementName()); 
    443                 VersionSymbol member = new VersionSymbol(getLoc(module, init), level, version); 
    444                 members.add(member); 
    445             } catch(NumberFormatException e) { 
    446                 VersionSymbol member = new VersionSymbol(getLoc(module, init), new IdentifierExp(ident), version); 
    447                 members.add(member); 
    448             } 
     342            fillVersionAssignment(module, members, init, state); 
    449343        } else if (init.isMixin()) { 
    450344            Expression exp = encoder.decodeExpression(init.getElementName().toCharArray()); 
     
    453347            members.add(member); 
    454348        } else if (init.isExtern()) { 
    455             // Also try to lazily initialize things inside: 
    456             // extern(C) { 
    457             //   // ... 
    458             // } 
    459             if (surface) { 
    460                 state.surface = surface; 
    461             } 
    462              
    463349            Dsymbols symbols = new Dsymbols(); 
    464350            fill(module, symbols, init.getChildren(), state); 
     
    467353            members.add(wrap(member, init)); 
    468354        } 
    469          
    470         state.surface = surface; 
    471     } 
    472  
    473     private void fillMethod(Module module, Dsymbols members, final IMethod method, boolean surface) throws JavaModelException { 
     355    } 
     356 
     357    public DebugSymbol fillDebugAssignment(Module module, Dsymbols members, IInitializer init, State state) { 
     358        char[] ident = init.getElementName().toCharArray(); 
     359         
     360        if (state != null) { 
     361            state.debugs.put(ident, this); 
     362        } 
     363         
     364        Version version = new Version(getLoc(module, init), ident); 
     365        DebugSymbol member; 
     366        try { 
     367            long level = Long.parseLong(init.getElementName()); 
     368            member = new DebugSymbol(getLoc(module, init), level, version); 
     369        } catch(NumberFormatException e) { 
     370            member = new DebugSymbol(getLoc(module, init), new IdentifierExp(ident), version); 
     371        } 
     372        members.add(member); 
     373        return member; 
     374    } 
     375 
     376    public VersionSymbol fillVersionAssignment(Module module, Dsymbols members, IInitializer init, State state) { 
     377        char[] ident = init.getElementName().toCharArray(); 
     378         
     379        if (state != null) { 
     380            state.versions.put(ident, this); 
     381        } 
     382         
     383        Version version = new Version(getLoc(module, init), ident); 
     384        VersionSymbol member; 
     385        try { 
     386            long level = Long.parseLong(init.getElementName()); 
     387            member = new VersionSymbol(getLoc(module, init), level, version); 
     388        } catch(NumberFormatException e) { 
     389            member = new VersionSymbol(getLoc(module, init), new IdentifierExp(ident), version); 
     390        } 
     391        members.add(member); 
     392        return member; 
     393    } 
     394 
     395    private void fillMethod(Module module, Dsymbols members, final IMethod method) throws JavaModelException { 
    474396        if (method.isConstructor()) { 
    475397            CtorDeclaration member = new CtorDeclaration(getLoc(module, method), getArguments(method), getVarargs(method)); 
     
    489411            members.add(wrap(member, method));   
    490412        } else {  
    491             final FuncDeclaration member; 
    492             if (LAZY_FUNCTIONS && surface && module.builder == null) { 
    493                 member = new FuncDeclaration(getLoc(module, method), getIdent(method), getStorageClass(method), null); 
    494                 member.rest = new SemanticRest(new Runnable() { 
    495                     public void run() { 
    496                         try { 
    497                             member.type = member.sourceType = getType(method); 
    498                         } catch (JavaModelException e) { 
    499                             Util.log(e); 
    500                         } 
    501                     } 
    502                 }); 
    503             } else { 
    504                 member = new FuncDeclaration(getLoc(module, method), getIdent(method), getStorageClass(method), getType(method)); 
    505             } 
    506              
     413            FuncDeclaration member = new FuncDeclaration(getLoc(module, method), getIdent(method), getStorageClass(method), getType(method)); 
    507414            member.setJavaElement(method); 
    508             members.add(wrapWithTemplate(module, member, method, surface)); 
     415            members.add(wrapWithTemplate(module, member, method)); 
    509416        } 
    510417    } 
     
    512419    public void fillType(final Module module, Dsymbols members, final IType type,  
    513420            final State state) throws JavaModelException { 
    514         boolean surface = state.surface; 
    515         state.surface = false; 
    516          
    517421        if (type.isClass()) { 
    518             final ClassDeclaration member; 
    519              
    520             if (LAZY_CLASSES && surface && module.builder == null) { 
    521                 member = new ClassDeclaration(getLoc(module, type), getIdent(type)); 
    522                 member.rest = new SemanticRest(new Runnable() { 
    523                     public void run() { 
    524                         try { 
    525                             member.baseclasses = getBaseClasses(type); 
    526                             if (member.baseclasses != null) {