Update to new icg constructor etc.

git-svn-id: svn://10.0.0.236/trunk@70954 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rogerl%netscape.com
2000-05-26 22:34:42 +00:00
parent 25a30b6f74
commit 29c270e28b
2 changed files with 12 additions and 18 deletions

View File

@@ -107,10 +107,7 @@ static void genCode(World &world, Context &cx, StmtNode *p)
ret = icg.genStmt(p);
p = p->next;
}
if (ret != NotARegister)
icg.addInstruction(new Return(ret));
else
icg.addInstruction(new ReturnVoid());
icg.returnStmt(ret);
stdOut << '\n';
stdOut << icg;
JSValue result = cx.interpret(icg.complete(), JSValues());
@@ -218,7 +215,7 @@ static float64 testFactorial(World &world, float64 n)
Context cx(world, &glob);
// generate code for factorial, and interpret it.
uint32 pos = 0;
ICodeGenerator icg;
ICodeGenerator icg(&world);
// fact(n) {
// var result = 1;
@@ -226,7 +223,7 @@ static float64 testFactorial(World &world, float64 n)
StringAtom &n_name = world.identifiers[widenCString("n")];
StringAtom &result_name = world.identifiers[widenCString("result")];
Register r_n = icg.allocateVariable(n_name);
Register r_n = icg.allocateParameter(n_name);
Register r_result = icg.allocateVariable(result_name);
Arena a;
@@ -264,7 +261,7 @@ static float64 testFactorial(World &world, float64 n)
}
// return result;
icg.addInstruction(new Return(r_result));
icg.returnStmt(r_result);
ICodeModule *icm = icg.complete();
stdOut << icg;
@@ -274,10 +271,10 @@ static float64 testFactorial(World &world, float64 n)
// now a script :
// return fact(n);
ICodeGenerator script;
ICodeGenerator script(&world);
RegisterList args(1);
args[0] = script.loadImmediate(n);
script.addInstruction(new Return(script.call(script.loadName(fact), args)));
script.returnStmt(script.call(script.loadName(fact), args));
stdOut << script;
// install a listener so we can trace execution of factorial.