summary refs log tree commit diff stats
path: root/nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2009-05-14 01:46:41 +0200
committerAndreas Rumpf <rumpf_a@web.de>2009-05-14 01:46:41 +0200
commit0e9d65e4abf949b00cd00546cb772de4e49f8369 (patch)
tree9d733047878867d469f34b2da41315dc645f09cb /nim
parent233687adf7613305664d9e02c5f37e898f7ba255 (diff)
downloadNim-0e9d65e4abf949b00cd00546cb772de4e49f8369.tar.gz
some bugfixes
Diffstat (limited to 'nim')
-rw-r--r--nim/ccgtypes.pas15
-rw-r--r--nim/cgen.pas8
2 files changed, 18 insertions, 5 deletions
diff --git a/nim/ccgtypes.pas b/nim/ccgtypes.pas
index ee7388e1c..600065078 100644
--- a/nim/ccgtypes.pas
+++ b/nim/ccgtypes.pas
@@ -148,6 +148,12 @@ begin
   end
 end;
 
+function mapReturnType(typ: PType): TCTypeKind;
+begin
+  if skipGeneric(typ).kind = tyArray then result := ctPtr
+  else result := mapType(typ)
+end;
+
 function getTypeDescAux(m: BModule; typ: PType;
                         var check: TIntSet): PRope; forward;
 
@@ -232,7 +238,8 @@ procedure fillResult(param: PSym);
 begin
   fillLoc(param.loc, locParam, param.typ, ropeff('Result', '%Result', []), 
           OnStack);
-  if (mapType(param.typ) <> ctArray) and IsInvalidReturnType(param.typ) then
+  if (mapReturnType(param.typ) <> ctArray) 
+  and IsInvalidReturnType(param.typ) then
   begin
     include(param.loc.flags, lfIndirect);
     param.loc.s := OnUnknown
@@ -277,8 +284,10 @@ begin
   end;
   if (t.sons[0] <> nil) and isInvalidReturnType(t.sons[0]) then begin
     if params <> nil then app(params, ', ');
-    app(params, getTypeDescAux(m, t.sons[0], check));
-    if (mapType(t.sons[0]) <> ctArray) or (gCmd = cmdCompileToLLVM) then 
+    arr := t.sons[0];
+    //if skipGeneric(arr).kind = tyArray then arr := arr.sons[1];
+    app(params, getTypeDescAux(m, arr, check));
+    if (mapReturnType(t.sons[0]) <> ctArray) or (gCmd = cmdCompileToLLVM) then 
       app(params, '*'+'');
     appff(params, ' Result', ' @Result', []);
   end;
diff --git a/nim/cgen.pas b/nim/cgen.pas
index ed12d3d8e..6a0ab0390 100644
--- a/nim/cgen.pas
+++ b/nim/cgen.pas
@@ -249,12 +249,12 @@ procedure UseMagic(m: BModule; const name: string); forward;
 {$include 'ccgtypes.pas'}
 
 // ------------------------------ Manager of temporaries ------------------
-
+(*
 function beEqualTypes(a, b: PType): bool;
 begin
   // returns whether two type are equal for the backend
   result := sameType(skipGenericRange(a), skipGenericRange(b))
-end;
+end; *)
 
 procedure getTemp(p: BProc; t: PType; var result: TLoc);
 begin
@@ -642,6 +642,10 @@ begin
     else begin
       fillResult(res);
       assignParam(p, res);
+      if skipGeneric(res.typ).kind = tyArray then begin
+        include(res.loc.flags, lfIndirect);
+        res.loc.s := OnUnknown;
+      end;
     end;
     initVariable(p, res);
     genObjectInit(p, res.typ, res.loc, true);