Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/trifork/erjang
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Burd committed Dec 15, 2011
2 parents 186b7b6 + 6ab2ac7 commit e7c5cc1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/java/erjang/beam/interpreter/Interpreter.template
Expand Up @@ -199,9 +199,11 @@ public class Interpreter extends AbstractInterpreter {
int argCnt = args.length;
EObject[] reg = getRegs(proc); //??
for (int i=0; i<argCnt; i++) {reg[i] = args[i];} //??
/*
if (log.isLoggable(Level.FINER)) {
for (int i=0; i<argCnt; i++) log.finer("INT| arg#"+i+"="+args[i]);
}
*/
return interpret(proc, start_pc, reg);
}

Expand All @@ -212,16 +214,18 @@ public class Interpreter extends AbstractInterpreter {
} else {
int argCnt = len;
for (int i=0; i<argCnt; i++) {reg[i] = args[i];} //??
/*
if (log.isLoggable(Level.FINER)) {
for (int i=0; i<argCnt; i++) log.finer("INT| arg#"+i+"="+args[i]);
}
*/
return interpret(proc, start_pc, reg);
}
}

/** Local call - with given PC and register array */
public EObject invoke_local(final EProc proc, final EObject[] reg, int argCnt, int pc) throws Pausable {
log.fine("INT| invoking "+name+"@"+pc+"...");
//log.fine("INT| invoking "+name+"@"+pc+"...");
return interpret(proc, pc, reg);
}

Expand Down Expand Up @@ -250,14 +254,16 @@ public class Interpreter extends AbstractInterpreter {
}
last_pc = pc;
final int opcode = code[pc++];
/*
if (log.isLoggable(Level.FINEST)) {
log.finest("STACK| "); for (int i=0; i<=sp; i++) {log.finest(" "+i+":"+stack[i]);} log.finest("");
}
log.finer("INTP|"+proc.self_handle()+" (pc="+(pc-1)+"; sp="+sp+")"+opcode+" "+reg[0]);
*/
switch (opcode) {
case ENSURE_REG_CAPACITY: {
int max_x = code[pc++];
log.finer("INTP|"+proc.self_handle()+" Ensure reg capacity: "+max_x);
//log.finer("INTP|"+proc.self_handle()+" Ensure reg capacity: "+max_x);
reg = ensureCapacity(reg, max_x);
} break;

Expand Down Expand Up @@ -309,15 +315,17 @@ public class Interpreter extends AbstractInterpreter {
}

public EObject invoke(final EProc proc, final EObject[] args) throws Pausable {
log.fine("INT| Closure invoked @ "+start_pc);
// log.fine("INT| Closure invoked @ "+start_pc);
int argCnt = args.length;
int envCnt = env.length;
EObject[] reg = new EObject[1024]; //??
for (int i=0; i<argCnt; i++) {reg[i] = args[i];} //??
for (int i=0; i<envCnt; i++) {reg[argCnt+i] = env[i];}
/*
if (log.isLoggable(Level.FINER)) {
for (int i=0; i<argCnt+envCnt; i++) log.finer("INT| reg#"+i+"="+reg[i]);
}
*/
return interpret(proc, start_pc, reg);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/erjang/beam/interpreter/ops.spec
Expand Up @@ -200,6 +200,9 @@ apply arity:
call_fun arity:
PRE_CALL(); int ary=GET(arity); reg[0] = ((EFun)reg[ary]).invoke(proc, reg, 0, ary); POST_CALL();

i_call_fun_last arity:
PRE_CALL(); int ary=GET(arity); return ((EFun)reg[ary]).invoke(proc, reg, 0, ary);

%class II(i1:I i2:I)
apply_last arity dealloc:
STACK_DEALLOC(GET(dealloc)); int ary = GET(arity); EFun fun = ERT.resolve_fun(reg[ary], reg[ary+1], ary); PRE_CALL(); return fun.invoke(proc, REGS_AS_ARRAY(ary));
Expand Down

0 comments on commit e7c5cc1

Please sign in to comment.