Beispiel #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());
        }
Beispiel #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));
        }
Beispiel #3
0
 void AddSuccessorByRelativeOpnd(FlatOperand opnd)
 {
     switch (opnd.OperandType)
     {
         case FlatOperandType.OPND_LABEL:
             {
                 AddSuccessorByLabel(opnd.ImmediateValue.ValueText);
                 return;
             }
             break;
     }
     throw new NotImplementedException();
 }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #6
0
 public static FlatStatement TRY(FlatOperand ehbeginLabel, string ehendLabel)
 {
     return new FlatStatement(Instruction.TRY, ehbeginLabel) { Comment = ehendLabel };
 }
Beispiel #7
0
 public static FlatStatement TABLESET(FlatOperand table, FlatOperand key, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.TABLESET, table, key, rvalue);
 }
Beispiel #8
0
 public static FlatStatement SWITCH(FlatOperand array_or_table, FlatOperand key)
 {
     return new FlatStatement(Instruction.SWITCH, array_or_table, key);
 }
Beispiel #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);
 }
Beispiel #10
0
 public static FlatStatement NEGATE(FlatOperand lvalue, FlatOperand left)
 {
     return new FlatStatement(Instruction.NEGATE, lvalue, left);
 }
Beispiel #11
0
 public static FlatStatement LABEL(FlatOperand label)
 {
     return new FlatStatement(Instruction.meta_LABEL, label);
 }
Beispiel #12
0
 public static FlatStatement JZ(FlatOperand label, FlatOperand left)
 {
     return new FlatStatement(Instruction.JZ, label, left);
 }
Beispiel #13
0
 public static FlatStatement JNE(FlatOperand label, FlatOperand left, FlatOperand right)
 {
     return new FlatStatement(Instruction.JNE, label, left, right);
 }
Beispiel #14
0
 public static FlatStatement JMP(FlatOperand label)
 {
     return new FlatStatement(Instruction.JMP, label);
 }
Beispiel #15
0
 public static FlatStatement IS(FlatOperand lvalue, FlatOperand subject, FlatOperand is_type)
 {
     return new FlatStatement(Instruction.IS, lvalue, subject, is_type);
 }
Beispiel #16
0
 public static FlatStatement SETSTATICFIELD(FlatOperand field, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.SETSTATICFIELD, field, rvalue);
 }
Beispiel #17
0
 public static FlatStatement SETSTATICPROPERTY(FlatOperand property, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.SETSTATICPROPERTY, property, rvalue);
 }
Beispiel #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);
 }
Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #21
0
 public static FlatStatement THROW(FlatOperand value)
 {
     return new FlatStatement(Instruction.THROW, value);
 }
Beispiel #22
0
 public static FlatStatement NULLIFY(FlatOperand lvalue)
 {
     return new FlatStatement(Instruction.NULLIFY, lvalue, lvalue);
 }
Beispiel #23
0
 public static FlatStatement TRY(FlatOperand ehbeginLabel, FlatOperand finallyLabel)
 {
     return new FlatStatement(Instruction.TRY, ehbeginLabel, finallyLabel);
 }
Beispiel #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);
 }
Beispiel #25
0
 public static FlatStatement XOR(FlatOperand lvalue, FlatOperand left, FlatOperand right)
 {
     return new FlatStatement(Instruction.XOR, lvalue, left, right);
 }
Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #28
0
 public static FlatStatement SETFIELD(FlatOperand field, FlatOperand subject, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.SETFIELD, field, subject, rvalue);
 }
Beispiel #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?");
        }
Beispiel #30
0
 public static FlatStatement SETPROPERTY(FlatOperand property, FlatOperand subject, FlatOperand rvalue)
 {
     return new FlatStatement(Instruction.SETPROPERTY, property, subject, rvalue);
 }