예제 #1
0
        public ParameterVar AssignParameterVar(List <Element> actions, ScopeGroup scopeGroup, bool isGlobal, string name, Range range)
        {
            ParameterVar var = new ParameterVar(actions, scopeGroup, name, isGlobal, UseVar, Assign(isGlobal), range);

            AllVars.Add(var);
            return(var);
        }
예제 #2
0
        public DefinedVar AssignDefinedVar(ScopeGroup scopeGroup, bool isGlobal, string name, Range range)
        {
            DefinedVar var = new DefinedVar(scopeGroup, name, isGlobal, UseVar, Assign(isGlobal), range);

            AllVars.Add(var);
            return(var);
        }
예제 #3
0
        public Var AssignVar(string name, bool isGlobal)
        {
            Var var = new Var("INTERNAL : " + name, isGlobal, UseVar, Assign(isGlobal));

            AllVars.Add(var);
            return(var);
        }
예제 #4
0
        /// <summary>
        /// Adds a variable to the collection of variables of the given type
        /// </summary>
        /// <typeparam name="T">The type matching the target collection of variables</typeparam>
        /// <param name="v">The variable to add to the collection of matching type</param>
        /// <returns>Returns true if the variable was successfully added</returns>
        public bool AddVariable <T>(T v)
        {
            Type varType = typeof(T);

            if (varType == typeof(IndependentVariable))
            {
                IndependentVariable iv = (IndependentVariable)Convert.ChangeType(v, typeof(IndependentVariable));
                if (!IndVars.ContainsKey(iv.Name))
                {
                    IndVars.Add(iv.Name, iv);
                }
                if (!AllVars.ContainsKey(iv.Name))
                {
                    AllVars.Add(iv.Name, iv);
                }
            }
            else
            {
                DependentVariable dv = (DependentVariable)Convert.ChangeType(v, typeof(DependentVariable));

                if (!DepVars.ContainsKey(dv.Name))
                {
                    DepVars.Add(dv.Name, dv);
                }
                if (!AllVars.ContainsKey(dv.Name))
                {
                    AllVars.Add(dv.Name, dv);
                }
            }
            return(true);
        }
예제 #5
0
        public void WeirdChamp(string varName, string type)
        {
            bool contains = false;
            Dictionary <string, string> table = new Dictionary <string, string>();

            if (Variables.ContainsKey(varName) || VariablesInt.ContainsKey(varName) || VariablesFloat.ContainsKey(varName))
            {
                contains = true;
            }
            switch (type)
            {
            case "string":
                table = Variables;
                break;

            case "int":
                table = VariablesInt;
                break;

            case "float":
                table = VariablesFloat;
                break;

            default:
                p.ExceptionHandler(11, LineN, Line);
                break;
            }
            if (contains)
            {
                if (!table.ContainsKey(varName))
                {
                    p.ExceptionHandler(6, LineN, Line);
                }
                else
                {
                    try
                    {
                        table[varName] = Console.ReadLine();
                    }
                    catch
                    {
                        p.ExceptionHandler(10, LineN, Line);
                    }
                }
            }
            else
            {
                try
                {
                    table.Add(varName, Console.ReadLine());
                    AllVars.Add(varName, table);
                }
                catch
                {
                    p.ExceptionHandler(10, LineN, Line);
                }
            }
        }
예제 #6
0
        public void PogU(string varName, string type, string value)
        {
            bool contains = false;
            Dictionary <string, string> table = new Dictionary <string, string>();

            if (Variables.ContainsKey(varName) || VariablesInt.ContainsKey(varName) || VariablesFloat.ContainsKey(varName))
            {
                contains = true;
            }
            switch (type)
            {
            case "string":
                table = Variables;
                break;

            case "int":
                table = VariablesInt;
                break;

            case "float":
                table = VariablesFloat;
                break;

            case "default":
                p.ExceptionHandler(11, LineN, Line);
                break;
            }
            if (contains)
            {
                if (!table.ContainsKey(varName))
                {
                    p.ExceptionHandler(6, LineN, Line);
                }
                else
                {
                    table[varName] = value;
                }
            }
            else
            {
                table.Add(varName, value);
                AllVars.Add(varName, table);
            }
        }