public override FlatOperand Resolve(ExpressionSyntax expression, ArgumentListSyntax argumentList, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions) { FlatOperand fop_subject; if (expression is IdentifierNameSyntax) { // typeof this fop_subject = FlatOperand.ThisRef(FlatValue.FromType(result_type.ConvertedType)); } else if (expression is MemberAccessExpressionSyntax) { MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)expression; fop_subject = function.ResolveExpression(meas.Expression, null, instructions); } else { throw new NotImplementedException("GetMetaTable on expression type " + expression.GetType().ToString()); } if (into_lvalue == null) { FlatOperand fop_register = function.AllocateRegister(""); into_lvalue = fop_register.GetLValue(function, instructions); } instructions.Add(FlatStatement.GETMETATABLE(into_lvalue, fop_subject)); return into_lvalue.AsRValue(FlatValue.Table()); }
public override FlatOperand Resolve(InvocationExpressionSyntax node, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions) { if (!(node.Expression is MemberAccessExpressionSyntax)) { throw new NotImplementedException("GETPROPERTY not on MemberAccessExpressionSyntax"); } MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)node.Expression; FlatOperand fop_subject = function.ResolveExpression(meas.Expression, null, instructions); if (into_lvalue == null) { FlatOperand fop_register = function.AllocateRegister(""); into_lvalue = fop_register.GetLValue(function, instructions); } instructions.Add(FlatStatement.STRINGVAL(into_lvalue, fop_subject)); return into_lvalue.AsRValue(FlatValue.String(string.Empty)); }
void AddSuccessorByRelativeOpnd(FlatOperand opnd) { switch (opnd.OperandType) { case FlatOperandType.OPND_LABEL: { AddSuccessorByLabel(opnd.ImmediateValue.ValueText); return; } break; } throw new NotImplementedException(); }
public EHInfo(EHInfo oldState,int numTryInstruction, FlatOperand catchesLabel, string ehendLabel) { CatchesLabel = catchesLabel.ImmediateValue.ValueText; ehEndLabel = ehendLabel; PreviousState = oldState; EHPart = EHPart.Try; NumTryInstruction = numTryInstruction; }
public static FlatStatement TYPEOF(FlatOperand lvalue, FlatOperand right) { if (lvalue.OperandType != FlatOperandType.OPND_IMMEDIATE) { throw new NotSupportedException("expected register number (LValue) in left"); } return new FlatStatement(Instruction.TYPEOF, lvalue, right); }
public static FlatStatement TRY(FlatOperand ehbeginLabel, string ehendLabel) { return new FlatStatement(Instruction.TRY, ehbeginLabel) { Comment = ehendLabel }; }
public static FlatStatement TABLESET(FlatOperand table, FlatOperand key, FlatOperand rvalue) { return new FlatStatement(Instruction.TABLESET, table, key, rvalue); }
public static FlatStatement SWITCH(FlatOperand array_or_table, FlatOperand key) { return new FlatStatement(Instruction.SWITCH, array_or_table, key); }
public static FlatStatement NEWARRAY(FlatOperand lvalue, FlatOperand size, FlatOperand fop_type) { if (lvalue.OperandType != FlatOperandType.OPND_IMMEDIATE) { throw new NotSupportedException("expected register number (LValue) in left"); } return new FlatStatement(Instruction.NEWARRAY, lvalue, size, fop_type); }
public static FlatStatement NEGATE(FlatOperand lvalue, FlatOperand left) { return new FlatStatement(Instruction.NEGATE, lvalue, left); }
public static FlatStatement LABEL(FlatOperand label) { return new FlatStatement(Instruction.meta_LABEL, label); }
public static FlatStatement JZ(FlatOperand label, FlatOperand left) { return new FlatStatement(Instruction.JZ, label, left); }
public static FlatStatement JNE(FlatOperand label, FlatOperand left, FlatOperand right) { return new FlatStatement(Instruction.JNE, label, left, right); }
public static FlatStatement JMP(FlatOperand label) { return new FlatStatement(Instruction.JMP, label); }
public static FlatStatement IS(FlatOperand lvalue, FlatOperand subject, FlatOperand is_type) { return new FlatStatement(Instruction.IS, lvalue, subject, is_type); }
public static FlatStatement SETSTATICFIELD(FlatOperand field, FlatOperand rvalue) { return new FlatStatement(Instruction.SETSTATICFIELD, field, rvalue); }
public static FlatStatement SETSTATICPROPERTY(FlatOperand property, FlatOperand rvalue) { return new FlatStatement(Instruction.SETSTATICPROPERTY, property, rvalue); }
public static FlatStatement NEWDELEGATE(FlatOperand lvalue, FlatOperand type, FlatOperand array_with_method_and_optional_type) { if (lvalue.OperandType != FlatOperandType.OPND_IMMEDIATE) { throw new NotSupportedException("expected register number (LValue) in left"); } return new FlatStatement(Instruction.NEWDELEGATE, lvalue, type, array_with_method_and_optional_type); }
public static FlatStatement TABLEGET(FlatOperand lvalue, FlatOperand table, FlatOperand key) { if (lvalue.OperandType != FlatOperandType.OPND_IMMEDIATE) { throw new NotSupportedException("expected register number (LValue) in left"); } return new FlatStatement(Instruction.TABLEGET, lvalue, table, key); }
public static FlatStatement NEWOBJECT(FlatOperand lvalue, FlatOperand constructor, FlatOperand arguments) { if (lvalue.OperandType != FlatOperandType.OPND_IMMEDIATE) { throw new NotSupportedException("expected register number (LValue) in left"); } return new FlatStatement(Instruction.NEWOBJECT, lvalue, constructor, arguments); }
public static FlatStatement THROW(FlatOperand value) { return new FlatStatement(Instruction.THROW, value); }
public static FlatStatement NULLIFY(FlatOperand lvalue) { return new FlatStatement(Instruction.NULLIFY, lvalue, lvalue); }
public static FlatStatement TRY(FlatOperand ehbeginLabel, FlatOperand finallyLabel) { return new FlatStatement(Instruction.TRY, ehbeginLabel, finallyLabel); }
public static FlatStatement REREFERENCE(FlatOperand lvalue, FlatOperand right) { /* if (lvalue.OperandType != FlatOperandType.OPND_IMMEDIATE) { throw new NotSupportedException("expected register number (LValue) in left"); } /**/ return new FlatStatement(Instruction.REREFERENCE, lvalue, right); }
public static FlatStatement XOR(FlatOperand lvalue, FlatOperand left, FlatOperand right) { return new FlatStatement(Instruction.XOR, lvalue, left, right); }
public static FlatStatement RESOLVETYPE(FlatOperand lvalue, FlatOperand typename) { if (lvalue.OperandType != FlatOperandType.OPND_IMMEDIATE) { throw new NotSupportedException("expected register number (LValue) in left"); } return new FlatStatement(Instruction.RESOLVETYPE, lvalue, typename); }
public EHInfo(EHInfo oldState,int numTryInstruction, FlatOperand catchesLabel, FlatOperand finallyLabel) { CatchesLabel = catchesLabel.ImmediateValue.ValueText; FinallyLabel = finallyLabel.ImmediateValue.ValueText; PreviousState = oldState; NumTryInstruction = numTryInstruction; EHPart = EHPart.Try; }
public static FlatStatement SETFIELD(FlatOperand field, FlatOperand subject, FlatOperand rvalue) { return new FlatStatement(Instruction.SETFIELD, field, subject, rvalue); }
void AddSuccessorBySwitch(FlatOperand opnd) { switch (opnd.ImmediateValue.ValueType) { case FlatValueType.VT_Array: { FlatArrayBuilder fab = (FlatArrayBuilder)opnd.ImmediateValue.Object; foreach (FlatValue value in fab.Values) { AddSuccessorByLabel(value.ValueText); } return; } break; case FlatValueType.VT_Table: { FlatTableBuilder ftb = (FlatTableBuilder)opnd.ImmediateValue.Object; foreach (KeyValuePair<string, FlatValue> kvp in ftb.Values) { AddSuccessorByLabel(kvp.Value.ValueText); } return; } break; } throw new NotImplementedException("unhandled switch type?"); }
public static FlatStatement SETPROPERTY(FlatOperand property, FlatOperand subject, FlatOperand rvalue) { return new FlatStatement(Instruction.SETPROPERTY, property, subject, rvalue); }