Ejemplo n.º 1
0
 public static void Set(string Name, SILInteger value)
 {
     if (!symbols_.ContainsKey(Name))
     {
         throw new Exception(String.Format("Key \"{0}\" was not found!", Name));
     }
     symbols_[Name] = value;
 }
Ejemplo n.º 2
0
        //Might be a good idea to move the below functions somewhere else?

        /// <summary>
        /// This function parses a variable into a correct SIL_Object class
        /// {number} = equation pulled from equations array
        /// xyz = user variable
        /// 123 = system variable
        /// </summary>
        /// <param name="variable"></param>
        /// <param name="equations"></param>
        /// <returns></returns>
        static ISILObject Retrieve_SIL_Object(string functionspace, string variable, List <ISILObject> equations)
        {
            variable = variable.Trim();
            //is it equation?
            if (variable.Contains('{'))
            {
                //remove the brackets
                variable = variable.Replace("{", "");
                variable = variable.Replace("}", "");
                int equationIndex = int.Parse(variable);
                return(equations[equationIndex]);
            }
            //is it a number?
            int iVal = 0;

            if (int.TryParse(variable, out iVal))
            {
                SILInteger silInt = new SILInteger();
                silInt = iVal;
                return(silInt);
            }
            if (variable.Contains("[]"))
            {
                return(ArrayTable.Arrays[functionspace + "." + variable.Substring(0, variable.Length - 2)]);
            }
            if (variable.Contains('['))
            {
                return(SILArrayElement.Parse(variable, functionspace));
            }
            if (variable.Contains('('))
            {
                SILFunction function;
                object[]    functionArgs = null;
                int         linenumber   = 0;
                CALL_Parse(functionspace, "CALL " + variable, ref functionArgs, ref linenumber);
                function = (SILFunction)functionArgs[0];
                return(function);
            }
            //is it a variable?
            SILVariable silVar = new SILVariable(functionspace + "." + variable); //naming validation is inside

            //if the variable is incorrectly named validation will throw an exception
            return(silVar);
        }