summary refs log tree commit diff stats
path: root/rod
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andreas-desktop>2010-06-04 00:45:46 +0200
committerAndreas Rumpf <andreas@andreas-desktop>2010-06-04 00:45:46 +0200
commitc441cdb64ca5394f74faadf76563bcfafeda18f4 (patch)
treea044b0464fe8066e362b028df67660b3e6c21c5b /rod
parent909f7dbf8cac95d4cdb08c4a2e1cb4ba2d42bfeb (diff)
downloadNim-c441cdb64ca5394f74faadf76563bcfafeda18f4.tar.gz
bugfix: exception handling (still not correct)
Diffstat (limited to 'rod')
-rwxr-xr-xrod/ccgstmts.nim34
-rwxr-xr-xrod/options.nim2
2 files changed, 18 insertions, 18 deletions
diff --git a/rod/ccgstmts.nim b/rod/ccgstmts.nim
index 3cf2123c9..f011f32a0 100755
--- a/rod/ccgstmts.nim
+++ b/rod/ccgstmts.nim
@@ -268,17 +268,13 @@ proc getRaiseFrmt(p: BProc): string =
     result = "raiseException((E_Base*)$1, $2);$n"
 
 proc genRaiseStmt(p: BProc, t: PNode) = 
-  var 
-    e: PRope
-    a: TLoc
-    typ: PType
   genLineDir(p, t)
   if t.sons[0] != nil: 
     if gCmd != cmdCompileToCpp: useMagic(p.module, "raiseException")
+    var a: TLoc
     InitLocExpr(p, t.sons[0], a)
-    e = rdLoc(a)
-    typ = t.sons[0].typ
-    while typ.kind in {tyVar, tyRef, tyPtr}: typ = typ.sons[0]
+    var e = rdLoc(a)
+    var typ = skipTypes(t.sons[0].typ, abstractPtrs)
     appf(p.s[cpsStmts], getRaiseFrmt(p), [e, makeCString(typ.sym.name.s)])
   else: 
     # reraise the last exception:
@@ -385,7 +381,8 @@ proc genStringCase(p: BProc, t: PNode) =
     strings, bitMask, labId: int
     a: TLoc
     branches: TRopeSeq
-  useMagic(p.module, "eqStrings") # count how many constant strings there are in the case:
+  useMagic(p.module, "eqStrings") 
+  # count how many constant strings there are in the case:
   strings = 0
   for i in countup(1, sonsLen(t) - 1): 
     if t.sons[i].kind == nkOfBranch: inc(strings, sonsLen(t.sons[i]) - 1)
@@ -411,7 +408,8 @@ proc genStringCase(p: BProc, t: PNode) =
              [intLiteral(j), branches[j]])
     app(p.s[cpsStmts], '}' & tnl) # else statement:
     if t.sons[sonsLen(t) - 1].kind != nkOfBranch: 
-      appf(p.s[cpsStmts], "goto LA$1;$n", [toRope(p.labels)]) # third pass: generate statements
+      appf(p.s[cpsStmts], "goto LA$1;$n", [toRope(p.labels)]) 
+    # third pass: generate statements
     genCaseSecondPass(p, t, labId)
   else: 
     genCaseGeneric(p, t, "", "if (eqStrings($1, $2)) goto $3;$n")
@@ -420,7 +418,7 @@ proc branchHasTooBigRange(b: PNode): bool =
   for i in countup(0, sonsLen(b) - 2): 
     # last son is block
     if (b.sons[i].Kind == nkRange) and
-        (b.sons[i].sons[1].intVal - b.sons[i].sons[0].intVal > RangeExpandLimit): 
+        b.sons[i].sons[1].intVal - b.sons[i].sons[0].intVal > RangeExpandLimit: 
       return true
   result = false
 
@@ -481,8 +479,10 @@ proc genCaseStmt(p: BProc, t: PNode) =
     genStringCase(p, t)
   of tyFloat..tyFloat128: 
     genCaseGeneric(p, t, "if ($1 >= $2 && $1 <= $3) goto $4;$n", 
-                   "if ($1 == $2) goto $3;$n") # ordinal type: generate a switch statement
-  else: genOrdinalCase(p, t)
+                   "if ($1 == $2) goto $3;$n") 
+  else: 
+    # ordinal type: generate a switch statement
+    genOrdinalCase(p, t)
   
 proc hasGeneralExceptSection(t: PNode): bool = 
   var length, i, blen: int
@@ -561,8 +561,8 @@ proc genTryStmtCpp(p: BProc, t: PNode) =
   app(p.s[cpsStmts], "excHandler = excHandler->prev;" & tnl)
   if (i < length) and (t.sons[i].kind == nkFinally): 
     genStmts(p, t.sons[i].sons[0])
-    if rethrowFlag != nil: 
-      appf(p.s[cpsStmts], "if ($1) { throw; }$n", [rethrowFlag])
+  if rethrowFlag != nil: 
+    appf(p.s[cpsStmts], "if ($1) { throw; }$n", [rethrowFlag])
   
 proc genTryStmt(p: BProc, t: PNode) = 
   # code to generate:
@@ -630,9 +630,9 @@ proc genTryStmt(p: BProc, t: PNode) =
   dec(p.nestedTryStmts)
   if (i < length) and (t.sons[i].kind == nkFinally): 
     genStmts(p, t.sons[i].sons[0])
-    useMagic(p.module, "raiseException")
-    appf(p.s[cpsStmts], "if ($1.status != 0) { " &
-        "raiseException($1.exc, $1.exc->name); }$n", [safePoint])
+  useMagic(p.module, "raiseException")
+  appf(p.s[cpsStmts], "if ($1.status != 0) { " &
+      "raiseException($1.exc, $1.exc->name); }$n", [safePoint])
 
 var 
   breakPointId: int = 0
diff --git a/rod/options.nim b/rod/options.nim
index 9ce54a41c..28b58f40a 100755
--- a/rod/options.nim
+++ b/rod/options.nim
@@ -11,7 +11,7 @@ import
   os, lists, strutils, nstrtabs
   
 const
-  hasTinyCBackend* = true
+  hasTinyCBackend* = false
 
 type                          # please make sure we have under 32 options
                               # (improves code efficiency a lot!)