some fixes for DMC

This commit is contained in:
Andreas Rumpf
2009-05-20 10:44:24 +02:00
parent 44a874e3a4
commit ce88dc3e67
15 changed files with 2413 additions and 2000 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2243,8 +2243,8 @@ begin
end
end;
// ---------------------- generation of complex constants -----------------
// ---------------------- generation of complex constants ---------------------
(*
function transformRecordExpr(n: PNode): PNode;
var
i: int;
@@ -2263,10 +2263,20 @@ begin
field := lookupInRecord(t.n, field.name);
if field = nil then
InternalError(n.sons[i].info, 'transformRecordExpr: unknown field');
if result.sons[field.position] <> nil then
InternalError(n.sons[i].info, 'transformRecordExpr: value twice');
if result.sons[field.position] <> nil then begin
InternalError(n.sons[i].info, 'transformRecordExpr: value twice: ' +
renderTree(n.sons[i]));
end;
result.sons[field.position] := copyTree(n.sons[i].sons[1]);
end;
end; *)
function genNamedConstExpr(p: BProc; n: PNode): PRope;
begin
if n.kind = nkExprColonExpr then
result := genConstExpr(p, n.sons[1])
else
result := genConstExpr(p, n);
end;
function genConstSimpleList(p: BProc; n: PNode): PRope;
@@ -2276,8 +2286,8 @@ begin
len := sonsLen(n);
result := toRope('{'+'');
for i := 0 to len - 2 do
appf(result, '$1,$n', [genConstExpr(p, n.sons[i])]);
if len > 0 then app(result, genConstExpr(p, n.sons[len-1]));
appf(result, '$1,$n', [genNamedConstExpr(p, n.sons[i])]);
if len > 0 then app(result, genNamedConstExpr(p, n.sons[len-1]));
app(result, '}' + tnl)
end;
@@ -2293,16 +2303,9 @@ begin
toBitSet(n, cs);
result := genRawSetData(cs, int(getSize(n.typ)))
end;
nkBracket: begin
nkBracket, nkPar: begin
// XXX: tySequence!
result := genConstSimpleList(p, n);
end;
nkPar: begin
if hasSonWith(n, nkExprColonExpr) then
trans := transformRecordExpr(n)
else
trans := n;
result := genConstSimpleList(p, trans);
end
else begin
// result := genLiteral(p, n)

View File

@@ -277,6 +277,7 @@ var
i: int;
sym: PSym;
r, s: PRope;
a: TLoc;
begin
genLineDir(p, t);
assert(t.kind = nkAsmStmt);
@@ -286,13 +287,19 @@ begin
nkStrLit..nkTripleStrLit: app(s, t.sons[i].strVal);
nkSym: begin
sym := t.sons[i].sym;
r := sym.loc.r;
if r = nil then begin // if no name has already been given,
// it doesn't matter much:
r := mangleName(sym);
sym.loc.r := r; // but be consequent!
end;
app(s, r)
if sym.kind = skProc then begin
initLocExpr(p, t.sons[i], a);
app(s, rdLoc(a));
end
else begin
r := sym.loc.r;
if r = nil then begin // if no name has already been given,
// it doesn't matter much:
r := mangleName(sym);
sym.loc.r := r; // but be consequent!
end;
app(s, r)
end
end
else
InternalError(t.sons[i].info, 'genAsmStmt()')

View File

@@ -612,11 +612,14 @@ begin
IdTablePut(m.typeCache, t, con(result, '*'+''));
if not isImportedType(t) then begin
useMagic(m, 'TGenericSeq');
appf(m.s[cfsSeqTypes],
'struct $2 {$n' +
' TGenericSeq Sup;$n' +
' $1 data[SEQ_DECL_SIZE];$n' +
'};$n', [getTypeDescAux(m, t.sons[0], check), result]);
if skipGeneric(t.sons[0]).kind <> tyEmpty then
appf(m.s[cfsSeqTypes],
'struct $2 {$n' +
' TGenericSeq Sup;$n' +
' $1 data[SEQ_DECL_SIZE];$n' +
'};$n', [getTypeDescAux(m, t.sons[0], check), result])
else
result := toRope('TGenericSeq')
end;
app(result, '*'+'');
end;
@@ -1018,6 +1021,7 @@ begin
end;
if dataGenerated then exit;
case t.kind of
tyEmpty: result := toRope('0'+'');
tyPointer, tyProc, tyBool, tyChar, tyCString, tyString,
tyInt..tyFloat128, tyVar:
genTypeInfoAuxBase(gmti, t, result, toRope('0'+''));

File diff suppressed because it is too large Load Diff

View File

@@ -540,32 +540,35 @@ begin
case skipRange(n.typ).kind of
tyInt..tyInt64: begin
case skipRange(a.typ).kind of
tyFloat..tyFloat64: begin
tyFloat..tyFloat64:
result := newIntNodeT(nsystem.toInt(getFloat(a)), n);
exit
end;
tyChar: begin
tyChar:
result := newIntNodeT(getOrdValue(a), n);
exit
end;
else begin end
else begin
result := a;
result.typ := n.typ;
end
end
end;
tyFloat..tyFloat64: begin
case skipRange(a.typ).kind of
tyInt..tyInt64, tyEnum, tyBool, tyChar: begin
tyInt..tyInt64, tyEnum, tyBool, tyChar:
result := newFloatNodeT(toFloat(int(getOrdValue(a))), n);
exit
else begin
result := a;
result.typ := n.typ;
end
else begin end
end
end;
tyOpenArray: exit;
else begin end
end;
result := a;
result.typ := n.typ
end;
tyOpenArray, tyProc: begin end;
else begin
//n.sons[1] := a;
//result := n;
result := a;
result.typ := n.typ;
end
end
end
else begin
end
end

View File

@@ -1,7 +1,7 @@
//
//
// The Nimrod Compiler
// (c) Copyright 2008 Andreas Rumpf
// (c) Copyright 2009 Andreas Rumpf
//
// See the file "copying.txt", included in this
// distribution, for details about the copyright.

View File

@@ -440,7 +440,10 @@ begin
addSon(result, n.sons[1]);
end
else result := n.sons[1];
end;
end; (*
tyArray, tySeq: begin
if skipGeneric(dest
end; *)
tyGenericParam, tyAnyEnum: result := n.sons[1];
// happens sometimes for generated assignments, etc.
else begin end
@@ -450,8 +453,7 @@ end;
function skipPassAsOpenArray(n: PNode): PNode;
begin
result := n;
while result.kind = nkPassAsOpenArray do
result := result.sons[0]
while result.kind = nkPassAsOpenArray do result := result.sons[0]
end;
type
@@ -855,7 +857,7 @@ begin
end
end;
cnst := getConstExpr(c.module, result);
if cnst <> nil then result := cnst; // do not miss an optimization
if cnst <> nil then result := cnst; // do not miss an optimization
end;
function processTransf(context: PPassContext; n: PNode): PNode;