summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-03-03 16:35:19 +0100
committerAraq <rumpf_a@web.de>2013-03-03 16:35:19 +0100
commit4b0cdc6db75ca9ef8499bbadbff2892b950773dd (patch)
treedd04f62fbc7ac5bc7f0af6e907efea0999529428
parent5b0d8246f79730a473a869792f12938089ecced6 (diff)
downloadNim-4b0cdc6db75ca9ef8499bbadbff2892b950773dd.tar.gz
fixes for the new overloading resolution
-rwxr-xr-xcompiler/ccgexprs.nim3
-rwxr-xr-xcompiler/ccgutils.nim5
-rwxr-xr-xcompiler/semexprs.nim12
-rwxr-xr-xcompiler/semgnrc.nim15
4 files changed, 14 insertions, 21 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 6b1a4b15d..5e5d22fb2 100755
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1526,8 +1526,9 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
   of mNewFinalize: genNewFinalize(p, e)
   of mNewSeq: genNewSeq(p, e)
   of mSizeOf:
+    let t = e.sons[1].typ.skipTypes({tyTypeDesc})
     putIntoDest(p, d, e.typ, ropef("((NI)sizeof($1))",
-                                   [getTypeDesc(p.module, e.sons[1].typ)]))
+                                   [getTypeDesc(p.module, t)]))
   of mChr: genCast(p, e, d)
   of mOrd: genOrd(p, e, d)
   of mLengthArray, mHigh, mLengthStr, mLengthSeq, mLengthOpenArray:
diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim
index 7e5c62daa..3dcec7d42 100755
--- a/compiler/ccgutils.nim
+++ b/compiler/ccgutils.nim
@@ -86,10 +86,9 @@ proc GetUniqueType*(key: PType): PType =
     if result == nil:
       gCanonicalTypes[k] = key
       result = key
-  of tyGenericParam, tyTypeClass:
+  of tyGenericParam, tyTypeClass, tyTypeDesc:
     InternalError("GetUniqueType")
-  of tyGenericInst, tyDistinct, tyOrdinal, tyMutable, tyConst, tyIter, 
-      tyTypeDesc:
+  of tyGenericInst, tyDistinct, tyOrdinal, tyMutable, tyConst, tyIter:
     result = GetUniqueType(lastSon(key))
   of tyArrayConstr, tyGenericInvokation, tyGenericBody,
      tyOpenArray, tyArray, tySet, tyRange, tyTuple,
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 98cc2fa45..fe2a3f811 100755
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -10,18 +10,6 @@
 # this module does the semantic checking for expressions
 # included from sem.nim
 
-proc restoreOldStyleType(n: PNode) =
-  # semExprWithType used to return the same type
-  # for nodes such as (100) or (int). 
-  # This is inappropriate. The type of the first expression
-  # should be "int", while the type of the second one should 
-  # be typedesc(int).
-  #
-  # This is strictly for backward compatibility until 
-  # the transition to types as first-class values is complete.
-  if n.typ.kind == tyTypeDesc and n.typ.sonsLen == 1:
-    n.typ = n.typ.sons[0]
-
 proc semTemplateExpr(c: PContext, n: PNode, s: PSym, semCheck = true): PNode = 
   markUsed(n, s)
   pushInfoContext(n.info)
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index 4eaa5f39b..2e1eccda2 100755
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -30,6 +30,11 @@ proc getIdentNode(n: PNode): PNode =
   else:
     illFormedAst(n)
     result = n
+  
+proc newSymNodeTypeDesc(s: PSym; info: TLineInfo): PNode =
+  result = newSymNode(s, info)
+  result.typ = newType(tyTypeDesc, s.owner)
+  result.typ.addSonSkipIntLit(s.typ)
 
 proc semGenericStmt(c: PContext, n: PNode, flags: TSemGenericFlags,
                     ctx: var TIntSet): PNode
@@ -63,12 +68,12 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym): PNode =
     else:
       result = symChoice(c, n, s, scOpen)
   of skGenericParam: 
-    result = newSymNode(s, n.info)
+    result = newSymNodeTypeDesc(s, n.info)
   of skParam: 
     result = n
   of skType: 
     if (s.typ != nil) and (s.typ.kind != tyGenericParam): 
-      result = newSymNode(s, n.info)
+      result = newSymNodeTypeDesc(s, n.info)
     else: 
       result = n
   else: result = newSymNode(s, n.info)
@@ -156,13 +161,13 @@ proc semGenericStmt(c: PContext, n: PNode,
       of skProc, skMethod, skIterator, skConverter: 
         result.sons[0] = symChoice(c, n.sons[0], s, scOption)
         first = 1
-      of skGenericParam: 
-        result.sons[0] = newSymNode(s, n.sons[0].info)
+      of skGenericParam:
+        result.sons[0] = newSymNodeTypeDesc(s, n.sons[0].info)
         first = 1
       of skType: 
         # bad hack for generics:
         if (s.typ != nil) and (s.typ.kind != tyGenericParam): 
-          result.sons[0] = newSymNode(s, n.sons[0].info)
+          result.sons[0] = newSymNodeTypeDesc(s, n.sons[0].info)
           first = 1
       else:
         result.sons[0] = newSymNode(s, n.sons[0].info)