Esempio n. 1
0
        /// <summary>
        /// See the base.
        /// </summary>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            ActivationSettings cmpSettings = obj as ActivationSettings;

            if (FunctionType != cmpSettings.FunctionType ||
                !Arg1.Equals(cmpSettings.Arg1) ||
                !Arg2.Equals(cmpSettings.Arg2) ||
                !Arg3.Equals(cmpSettings.Arg3) ||
                !Arg4.Equals(cmpSettings.Arg4) ||
                !Arg5.Equals(cmpSettings.Arg5) ||
                !Arg6.Equals(cmpSettings.Arg6) ||
                !Arg7.Equals(cmpSettings.Arg7) ||
                !Arg8.Equals(cmpSettings.Arg8) ||
                !Arg9.Equals(cmpSettings.Arg9) ||
                !Arg10.Equals(cmpSettings.Arg10) ||
                !Arg11.Equals(cmpSettings.Arg11) ||
                !Arg12.Equals(cmpSettings.Arg12) ||
                !Arg13.Equals(cmpSettings.Arg13) ||
                !Arg14.Equals(cmpSettings.Arg14) ||
                !Arg15.Equals(cmpSettings.Arg15)
                )
            {
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        public override double Compute(IReadOnlyDictionary <string, double> variableValues)
        {
            double arg    = Arg1.Compute(variableValues);
            double Radian = arg * Math.PI / 180;

            return(1 / Math.Tan(Radian));
        }
Esempio n. 3
0
 public override Expr Diff()
 {
     if (!IsConstant)
     {
         if (Arg1.IsConstant)
         {
             if (Arg1.Compute() == E)
             {
                 return(new FunPow(Arg1, Arg2));
             }
             else
             {
                 return(Pow(Arg1, Arg2) * Log(Arg1));
             }
         }
         else if (Arg2.IsConstant)
         {
             return(Arg2 * Pow(Arg1, Arg2 - 1));
         }
         throw new NotImplementedException();
     }
     else
     {
         return(new Constant(0));
     }
 }
Esempio n. 4
0
        public override int Eval()
        {
            if (Operator == "+")
            {
                return(Arg1.Eval() + Arg2.Eval());
            }

            throw new NotImplementedException();
        }
Esempio n. 5
0
        internal override Tile <T_Query> Replace(Tile <T_Query> oldTile, Tile <T_Query> newTile)
        {
            Tile <T_Query> newArg1 = Arg1.Replace(oldTile, newTile);
            Tile <T_Query> newArg2 = Arg2.Replace(oldTile, newTile);

            if (newArg1 != Arg1 || newArg2 != Arg2)
            {
                return(new TileBinaryOperator <T_Query>(newArg1, newArg2, OpKind, Query));
            }
            return(this);
        }
Esempio n. 6
0
 public override string ToString()
 {
     if (Arg2 == null)
     {
         return("Log(" + "" + Arg1.ToString() + ")");
     }
     else
     {
         return("Log(" + "" + Arg1.ToString() + "," + Arg2.ToString() + ")");
     }
 }
Esempio n. 7
0
        public void ConstructorSelectionTests_Arg_ByInterface()
        {
            using var container = new StashboxContainer();
            var arg  = new Arg();
            var arg1 = new Arg1();

            container.Register <Test1>(context => context.WithConstructorByArguments(arg, arg1));
            var test = container.Resolve <Test1>();

            Assert.Same(arg, test.PArg);
            Assert.Same(arg1, test.PArg1);
        }
Esempio n. 8
0
 public bool Equals(GetUsersFunction other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Arg1.SequenceEqual(other.Arg1));
 }
Esempio n. 9
0
 public Type1(Arg1 arg1, Arg2 arg2)
 {
     Arg1 = arg1;
     Arg2 = arg2;
 }
Esempio n. 10
0
 protected override string toString(int depth)
 {
     return(functionName + "(" + Arg1.ToString(depth) + "; " + Arg2.ToString(depth) + ")");
 }
Esempio n. 11
0
 public override int GetHashCode()
 {
     return(Arg1 != null ? Arg1.GetHashCode() : 0);
 }
Esempio n. 12
0
 public override Expr Diff() => !IsConstant ? -(1 / Pow(Ch(Arg1), 2)) * Arg1.Diff() : new Constant(0);
Esempio n. 13
0
 public override Expr Diff() => !IsConstant?Arg1 *Arg1.Diff() : new Constant(0);
Esempio n. 14
0
        protected override double evaluate(int cacheGeneration)
        {
            var value1 = Arg1.Evaluate(cacheGeneration);

            return(value1 == 0 ? 0 : _evaluate(value1, Arg2.Evaluate(cacheGeneration)));
        }
Esempio n. 15
0
 protected override Expression derivate(Variable variable)
 {
     return((Arg2 * Arg1.Derivate(variable) - Arg1 * Arg2.Derivate(variable)) / (Arg1.Square() + Arg2.Square()));
 }
Esempio n. 16
0
 private void ReportDuration(System.Diagnostics.Stopwatch stopwatch, string suffix, string port)
 {
     System.Diagnostics.Debug.WriteLine(string.Format(port + ": COMMAND+{0} DURATION: {6} {1}(0x{2}, 0x{3}, 0x{4}, 0x{5})", suffix, Command, Arg0.ToString("X8"), Arg1.ToString("X8"), Arg2.ToString("X8"), Arg3.ToString("X8"), stopwatch.Elapsed));
 }
Esempio n. 17
0
 public override double Compute(IReadOnlyDictionary <string, double> variableValues) =>
 Arg1.Compute(variableValues) - Arg2.Compute(variableValues);
Esempio n. 18
0
 public override string ToString() => "Cth(" + Arg1.ToString() + ")";
        public DataType GetDataType()
        {
            switch (ExpressionType)
            {
            //void:
            case Instruction.Statement:
            case Instruction.SWITCH:
            case Instruction.SwitchCase:
            case Instruction.A_REALLOC:
            case Instruction.A_PUSHBACK:
            case Instruction.A_POPBACK:
            case Instruction.A_ALLOC:
            case Instruction.A_FREE:
            case Instruction.A_INSERT:
            case Instruction.A_REVERSE:
            case Instruction.A_SORT:
            case Instruction.ASSERT:
            case Instruction.Break:
            case Instruction.CALLONJUMP:
            case Instruction.Continue:
            case Instruction.DELETE:
            case Instruction.ENDFUNC:
            case Instruction.EOF:
            case Instruction.ForLoop:
            case Instruction.FUNC:
            case Instruction.IfElse:
            case Instruction.IFNZ:
            case Instruction.IFZ:
            case Instruction.JUMP:
            case Instruction.MSG:
            case Instruction.Nop:
            case Instruction.Null:
            case Instruction.OBJSWAP:
            case Instruction.POP:
            case Instruction.S_ERASE:
            case Instruction.S_ERASE2:
            case Instruction.S_POP:
            case Instruction.S_POPBACK:
            case Instruction.S_POPBACK2:
            case Instruction.S_PUSHBACK:
            case Instruction.S_PUSHBACK2:
            case Instruction.SJUMP:
            case Instruction.SP_DEC:
            case Instruction.SP_INC:
            case Instruction.SR_POP:
            case Instruction.SH_LOCALASSIGN:
            case Instruction.SH_LOCALINC:
            case Instruction.SH_LOCALDEC:
            case Instruction.SWAP:
            case Instruction.WhileLoop:
            case Instruction.DoWhileLoop:
                return(DataType.Void);

            //int
            case Instruction.A_FIND:
            case Instruction.A_NUMOF:
            case Instruction.A_NUMOF_GLOB_1:
            case Instruction.A_NUMOF_STRUCT_1:
            case Instruction.ADD:
            case Instruction.AND:
            case Instruction.ANDA:
            case Instruction.COMPL:
            case Instruction.DEC:
            case Instruction.DIV:
            case Instruction.DIVA:
            case Instruction.FTOI:
            case Instruction.INC:
            case Instruction.INV:
            case Instruction.LSHIFT:
            case Instruction.LSHIFTA:
            case Instruction.MINUSA:
            case Instruction.MOD:
            case Instruction.MODA:
            case Instruction.MUL:
            case Instruction.MULA:
            case Instruction.OR:
            case Instruction.ORA:
            case Instruction.PLUSA:
            case Instruction.PUSH:
            case Instruction.RSHIFT:
            case Instruction.RSHIFTA:
            case Instruction.S_FIND:
            case Instruction.S_LENGTH:
            case Instruction.S_LENGTH2:
            case Instruction.S_LENGTHBYTE:
            case Instruction.S_LENGTHBYTE2:
            case Instruction.STOI:
            case Instruction.SUB:
            case Instruction.XOR:
            case Instruction.XORA:
            case Instruction.PreDecrement:
            case Instruction.PreIncrement:
                return(DataType.Int);

            //string
            case Instruction.FTOS:
            case Instruction.I_STRING:
            case Instruction.S_ADD:
            case Instruction.S_ASSIGN:
            case Instruction.S_GETPART:
            case Instruction.S_MOD:
            case Instruction.S_PLUSA:
            case Instruction.S_PLUSA2:
            case Instruction.S_PUSH:
                return(DataType.String);

            //bool
            case Instruction.A_EMPTY:
            case Instruction.EQUALE:
            case Instruction.F_EQUALE:
            case Instruction.F_GT:
            case Instruction.F_GTE:
            case Instruction.F_LTE:
            case Instruction.F_LT:
            case Instruction.F_NOTE:
            case Instruction.GT:
            case Instruction.GTE:
            case Instruction.ITOB:
            case Instruction.LT:
            case Instruction.LTE:
            case Instruction.NOT:
            case Instruction.NOTE:
            case Instruction.R_EQUALE:
            case Instruction.R_NOTE:
            case Instruction.S_EMPTY:
            case Instruction.S_EQUALE:
            case Instruction.S_GT:
            case Instruction.S_GTE:
            case Instruction.S_LT:
            case Instruction.S_LTE:
            case Instruction.S_NOTE:
            case Instruction.LogicalAnd:
            case Instruction.LogicalOr:
                return(DataType.Bool);

            case Instruction.DG_CALLBEGIN:
            {
                int delegateNumber = this.Value;
                if (delegateNumber >= 0 && delegateNumber < ainFile.Delegates.Count)
                {
                    var dele = ainFile.Delegates[delegateNumber];
                    return(dele.DataType);
                }
                else
                {
                    return(DataType.Void);
                }
            }
            break;

            case Instruction.CALLFUNC:
            case Instruction.CALLMETHOD:
            {
                int functionNumber = this.Value;
                var function       = ainFile.Functions[functionNumber];
                return(function.DataType);
            }
            break;

            case Instruction.CALLHLL:
            {
                int libraryNumber  = this.Value;
                int functionNumber = this.Value2;
                var library        = ainFile.Libraries[libraryNumber];
                var function       = library.Functions[functionNumber];
                return(function.DataType);
            }
            break;

            case Instruction.CALLSYS:
            {
                int systemCallNumber = this.Value;
                if (systemCallNumber >= 0 && systemCallNumber < AinFile.SystemCalls.Count)
                {
                    var function = AinFile.SystemCalls[systemCallNumber];
                    return(function.DataType);
                }
                return(DataType.Void);
            }
            break;

            case Instruction.PUSHLOCALPAGE:
                return(DataType.LocalPage);

            case Instruction.PUSHGLOBALPAGE:
                return(DataType.GlobalPage);

            case Instruction.PUSHSTRUCTPAGE:
                return(DataType.Struct);

            case Instruction.C_ASSIGN:
            case Instruction.C_REF:
                return(DataType.Int);

            case Instruction.ArrayIndex:
            case Instruction.ArrayIndexReference:
            {
                var dataType = Arg1.GetDataType();
                return(dataType.GetTypeOfArrayElement());
            }
            break;

            case Instruction.LI_ADD:
            case Instruction.LI_ANDA:
            case Instruction.LI_ASSIGN:
            case Instruction.LI_DEC:
            case Instruction.LI_DIV:
            case Instruction.LI_DIVA:
            case Instruction.LI_INC:
            case Instruction.LI_LSHIFTA:
            case Instruction.LI_MINUSA:
            case Instruction.LI_MOD:
            case Instruction.LI_MODA:
            case Instruction.LI_MUL:
            case Instruction.LI_MULA:
            case Instruction.LI_ORA:
            case Instruction.LI_PLUSA:
            case Instruction.LI_RSHIFTA:
            case Instruction.LI_SUB:
            case Instruction.LI_XORA:
            case Instruction.ITOLI:
            {
                return(DataType.Lint);
            }
            break;

            case Instruction.ITOF:
            case Instruction.F_PUSH:
            case Instruction.F_ADD:
            case Instruction.F_ASSIGN:
            case Instruction.F_DIV:
            case Instruction.F_DIVA:
            case Instruction.F_INV:
            case Instruction.F_MINUSA:
            case Instruction.F_MUL:
            case Instruction.F_MULA:
            case Instruction.F_PLUSA:
            case Instruction.F_SUB:
            {
                return(DataType.Float);
            }
            break;

            case Instruction.DG_COPY:
            case Instruction.DG_NEW_FROM_METHOD:
            {
                return(DataType.Delegate);
            }
            break;

            case Instruction.DG_SET:
            case Instruction.DG_ADD:
            {
                return(DataType.Void);
            }
            break;

            case Instruction.DG_NUMOF:
            {
                return(DataType.Int);
            }
            break;

            case Instruction.DG_EXIST:
            {
                return(DataType.Bool);
            }
            break;


            case Instruction.A_COPY:
            case Instruction.A_FILL:
            case Instruction.A_ERASE:
            {
                return(DataType.Int);
            }

            case Instruction.SR_ASSIGN:
            {
                return(DataType.Void);
            }

            //case Instruction.A_REALLOC:
            case Instruction.FT_ASSIGNS:
            {
                return(DataType.String);
            }
            }
            return((DataType)0);
        }
Esempio n. 20
0
 protected override string toString(int depth)
 {
     return(Arg1.ToString(depth, Priority) + " - " + Arg2.ToString(depth, Priority));
 }
Esempio n. 21
0
        public override string ToString()
        {
            string str = "";

            switch (Op)
            {
            case Operator.COPY:
                str += "(COPY, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.MUL:
                str += "(*, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.DIV:
                str += "(/, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.ADD:
                str += "(+, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.SUB:
                str += "(-, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.NOT:
                str += "(not, " + Arg1.ToString() + ", " + "---" + ")";
                break;

            case Operator.PARAM:
                str += "(PARAM, " + Arg1.ToString() + ", " + "---" + ")";
                break;

            case Operator.GOTO:
                str += "(GOTO, " + "---" + ", " + Arg2.ToString() + ")";
                break;

            case Operator.IFTRUE:
                str += "(IFTRUE, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.IFFALSE:
                str += "(IFFALSE, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.CALL:
                str += "(CALL, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.LT:
                str += "(<, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.LE:
                str += "(<=, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.GT:
                str += "(>, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.GE:
                str += "(>=, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.EQ:
                str += "(=, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.NEQ:
                str += "(<>, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.FROMARRAY:
                str += "(FROMARRAY, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.TOARRAY:
                str += "(TOARRAY, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.RETURN:
                str += "(RETURN, " + "---" + ", " + "---" + ")";
                break;

            case Operator.RETVAL:
                str += "(RETURN, " + Arg1.ToString() + ", " + "---" + ")";
                break;

            case Operator.CONTINUE:
                if (Arg1 != null && Arg2 != null)
                {
                    str += "(CONTINUE, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                }
                else if (Arg1 != null)
                {
                    str += "(CONTINUE, " + Arg1.ToString() + ", " + "---" + ")";
                }
                else     // if (Arg2 != null)
                {
                    str += "(CONTINUE, " + "---" + ", " + Arg2.ToString() + ")";
                }
                break;

            case Operator.INC:     // Não usado no MiniPascal
                str += "(++, " + Arg1.ToString() + ", " + "---" + ")";
                break;

            case Operator.DEC:     // Não usado no MiniPascal
                str += "(--, " + Arg1.ToString() + ", " + "---" + ")";
                break;

            case Operator.NEG:     // Não usado no MiniPascal
                str += "(-, " + Arg1.ToString() + ", " + "---" + ")";
                break;

            case Operator.IFEXP:     // Não usado no MiniPascal
                str += "(IFEXP)";
                break;

            case Operator.ADDRESS:     // Não usado no MiniPascal
                str += "(&, " + Arg1.ToString() + ", " + Arg2.ToString() + ")";
                break;

            case Operator.FROMMEMORY:     // Não usado no MiniPascal
                str += "(FROMMEMORY)";
                break;

            case Operator.TOMEMORY:     // Não usado no MiniPascal
                str += "(TOMEMORY)";
                break;
            }

            return(str);
        }
Esempio n. 22
0
 protected override Expression derivate(Variable variable)
 {
     return(Arg1.Derivate(variable) - Arg2.Derivate(variable));
 }
Esempio n. 23
0
 protected override Expression derivate(Variable variable)
 {
     return(IfPositive(Arg1 - Arg2, Arg1.Derivate(variable), Arg2.Derivate(variable)));
 }
Esempio n. 24
0
 public override double Compute(IReadOnlyDictionary <string, double> variableValues) => 1 / Math.Tanh(Arg1.Compute(variableValues));