Ejemplo n.º 1
0
 public Value.Value_Type ValueType(string value)
 {
     //Find out if checking variable
     //if checking variable return variable value type
     //else return variable type
     if (value == "{" || IsArray(value))
     {
         return(Value.Value_Type.Array);
     }
     if (InnerVariables.IsVariable(value))
     {
         return(InnerVariables.GetVariable(value).ValueType());
     }
     else if (OuterVariables != null && OuterVariables.IsVariable(value))
     {
         return(OuterVariables.GetVariable(value).ValueType());
     }
     else if (GlobalVariables.IsVariable(value))
     {
         return(GlobalVariables.GetVariable(value).ValueType());
     }
     else
     {
         return(Value.ValueType(value));
     }
 }
Ejemplo n.º 2
0
        void ArrayValueChangeStatement(Statement statement)
        {
            //elements[$elements-1] = "Nothing else";
            string variableName = statement.tokens[0].Split('[')[0];

            int indexOfVName     = statement.tokens[0].IndexOf(variableName) + variableName.Length + 1;
            int indexOfLastBrack = statement.tokens[0].LastIndexOf(']');

            string pointerIndex    = statement.tokens[0].Substring(indexOfVName, indexOfLastBrack - indexOfVName);
            int    pointerIndexInt = (int)valueHanlder.ParseNumberExpression(pointerIndex, Math.MathEngine.ReturnType.Int);

            Array arr = null;

            if (InnerVariables.IsArray(variableName))
            {
                arr = (Array)InnerVariables.GetVariable(variableName);
            }
            else if (OuterVariables.IsArray(variableName))
            {
                arr = (Array)OuterVariables.GetVariable(variableName);
            }
            else if (GlobalVariables.IsArray(variableName))
            {
                arr = (Array)GlobalVariables.GetVariable(variableName);
            }
            else
            {
                //Throw
                //To be implemented
            }

            List <string> internalTokens = new List <string>();

            for (int i = 2; i < statement.tokens.Count - 1; i++)
            {
                internalTokens.Add(statement.tokens[i]);
            }

            dynamic value = valueHanlder.ParseStringExpression(internalTokens, false);

            arr.SetValue(value, pointerIndexInt);
        }