Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 void AddSuccessorByRelativeOpnd(FlatOperand opnd)
 {
     switch (opnd.OperandType)
     {
         case FlatOperandType.OPND_LABEL:
             {
                 AddSuccessorByLabel(opnd.ImmediateValue.ValueText);
                 return;
             }
             break;
     }
     throw new NotImplementedException();
 }
Ejemplo n.º 4
0
 public EHInfo(EHInfo oldState,int numTryInstruction, FlatOperand catchesLabel, string ehendLabel)
 {
     CatchesLabel = catchesLabel.ImmediateValue.ValueText;
     ehEndLabel = ehendLabel;
     PreviousState = oldState;
     EHPart = EHPart.Try;
     NumTryInstruction = numTryInstruction;
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 public static FlatStatement TRY(FlatOperand ehbeginLabel, string ehendLabel)
 {
     return new FlatStatement(Instruction.TRY, ehbeginLabel) { Comment = ehendLabel };
 }
Ejemplo n.º 7
0
 public static FlatStatement TABLESET(FlatOperand table, FlatOperand key, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.TABLESET, table, key, rvalue);
 }
Ejemplo n.º 8
0
 public static FlatStatement SWITCH(FlatOperand array_or_table, FlatOperand key)
 {
     return new FlatStatement(Instruction.SWITCH, array_or_table, key);
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 public static FlatStatement NEGATE(FlatOperand lvalue, FlatOperand left)
 {
     return new FlatStatement(Instruction.NEGATE, lvalue, left);
 }
Ejemplo n.º 11
0
 public static FlatStatement LABEL(FlatOperand label)
 {
     return new FlatStatement(Instruction.meta_LABEL, label);
 }
Ejemplo n.º 12
0
 public static FlatStatement JZ(FlatOperand label, FlatOperand left)
 {
     return new FlatStatement(Instruction.JZ, label, left);
 }
Ejemplo n.º 13
0
 public static FlatStatement JNE(FlatOperand label, FlatOperand left, FlatOperand right)
 {
     return new FlatStatement(Instruction.JNE, label, left, right);
 }
Ejemplo n.º 14
0
 public static FlatStatement JMP(FlatOperand label)
 {
     return new FlatStatement(Instruction.JMP, label);
 }
Ejemplo n.º 15
0
 public static FlatStatement IS(FlatOperand lvalue, FlatOperand subject, FlatOperand is_type)
 {
     return new FlatStatement(Instruction.IS, lvalue, subject, is_type);
 }
Ejemplo n.º 16
0
 public static FlatStatement SETSTATICFIELD(FlatOperand field, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.SETSTATICFIELD, field, rvalue);
 }
Ejemplo n.º 17
0
 public static FlatStatement SETSTATICPROPERTY(FlatOperand property, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.SETSTATICPROPERTY, property, rvalue);
 }
Ejemplo n.º 18
0
 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);
 }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
 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);
 }
Ejemplo n.º 21
0
 public static FlatStatement THROW(FlatOperand value)
 {
     return new FlatStatement(Instruction.THROW, value);
 }
Ejemplo n.º 22
0
 public static FlatStatement NULLIFY(FlatOperand lvalue)
 {
     return new FlatStatement(Instruction.NULLIFY, lvalue, lvalue);
 }
Ejemplo n.º 23
0
 public static FlatStatement TRY(FlatOperand ehbeginLabel, FlatOperand finallyLabel)
 {
     return new FlatStatement(Instruction.TRY, ehbeginLabel, finallyLabel);
 }
Ejemplo n.º 24
0
 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);
 }
Ejemplo n.º 25
0
 public static FlatStatement XOR(FlatOperand lvalue, FlatOperand left, FlatOperand right)
 {
     return new FlatStatement(Instruction.XOR, lvalue, left, right);
 }
Ejemplo n.º 26
0
 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);
 }
Ejemplo n.º 27
0
 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;
 }
Ejemplo n.º 28
0
 public static FlatStatement SETFIELD(FlatOperand field, FlatOperand subject, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.SETFIELD, field, subject, rvalue);
 }
Ejemplo n.º 29
0
        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?");
        }
Ejemplo n.º 30
0
 public static FlatStatement SETPROPERTY(FlatOperand property, FlatOperand subject, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.SETPROPERTY, property, subject, rvalue);
 }