Example #1
0
        public override bool Run(Variables runtime)
        {
            if (++_iterations > Program.MaxIterations)
            {
                throw new Exception(string.Format("Stackoverflow. Max iterations is {0}", Program.MaxIterations));
            }
            ;

            if (ExternalFunction == null)
            {
                FunctionScope.Run(runtime);
            }
            else
            {
                ValueBase parm0  = runtime.GetVariable(Parameters[0].TheName);
                var       parm0s = parm0 as ValueTyped <string>;
                if (parm0s == null)
                {
                    throw new Exception(string.Format("The parameter '{0}' for function '{1}' is not a string", Parameters[0].TheName, Name));
                }

                ExternalFunction(parm0s.Value);
            }
            _iterations--;
            return(false);
        }
Example #2
0
        public void BuildVariable(DefType theType, string name, CodeElement elem)
        {
            if (Vars.ContainsKey(name))
            {
                throw new Exception(string.Format("A variable called '{0}', {1}, is allready declared", name, elem.GetLineAndColumn()));
            }

            ValueBase variable = ValueBase.Compile(theType, this, null);

            Vars.Add(name, variable);
        }
Example #3
0
        public Variables InitiateVariables(Variables runtime)
        {
            var parm = new Dictionary <string, ValueBase>();

            for (int i = 0; i < Parameters.Count; i++)
            {
                parm.Add(Func.Parameters[i].TheName, ValueBase.Create(Func.Parameters[i].TheType, runtime, Parameters[i]));
            }

            if (Func.FuncType != DefType.Void)
            {
                parm.Add(ProgramBuilder.VariableReturn, ValueBase.Create(Func.FuncType));
            }

            return(new Variables(runtime, parm));
        }
Example #4
0
        public void DeclareVariable(DefType theType, string name, ExpBase exp)
        {
            ValueBase variable = ValueBase.Create(theType, this, exp);

            Vars.Add(name, variable);
        }