Created
November 23, 2013 21:52
-
-
Save BitPuffin/7620412 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| proc SearchForProc*(c: PContext, scope: PScope, fn: PSym): PSym = | |
| # Searchs for a forward declaration or a "twin" symbol of fn | |
| # in the symbol table. If the parameter lists are exactly | |
| # the same the sym in the symbol table is returned, else nil. | |
| var it: TIdentIter | |
| result = initIdentIter(it, scope.symbols, fn.Name) | |
| if isGenericRoutine(fn): | |
| # we simply check the AST; this is imprecise but nearly the best what | |
| # can be done; this doesn't work either though as type constraints are | |
| # not kept in the AST .. | |
| while result != nil: | |
| if result.Kind == fn.kind and isGenericRoutine(result): | |
| let genR = result.ast.sons[genericParamsPos] | |
| let genF = fn.ast.sons[genericParamsPos] | |
| if ExprStructuralEquivalent(genR, genF) and | |
| ExprStructuralEquivalent(result.ast.sons[paramsPos], | |
| fn.ast.sons[paramsPos]) and | |
| equalGenericParams(genR, genF): | |
| if fn.info ?? "poop.nim": | |
| debug result.ast.sons[paramsPos] | |
| debug fn.ast.sons[paramsPos] | |
| return | |
| result = NextIdentIter(it, scope.symbols) | |
| else: | |
| if fn.info ?? "poop.nim": echo "WTFinF!?" | |
| while result != nil: | |
| if result.Kind == fn.kind and not isGenericRoutine(result): | |
| case equalParams(result.typ.n, fn.typ.n) | |
| of paramsEqual: | |
| return | |
| of paramsIncompatible: | |
| LocalError(fn.info, errNotOverloadable, fn.name.s) | |
| return | |
| of paramsNotEqual: | |
| nil | |
| result = NextIdentIter(it, scope.symbols) | |
| ./bin/nimrod c --verbosity:3 poop.nim | |
| config/nimrod.cfg(36, 2) Hint: added path: '/home/isak/.babel/pkgs/jester-0.1.0' [Path] | |
| config/nimrod.cfg(36, 2) Hint: added path: '/home/isak/.babel/pkgs/' [Path] | |
| Hint: used config file '/home/isak/src/nim/Nimrod/config/nimrod.cfg' [Conf] | |
| Hint: system [Processing] | |
| lib/system.nim(1, 0) Hint: 2 [Processing] | |
| lib/system.nim(10, 0) Hint: 2 [Processing] | |
| lib/system.nim(17, 0) Hint: 2 [Processing] | |
| lib/system.nim(33, 0) Hint: 2 [Processing] | |
| lib/system.nim(35, 0) Hint: 2 [Processing] | |
| lib/system.nim(39, 0) Hint: 2 [Processing] | |
| lib/system.nim(46, 0) Hint: 2 [Processing] | |
| lib/system.nim(50, 0) Hint: 2 [Processing] | |
| lib/system.nim(2342, 0) Hint: 99 [Processing] | |
| lib/system.nim(2346, 0) Hint: 99 [Processing] | |
| lib/system.nim(2349, 0) Hint: 99 [Processing] | |
| lib/system.nim(2365, 0) Hint: 99 [Processing] | |
| lib/system.nim(2386, 0) Hint: 117 [Processing] | |
| lib/system.nim(2393, 0) Hint: 117 [Processing] | |
| lib/system.nim(2402, 0) Hint: 117 [Processing] | |
| lib/system.nim(2412, 0) Hint: 117 [Processing] | |
| lib/system.nim(2424, 0) Hint: 117 [Processing] | |
| lib/system.nim(2431, 0) Hint: 117 [Processing] | |
| lib/system.nim(2442, 0) Hint: 117 [Processing] | |
| lib/system.nim(2445, 0) Hint: 117 [Processing] | |
| lib/system.nim(2453, 0) Hint: 117 [Processing] | |
| lib/system.nim(2457, 0) Hint: 117 [Processing] | |
| lib/system.nim(2471, 0) Hint: 117 [Processing] | |
| lib/system.nim(2474, 0) Hint: 117 [Processing] | |
| lib/system.nim(2477, 0) Hint: 117 [Processing] | |
| lib/system.nim(2481, 0) Hint: 117 [Processing] | |
| lib/system.nim(2485, 0) Hint: 117 [Processing] | |
| lib/system.nim(2489, 0) Hint: 117 [Processing] | |
| lib/system.nim(2493, 0) Hint: 117 [Processing] | |
| lib/system.nim(2497, 0) Hint: 117 [Processing] | |
| lib/system.nim(2499, 0) Hint: 117 [Processing] | |
| lib/system.nim(2502, 0) Hint: 117 [Processing] | |
| lib/system.nim(2506, 0) Hint: 117 [Processing] | |
| lib/system.nim(2537, 0) Hint: 117 [Processing] | |
| lib/system.nim(2540, 0) Hint: 117 [Processing] | |
| lib/system.nim(2543, 0) Hint: 118 [Processing] | |
| lib/system.nim(2551, 0) Hint: 118 [Processing] | |
| lib/system.nim(2563, 0) Hint: 118 [Processing] | |
| lib/system.nim(2571, 0) Hint: 118 [Processing] | |
| lib/system.nim(2574, 0) Hint: 118 [Processing] | |
| lib/system.nim(2597, 0) Hint: 118 [Processing] | |
| lib/system.nim(2605, 0) Hint: 118 [Processing] | |
| lib/system.nim(2613, 0) Hint: 118 [Processing] | |
| lib/system.nim(2618, 0) Hint: 118 [Processing] | |
| lib/system.nim(2625, 0) Hint: 118 [Processing] | |
| lib/system.nim(2639, 0) Hint: 122 [Processing] | |
| lib/system.nim(2649, 0) Hint: 122 [Processing] | |
| lib/system.nim(2652, 0) Hint: 122 [Processing] | |
| lib/system.nim(2666, 0) Hint: 122 [Processing] | |
| Hint: poop [Processing] | |
| poop.nim(1, 0) Hint: 124 [Processing] | |
| poop.nim(3, 0) Hint: 124 [Processing] | |
| poop.nim(5, 0) Hint: 124 [Processing] | |
| { | |
| "kind": "nkFormalParams", | |
| "sons": [ | |
| { | |
| "kind": "nkEmpty", | |
| "info": ["???", -1, -1] | |
| }, | |
| { | |
| "kind": "nkIdentDefs", | |
| "sons": [ | |
| { | |
| "kind": "nkIdent", | |
| "ident": "p", | |
| "info": ["poop.nim", 3, 12] | |
| }, | |
| { | |
| "kind": "nkBracketExpr", | |
| "sons": [ | |
| { | |
| "kind": "nkSym", | |
| "sym": TType_77002, | |
| "info": ["poop.nim", 3, 15] | |
| }, | |
| { | |
| "kind": "nkSym", | |
| "sym": T_77014, | |
| "info": ["poop.nim", 3, 21] | |
| }, | |
| { | |
| "kind": "nkSym", | |
| "sym": AnonType_77020, | |
| "info": ["poop.nim", 3, 29] | |
| } | |
| ], | |
| "info": ["poop.nim", 3, 20] | |
| }, | |
| { | |
| "kind": "nkEmpty", | |
| "info": ["???", -1, -1] | |
| } | |
| ], | |
| "info": ["poop.nim", 3, 12] | |
| } | |
| ], | |
| "info": ["poop.nim", 3, 11] | |
| } | |
| { | |
| "kind": "nkFormalParams", | |
| "sons": [ | |
| { | |
| "kind": "nkEmpty", | |
| "info": ["???", -1, -1] | |
| }, | |
| { | |
| "kind": "nkIdentDefs", | |
| "sons": [ | |
| { | |
| "kind": "nkIdent", | |
| "ident": "p", | |
| "info": ["poop.nim", 5, 12] | |
| }, | |
| { | |
| "kind": "nkBracketExpr", | |
| "sons": [ | |
| { | |
| "kind": "nkSym", | |
| "sym": TType_77002, | |
| "info": ["poop.nim", 5, 15] | |
| }, | |
| { | |
| "kind": "nkSym", | |
| "sym": T_77026, | |
| "info": ["poop.nim", 5, 21] | |
| }, | |
| { | |
| "kind": "nkSym", | |
| "sym": AnonType_77032, | |
| "info": ["poop.nim", 5, 29] | |
| } | |
| ], | |
| "info": ["poop.nim", 5, 20] | |
| }, | |
| { | |
| "kind": "nkEmpty", | |
| "info": ["???", -1, -1] | |
| } | |
| ], | |
| "info": ["poop.nim", 5, 12] | |
| } | |
| ], | |
| "info": ["poop.nim", 5, 11] | |
| } | |
| poop.nim(5, 0) Error: redefinition of 'foo' | |
| proc foo[T](p: TType[T, range[0..2]]) = | |
| ^ | |
| Traceback (most recent call last) | |
| nimrod.nim(79) nimrod | |
| nimrod.nim(55) HandleCmdLine | |
| main.nim(308) MainCommand | |
| main.nim(73) CommandCompileToC | |
| modules.nim(193) CompileProject | |
| modules.nim(151) compileModule | |
| passes.nim(192) processModule | |
| passes.nim(136) processTopLevelStmt | |
| sem.nim(312) myProcess | |
| sem.nim(286) SemStmtAndGenerateGenerics | |
| semstmts.nim(1263) semStmt | |
| semexprs.nim(826) semExprNoType | |
| semexprs.nim(2007) semExpr | |
| semstmts.nim(1099) semProc | |
| semstmts.nim(1016) semProcAux | |
| lookups.nim(134) WrongRedefinition | |
| msgs.nim(803) LocalError | |
| msgs.nim(791) liMessage | |
| msgs.nim(704) handleError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment