public FunctionCallStatement(FunctionCall call) { this.call = call; }
public CallOperation(int line, FunctionCall call) : base(line) { this.call = call; }
public FunctionCallStatement(FunctionCall call) { this.call = call; }
private List<Operation> processLine(int line) { List<Operation> operations = new List<Operation>(); int A = code.A(line); int B = code.B(line); int C = code.C(line); int Bx = code.Bx(line); switch(code.op(line)) { case Op.MOVE: operations.Add(new RegisterSet(line, A, r.getExpression(B, line))); break; case Op.LOADK: operations.Add(new RegisterSet(line, A, f.getConstantExpression(Bx))); break; case Op.LOADBOOL: operations.Add(new RegisterSet(line, A, new ConstantExpression(new Constant(B != 0 ? LBoolean.LTRUE : LBoolean.LFALSE), -1))); break; case Op.LOADNIL: { int maximum; if(function.header.version.usesOldLoadNilEncoding()) { maximum = B; } else { maximum = A + B; } while(A <= maximum) { operations.Add(new RegisterSet(line, A, Expression.NIL)); A++; } break; } //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case Op.GETUPVAL: operations.Add(new RegisterSet(line, A, upvalues.getExpression(B))); break; case Op.GETTABUP: if(B == 0 && (C & 0x100) != 0) { operations.Add(new RegisterSet(line, A, f.getGlobalExpression(C & 0xFF))); //TODO: check } else { operations.Add(new RegisterSet(line, A, new TableReference(upvalues.getExpression(B), r.getKExpression(C, line)))); } break; case Op.GETGLOBAL: operations.Add(new RegisterSet(line, A, f.getGlobalExpression(Bx))); break; case Op.GETTABLE: operations.Add(new RegisterSet(line, A, new TableReference(r.getExpression(B, line), r.getKExpression(C, line)))); break; case Op.SETUPVAL: operations.Add(new UpvalueSet(line, upvalues.getName(B), r.getExpression(A, line))); break; case Op.SETTABUP: if(A == 0 && (B & 0x100) != 0) { operations.Add(new GlobalSet(line, f.getGlobalName(B & 0xFF), r.getKExpression(C, line))); //TODO: check } else { operations.Add(new TableSet(line, upvalues.getExpression(A), r.getKExpression(B, line), r.getKExpression(C, line), true, line)); } break; case Op.SETGLOBAL: operations.Add(new GlobalSet(line, f.getGlobalName(Bx), r.getExpression(A, line))); break; case Op.SETTABLE: operations.Add(new TableSet(line, r.getExpression(A, line), r.getKExpression(B, line), r.getKExpression(C, line), true, line)); break; case Op.NEWTABLE: operations.Add(new RegisterSet(line, A, new TableLiteral(B, C))); break; case Op.SELF: { // We can later determine is : syntax was used by comparing subexpressions with == Expression common = r.getExpression(B, line); operations.Add(new RegisterSet(line, A + 1, common)); operations.Add(new RegisterSet(line, A, new TableReference(common, r.getKExpression(C, line)))); break; } //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case Op.ADD: operations.Add(new RegisterSet(line, A, Expression.makeADD(r.getKExpression(B, line), r.getKExpression(C, line)))); break; case Op.SUB: operations.Add(new RegisterSet(line, A, Expression.makeSUB(r.getKExpression(B, line), r.getKExpression(C, line)))); break; case Op.MUL: operations.Add(new RegisterSet(line, A, Expression.makeMUL(r.getKExpression(B, line), r.getKExpression(C, line)))); break; case Op.DIV: operations.Add(new RegisterSet(line, A, Expression.makeDIV(r.getKExpression(B, line), r.getKExpression(C, line)))); break; case Op.MOD: operations.Add(new RegisterSet(line, A, Expression.makeMOD(r.getKExpression(B, line), r.getKExpression(C, line)))); break; case Op.POW: operations.Add(new RegisterSet(line, A, Expression.makePOW(r.getKExpression(B, line), r.getKExpression(C, line)))); break; case Op.UNM: operations.Add(new RegisterSet(line, A, Expression.makeUNM(r.getExpression(B, line)))); break; case Op.NOT: operations.Add(new RegisterSet(line, A, Expression.makeNOT(r.getExpression(B, line)))); break; case Op.LEN: operations.Add(new RegisterSet(line, A, Expression.makeLEN(r.getExpression(B, line)))); break; case Op.CONCAT: Expression @value1 = r.getExpression(C, line); //Remember that CONCAT is right associative. while(C-- > B) { @value1 = Expression.makeCONCAT(r.getExpression(C, line), @value1); } operations.Add(new RegisterSet(line, A, @value1)); break; //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case Op.JMP: case Op.EQ: case Op.LT: case Op.LE: case Op.TEST: case Op.TESTSET: // Do nothing... handled with branches break; case Op.CALL: { bool multiple = (C >= 3 || C == 0); if(B == 0) B = registers - A; if(C == 0) C = registers - A + 1; Expression function2 = r.getExpression(A, line); Expression[] arguments = new Expression[B - 1]; for(int register = A + 1; register <= A + B - 1; register++) { arguments[register - A - 1] = r.getExpression(register, line); } FunctionCall @value = new FunctionCall(function2, arguments, multiple); if(C == 1) { operations.Add(new CallOperation(line, @value)); } else { if(C == 2 && !multiple) { operations.Add(new RegisterSet(line, A, @value)); } else { for(int register = A; register <= A + C - 2; register++) { operations.Add(new RegisterSet(line, register, @value)); } } } break; } //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case Op.TAILCALL: { if(B == 0) B = registers - A; Expression function1 = r.getExpression(A, line); Expression[] arguments = new Expression[B - 1]; for(int register = A + 1; register <= A + B - 1; register++) { arguments[register - A - 1] = r.getExpression(register, line); } FunctionCall @value2 = new FunctionCall(function1, arguments, true); operations.Add(new ReturnOperation(line, @value2)); skip[line + 1] = true; break; } //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case Op.RETURN: { if(B == 0) B = registers - A + 1; Expression[] values = new Expression[B - 1]; for(int register = A; register <= A + B - 2; register++) { values[register - A] = r.getExpression(register, line); } operations.Add(new ReturnOperation(line, values)); break; } //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case Op.FORLOOP: case Op.FORPREP: case Op.TFORCALL: case Op.TFORLOOP: // Do nothing... handled with branches break; case Op.SETLIST: if(C == 0) { C = code.codepoint(line + 1); skip[line + 1] = true; } if(B == 0) { B = registers - A - 1; } Expression table = r.getValue(A, line); for(int i = 1; i <= B; i++) { operations.Add(new TableSet(line, table, new ConstantExpression(new Constant((C - 1) * 50 + i), -1), r.getExpression(A + i, line), false, r.getUpdated(A + i, line))); } break; //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case Op.CLOSE: break; case Op.CLOSURE: LFunction f2 = functions[Bx]; operations.Add(new RegisterSet(line, A, new ClosureExpression(f2, declList, line + 1))); if(function.header.version.usesInlineUpvalueDeclarations()) { // Skip upvalue declarations for(int i = 0; i < f2.numUpvalues; i++) { skip[line + 1 + i] = true; } } break; //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': case Op.VARARG: bool multiple1 = (B != 2); if(B == 1) throw new Exception(); if(B == 0) B = registers - A + 1; Expression @value3 = new Vararg(B - 1, multiple1); for(int register = A; register <= A + B - 2; register++) { operations.Add(new RegisterSet(line, register, @value3)); } break; //JAVA TO VB & C# CONVERTER TODO TASK: C# does not allow fall-through from a non-empty 'case': default: throw new Exception("Illegal instruction: " + code.op(line)); } return operations; }