예제 #1
0
        public void LoadInfo(ScopeStorage scope)
        {
            Dictionary <string, AType> functions = ExtractFunctions(scope);

            foreach (KeyValuePair <string, AType> function in functions)
            {
                AFunc func = function.Value.Data as AFunc;

                if (func.Valence <= 1)
                {
                    // skip the niladic functions
                    continue;
                }

                if (func.IsOperator)
                {
                    if (func.IsDyadic)
                    {
                        this.dyadicOperators.Add(function.Key);
                    }
                    else
                    {
                        this.monadicOperators.Add(function.Key);
                    }
                }
                else
                {
                    this.globalFunctions.Add(function.Key);
                }
            }
        }
예제 #2
0
        protected override int RunFile(ScriptSource source)
        {
            if (this.ScriptScope == null)
            {
                this.ScriptScope = this.Engine.CreateScope();

                this.ScriptScope.SetVariable(
                    "time",
                    AFunc.Create(
                        "time",
                        (Func <Aplus, AType>)Time,
                        1,
                        "returns the user time of the current process"
                        )
                    );
            }

            try
            {
                AType result = source.Execute <AType>(this.ScriptScope);
                Console.WriteLine(result.ToString(), Style.Out);
            }
            catch (Error error)
            {
                Console.ErrorOutput.Write(error);
                return(1);
            }
            catch (Exception)
            {
                throw;
            }
            return(0);
        }
예제 #3
0
 internal RankJobInfo(int[] rankSpecifier, AFunc function)
 {
     this.rankSpecifier = rankSpecifier;
     this.function      = (Func <Aplus, AType, AType, AType>)function.Method;
     this.check         = ATypes.AType;
     this.floatConvert  = false;
 }
예제 #4
0
        public void UserDefined1()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AInteger.Create(-10),
                AInteger.Create(1),
                AInteger.Create(2),
                AInteger.Create(3)
                );

            AType function = AFunc.Create("T", (Func <Aplus, AType, AType, AType, AType>)TestMethod, 4, "Test method");

            var scope = this.engine.CreateScope();

            scope.SetVariable(".T", function);

            scope.SetVariable(
                ".a",
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(0),
                    AInteger.Create(1),
                    AInteger.Create(2),
                    AInteger.Create(3)
                    )
                );

            this.engine.Execute <AType>("T{0;1;a} := -10", scope);

            Assert.AreEqual <AType>(expected, scope.GetVariable <AType>(".a"), "Incorrect assignment performed");
        }
예제 #5
0
        public AType Execute(AType function, AType n, AType right, AType left, Aplus environment = null)
        {
            if (!(function.Data is AFunc))
            {
                throw new Error.NonFunction("Rank");
            }

            AFunc func = (AFunc)function.Data;

            if (!func.IsBuiltin)
            {
                if (func.Valence - 1 != 2)
                {
                    throw new Error.Valence("Rank");
                }
            }

            int[]       rankSpecifier = GetRankSpecifier(n, left, right, environment);
            RankJobInfo rankInfo      = new RankJobInfo(rankSpecifier, func);

            AType result = Walker(left, right, environment, rankInfo);

            if (rankInfo.FloatConvert && result.IsArray)
            {
                result.ConvertToFloat();
            }

            return(result);
        }
예제 #6
0
        public AType Execute(AType functionScalar, AType argument, Aplus environment = null)
        {
            //'Disclose' the function from functionscalar.
            AFunc function = (AFunc)functionScalar.NestedItem.Data;

            //Convert method to the correspond function format.
            if (function.IsBuiltin)
            {
                Func <Aplus, AType, AType, AType> primitiveFunction =
                    (Func <Aplus, AType, AType, AType>)function.Method;

                return(primitiveFunction(environment, argument, null));
            }
            else
            {
                //If function is user defined, we check the valance.
                if (function.Valence - 1 != 1)
                {
                    throw new Error.Valence("Apply");
                }

                //Convert method to the correspond function format.
                Func <Aplus, AType, AType> userDefinedFunction =
                    (Func <Aplus, AType, AType>)function.Method;

                return(userDefinedFunction(environment, argument));
            }
        }
예제 #7
0
        private AType NullWalker(AType argument, AFunc function, int number, Aplus environment)
        {
            AType result;

            if (argument.Type == ATypes.ANull)
            {
                if (number == 0)
                {
                    throw new Error.Type("Rank");
                }

                result = ExecuteFunction(function, Utils.ANull(), environment);

                if (result.Type == ATypes.ABox || result.Type == ATypes.ASymbol)
                {
                    result.Type = ATypes.ANull;
                }
            }
            else
            {
                result = AArray.Create(ATypes.AArray);

                result.Length = argument.Length;
                result.Shape  = new List <int>(argument.Shape.GetRange(0, argument.Rank));
                result.Rank   = argument.Rank;
                result.Type   = ExecuteFunction(function, Utils.ANull(argument.Type), environment).Type;
            }

            return(result);
        }
예제 #8
0
    void UpdateFuncState()
    {
        if (funcController == null)
        {
            return;
        }
        while (listFuncState.Count < funcController.listCurrentFuncInShip.Count)
        {
            Slider slider = (Slider)Instantiate(funcState);
            slider.transform.SetParent(transform);
            listFuncState.Add(slider);
            Vector2 pos = new Vector2(700, 300 - 90 * (listFuncState.Count - 1));
            slider.transform.position = pos;
            slider.transform.GetChild(0).GetComponent <Image>().sprite             = ((GameObject)funcController.listCurrentFuncInShip[listFuncState.Count - 1]).GetComponent <SpriteRenderer>().sprite;
            slider.transform.GetChild(1).GetChild(0).GetComponent <Image>().sprite = ((GameObject)funcController.listCurrentFuncInShip[listFuncState.Count - 1]).GetComponent <SpriteRenderer>().sprite;
        }

        for (int i = 0; i < listFuncState.Count; i++)
        {
            AFunc aFunc = ((GameObject)funcController.listCurrentFuncInShip[i]).GetComponent <AFunc>();
            if (aFunc.isChosen)
            {
                Slider sl = ((Slider)listFuncState[i]);
                sl.value = (aFunc.currentTimeChoosing / aFunc.timeOverload);
            }
            else
            {
                Slider sl = ((Slider)listFuncState[i]);
                sl.value = aFunc.currentTimeDelayChoosing / aFunc.timeDelayChoosing;
            }
        }
    }
예제 #9
0
        /// <summary>
        /// Searches for System functions inside the <see cref="SystemFunction"/> class.
        /// </summary>
        /// <returns>Returns a dictionary of system function names and the <see cref="AFunc"/> for each.</returns>
        internal static Dictionary <string, AType> DiscoverSystemFunctions()
        {
            Dictionary <string, AType> functions = new Dictionary <string, AType>();

            Type         systemFunctionType = typeof(SystemFunction);
            BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

            foreach (MethodInfo method in systemFunctionType.GetMethods(flags))
            {
                SystemFunctionAttribute attibute = method.GetSingleAttribute <SystemFunctionAttribute>();

                if (attibute == null)
                {
                    continue;
                }

                if (functions.ContainsKey(attibute.Name))
                {
                    // TODO: what should we do here? Exception? Overwrite?
                }

                ParameterInfo[] parameters = method.GetParameters();
                List <Type>     types      = new List <Type>(parameters.Select(parameter => parameter.ParameterType));
                types.Add(method.ReturnType);

                Delegate methodDelegate = Delegate.CreateDelegate(DLR.Expression.GetFuncType(types.ToArray()), method);

                functions[attibute.Name] = AFunc.Create(attibute.Name, methodDelegate, parameters.Length, attibute.Description);
            }

            return(functions);
        }
예제 #10
0
        public static AType CreateBuiltIn(string name, object method, string codestring, bool derived)
        {
            AFunc function = new AFunc(name, method, 3, codestring);

            function.builtin = true;
            function.derived = derived;
            return(new AReference(function));
        }
예제 #11
0
        public static AType CreateUserOperator(string name, bool isDyadic, object method, int valence, string codestring)
        {
            AFunc op = new AFunc(name, method, valence, codestring);

            op.isOperator = true;
            op.isDyadic   = isDyadic;
            return(new AReference(op));
        }
예제 #12
0
        public void TypeError()
        {
            AType function = AFunc.Create("f", TestUtils.DyadicTypeAlternateFunction, 3, "TypeAlternatingMethod");

            var scope = this.engine.CreateScope();

            scope.SetVariable(".f", function);

            this.engine.Execute <AType>("1 2 3 f @ 0 (1 2 3)", scope);
        }
예제 #13
0
        /// <summary>
        /// Build an AFunction for the given method.
        /// </summary>
        /// <param name="method">The method to wrap inside an AFunction.</param>
        /// <param name="name">The name of AFunction.</param>
        /// <param name="description">Description for the AFunction.</param>
        /// <returns>Returns an AFunction for the given method.</returns>
        internal static AType BuildAFunction(this MethodInfo method, string name, string description)
        {
            ParameterInfo[] parameters = method.GetParameters();
            List <Type>     types      = new List <Type>(parameters.Select(parameter => parameter.ParameterType));

            types.Add(method.ReturnType);

            Delegate methodDelegate = Delegate.CreateDelegate(DLR.Expression.GetFuncType(types.ToArray()), method);

            return(AFunc.Create(name, methodDelegate, parameters.Length, description));
        }
예제 #14
0
        public void FloatIntMixedTypeResult2()
        {
            AType expected = AArray.Create(ATypes.AFloat, AFloat.Create(1.1), AFloat.Create(0));

            AType function = AFunc.Create("f", TestUtils.DyadicTypeAlternateFunction, 3, "TypeAlternatingMethod");

            var scope = this.engine.CreateScope();

            scope.SetVariable(".f", function);

            AType result = this.engine.Execute <AType>("0 1 f @ 0 (0 1)", scope);

            Assert.AreEqual(expected, result);
        }
예제 #15
0
        public override bool Equals(object obj)
        {
            if (obj is AFunc)
            {
                AFunc other = (AFunc)obj;

                if (IsBuiltin)
                {
                    return(this.valence == other.valence && this.name == other.name);
                }

                return(other.method == this.method && this.valence == other.valence && this.name == other.name);
            }
            return(false);
        }
예제 #16
0
        public DenseMatrix Fire(bool storeDerivative = false)
        {
            var actualInps = inputFuncOutput;

            if (this.biased)
            {
                actualInps = DenseMatrix.OfColumnVectors(
                    inputFuncOutput.ColumnEnumerator().Select(tuple => tuple.Item2 + this.biases).ToArray());
            }
            output = AFunc.Apply(actualInps);
            if (storeDerivative)
            {
                activationFuncDerivative = AFunc.Differentiate(output, inputFuncOutput);
            }
            return(output);
        }
예제 #17
0
        protected override int RunInteractive()
        {
            this.ScriptScope = this.Engine.CreateScope();

            this.ScriptScope.SetVariable(
                "time",
                AFunc.Create(
                    "time",
                    (Func <Aplus, AType>)Time,
                    1,
                    "returns the user time of the current process"
                    )
                );

            return(base.RunInteractive());
        }
예제 #18
0
    new void OnTriggerEnter2D(Collider2D other)
    {
        GameObject objectCollider = other.gameObject;
        Damage     damage         = objectCollider.GetComponent <Damage>();

        switch (objectCollider.tag)
        {
        case "Player":
            AFunc aFunc = objectCollider.GetComponent <AFunc>();
            if (aFunc != null)
            {
                switch (aFunc.id)
                {
                case FuncController.SHEILD:
                    colliderPosition = objectCollider.transform.parent.transform.position;
                    ShieldController shieldController = (ShieldController)aFunc;
                    if (shieldController.currentTimePush > 0)
                    {
                        SetUpObstacle();
                        StartCoroutine(IEnDestroyInTime(1, damage.damage));
                        transform.rotation = objectCollider.transform.rotation;
                    }
                    else
                    {
                        OnDamage(damage.damage);
                    }
                    break;
                }
            }
            else
            {
                OnDamage(damage.damage);
            }
            break;

        case "Obstacle":
            OnDamage(damage.damage);
            break;

        case "Enemy":
            if (gameObject.CompareTag("Obstacle"))
            {
                OnDamage(damage.damage);
            }
            break;
        }
    }
예제 #19
0
        private static AType ExecuteFunction(AFunc function, AType argument, Aplus environment)
        {
            AType result;

            if (function.IsBuiltin)
            {
                var method = (Func <Aplus, AType, AType, AType>)function.Method;
                result = method(environment, argument, null);
            }
            else
            {
                var method = (Func <Aplus, AType, AType>)function.Method;
                result = method(environment, argument);
            }

            return(result);
        }
예제 #20
0
        public AType Execute(AType functionScalar, AType right, AType left, Aplus environment = null)
        {
            //'Disclose' the function from functionscalar.
            AFunc func = (AFunc)functionScalar.NestedItem.Data;

            //If function is user defined, we check the valance.
            if (!func.IsBuiltin)
            {
                if (func.Valence - 1 != 2)
                {
                    throw new Error.Valence("Apply");
                }
            }

            //Convert method to the correspond function format.
            var function = (Func <Aplus, AType, AType, AType>)func.Method;

            return(function(environment, right, left));
        }
예제 #21
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        GameObject go = collision.gameObject;

        if (go.CompareTag("Player"))
        {
            AFunc aFunc = go.GetComponent <AFunc>();
            if (aFunc != null)
            {
                switch (aFunc.id)
                {
                case FuncController.SHEILD:
                    ShieldController shieldController = (ShieldController)aFunc;
                    if (shieldController.currentTimePush > 0)
                    {
                        SetDirRevert();
                        SetUpForPlayer();
                    }
                    else
                    {
                        Destroy(gameObject);
                    }
                    break;
                }
            }
            else
            {
                Destroy(gameObject);
            }
        }
        if (go.CompareTag("Enemy"))
        {
            if (gameObject.CompareTag("Player"))
            {
                Destroy(gameObject);
            }
        }
        if (go.CompareTag("Obstacle"))
        {
            Destroy(gameObject);
        }
    }
예제 #22
0
        public AType Execute(AType function, AType argument, Aplus environment = null)
        {
            //If function is not function, we throw an exception.
            if (!(function.Data is AFunc))
            {
                throw new Error.NonFunction("Each");
            }

            AFunc func = (AFunc)function.Data;

            //If function is user defined, we check function is monadic.
            if (!func.IsBuiltin)
            {
                if (func.Valence - 1 != 1)
                {
                    throw new Error.Valence("Each");
                }
            }

            return(Walker(argument, environment, argument.Shape.Contains(0), func));
        }
예제 #23
0
        /// <summary>
        /// Execute 'monadic' Each algorithm.
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="environment"></param>
        /// <param name="isNull"></param>
        /// <param name="function"></param>
        /// <returns></returns>
        private AType Walker(AType argument, Aplus environment, bool isNull, AFunc function)
        {
            if (argument.IsArray)
            {
                AType result = AArray.Create(ATypes.AArray);

                foreach (AType item in argument)
                {
                    result.AddWithNoUpdate(Walker(item, environment, isNull, function));
                }

                result.Type   = isNull ? ATypes.ANull : ATypes.ABox;
                result.Length = argument.Length;
                result.Shape  = new List <int>(argument.Shape);
                result.Rank   = argument.Rank;

                return(result);
            }
            else
            {
                //Disclose scalar argument.
                AType result = MonadicFunctionInstance.Disclose.Execute(argument);

                //Pick the holden function and apply it.
                if (function.IsBuiltin)
                {
                    var method = (Func <Aplus, AType, AType, AType>)function.Method;
                    result = method(environment, result, null);
                }
                else
                {
                    var method = (Func <Aplus, AType, AType>)function.Method;
                    result = method(environment, result);
                }

                //Enclose the result.
                result = MonadicFunctionInstance.Enclose.Execute(result);
                return(result);
            }
        }
예제 #24
0
        private AType Walker(
            AType argument, AFunc function, int number, Aplus environment, ref ATypes typeChecker, ref bool floatConvert)
        {
            AType result;

            if (argument.Rank != number)
            {
                result = AArray.Create(ATypes.AArray);

                foreach (AType item in argument)
                {
                    AType resultItem = Walker(item, function, number, environment, ref typeChecker, ref floatConvert);

                    if (typeChecker == ATypes.AType)
                    {
                        typeChecker = resultItem.Type;
                    }
                    else if (typeChecker == ATypes.AFloat && resultItem.Type == ATypes.AInteger ||
                             resultItem.Type == ATypes.AFloat && typeChecker == ATypes.AInteger)
                    {
                        floatConvert = true;
                    }
                    else if (typeChecker != resultItem.Type)
                    {
                        throw new Error.Type("Rank");
                    }

                    result.AddWithNoUpdate(resultItem);
                }

                result.UpdateInfo();
            }
            else
            {
                result = ExecuteFunction(function, argument, environment);
            }

            return(result);
        }
예제 #25
0
        public AType Execute(AType function, AType n, AType argument, Aplus environment = null)
        {
            if (!(function.Data is AFunc))
            {
                throw new Error.NonFunction("Rank");
            }

            AFunc func = (AFunc)function.Data;

            if (!func.IsBuiltin)
            {
                if (func.Valence - 1 != 1)
                {
                    throw new Error.Valence("Rank");
                }
            }

            AType result;
            int   number = GetNumber(argument, n, environment);

            if (argument.Shape.Contains(0))
            {
                result = NullWalker(argument, func, number, environment);
            }
            else
            {
                ATypes typeChecker  = ATypes.AType;
                bool   floatConvert = false;

                result = Walker(argument, func, number, environment, ref typeChecker, ref floatConvert);

                if (floatConvert && result.IsArray)
                {
                    result.ConvertToFloat();
                }
            }

            return(result);
        }
예제 #26
0
        public AType Execute(AType function, AType right, AType left, Aplus environment = null)
        {
            //If function is not function, we throw an exception.
            if (!(function.Data is AFunc))
            {
                throw new Error.NonFunction("Each");
            }

            AFunc func = (AFunc)function.Data;

            //If left and right side is array, we chech rank and shape.
            if (right.IsArray && left.IsArray)
            {
                if (right.Rank != left.Rank)
                {
                    throw new Error.Rank("Each");
                }

                if (!right.Shape.SequenceEqual(left.Shape))
                {
                    throw new Error.Length("Each");
                }
            }

            //If function is user defined, we check function is dyadic.
            if (!func.IsBuiltin)
            {
                if (func.Valence - 1 != 2)
                {
                    throw new Error.Valence("Each");
                }
            }

            //Null array flag.
            bool isNull = right.Shape.Contains(0) || left.Shape.Contains(0);

            return(Walker(left, right, environment, isNull, func));
        }
예제 #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="target">The <see cref="CallbackItem"/> to use.</param>
        /// <param name="args"></param>
        /// <remarks>
        /// Order of items in the <see cref="args"/> array:
        /// <list type="number">
        ///  <item><see cref="Aplus"/></item>
        ///  <item>New value for the global variable</item>
        /// </list>
        /// </remarks>
        /// <returns></returns>
        public override DYN.DynamicMetaObject Bind(DYN.DynamicMetaObject target, DYN.DynamicMetaObject[] args)
        {
            ContractUtils.RequiresNotNull(target, "target");
            ContractUtils.RequiresNotNullItems(args, "args");

            if (target.HasValue && target.Value is CallbackItem)
            {
                CallbackItem callbackItem      = (CallbackItem)target.Value;
                AFunc        callbackAFunction = (AFunc)callbackItem.CallbackFunction.Data;

                DLR.Expression callbackItemExpression = DLR.Expression.Convert(
                    target.Expression, typeof(CallbackItem)
                    );


                DYN.BindingRestrictions baseRestriction = DYN.BindingRestrictions.GetTypeRestriction(
                    target.Expression, target.LimitType
                    );

                DLR.Expression callbackAFunctionExpression = DLR.Expression.Convert(
                    DLR.Expression.Convert(target.Expression, typeof(CallbackItem))
                    .Property("CallbackFunction").Property("Data"),
                    typeof(AFunc)
                    );

                DYN.BindingRestrictions valenceRestriction =
                    DYN.BindingRestrictions.GetExpressionRestriction(
                        DLR.Expression.Equal(
                            callbackAFunctionExpression.Property("Valence"),
                            DLR.Expression.Constant(callbackAFunction.Valence)
                            )
                        );

                // TODO: refactor the argument generation, something similar is in the InvokeBinder

                IEnumerable <DLR.Expression> callbackBaseArguments = new DLR.Expression[] {
                    callbackItemExpression.Property("StaticData"),             // static data
                    DLR.Expression.Convert(args[1].Expression, typeof(AType)), // new value
                    DLR.Expression.Convert(args[2].Expression, typeof(AType)), // index/set of indices
                    DLR.Expression.Convert(args[3].Expression, typeof(AType)), // path (left argument of pick)
                    callbackItemExpression.Property("Context"),                // context of the global variable
                    callbackItemExpression.Property("UnqualifiedName")         // name of the global variable
                }.Where((item, i) => i < callbackAFunction.Valence - 1).Reverse();
                List <DLR.Expression> callbackArguments = new List <DLR.Expression>();

                // Aplus
                callbackArguments.Add(DLR.Expression.Convert(args[0].Expression, args[0].RuntimeType));
                callbackArguments.AddRange(callbackBaseArguments);


                Type[] callTypes = new Type[callbackAFunction.Valence + 1];
                callTypes[0] = typeof(Aplus);

                for (int i = 1; i < callbackAFunction.Valence; i++)
                {
                    callTypes[i] = typeof(AType);
                }

                // return type
                callTypes[callbackAFunction.Valence] = typeof(AType);


                DLR.Expression codeBlock = DLR.Expression.Invoke(
                    DLR.Expression.Convert(
                        callbackAFunctionExpression.Property("Method"),
                        DLR.Expression.GetFuncType(callTypes)
                        ),
                    callbackArguments
                    );

                DYN.DynamicMetaObject dynobj =
                    new DYN.DynamicMetaObject(codeBlock, baseRestriction.Merge(valenceRestriction));

                return(dynobj);
            }

            // Throw a non-function error
            return(new DYN.DynamicMetaObject(
                       DLR.Expression.Throw(
                           DLR.Expression.New(
                               typeof(Error.NonFunction).GetConstructor(new Type[] { typeof(string) }),
                               DLR.Expression.Call(
                                   target.Expression,
                                   typeof(object).GetMethod("ToString")
                                   )
                               ),
                           typeof(Error.NonFunction)
                           ),
                       DYN.BindingRestrictions.GetTypeRestriction(target.Expression, target.RuntimeType)
                       ));
        }
        // private GInterface163 test;
        private void Update()
        {
            #region Capture scene name for checks
            if (Time.time >= _scanSceneR)
            {
                _scanSceneR      = Time.time + 5f;
                this.m_Scen      = SceneManager.GetActiveScene();
                this.m_Scen_name = m_Scen.name;
            }
            #endregion
            #region Hotkeys
            //if (Input.GetKeyDown(KeyCode.End))
            //{ Unload(); } // never unload

            if (Input.GetKeyDown(KeyCode.F8))
            {
                if (saveVector.y == 0f)
                {
                    saveVector = MovementState.G;
                }

                if (MovementState.G_y == 0.00001f)
                {
                    MovementState.G   = saveVector;
                    MovementState.G_y = saveVector.y;
                }
                else
                {
                    MovementState.G   = new Vector3(0.00001f, 0.00001f, 0.00001f);
                    MovementState.G_y = 0.00001f;
                }

                // test.imethod_saveProgress();
                //    DUMP.DUMPER();
            }

            if (Input.GetKeyDown(KeyCode.F11))
            {
                Debug.logger.logEnabled = !Debug.logger.logEnabled;
            }
            if (Input.GetKeyDown(KeyCode.Home))
            {
                _pInfor = !_pInfor;
            }
            if (Input.GetKeyDown(KeyCode.Insert))
            {
                _cH = !_cH;
            }
            #region Porting
            if (Input.GetKeyDown(KeyCode.F10) && _lP != null)
            {
                //if (Time.time >= _secTime) {
                // _secTime = Time.time + 1f;
                _lP.Transform.position = _lP.Transform.position + Camera.main.transform.forward * 1f;
                //}
            }
            if (Input.GetKeyDown(KeyCode.Keypad2) && _lP != null)
            {
                _lP.Transform.position = new Vector3(_lP.Transform.position.x, _lP.Transform.position.y - 1f, _lP.Transform.position.z);
            }
            if (Input.GetKeyDown(KeyCode.Keypad8) && _lP != null)
            {
                _lP.Transform.position = new Vector3(_lP.Transform.position.x, _lP.Transform.position.y + 1f, _lP.Transform.position.z);
            }
            #endregion
            if (Input.GetKeyDown(KeyCode.F9))
            {
                _rec = !_rec;
            }
            #endregion
            #region mouse events capture for AFunc
            if (Input.GetMouseButtonDown(1))
            {
                _aim = true;
            }
            if (Input.GetMouseButtonUp(1))
            {
                _aim = false;
            }
            if (Input.GetKeyDown(KeyCode.F5))
            {
                _aimA = !_aimA;
            }
            #endregion
            #region AFunc activator with preventions
            if (_aim && _aimA && m_Scen_name != "EnvironmentUIScene" && m_Scen_name != "MenuUIScene")
            {
                AFunc.DPI_Detection(_ply, _lP, _AimSpeed, 200f, 50);
            }
            #endregion
        }
예제 #29
0
 public override AType ExecutePrimitive(AFunc argument, Aplus environment = null)
 {
     return(new AReference(argument));
 }
예제 #30
0
 public static AType CreateBuiltIn(string name, object method, string codestring, bool derived)
 {
     AFunc function = new AFunc(name, method, 3, codestring);
     function.builtin = true;
     function.derived = derived;
     return new AReference(function);
 }
예제 #31
0
        /// <summary>
        /// Execute 'dyadic' Each algorithm.
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="environment"></param>
        /// <param name="isNull"></param>
        /// <param name="function"></param>
        /// <returns></returns>
        private AType Walker(AType left, AType right, Aplus environment, bool isNull, AFunc function)
        {
            if (left.IsArray)
            {
                AType result = AArray.Create(ATypes.AArray);

                AType rightArray = right.IsArray ? right : AArray.Create(right.Type, right);

                for (int i = 0; i < left.Length; i++)
                {
                    result.AddWithNoUpdate(Walker(left[i], rightArray[right.IsArray ? i : 0], environment, isNull, function));
                }

                result.Type   = isNull ? ATypes.ANull : ATypes.ABox;
                result.Length = left.Length;
                result.Shape  = new List <int>(left.Shape);
                result.Rank   = left.Rank;

                return(result);
            }
            else
            {
                if (right.IsArray)
                {
                    AType result = AArray.Create(ATypes.AArray);

                    for (int i = 0; i < right.Length; i++)
                    {
                        result.AddWithNoUpdate(Walker(left, right[i], environment, isNull, function));
                    }

                    result.Type   = isNull ? ATypes.ANull : ATypes.ABox;
                    result.Length = right.Length;
                    result.Shape  = new List <int>(right.Shape);
                    result.Rank   = right.Rank;

                    return(result);
                }
                else
                {
                    //Disclose left and right scalar argument.
                    AType disclosedRight = MonadicFunctionInstance.Disclose.Execute(right, environment);
                    AType disclosedLeft  = MonadicFunctionInstance.Disclose.Execute(left, environment);

                    var method = (Func <Aplus, AType, AType, AType>)function.Method;

                    //Execute the holden function and enclose the result.
                    AType result = method(environment, disclosedRight, disclosedLeft);
                    result = MonadicFunctionInstance.Enclose.Execute(result);

                    return(result);
                }
            }
        }
예제 #32
0
 public static AType CreateUserOperator(string name, bool isDyadic, object method, int valence, string codestring)
 {
     AFunc op = new AFunc(name, method, valence, codestring);
     op.isOperator = true;
     op.isDyadic = isDyadic;
     return new AReference(op);
 }