Changeset 1155
- Timestamp:
- 05/04/08 22:32:49 (8 months ago)
- Files:
-
- trunk/descent.core/src/descent/core/compiler/IProblem.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/SourceElementParser.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/lookup/ModuleBuilder.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ASTDmdNode.java (modified) (5 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/FuncDeclaration.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/Module.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/Problem.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.properties (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/STC.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/TemplateDeclaration.java (modified) (11 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/TemplateInstance.java (modified) (7 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/TemplateMixin.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/TemplateTypeParameter.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/Type.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/TypeInstance.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/TypeSArray.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/core/CompilationUnitElementInfo.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/core/CompilationUnitStructureRequestor.java (modified) (10 diffs)
- trunk/descent.core/template/problem/problems.txt (modified) (2 diffs)
- trunk/descent.ui/plugin.xml (modified) (2 diffs)
- trunk/update.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.core/src/descent/core/compiler/IProblem.java
r1120 r1155 640 640 int CannotDeclareTemplateAtFunctionScope = 429; 641 641 int TemplateHasNoValue = 430; 642 int InconsistentNestingLevels = 431; 643 int CannotUseLocalAsTemplateParameter = 432; 644 int NoSizeForType = 433; 645 int SymbolDotSymbolIsNotADeclaration = 434; 646 int ThisIsRequiredButIsNotABaseClassOf = 435; 647 int ForwardReferenceToSymbol = 436; 648 int IdentifierOfSymbolIsNotDefined = 437; 649 int StructIsForwardReferenced = 438; 650 int CannotUseTemplateToAddFieldToAggregate = 439; 651 int CannotModifyFinalVariable = 440; 652 int InvalidUtf8Sequence2 = 441; 653 int Utf16HighValuePastEndOfString = 442; 654 int Utf16LowValueOutOfRange = 443; 655 int UnpairedUtf16Value = 444; 656 int IllegalUtf16Value = 445; 657 int StaticConstructorCanOnlyBePartOfStructClassModule = 446; 658 int ShiftAssignIsOutsideTheRange = 447; 642 int CannotUseLocalAsTemplateParameter = 431; 643 int NoSizeForType = 432; 644 int SymbolDotSymbolIsNotADeclaration = 433; 645 int ThisIsRequiredButIsNotABaseClassOf = 434; 646 int ForwardReferenceToSymbol = 435; 647 int IdentifierOfSymbolIsNotDefined = 436; 648 int StructIsForwardReferenced = 437; 649 int CannotUseTemplateToAddFieldToAggregate = 438; 650 int CannotModifyFinalVariable = 439; 651 int InvalidUtf8Sequence2 = 440; 652 int Utf16HighValuePastEndOfString = 441; 653 int Utf16LowValueOutOfRange = 442; 654 int UnpairedUtf16Value = 443; 655 int IllegalUtf16Value = 444; 656 int StaticConstructorCanOnlyBePartOfStructClassModule = 445; 657 int ShiftAssignIsOutsideTheRange = 446; 658 int TemplateTupleParameterMustBeLastOne = 447; 659 int SymbolIsNestedInBoth = 448; 659 660 660 661 } trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java
r1154 r1155 334 334 } 335 335 336 //long time = System.currentTimeMillis();336 long time = System.currentTimeMillis(); 337 337 338 338 this.requestor.beginReporting(); … … 429 429 this.requestor.endReporting(); 430 430 431 //time = System.currentTimeMillis() - time;431 time = System.currentTimeMillis() - time; 432 432 // System.out.println("Completion took " + time + " milliseconds to complete."); 433 433 } trunk/descent.core/src/descent/internal/compiler/SourceElementParser.java
r1141 r1155 417 417 @Override 418 418 public boolean visit(TemplateDeclaration node) { 419 // TODO Java -> D420 419 if (node.wrapper) { 421 420 Dsymbol wrappedSymbol = node.members.get(0); // SEMANTIC … … 1027 1026 @Override 1028 1027 public void endVisit(TemplateDeclaration node) { 1028 int end; 1029 1029 if (node.postComment != null) { 1030 requestor.exitType(endOfDeclaration(node.postComment));1030 end = endOfDeclaration(node.postComment); 1031 1031 } else { 1032 requestor.exitType(endOfDeclaration(node)); 1032 end = endOfDeclaration(node); 1033 } 1034 1035 if (node.wrapper) { 1036 Dsymbol wrappedSymbol = node.members.get(0); // SEMANTIC 1037 if (wrappedSymbol.getNodeType() == ASTDmdNode.FUNC_DECLARATION) { 1038 requestor.exitMethod(end, -1, -1); 1039 } else { 1040 requestor.exitType(end); 1041 } 1033 1042 } 1034 1043 if (!node.wrapper) { trunk/descent.core/src/descent/internal/compiler/lookup/ModuleBuilder.java
r1154 r1155 89 89 * Wether to make surface Module semantic. 90 90 */ 91 public boolean LAZY_MODULES = LAZY & true;91 public boolean LAZY_MODULES = LAZY & false; 92 92 93 93 /* … … 180 180 this.encoder = encoder; 181 181 182 switch(config.semanticAnalysisLevel) {183 case 0: // None184 LAZY_MODULES = LAZY & true;185 LAZY_VARS = LAZY & true;186 break;187 case 1: // Some188 case 2: // All189 LAZY_MODULES = false;190 LAZY_VARS = false;191 break;192 }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 // } 193 193 } 194 194 … … 208 208 public void run() { 209 209 try { 210 long time = System.currentTimeMillis(); 211 210 212 IPackageDeclaration[] packageDeclarations = unit.getPackageDeclarations(); 211 213 if (packageDeclarations.length == 1) { … … 222 224 223 225 state.surface = false; 226 227 time = System.currentTimeMillis() - time; 228 System.out.println(module.moduleName + ": " + time); 224 229 } catch (JavaModelException e) { 225 230 Util.log(e); trunk/descent.core/src/descent/internal/compiler/parser/ASTDmdNode.java
r1154 r1155 42 42 import static descent.internal.compiler.parser.TY.Tdelegate; 43 43 import static descent.internal.compiler.parser.TY.Tfunction; 44 import static descent.internal.compiler.parser.TY.Tident; 44 45 import static descent.internal.compiler.parser.TY.Tsarray; 45 46 import static descent.internal.compiler.parser.TY.Tstruct; … … 1651 1652 1652 1653 if (null == t2 || !t1.equals(t2)) { 1653 // goto L 1;1654 // goto Lnomatch; 1654 1655 return false; 1655 1656 } 1656 1657 } else if (e1 != null) { 1657 if (null == e2 || !e1.equals(e2)) { 1658 // goto L1; 1658 if (null == e2) { 1659 // goto Lnomatch; 1660 return false; 1661 } 1662 if (!e1.equals(e2)) { 1663 // goto Lnomatch; 1659 1664 return false; 1660 1665 } 1661 1666 } else if (s1 != null) { 1662 1667 if (null == s2 || !s1.equals(s2) || s1.parent != s2.parent) { 1663 // goto L 1;1668 // goto Lnomatch; 1664 1669 return false; 1665 1670 } 1666 1671 } else if (v1 != null) { 1667 1672 if (null == v2) { 1668 // goto L 1;1673 // goto Lnomatch; 1669 1674 return false; 1670 1675 } 1671 1676 if (size(v1.objects) != size(v2.objects)) { 1672 // goto L 1;1677 // goto Lnomatch; 1673 1678 return false; 1674 1679 } … … 1676 1681 if (!match((ASTDmdNode) v1.objects.get(i), 1677 1682 (ASTDmdNode) v2.objects.get(i), tempdecl, sc, context)) { 1678 // goto L 1;1683 // goto Lnomatch; 1679 1684 return false; 1680 1685 } … … 1682 1687 } 1683 1688 return true; // match 1684 // L 1:1689 // Lnomatch: 1685 1690 // return 0; // nomatch; 1686 1691 } … … 1843 1848 } 1844 1849 1850 public static int templateIdentifierLookup(IdentifierExp id, TemplateParameters parameters) { 1851 for (int i = 0; i < size(parameters); i++) { 1852 TemplateParameter tp = (TemplateParameter) parameters.get(i); 1853 1854 if (equals(tp.ident, id)) 1855 return i; 1856 } 1857 1858 return -1; 1859 } 1860 1861 public static int templateParameterLookup(Type tparam, 1862 TemplateParameters parameters) { 1863 if (tparam.ty != Tident) { 1864 throw new IllegalStateException("assert(tparam.ty == Tident);"); 1865 } 1866 TypeIdentifier tident = (TypeIdentifier) tparam; 1867 if (size(tident.idents) == 0) { 1868 return templateIdentifierLookup(tident.ident, parameters); 1869 } 1870 return -1; 1871 } 1872 1845 1873 public void errorOnModifier(int problemId, TOK tok, SemanticContext context) { 1846 1874 boolean reported = false; trunk/descent.core/src/descent/internal/compiler/parser/FuncDeclaration.java
r1154 r1155 992 992 // Verify this doesn't override previous final function 993 993 if (cd.baseClass != null) { 994 if (ident.toString().equals("callWindowProc")) { 995 System.out.println(1); 996 } 997 994 998 Dsymbol s = cd.baseClass.search(loc, ident, 0, context); 995 999 if (s != null) { 996 1000 FuncDeclaration f2 = s.isFuncDeclaration(); 1001 if (f2 == null) { 1002 cd.baseClass.search(loc, ident, 0, context); 1003 } 997 1004 f2 = f2.overloadExactMatch(type, context); 998 1005 if (f2 != null && f2.isFinal() trunk/descent.core/src/descent/internal/compiler/parser/Module.java
r1154 r1155 6 6 import melnorme.miscutil.tree.TreeVisitor; 7 7 import descent.core.ICompilationUnit; 8 import descent.core.JavaModelException; 8 9 import descent.core.compiler.CharOperation; 9 10 import descent.core.compiler.IProblem; 10 11 import descent.internal.compiler.lookup.SemanticRest; 11 12 import descent.internal.compiler.parser.ast.IASTVisitor; 13 import descent.internal.core.CompilationUnit; 14 import descent.internal.core.CompilationUnitElementInfo; 15 import descent.internal.core.util.Util; 12 16 13 17 // DMD 1.020 14 18 public class Module extends Package { 19 20 private final static boolean FAST_SEARCH = false; 15 21 16 22 public int apiLevel; … … 177 183 semanticdone = semanticstarted; 178 184 179 nest--;185 // nest--; 180 186 } 181 187 … … 346 352 s = this.searchCacheSymbol; 347 353 } else { 354 this.insearch = true; 355 348 356 // Descent: lazy initailization 349 consumeRestStructure(); 350 consumeRest(); 357 if (FAST_SEARCH && javaElement != null && rest != null && !rest.isConsumed()) { 358 try { 359 CompilationUnit unit = (CompilationUnit) javaElement; 360 CompilationUnitElementInfo info = (CompilationUnitElementInfo) unit.getElementInfo(); 361 if (info.containsTopLevelIdentifier(ident)) { 362 consumeRestStructure(); 363 consumeRest(); 364 s = super.search(loc, ident, flags, context); 365 } else { 366 s = null; 367 } 368 } catch (JavaModelException e) { 369 Util.log(e); 370 s = null; 371 } 372 } else { 373 consumeRestStructure(); 374 consumeRest(); 375 s = super.search(loc, ident, flags, context); 376 } 351 377 352 this.insearch = true;353 s = super.search(loc, ident, flags, context);354 378 this.insearch = false; 355 379 356 this.searchCacheIdent = ident; 357 358 if ("SOCKET_ERROR".equals(new String(ident)) && s == null) { 359 this.insearch = true; 360 s = super.search(loc, ident, flags, context); 361 this.insearch = false; 362 this.searchCacheIdent = ident; 363 } 364 380 this.searchCacheIdent = ident; 365 381 this.searchCacheSymbol = s; 366 382 this.searchCacheFlags = flags; trunk/descent.core/src/descent/internal/compiler/parser/Problem.java
r1120 r1155 988 988 case TemplateHasNoValue: 989 989 return String.format(ProblemMessages.TemplateHasNoValue, arguments[0]); 990 case InconsistentNestingLevels:991 return String.format(ProblemMessages.InconsistentNestingLevels, arguments[0], arguments[1]);992 990 case CannotUseLocalAsTemplateParameter: 993 991 return String.format(ProblemMessages.CannotUseLocalAsTemplateParameter, arguments[0]); … … 1022 1020 case ShiftAssignIsOutsideTheRange: 1023 1021 return String.format(ProblemMessages.ShiftAssignIsOutsideTheRange, arguments[0], arguments[1]); 1022 case TemplateTupleParameterMustBeLastOne: 1023 return String.format(ProblemMessages.TemplateTupleParameterMustBeLastOne); 1024 case SymbolIsNestedInBoth: 1025 return String.format(ProblemMessages.SymbolIsNestedInBoth, arguments[0], arguments[1], arguments[2]); 1024 1026 default: 1025 1027 return ""; trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.java
r1120 r1155 441 441 public static String CannotDeclareTemplateAtFunctionScope; 442 442 public static String TemplateHasNoValue; 443 public static String InconsistentNestingLevels;444 443 public static String CannotUseLocalAsTemplateParameter; 445 444 public static String NoSizeForType; … … 458 457 public static String StaticConstructorCanOnlyBePartOfStructClassModule; 459 458 public static String ShiftAssignIsOutsideTheRange; 459 public static String TemplateTupleParameterMustBeLastOne; 460 public static String SymbolIsNestedInBoth; 460 461 461 462 static { trunk/descent.core/src/descent/internal/compiler/parser/ProblemMessages.properties
r1120 r1155 429 429 CannotDeclareTemplateAtFunctionScope=Cannot declare template at function scope %1$s 430 430 TemplateHasNoValue=Template %1$s has no value 431 InconsistentNestingLevels=Inconsistent nesting levels %1$s and %2$s432 431 CannotUseLocalAsTemplateParameter=Cannot use local '%1$s' as template parameter 433 432 NoSizeForType=No size for type %1$s … … 446 445 StaticConstructorCanOnlyBePartOfStructClassModule=Static constructor can only be part of struct/class/module 447 446 ShiftAssignIsOutsideTheRange=Shift assign by %1$s is outside the range 0..%2$s 447 TemplateTupleParameterMustBeLastOne=Template tuple parameter must be last one 448 SymbolIsNestedInBoth=%1$s is nested in both %2$s and %2$s trunk/descent.core/src/descent/internal/compiler/parser/STC.java
r718 r1155 27 27 public final static int STCinvariant = 0x100000; 28 28 public final static int STCref = 0x200000; 29 public final static int STCinit = 0x400000; // has explicit initializer 30 public final static int STCmanifest = 0x800000; // manifest constant 31 public final static int STCnodtor = 0x1000000; // don't run destructor 32 public final static int STCnothrow = 0x2000000; // never throws exceptions 29 33 30 34 public static int fromTOK(TOK tok) { trunk/descent.core/src/descent/internal/compiler/parser/TemplateDeclaration.java
r1154 r1155 6 6 import melnorme.miscutil.tree.TreeVisitor; 7 7 import descent.core.IJavaElement; 8 import descent.core.compiler.CharOperation; 8 9 import descent.core.compiler.IProblem; 9 10 import descent.internal.compiler.lookup.SemanticRest; … … 177 178 td_best.leastAsSpecialized(td, context); 178 179 179 if ( 0 != c1 && 0 ==c2) {180 if (c1 > c2) { 180 181 // Ltd: 181 182 td_ambig = null; 182 183 continue; 183 } else if ( 0 == c1 && 0 !=c2) {184 } else if (c1 < c2) { 184 185 // Ltd_best: 185 186 td_ambig = null; … … 239 240 int i; 240 241 int nfparams; 241 int nfparams2;242 242 int nfargs; 243 243 int nargsi; 244 int fptupindex = -1; 245 int tuple_dim = 0; 244 246 MATCH match = MATCHexact; 245 247 FuncDeclaration fd = onemember.toAlias(context).isFuncDeclaration(); … … 261 263 paramsym.parent = scope.parent; 262 264 Scope paramscope = scope.push(paramsym); 265 266 tp = isVariadic(); 263 267 264 268 nargsi = 0; … … 266 270 267 271 nargsi = targsi.size(); 268 if (nargsi > parameters.size()) 269 return Lnomatch(paramscope); // goto Lnomatch; 272 if (nargsi > parameters.size()) { 273 if (null == tp) { 274 return Lnomatch(paramscope); // goto Lnomatch; 275 } 276 dedargs.setDim(nargsi); 277 dedargs.zero(); 278 } 270 279 271 280 //memcpy(dedargs.data, targsi.data, nargsi * sizeof(dedargs.data)); … … 302 311 // function 303 312 // parameters 304 nfparams2 = nfparams;305 313 nfargs = fargs.size(); // number of function arguments 306 314 … … 324 332 throw GOTO_L1; 325 333 } else { 326 /* 327 * See if 'A' of the template parameter matches 'A' of the 328 * type of the last function parameter. 329 */ 330 Argument fparam = (Argument) fdtype.parameters 331 .get(nfparams - 1); 332 if (fparam.type.ty != Tident) { 333 throw GOTO_L1; 334 /* 335 * Figure out which of the function parameters matches 336 * the tuple template parameter. Do this by matching 337 * type identifiers. 338 * Set the index of this function parameter to fptupindex. 339 */ 340 for (fptupindex = 0; fptupindex < nfparams; fptupindex++) { 341 Argument fparam = (Argument) fdtype.parameters 342 .get(fptupindex); 343 if (fparam.type.ty != Tident) { 344 continue; 345 } 346 TypeIdentifier tid = (TypeIdentifier) fparam.type; 347 348 if (!equals(tp.ident, tid.ident) 349 || (tid.idents != null && tid.idents.size() > 0)) { 350 continue; 351 } 352 if (fdtype.varargs > 0) // variadic function doesn't 353 return Lnomatch(paramscope); // goto Lnomatch; // go 354 // with 355 // variadic template 356 357 /* 358 * The types of the function arguments 359 * now form the tuple argument. 360 */ 361 Tuple t = new Tuple(); 362 dedargs.set(parameters.size() - 1, t); 363 364 tuple_dim = nfargs - (nfparams - 1); 365 t.objects.setDim(tuple_dim); 366 for (i = 0; i < tuple_dim; i++) { 367 Expression farg = (Expression) fargs.get(fptupindex + 1); 368 t.objects.set(i, farg.type); 369 } 370 throw GOTO_L2; 334 371 } 335 TypeIdentifier tid = (TypeIdentifier) fparam.type; 336 337 if (!equals(tp.ident, tid.ident) 338 || (tid.idents != null && tid.idents.size() > 0)) { 339 throw GOTO_L1; 340 } 341 if (fdtype.varargs > 0) // variadic function doesn't 342 return Lnomatch(paramscope); // goto Lnomatch; // go 343 // with 344 // variadic template 345 346 /* 347 * The types of the function arguments [nfparams - 1 .. 348 * nfargs] now form the tuple argument. 349 */ 350 Tuple t = new Tuple(); 351 dedargs.set(parameters.size() - 1, t); 352 353 int tuple_dim = nfargs - (nfparams - 1); 354 t.objects.setDim(tuple_dim); 355 for (i = 0; i < tuple_dim; i++) { 356 Expression farg = (Expression) fargs.get(nfparams - 1 357 + i); 358 t.objects.set(i, farg.type); 359 } 360 nfparams2--; // don't consider the last parameter for 361 // type 362 // deduction 363 throw GOTO_L2; 372 fptupindex--; 364 373 } 365 374 } … … 383 392 // L2: 384 393 // Loop through the function parameters 385 for (i = 0; i < nfparams2; i++) { 394 for (i = 0; i < nfparams; i++) { 395 396 /* Skip over function parameters which wound up 397 * as part of a template tuple parameter. 398 */ 399 if (i == fptupindex) { 400 if (fptupindex == nfparams - 1) 401 break; 402 i += tuple_dim - 1; 403 continue; 404 } 405 386 406 Argument fparam = Argument.getNth(fdtype.parameters, i, context); 387 407 Expression farg; … … 756 776 } 757 777 758 for (TemplateParameter tp : parameters) { 778 for (int i = 0; i < parameters.size(); i++) { 779 TemplateParameter tp = parameters.get(i); 759 780 tp.semantic(paramscope, context); 781 782 if (i + 1 != parameters.size() && tp.isTemplateTupleParameter() != null) { 783 if (context.acceptsProblems()) { 784 context.acceptProblem(Problem.newSemanticTypeError(IProblem.TemplateTupleParameterMustBeLastOne, tp)); 785 } 786 } 760 787 } 761 788 … … 771 798 } 772 799 } 773 774 // Descent: do semantic of my members without reporting 775 // problems, in order to get code selection, code completion, 776 // code evaluation and bindings. 777 // context.muteProblems++; 778 // for(Dsymbol member : members) { 779 // member.semantic(scope, context); 780 // } 781 // context.muteProblems--; 782 } 783 } 784 785 // @Override 786 // public void semantic2(Scope sc, SemanticContext context) { 787 // // Descent: do semantic of my members without reporting 788 // // problems, in order to get code selection, code completion, 789 // // code evaluation and bindings. 790 // context.muteProblems++; 791 // for(Dsymbol member : members) { 792 // member.semantic2(scope, context); 793 // } 794 // context.muteProblems--; 795 // } 796 // 797 // @Override 798 // public void semantic3(Scope sc, SemanticContext context) { 799 // // Descent: do semantic of my members without reporting 800 // // problems, in order to get code selection, code completion, 801 // // code evaluation and bindings. 802 // context.muteProblems++; 803 // for(Dsymbol member : members) { 804 // member.semantic3(scope, context); 805 // } 806 // context.muteProblems--; 807 // } 800 } 801 } 808 802 809 803 @Override … … 894 888 } 895 889 890 /** 891 * We can overload templates. 892 */ 893 public boolean isOverloadable() { 894 return true; 895 } 896 896 897 public void setJavaElement(IJavaElement javaElement) { 897 898 this.javaElement = javaElement; trunk/descent.core/src/descent/internal/compiler/parser/TemplateInstance.java
r1154 r1155 8 8 import descent.internal.compiler.parser.ast.IASTVisitor; 9 9 10 import static descent.internal.compiler.parser.STC.*; 10 11 import static descent.internal.compiler.parser.MATCH.MATCHnomatch; 11 12 12 import static descent.internal.compiler.parser.TOK. TOKfunction;13 import static descent.internal.compiler.parser.TOK.*; 13 14 import static descent.internal.compiler.parser.TOK.TOKtuple; 14 15 import static descent.internal.compiler.parser.TOK.TOKvar; … … 121 122 122 123 dedtypes.setDim(size(td.parameters)); 124 dedtypes.zero(); 125 123 126 if (null == td.scope) { 124 127 if (context.acceptsProblems()) { … … 152 155 int c2 = td_best.leastAsSpecialized(td, context); 153 156 154 if (c1 != 0 && 0 ==c2) {157 if (c1 > c2) { 155 158 // goto Ltd; 156 159 td_ambig = null; … … 163 166 tdtypes.memcpy(dedtypes); 164 167 continue; 165 } else if ( 0 == c1 && c2 != 0) {168 } else if (c1 < c2) { 166 169 // goto Ltd_best; 167 170 td_ambig = null; … … 404 407 } 405 408 406 public booleanisNested(Objects args, SemanticContext context) {407 boolean nested = false;409 public int isNested(Objects args, SemanticContext context) { 410 int nested = 0; 408 411 409 412 /* A nested instance happens when an argument references a local … … 435 438 if (gotoLsa) { 436 439 Declaration d = sa.isDeclaration(); 437 if (null != d 440 441 boolean condition = null != d 438 442 && !d.isDataseg(context) 439 443 && (null == d.isFuncDeclaration() || d 440 444 .isFuncDeclaration().isNested()) 441 && null == isTemplateMixin()) { 445 && null == isTemplateMixin(); 446 if (context.apiLevel == Parser.D2) { 447 condition = condition && null != d && 0 == (d.storage_class & STCmanifest); 448 } 449 450 if (condition) { 442 451 // if module level template 443 452 if (null != tempdecl.toParent().isModule()) { 444 if (null != isnested && isnested != d.toParent()) { 453 Dsymbol dparent = d.toParent(); 454 if (null == isnested) 455 isnested = dparent; 456 else if (isnested != dparent) { 457 boolean gotoL1 = false; 458 459 /* Select the more deeply nested of the two. 460 * Error if one is not nested inside the other. 461 */ 462 for (Dsymbol p = isnested; p != null; p = p.parent) { 463 if (p == dparent) { 464 // goto L1; // isnested is most nested 465 gotoL1 = true; 466 break; 467 } 468 } 469 470 if (!gotoL1) { 471 for (Dsymbol p = dparent; true; p = p.parent) { 472 if (p == isnested) { 473 isnested = dparent; 474 // goto L1; // dparent is most nested 475 break; 476 } 477 } 478 } 445 479 if (context.acceptsProblems()) { 446 context.acceptProblem(Problem.newSemanticTypeError( 447 IProblem.InconsistentNestingLevels, this, new String[] { isnested.toChars(context), d.toParent().toChars(context) })); 480 context.acceptProblem(Problem.newSemanticTypeErrorLoc( 481 IProblem.SymbolIsNestedInBoth, 482 this, 483 new String[] { 484 this.toChars(context), 485 isnested.toChars(context), 486 dparent.toChars(context) })); 448 487 } 449 488 } 450 isnested = d.toParent();451 nested = true;489 // L1: 490 nested |= 1; 452 491 } else { 453 492 if (context.acceptsProblems()) { 454 context.acceptProblem(Problem.newSemanticTypeError( 455 IProblem.CannotUseLocalAsTemplateParameter, this, new String[] { d.toChars(context) })); 493 context 494 .acceptProblem(Problem 495 .newSemanticTypeError( 496 IProblem.CannotUseLocalAsTemplateParameter, 497 this, 498 new String[] { d 499 .toChars(context) })); 456 500 } 457 501 } … … 929 973 ea[0] = ea[0].optimize(WANTvalue | WANTinterpret, context); 930 974 tiargs.set(j, ea[0]); 975 if (ea[0].op == TOKtype) { 976 tiargs.set(j, ea[0].type); 977 } 931 978 } else if (sa[0] != null) { 932 979 } else { trunk/descent.core/src/descent/internal/compiler/parser/TemplateMixin.java
r1154 r1155 268 268 argsym.parent = scy.parent; 269 269 Scope scope = scy.push(argsym); 270 271 int errorsave = context.global.errors; 270 272 271 273 // Declare each template parameter as an alias for the argument type … … 303 305
