Beispiel #1
0
        Variable addition_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            Double sum = 0;

            foreach (Address addr in _parameter_addresses)
            {
                Variable var = RuntimeEngine.GetVariable(addr);
                double   tempval;
                if (var.Value.GetType() == typeof(int))
                {
                    tempval = (int)var.Value;
                }
                else
                {
                    tempval = (Double)var.Value;
                }
                sum += tempval;
                if (var.Address.Name.Contains("$SYSTEM$_temp"))
                {
                    RuntimeEngine.GetPool(addr.Parent).Pull(addr.Name);
                }
            }
            Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
 public Variable this[string tuple_field_name]
 {
     get
     {
         Address addr = new Address(Address.Path, Address.Name + "." + tuple_field_name, AddressType.Variable);
         return(RuntimeEngine.GetVariable(addr));
     }
 }
Beispiel #3
0
        private Variable Length_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            string   str    = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value;
            Variable result = new Variable(str.Length, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #4
0
        private Variable ToString_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            Variable var0   = RuntimeEngine.GetVariable(_parameter_addresses[0]);
            Variable result = new Variable(var0.Value.ToString(), TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #5
0
        private Variable EqualSign_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            Variable var0   = RuntimeEngine.GetVariable(_parameter_addresses[0]);
            Variable var1   = RuntimeEngine.GetVariable(_parameter_addresses[1]);
            Variable result = new Variable((int)var0.Value == (int)var1.Value, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Boolean", AddressType.Type)));

            return(result);
        }
Beispiel #6
0
        Variable not_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            Variable var    = RuntimeEngine.GetVariable(_parameter_addresses[0]);
            bool     sum    = (bool)var.Value;
            Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Boolean", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #7
0
        private Variable FromString_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            Variable var0 = RuntimeEngine.GetVariable(_parameter_addresses[0]);
            bool     outint;

            bool.TryParse((string)var0.Value, out outint);
            Variable result = new Variable(outint, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Boolean", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #8
0
        Variable subtraction_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            int      diff = 0;
            Variable var0 = RuntimeEngine.GetVariable(_parameter_addresses[0]);
            Variable var1 = RuntimeEngine.GetVariable(_parameter_addresses[1]);

            diff = (int)var0.Value - (int)var1.Value;
            Variable result = new Variable(diff, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #9
0
        Variable and_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            bool sum = true;

            foreach (Address addr in _parameter_addresses)
            {
                Variable var = RuntimeEngine.GetVariable(addr);
                sum = sum && (bool)var.Value;
            }
            Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Boolean", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #10
0
        Variable addition_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            int sum = 0;

            foreach (Address addr in _parameter_addresses)
            {
                Variable var = RuntimeEngine.GetVariable(addr);
                sum += (int)var.Value;
            }
            Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #11
0
        private Variable Removal_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            string removed = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value;

            for (int i = 1; i < _parameter_addresses.Length; i++)
            {
                string toremove = (string)RuntimeEngine.GetVariable(_parameter_addresses[i]).Value;
                removed = removed.Replace(toremove, "");
            }
            Variable result = new Variable(removed, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #12
0
        private Variable Multipleconcat_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            string   concatto = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value;
            Variable result   = new Variable();

            RuntimeEngine.PutVariable(_destination_address, result);
            for (int i = 1; i < _parameter_addresses.Length; i++)
            {
                Variable concat = new Variable(concatto + (string)RuntimeEngine.GetVariable(_parameter_addresses[i]).Value,
                                               TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type)));
                result.AddTupleValue((i - 1) + "", concat);
            }
            return(result);
        }
Beispiel #13
0
        private Variable Concatenation_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            string sum = "";

            foreach (Address addr in _parameter_addresses)
            {
                Variable var = RuntimeEngine.GetVariable(addr);
                sum += (string)var.Value;
            }
            Variable result = new Variable(sum, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #14
0
        private Variable Indexof_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            string str = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value;
            string of  = (string)RuntimeEngine.GetVariable(_parameter_addresses[1]).Value;
            int    idx = 0;

            if (_parameter_addresses.Length > 2)
            {
                idx = (int)RuntimeEngine.GetVariable(_parameter_addresses[2]).Value;
            }
            idx = str.IndexOf(of, idx);
            Variable result = new Variable(idx, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #15
0
        private Variable Substring_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            string str  = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value;
            int    from = (int)RuntimeEngine.GetVariable(_parameter_addresses[1]).Value;
            int    to   = str.Length;

            if (_parameter_addresses.Length > 2)
            {
                to = (int)RuntimeEngine.GetVariable(_parameter_addresses[2]).Value;
            }
            str = str.Substring(from, to - from);
            Variable result = new Variable(str, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #16
0
        Variable division_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            int      quotient  = 0;
            int      remainder = 0;
            Variable var0      = RuntimeEngine.GetVariable(_parameter_addresses[0]);
            Variable var1      = RuntimeEngine.GetVariable(_parameter_addresses[1]);

            quotient  = (int)var0.Value / (int)var1.Value;
            remainder = (int)var0.Value - (quotient * (int)var1.Value);
            Variable result = new Variable(quotient, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            Variable remaindertup = new Variable(remainder, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.Type)));

            result.AddTupleValue("Remainder", remaindertup);
            return(result);
        }
Beispiel #17
0
        private Variable FromString_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            Variable var0   = RuntimeEngine.GetVariable(_parameter_addresses[0]);
            double   outint = 0.0;

            if (var0.Value.GetType() == typeof(string))
            {
                double.TryParse((string)var0.Value, out outint);
            }
            else
            {
                string double_str = var0.Value.ToString();
                double.TryParse(double_str, out outint);
            }
            Variable result = new Variable(outint, TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Real", AddressType.Type)));

            RuntimeEngine.PutVariable(_destination_address, result);
            return(result);
        }
Beispiel #18
0
        private Variable Split_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            string concatto = (string)RuntimeEngine.GetVariable(_parameter_addresses[0]).Value;

            string[] splistrs = new string[_parameter_addresses.Length - 1];
            Variable result   = new Variable();

            RuntimeEngine.PutVariable(_destination_address, result);
            for (int i = 1; i < _parameter_addresses.Length; i++)
            {
                string str = (string)RuntimeEngine.GetVariable(_parameter_addresses[i]).Value;
                splistrs[i - 1] = str;
            }
            string[] splits = concatto.Split(splistrs, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < splits.Length; i++)
            {
                Variable concat = new Variable(splits[i], TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "String", AddressType.Type)));
                result.AddTupleValue(i + "", concat);
            }
            return(result);
        }
Beispiel #19
0
        Variable castFromInteger_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            Variable integerOne = RuntimeEngine.GetVariable(_parameter_addresses[0]);
            double   temp_double;

            if (integerOne.Value.GetType() == typeof(double))
            {
                temp_double = (double)integerOne.Value;
            }
            else
            {
                temp_double = (int)integerOne.Value;
            }
            int      value    = (int)temp_double;
            Double   real     = value * 1.0;
            Type     realType = TypeEngine.GetType(new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Real", AddressType.Type));
            Variable realOne  = new Variable(real, realType);

            RuntimeEngine.PutVariable(_destination_address, realOne);
            return(realOne);
        }
        public static bool ParametersMatch(Function function, params Address[] _parameters)
        {
            bool equivalence = function._function_parameters.Count == _parameters.Length;

            if (function.SingleRepetitiveParameterized)
            {
                equivalence = true;
            }
            if (equivalence)
            {
                if (_parameters.Length == 0)
                {
                    return(true);
                }
                equivalence = true;
                for (int i = 1; i < _parameters.Length && equivalence; i++)
                {
                    Variable temp = RuntimeEngine.GetVariable(_parameters[i]);
                    if (!function.SingleRepetitiveParameterized)
                    {
                        bool funcequal = function.Parameters[i].Equals(temp.Type.Address);
                        bool hascastto = temp.Type.HasCastTo(function.Parameters[i]);
                        equivalence = equivalence && (funcequal || hascastto);
                    }
                    else
                    {
                        bool funcequal = function.Parameters[0].Equals(temp.Type.Address);

                        /*if (temp.Type.Address.FullPath.Equals("/Object"))
                         * {
                         *  Variable temp_var = new Variable(temp.Value, )
                         * }*/
                        bool hascastto = temp.Type.HasCastTo(function.Parameters[0]);
                        equivalence = equivalence && (funcequal || hascastto);
                    }
                }
                return(equivalence);
            }
            return(false);
        }
        public Variable Execute(Address _destination_address, params Address[] _parameters)
        {
            Variable[] vars = new Variable[_parameters.Length];
            vars[0] = RuntimeEngine.GetVariable(_parameters[0]);
            bool matching = true;
            int  i        = 1;

            for (; i < _parameters.Length; i++)
            {
                vars[i] = RuntimeEngine.GetVariable(_parameters[i]);
                int idx = i;
                if (_single_repetitive_parameterized)
                {
                    idx = 0;
                }
                if (vars[i].Type.HasCastTo(Parameters[idx]))
                {
                    Address  _tempAddress = new Address(_parameters[i].Path, "$SYSTEM$_temp" + ICASMInterpreter.TemporaryVariableCount, AddressType.Variable);
                    Variable _tempCast    = vars[i].Type.ExecuteFunction(_tempAddress, "$SYSTEM$_Runtime.CastTo_" + Parameters[idx].FullPath.Replace("/", "_").Replace("/$SYSTEM$_Runtime.TypeSpace@TypeEngine", ""), _parameters[i]);
                    _parameters[i] = _tempAddress;
                    ICASMInterpreter.MemoryStack.Push(_tempAddress);
                    ICASMInterpreter.TemporaryVariableCount++;
                    vars[i] = _tempCast;
                }
                matching = matching && (vars[i].Type.Address.Equals(Parameters[idx]));
                if (!matching)
                {
                    break;
                }
            }
            if (i == _parameters.Length)
            {
                return(ExecuteFunction(this, _destination_address, _parameters));
            }
            else
            {
                return(null);
            }
        }
Beispiel #22
0
        private Variable ICASMFunction_ExecuteFunction(Function _executing_function, Address _destination_address, params Address[] _parameter_addresses)
        {
            ICASMFunction func = (ICASMFunction)_executing_function;

            string[] statements = func.ExecutionQueue.ToArray();
            for (int i = 0; i < statements.Length; i++)
            {
                for (int j = 0; j < _parameter_addresses.Length; j++)
                {
                    statements[i] = statements[i].Replace("[" + j + "]", _parameter_addresses[j].FullPath);
                }
            }
            Scope _functionScope                 = new Scope("/" + func.Name);
            ICASMExecutionResult result          = ICASMInterpreter.Execute(_functionScope, statements);
            Variable             result_variable = null;

            if (result.Data.ContainsKey("ReturnDirective"))
            {
                result_variable = RuntimeEngine.GetVariable((Address)result.Data["ReturnDirective"]);
                RuntimeEngine.PutVariable(_destination_address, result_variable);
            }
            return(result_variable);
        }
Beispiel #23
0
        public static ICASMValue ParseValue(string value)
        {
            value = value.Trim();
            bool isType = false;

            if (value.StartsWith("typeof"))
            {
                value = value.Substring(6).Trim();
                if (value.StartsWith("(") && value.EndsWith(")"))
                {
                    value = value.Substring(1, value.Length - 2).Trim();
                    if (value.Equals("stack"))
                    {
                        return(new ICASMValue(ICASMValueType.Address, RuntimeEngine.GetVariable(ICASMInterpreter.MemoryStack.Peek()).Type.Address.FullPath));
                    }
                    else if (value.Equals("stackp"))
                    {
                        return(new ICASMValue(ICASMValueType.Address, RuntimeEngine.GetVariable(ICASMInterpreter.MemoryStack.Pop()).Type.Address.FullPath));
                    }
                    isType = true;
                }
            }
            int intValue; double doubleValue; bool boolValue;

            if (bool.TryParse(value, out boolValue))
            {
                if (isType)
                {
                    return(new ICASMValue(ICASMValueType.Address, "/Boolean"));
                }
                return(new ICASMValue(ICASMValueType.Normal, boolValue, ICASMPrimitiveDataType.Integer));
            }
            else if (int.TryParse(value, out intValue))
            {
                if (isType)
                {
                    return(new ICASMValue(ICASMValueType.Address, "/Integer"));
                }
                return(new ICASMValue(ICASMValueType.Normal, intValue, ICASMPrimitiveDataType.Integer));
            }
            else if (double.TryParse(value, out doubleValue))
            {
                if (isType)
                {
                    return(new ICASMValue(ICASMValueType.Address, "/Real"));
                }
                return(new ICASMValue(ICASMValueType.Normal, doubleValue, ICASMPrimitiveDataType.Real));
            }
            else if (value.StartsWith("'") && value.EndsWith("'") && value.Length == 3)
            {
                if (isType)
                {
                    return(new ICASMValue(ICASMValueType.Address, "/Character"));
                }
                return(new ICASMValue(ICASMValueType.Normal, value[1], ICASMPrimitiveDataType.Character));
            }
            else if (value.StartsWith("\"") && value.EndsWith("\""))
            {
                if (isType)
                {
                    return(new ICASMValue(ICASMValueType.Address, "/String"));
                }
                return(new ICASMValue(ICASMValueType.Normal, value.Substring(1, value.Length - 2),
                                      ICASMPrimitiveDataType.String));
            }
            LiteralGrammarElement lge = new LiteralGrammarElement("+var", "-var", "+pool", "-pool", "+type", "-type", "+field", "-field", "+fields", "-fields", "+typespace", "-typespace", "-all", "+function", "-function", "call", "assign", "goto", "return", "clear", "if", "elseif", "else", "while", "repeat", "end+");
            string temp = value;

            if (lge.Validate(ref temp, true).Result)
            {
                return(new ICASMValue(ICASMValueType.ExecutableResult, value));
            }
            Grammar checker = Infinity.Scripting.InfinityGrammarScript.LoadGrammar("Symbol Underscore = \"_\"\n" +
                                                                                   "SymbolSet Digit = new Digit\n" +
                                                                                   "SymbolSet ForwardSlash = [\"/\"]\n" +
                                                                                   "SymbolSet IdentifierStartSymbol = new Alphabet, Underscore\n" +
                                                                                   "SymbolSet IdentifierContinuationSymbol = new Alphabet, new Digit, Underscore\n" +
                                                                                   "SymbolSet DefaultOperators	= ['+','-','*','/','%','!','@','#','$','^','&','=','|',':','<','>','?']\n"+
                                                                                   "SymbolSet FunctionIdentifierSymbol = new Alphabet, Underscore, DefaultOperators\n" +
                                                                                   "GrammarElement Integer = Digit+\n" +
                                                                                   "GrammarElement Identifier = IdentifierStartSymbol IdentifierContinuationSymbol*\n" +
                                                                                   "GrammarElement FunctionIdentifier = FunctionIdentifierSymbol FunctionIdentifierSymbol*\n" +
                                                                                   "GrammarElement AddressNode = ForwardSlash Identifier\n" +
                                                                                   "GrammarElement Root = \"/\"\n" +
                                                                                   "GrammarElement PureAddress = AddressNode AddressNode *\n" +
                                                                                   "GrammarElement DotIdentifier = \".\" Identifier\n" +
                                                                                   "GrammarElement TupleAddress = PureAddress DotIdentifier *\n" +
                                                                                   "GrammarElement Address = TupleAddress or PureAddress, precedence: Ascending\n" +
                                                                                   "GrammarElement ParameterAccess = \"[\" Integer \"]\" DotIdentifier*\n" +
                                                                                   "GrammarElement AddressorRoot = Address or Root, precedence: Ascending\n" +
                                                                                   "StartSymbol = AddressorRoot");

            temp = value;
            if (checker.Terminals["AddressorRoot"].Validate(ref temp, true).Result)
            {
                if (isType)
                {
                    return(new ICASMValue(ICASMValueType.Address, RuntimeEngine.GetVariable(value).Type.Address.FullPath));
                }
                return(new ICASMValue(ICASMValueType.Address, value));
            }
            temp = value;
            if (checker.Terminals["ParameterAccess"].Validate(ref temp, true).Result)
            {
                return(new ICASMValue(ICASMValueType.FunctionParameterAccess, value));
            }
            temp = value;
            if (checker.Terminals["Identifier"].Validate(ref temp, true).Result)
            {
                if (value.Equals("stack"))
                {
                    return(new ICASMValue(ICASMValueType.Address, ICASMInterpreter.MemoryStack.Peek().FullPath));
                }
                else if (value.Equals("stackp"))
                {
                    return(new ICASMValue(ICASMValueType.Address, ICASMInterpreter.MemoryStack.Pop().FullPath));
                }
                if (isType)
                {
                    return(new ICASMValue(ICASMValueType.Address, RuntimeEngine.GetVariable("/" + value).Type.Address.FullPath));
                }
                return(new ICASMValue(ICASMValueType.Identifier, value));
            }
            temp = value;
            if (checker.Terminals["FunctionIdentifier"].Validate(ref temp, true).Result)
            {
                return(new ICASMValue(ICASMValueType.FunctionIdentifier, value));
            }
            return(null);
        }
Beispiel #24
0
        public static ICASMExecutionResult Execute(Scope _currentScope, ICASMDirectiveType type, ICASMTagType tag, ICASMDirectiveParameters parameters)
        {
            ICASMExecutionResult result = new ICASMExecutionResult()
            {
                Success = true
            };
            ICASMValue varname, varvalue, varscope, vartype;
            Variable   variable;
            Address    address;
            string     _ideoutput = "";

            switch (type)
            {
                #region VariableAddDirective
            case ICASMDirectiveType.VariableAddDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tVariableAddDirective, usage - \n\t+var <name> <?scope> <?type> <?value>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0].Check(ICASMValueType.Identifier);
                varscope = new ICASMValue(ICASMValueType.Address, "/");
                vartype  = null;
                varvalue = new ICASMValue(ICASMValueType.Normal, null);
                if (parameters.Count > 1)
                {
                    varscope = parameters[1].Check(ICASMValueType.Address);
                    if (parameters.Count > 2)
                    {
                        vartype = parameters[2].Check(ICASMValueType.Address);
                        if (parameters.Count > 3)
                        {
                            varvalue = parameters[3].Check(ICASMValueType.Address, ICASMValueType.ExecutableResult, ICASMValueType.Identifier, ICASMValueType.Normal);
                        }
                    }
                }
                Data.Type varType = null;
                if (vartype != null)
                {
                    varType = TypeEngine.GetType(Address.FromScope(new Scripting.Scope((string)vartype.Value)));
                }
                else
                {
                    varType = ICASMValue.GetTypeFromPrimitiveType(varvalue.PrimitiveType);
                }
                string[] memberCreation = varType.MemberCreationQueue.ToArray();
                variable = new Variable(varvalue.Value, varType);
                for (int i = 0; i < memberCreation.Length; i++)
                {
                    ICASMDirective _temp_directive_function_member = ICASMInterpreter.ParseDirective(_currentScope, memberCreation[i]);
                    if (_temp_directive_function_member.Type == ICASMDirectiveType.VariableAddDirective)
                    {
                        _temp_directive_function_member.SetTag(ICASMTagType.AppendTuple);
                        string varscopestr = (string)varscope.Value;
                        if (!varscopestr.Equals("/"))
                        {
                            varscopestr = varscopestr + "/";
                        }
                        _temp_directive_function_member.Parameters.Insert(1, new ICASMValue(ICASMValueType.Address, varscopestr + (string)varname.Value));
                        ICASMExecutionResult res = Execute(_currentScope, _temp_directive_function_member);
                        variable.TupleAddresses.Add((string)_temp_directive_function_member.Parameters[0].Value, (Address)res.Data["VariableAddDirective"]);
                    }
                }
                address = Address.FromScope(new Scripting.Scope((string)varscope.Value + "/" + (string)varname.Value));
                if (tag == ICASMTagType.Suppress)
                {
                    RuntimeEngine.CreatePool(address.Parent);
                    if (RuntimeEngine.GetPool(address.Parent).HasVariable(address.Name))
                    {
                        RuntimeEngine.GetPool(address.Parent).Pull(address.Name);
                    }
                }
                else if (tag == ICASMTagType.AppendTuple)
                {
                    address = Address.FromScope(new Scripting.Scope((string)varscope.Value + "." + (string)varname.Value));
                }
                RuntimeEngine.PutVariable(address, variable);
                result.Success = true;
                result.Data.Add(type.ToString(), address);
                break;

                #endregion
                #region VariableRemoveDirective
            case ICASMDirectiveType.VariableRemoveDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tVariableRemoveDirective, usage - \n\t-var <name> <?scope>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0].Check(ICASMValueType.Identifier);
                varscope = new ICASMValue(ICASMValueType.Address, "/");
                if (parameters.Count > 1)
                {
                    varscope = parameters[1].Check(ICASMValueType.Address);
                }
                VariablePool pool = RuntimeEngine.GetPool(Address.FromScope(new Scope((string)varscope.Value)));
                variable = pool.Pull((string)varname.Value);
                if (variable != null)
                {
                    result.Success = true;
                    result.Data.Add(type.ToString(), new Address((string)varscope.Value, (string)varname.Value, AddressType.Variable));
                }
                break;

                #endregion
                #region VariablePoolAddDirective
            case ICASMDirectiveType.VariablePoolAddDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tVariablePoolAddDirective, usage - \n\t+pool <name> <?scope>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0].Check(ICASMValueType.Identifier);
                varscope = new ICASMValue(ICASMValueType.Address, "/");
                if (parameters.Count > 1)
                {
                    varscope = parameters[1].Check(ICASMValueType.Address);
                }
                address = Address.FromScope(new Scope((string)varscope.Value + "/" + (string)varname.Value));
                RuntimeEngine.CreatePool(address);
                result.Success = true;
                result.Data.Add(type.ToString(), address);
                break;

                #endregion
                #region VariablePoolRemoveDirective
            case ICASMDirectiveType.VariablePoolRemoveDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tVariablePoolRemoveDirective, usage - \n\t-pool <name> <?scope>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0].Check(ICASMValueType.Identifier);
                varscope = new ICASMValue(ICASMValueType.Address, "/");
                if (parameters.Count > 1)
                {
                    varscope = parameters[1].Check(ICASMValueType.Address);
                }
                address = Address.FromScope(new Scope((string)varscope.Value + "/" + (string)varname.Value));
                RuntimeEngine.GetPool(address.Parent).PullPool(address.Name);
                result.Success = true;
                result.Data.Add(type.ToString(), address);
                break;

                #endregion
                #region CallDirective
            case ICASMDirectiveType.CallDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tCallDirective, usage - \n\tcall <type> <function name> <?parameters>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname = parameters[0];
                if (varname.Type == ICASMValueType.Identifier && varname.Value.Equals("type(stack)"))
                {
                    varname.Value = MemoryStack.Peek();
                }
                else
                {
                    varname = varname.Check(ICASMValueType.Address);
                }
                varscope = parameters[1];
                if ((string)varscope.Value == "/")
                {
                    varscope.Type = ICASMValueType.FunctionIdentifier;
                }
                varscope = varscope.Check(ICASMValueType.FunctionIdentifier, ICASMValueType.Identifier);
                if (parameters.Count > 2)
                {
                    Address[] _addresses = new Address[parameters.Count - 2];
                    for (int i = 2; i < parameters.Count; i++)
                    {
                        if (parameters[i].Type == ICASMValueType.Normal)
                        {
                            Data.Type ttt = ICASMValue.GetTypeFromPrimitiveType(parameters[i].PrimitiveType);
                            variable = new Variable(parameters[i].Value, ttt);
                            RuntimeEngine.PutVariable("/$SYSTEM$_temp" + (_temps), variable);
                            _addresses[i - 2] = "/$SYSTEM$_temp" + _temps;
                            MemoryStack.Push(_addresses[i - 2]);
                            _temps++;
                        }
                        else if (parameters[i].Type == ICASMValueType.Address)
                        {
                            _addresses[i - 2] = (string)parameters[i].Value;
                        }
                        else if (parameters[i].Type == ICASMValueType.Identifier)
                        {
                            _addresses[i - 2] = "/" + (string)parameters[i].Value;
                        }
                    }
                    address = (string)varname.Value;
                    string temp_address = "/$SYSTEM$_temp" + (_temps);
                    _executingFunction = true;
                    TypeEngine.GetType(address).ExecuteFunction(temp_address, (string)varscope.Value, _addresses);
                    MemoryStack.Push(temp_address);
                    address        = temp_address;
                    result.Success = true;
                    result.Data.Add(type.ToString(), (Address)temp_address);
                    _temps++;
                }
                break;

                #endregion
                #region AssignDirective
            case ICASMDirectiveType.AssignDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tAssignDirective, usage - \n\tassign <value> <address of variable>\n\t\t<value> - can be any primitive value, address, identifier or another nested <?call> or <?ewfc>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0];
                varscope = parameters[1].Check(ICASMValueType.Identifier, ICASMValueType.Address);
                address  = (string)varscope.Value;
                variable = new Variable();
                Address addr = null;
                if (varname.Type == ICASMValueType.Normal)
                {
                    Data.Type ttt = ICASMValue.GetTypeFromPrimitiveType(varname.PrimitiveType);
                    variable = new Variable(varname.Value, ttt);
                }
                else if (varname.Type == ICASMValueType.Identifier)
                {
                    addr     = "/" + (string)varname.Value;
                    variable = RuntimeEngine.GetVariable(addr);
                }
                else if (varname.Type == ICASMValueType.Address)
                {
                    addr     = (string)varname.Value;
                    variable = RuntimeEngine.GetVariable(addr);
                }
                if (tag == ICASMTagType.Suppress)
                {
                    RuntimeEngine.CreatePool(address.Parent);
                    VariablePool variablep = RuntimeEngine.GetPool(address.Parent);
                    if (variablep.HasVariable(address.Name))
                    {
                        variablep.Pull(address.Name);
                    }
                    RuntimeEngine.PutVariable(address, variable);
                }
                RuntimeEngine.SetVariable(address, variable);
                result.Success = true;
                result.Data.Add(type.ToString(), address);
                break;

                #endregion
                #region FunctionAddDirective
            case ICASMDirectiveType.FunctionAddDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tFunctionAddDirective, usage - \n\t+function <name> <type address> <function type> <?parameter type addresses>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname = parameters[0].Check(ICASMValueType.FunctionIdentifier, ICASMValueType.Identifier);
                if (varname == null && parameters[0].Value.Equals("/"))
                {
                    varname = parameters[0];
                }
                varscope = parameters[1].Check(ICASMValueType.Address);
                vartype  = parameters[2].Check(ICASMValueType.Identifier);
                List <Address> parametertypes = new List <Address>();
                int            j = 3;
                while (j < parameters.Count && parameters[j].Type == ICASMValueType.Address)
                {
                    parametertypes.Add((string)parameters[j].Value);
                    j++;
                }
                FunctionType  _newFunctionType = (FunctionType)Enum.Parse(typeof(FunctionType), (string)vartype.Value);
                ICASMFunction new_function     = new ICASMFunction((string)varname.Value, (string)varname.Value,
                                                                   _newFunctionType, (string)varscope.Value, parametertypes.ToArray());
                _mode           = ICASMInterpreterMode.Function;
                currentFunction = new_function;
                break;

                #endregion
                #region FunctionRemoveDirective
            case ICASMDirectiveType.FunctionRemoveDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tFunctionRemoveDirective, usage - \n\t+function <name> <type address>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                //To-do
                break;

                #endregion
                #region FieldsAddDirective
            case ICASMDirectiveType.FieldsAddDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tFieldsAddDirective, usage - \n\t+fields <type address>\n\t\t<... var add statements>\n\tend+";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname     = parameters[0].Check(ICASMValueType.Address);
                currentType = TypeEngine.GetType((string)varname.Value);
                _mode       = ICASMInterpreterMode.Fields;
                break;

                #endregion
                #region TypeAddDirective
            case ICASMDirectiveType.TypeAddDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tTypeAddDirective, usage - \n\t+type <name> <typespace address>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0].Check(ICASMValueType.Identifier);
                varscope = new ICASMValue(ICASMValueType.Address, "/");
                if (parameters.Count > 1)
                {
                    varscope = parameters[1].Check(ICASMValueType.Address);
                }
                Data.Type t = new Data.Type((string)varname.Value, (string)varscope.Value);
                TypeEngine.AddType(t.Address, t);
                break;

                #endregion
                #region TypeRemoveDirective
            case ICASMDirectiveType.TypeRemoveDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tTypeRemoveDirective, usage - \n\t-type <name> <typespace address>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0].Check(ICASMValueType.Identifier);
                varscope = new ICASMValue(ICASMValueType.Address, "/");
                if (parameters.Count > 1)
                {
                    varscope = parameters[1].Check(ICASMValueType.Address);
                }
                TypeSpace from = TypeEngine.GetTypeSpace((string)varscope.Value);
                if (from.HasType((string)varname.Value))
                {
                    from.Pull((string)varname.Value);
                }
                break;

                #endregion
                #region TypespaceAddDirective
            case ICASMDirectiveType.TypespaceAddDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tTypespaceAddDirective, usage - \n\t+typespace <name> <?typespace parent>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0].Check(ICASMValueType.Identifier);
                varscope = new ICASMValue(ICASMValueType.Address, "/");
                if (parameters.Count > 1)
                {
                    varscope = parameters[1].Check(ICASMValueType.Address);
                }
                TypeSpace _toCreateTypespaceIn = TypeEngine.GetTypeSpace((string)varscope.Value);
                _toCreateTypespaceIn.CreateTypeSpace((string)varname.Value);
                break;

                #endregion
                #region TypespaceRemoveDirective
            case ICASMDirectiveType.TypespaceRemoveDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tTypespaceRemoveDirective, usage - \n\t-typespace <name> <?typespace parent>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname  = parameters[0].Check(ICASMValueType.Identifier);
                varscope = new ICASMValue(ICASMValueType.Address, "/");
                if (parameters.Count > 1)
                {
                    varscope = parameters[1].Check(ICASMValueType.Address);
                }
                TypeSpace _toRemoveTypespaceFrom = TypeEngine.GetTypeSpace((string)varscope.Value);
                _toRemoveTypespaceFrom.PullTypeSpace((string)varname.Value);
                break;

                #endregion
                #region ReturnDirective
            case ICASMDirectiveType.ReturnDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tReturnDirective, usage - \n\treturn <identifier/address/value>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                address = null;
                varname = parameters[0].Check(ICASMValueType.Address, ICASMValueType.Identifier, ICASMValueType.Normal);
                if (varname.Type == ICASMValueType.Address)
                {
                    address = (string)varname.Value;
                }
                else if (varname.Type == ICASMValueType.Identifier)
                {
                    address = "/" + (string)varname.Value;
                }
                else if (varname.Type == ICASMValueType.Normal)
                {
                    Data.Type ttt = ICASMValue.GetTypeFromPrimitiveType(varname.PrimitiveType);
                    variable = new Variable(varname.Value, ttt);
                    RuntimeEngine.PutVariable("/$SYSTEM$_temp" + (_temps), variable);
                    address = "/$SYSTEM$_temp" + _temps;
                    MemoryStack.Push(address);
                    _temps++;
                }
                if (address != null)
                {
                    result.Success = true;
                    result.Data.Add(type.ToString(), address);
                }
                _functionReturned  = true;
                _executingFunction = false;
                break;

                #endregion
                #region TypeAddDirective
            case ICASMDirectiveType.ImportDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tTypeAddDirective, usage - \n\timport <librarypath/filepath>\n\t\t-path - for importing a file";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname = parameters[0].Check(ICASMValueType.Normal);
                string _importPath = (string)varname.Value;
                LoadAndExecute(_importPath.Trim());
                break;

                #endregion
                #region EwfcDirective
            case ICASMDirectiveType.EwfcDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tEwfcDirective, usage - \n\tewfc <.net namespace> <function name> <?parameters>";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varscope    = parameters[0].Check(ICASMValueType.Address);
                varname     = parameters[1].Check(ICASMValueType.Identifier);
                _importPath = (string)varscope.Value;
                string _importMethodName = (string)varname.Value;
                _importPath = _importPath.Replace('/', '.').Trim('.');
                object[]      _parametersToCallingFunction     = new object[parameters.Count - 2];
                System.Type[] _parameterTypesToCallingFunction = new System.Type[parameters.Count - 2];
                variable = new Variable();
                for (int i = 2; i < parameters.Count; i++)
                {
                    if (parameters[i].Type == ICASMValueType.Normal)
                    {
                        Data.Type ttt = ICASMValue.GetTypeFromPrimitiveType(parameters[i].PrimitiveType);
                        variable = new Variable(parameters[i].Value, ttt);
                    }
                    else if (parameters[i].Type == ICASMValueType.Address)
                    {
                        variable = RuntimeEngine.GetVariable((string)parameters[i].Value);
                    }
                    else if (parameters[i].Type == ICASMValueType.Identifier)
                    {
                        variable = RuntimeEngine.GetVariable("/" + (string)parameters[i].Value);
                    }
                    if (variable.Value == null)
                    {
                        continue;
                    }
                    _parametersToCallingFunction[i - 2]     = variable.Value;
                    _parameterTypesToCallingFunction[i - 2] = variable.Value.GetType();
                }
                System.Type _typeOfCallingMethod = System.Type.GetType(_importPath);
                MethodInfo  _callingMethodInfo   = _typeOfCallingMethod.GetMethod(_importMethodName, _parameterTypesToCallingFunction);
                object      _methodCallResult    = _callingMethodInfo.Invoke(null, _parametersToCallingFunction);
                if (_methodCallResult != null)
                {
                    string     _methodResultValue        = _methodCallResult.ToString();
                    ICASMValue icasm_methodReturnedValue = null;
                    Variable   _methodCallResultVariable = null;
                    if ((icasm_methodReturnedValue = ICASMValue.ParseValue(_methodResultValue)) != null)
                    {
                        Data.Type ttt = ICASMValue.GetTypeFromPrimitiveType(icasm_methodReturnedValue.PrimitiveType);
                        _methodCallResultVariable = new Variable(icasm_methodReturnedValue.Value, ttt);
                    }
                    else
                    {
                        _methodCallResultVariable = new Variable(_methodCallResult, new Data.Type("Object", "/"));
                    }
                    address = "/$SYSTEM$_temp" + _temps;
                    RuntimeEngine.PutVariable(address, _methodCallResultVariable);
                    result.Success = true;
                    result.Data.Add(ICASMDirectiveType.CallDirective.ToString(), address);
                    MemoryStack.Push(address);
                    _temps++;
                }
                break;

                #endregion
                #region ReflectDirective
            case ICASMDirectiveType.ReflectDirective:
                if (tag == ICASMTagType.Help)
                {
                    _ideoutput = "\n\tReflectDirective, usage - \n\treflect <address>\n\t\t-variable - reflect variable\n\t\t-pool - reflect variable pool\n\t\t-typespace - reflect typespace\n\t\t-type - reflect type";
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                    break;
                }
                varname = parameters[0].Check(ICASMValueType.Address);
                if (tag == ICASMTagType.Variable)
                {
                    Variable _reflectVariable = RuntimeEngine.GetVariable((string)varname.Value);
                    _ideoutput  = "\n\tReflect options - " + tag + ", " + _reflectVariable.Address;
                    _ideoutput += "\n\tVariable Address - " + _reflectVariable.Address;
                    _ideoutput += "\n\tVariable Value - " + _reflectVariable.Value;
                    if (_reflectVariable.Type != null)
                    {
                        _ideoutput += "\n\tVariable Type - " + _reflectVariable.Type.Address + "\n\tTuples - ";
                    }
                    foreach (Address _reflectVariableTuple in _reflectVariable.TupleAddresses.Values)
                    {
                        _ideoutput += "\n\t\t" + _reflectVariableTuple;
                    }
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                }
                else if (tag == ICASMTagType.Pool)
                {
                    VariablePool _reflectPool = RuntimeEngine.GetPool((string)varname.Value);
                    _ideoutput  = "\n\tReflect options - " + tag + ", " + _reflectPool.Address;
                    _ideoutput += "\n\tVariable Address - " + _reflectPool.Address;
                    _ideoutput += "\n\tVariablePools - " + _reflectPool.VariablePoolCount;
                    foreach (VariablePool _pool in _reflectPool.VariablePools.Values)
                    {
                        _ideoutput += "\n\t\t" + _pool.Address;
                    }
                    _ideoutput += "\n\tVariables - " + _reflectPool.VariableCount;
                    foreach (Variable _var in _reflectPool.Variables.Values)
                    {
                        _ideoutput += "\n\t\t" + _var.Address;
                    }
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                }
                else if (tag == ICASMTagType.Type)
                {
                    Data.Type _reflectType = TypeEngine.GetType((string)varname.Value);
                    _ideoutput  = "\n\tReflect options - " + tag + ", " + _reflectType.Address;
                    _ideoutput += "\n\tFunctions - " + _reflectType.FunctionCount;
                    foreach (FunctionOverloads f in _reflectType.Functions.Values)
                    {
                        _ideoutput += "\n\t\t" + f.AccessKey + " (overloads " + f.Overloads.Count + ")";
                        for (int i = 0; i < f.Overloads.Count; i++)
                        {
                            _ideoutput += "\n\t\t\t" + i + " - ";
                            foreach (Address typse in f.Overloads[i].Parameters)
                            {
                                _ideoutput += "[" + typse.FullPath + "] ";
                            }
                        }
                    }
                    result.Data.Add("$IDE_OUTPUT$", _ideoutput);
                }
                else if (tag == ICASMTagType.Typespace)
                {
                }
                break;

                #endregion
                #region JumpDirective
            case ICASMDirectiveType.JumpDirective:
                varname = parameters[0];
                int step = (int)varname.Value;
                result.Success = true;
                result.Data.Add(ICASMDirectiveType.JumpDirective.ToString(), step);
                break;
                #endregion
            }
            if (!_executingFunction)
            {
                while (MemoryStack.Count != 0)
                {
                    Address addr = MemoryStack.Pop();
                    if (result.Data.ContainsKey("CallDirective"))
                    {
                        Address addr_c1 = (Address)result.Data["CallDirective"];
                        if (addr_c1.Equals(addr))
                        {
                            continue;
                        }
                    }
                    else if (result.Data.ContainsKey("ReturnDirective"))
                    {
                        if (result.Data["ReturnDirective"].Equals(addr.FullPath))
                        {
                            continue;
                        }
                    }
                    VariablePool pool = RuntimeEngine.VariablePool;
                    RuntimeEngine.GetPool(addr.Parent).Pull(addr.Name, true);
                }
            }
            return(result);
        }