Esempio n. 1
0
        static void CALL_Execute(SIL_Action action)
        {
            SILFunction function = (SILFunction)action.ParsingArgs[0];
            ISILObject  value    = function.Value;

            action.ExecutionArgs = new object[] { value };
        }
Esempio n. 2
0
        public static void Execute()
        {
            SILFunction mainFunction = new SILFunction("Main", new ISILObject[] {});
            SIL_Action  action       = new SIL_Action(ActionType.CALL, new object[] { mainFunction }, 0, "Main");

            action.OnAction += new SIL_Action.Action(action_OnAction);
            executeSymbols_[action.ActionType](action); //first execute internal logic
            action.Execute();                           //lin action with GUI
        }
Esempio n. 3
0
        static ActionType CALL_Parse(string functionspace, string unparsedArgs, ref object[] parsedArgs, ref int lineNumber)
        {
            string parameters = unparsedArgs.Substring(5, unparsedArgs.Length - 5);

            if (!parameters.Contains("("))
            {
                throw new Exception("\"(\" Expected!");
            }
            string[] split = parameters.Split(new char[] { '(' }, StringSplitOptions.RemoveEmptyEntries);
            if (split.Length != 2)
            {
                throw new SyntaxErrorException();
            }
            string            functionName = split[0];
            FunctionPrototype prototype    = FunctionTable.Get(functionName);

            //Parse parameters & their types
            split[1] = split[1].Trim();
            if (split[1][split[1].Length - 1] != ')')
            {
                throw new Exception("\")\" Expected!");
            }
            split[1] = split[1].Substring(0, split[1].Length - 1);
            string[] split2 = split[1].Split(',');
            if (split2.Length == 1 && split2[0].Trim() == "")
            {
                split2 = new string[] { }
            }
            ;
            if (split2.Length != prototype.ParameterTypes.Length)
            {
                throw new Exception("Incorrect number of arguments!");
            }
            List <ISILObject> functionParameters = new List <ISILObject>();

            for (int i = 0; i < split2.Length; i++)
            {
                string parameter_s = split2[i].Trim();
                if (parameter_s == "")
                {
                    throw new Exception(string.Format("Missing parameter type and name for argument #{0}!", i));
                }
                ISILObject parameter;
                if (SIL_Math.IsEquation(parameter_s))
                {
                    parameter = ExpressionParse(functionspace, parameter_s, new List <ISILObject>());
                }
                else
                {
                    parameter = Retrieve_SIL_Object(functionspace, parameter_s, null);
                }

                if ((prototype.ParameterTypes[i] == ObjectType.Array && parameter.Type != ObjectType.Array) ||
                    (prototype.ParameterTypes[i] == ObjectType.Integer && parameter.Type == ObjectType.Array))
                {
                    throw new Exception(
                              string.Format("Incorrect type of parameter #{0}, {1} expexted!",
                                            i, Enum.GetName(typeof(ObjectType), prototype.ParameterTypes[i])));
                }
                functionParameters.Add(parameter);
            }

            SILFunction function = new SILFunction(functionName, functionParameters.ToArray());

            parsedArgs = new object[] { function };
            return(ActionType.CALL);
        }