コード例 #1
0
        public void ReportError(IError error)
        {
            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            _executionContext.AddError(error);
        }
コード例 #2
0
        public override sealed void Execute(IExecutionContext ctx)
        {
            IValue temp1 = ctx.Stack.Pop();
            IValue temp2 = ctx.Stack.Pop();

            if ((temp1.Type.FullName == temp2.Type.FullName) && temp1.Type.IsNumeric)
            {
                ctx.Stack.Push(Operator(temp2, temp1));
            }
            else
            {
                ctx.AddError("Two numeric values excepted for Binary Operation");
            }
        }
コード例 #3
0
        public sealed override void Execute(IExecutionContext ctx)
        {
            IValue temp  = ctx.Stack.Pop();
            IValue temp2 = ctx.Stack.Pop();

            if (temp.Type.FullName == temp2.Type.FullName && ((int)temp.Data == 0 || (int)temp.Data == 1) && ((int)temp2.Data == 0 || (int)temp2.Data == 1))
            {
                ctx.Stack.Push(this.Operator(temp2, temp));
            }
            else
            {
                ctx.AddError("Incorrect type on Binary Boolean Operator. Two booleans excepted.");
            }
        }
コード例 #4
0
        public sealed override void Execute(IExecutionContext ctx)
        {
            IValue temp  = ctx.Stack.Pop();
            IValue temp2 = ctx.Stack.Pop();

            if (temp.Type.FullName == temp2.Type.FullName && temp.Type.IsInt32())
            {
                ctx.Stack.Push(this.Comparator(temp2, temp));
            }
            else
            {
                ctx.AddError("Incorrect type on Comparator. Two integers excepted.");
            }
        }
コード例 #5
0
ファイル: NotNode.cs プロジェクト: PlumpMath/Cil-Cowding
        public override void Execute(IExecutionContext ctx)
        {
            IValue temp = ctx.Stack.Pop();

            if (temp.Type.IsInt32() && ((int)temp.Data == 0 || (int)temp.Data == 1))
            {
                if (!Convert.ToBoolean(temp.Data))
                {
                    ctx.Stack.Push(new Value(temp.Type, 1));
                }
                else
                {
                    ctx.Stack.Push(new Value(temp.Type, 0));
                }
            }
            else
            {
                ctx.AddError("Incorrect type on not operator");
            }
        }
コード例 #6
0
ファイル: BrfalseNode.cs プロジェクト: PlumpMath/Cil-Cowding
        public override void Execute(IExecutionContext ctx)
        {
            IValue temp = ctx.Stack.Pop();

            if (temp.Type.IsInt32() && ((int)temp.Data == 0 || (int)temp.Data == 1))
            {
                if ((int)temp.Data == 0)
                {
                    int index = ctx.Stack.LastFrame.Fct.GetIndexLabel(_label);
                    ctx.Stack.LastFrame.SetCurrentInstruction(index);
                }
                else if ((int)temp.Data == 1)
                {
                    //don't branch
                }
            }
            else
            {
                ctx.AddError("Brfalse expect a boolean, 0 or 1.");
            }
        }
コード例 #7
0
        public override void Execute(IExecutionContext ctx)
        {
            IValue temp = ctx.Stack.Pop();

            if (temp.Type.IsNumeric)
            {
                #region Switch
                switch (Type.GetTypeCode(temp.Type.NetType))
                {
                case TypeCode.SByte:
                    ctx.Stack.Push(new Value(temp.Type, -(sbyte)temp.Data));
                    break;

                case TypeCode.Byte:
                    ctx.Stack.Push(new Value(temp.Type, -(byte)temp.Data));
                    break;

                case TypeCode.Int16:
                    ctx.Stack.Push(new Value(temp.Type, -(short)temp.Data));
                    break;

                case TypeCode.UInt16:
                    ctx.Stack.Push(new Value(temp.Type, -(ushort)temp.Data));
                    break;

                case TypeCode.Int32:
                    ctx.Stack.Push(new Value(temp.Type, -(int)temp.Data));
                    break;

                case TypeCode.UInt32:
                    ctx.Stack.Push(new Value(temp.Type, -(uint)temp.Data));
                    break;

                case TypeCode.Int64:
                    ctx.Stack.Push(new Value(temp.Type, -(long)temp.Data));
                    break;

                case TypeCode.UInt64:
                    //ctx.Stack.Push( new Value( temp.Type, -(ulong)temp.Data ) );
                    break;

                case TypeCode.Single:
                    ctx.Stack.Push(new Value(temp.Type, -(float)temp.Data));
                    break;

                case TypeCode.Double:
                    ctx.Stack.Push(new Value(temp.Type, -(double)temp.Data));
                    break;

                case TypeCode.Decimal:
                    ctx.Stack.Push(new Value(temp.Type, -(decimal)temp.Data));
                    break;

                default:
                    ctx.Stack.Push(new Value(null, null));
                    break;
                }
                #endregion
            }
            else
            {
                ctx.AddError("Cannot negate non numeric value.");
            }
        }