public static void SetVariable(Address _variable_address, Variable variable)
        {
            VariablePool varpool = GetPool(_variable_address.Parent);
            Variable     temp    = varpool.Pull(_variable_address.Name);

            varpool.Put(_variable_address.Name, variable);
        }
Example #2
0
 public int sceKernelTryAllocateVpl(CpuThreadState CpuThreadState, VariablePool VariablePool, int Size,
                                    PspPointer *AddressPointer)
 {
     if (VariablePool.TryAllocate(CpuThreadState, Size, AddressPointer))
     {
         return(0);
     }
     else
     {
         return((int)SceKernelErrors.ERROR_KERNEL_NO_MEMORY);
     }
 }
Example #3
0
        static void Main(string[] args)
        {
            VariablePool pool  = RuntimeEngine.VariablePool;
            TypeSpace    space = TypeEngine.RuntimeTypes;

            ICASMInterpreter.LoadAndExecute(@"G:\test2.icasm");
            var stack = ICASMInterpreter.MemoryStack;

            Console.ReadKey();

            return;
        }
Example #4
0
        static void dd_OnDataArrived(byte[] in_listVariablePool)
        {
            Console.WriteLine("收到数据!");
            VariablePool vp = new VariablePool();

            vp.Init(in_listVariablePool);
            string ip = (string)vp.Get("IP", 0);// 获取发送方的IP

            // 以上是接受数据
            // 下方是发送数据
            vp.Init();
            vp.Put("IP", ip);
            vp.Put("string", DateTime.Now.ToString());
            dd.Send(vp.GetVariablePool(), ip);
        }
        public static void PutVariable(Address _variable_address, Variable variable, bool auto_purge = true)
        {
            VariablePool varpool = GetPool(_variable_address.Parent);

            if (auto_purge && variable.Address != null)
            {
                if (variable.Address.Name.Contains("$SYSTEM$__temp"))
                {
                    if (varpool.HasVariable(variable.Address.Name))
                    {
                        varpool.Pull(variable.Address.Name);
                    }
                }
            }
            varpool.Put(_variable_address.Name, variable);
            variable.Address = _variable_address;
        }
        public static VariablePool CreatePool(Address _pool_address)
        {
            Scope         scope  = _pool_address.ToScope();
            List <string> levels = scope.ToList();

            levels.Reverse();
            VariablePool runtimePool = RuntimeEngine.VariablePool;

            foreach (string level in levels)
            {
                if (!runtimePool.HasPool(level))
                {
                    runtimePool.CreatePool(level);
                }
                runtimePool = runtimePool.GetPool(level);
            }
            return(runtimePool);
        }
Example #7
0
        public VariablePool sceKernelCreateVpl(string Name, MemoryPartitions PartitionId, VplAttributeEnum Attribute,
                                               int Size, void *Options)
        {
            var VariablePool = new VariablePool(this)
            {
                PartitionId = PartitionId,
                Info        = new SceKernelVplInfo()
                {
                    Attribute = Attribute,
                    PoolSize  = Size,
                    FreeSize  = Size,
                }
            };

            VariablePool.Init();

            return(VariablePool);
        }
        public static VariablePool GetPool(Address addr)
        {
            string[]     _nodes  = addr.FullPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            VariablePool varpool = RuntimeEngine.VariablePool;
            int          i       = 0;

            if (_nodes.Length >= 1)
            {
                if (_nodes[0].Equals("$SYSTEM$_Runtime.Pool@" + typeof(RuntimeEngine).Name))
                {
                    i = 1;
                }
            }
            for (; i < _nodes.Length; i++)
            {
                varpool = varpool.GetPool(_nodes[i]);
            }
            return(varpool);
        }
Example #9
0
        public VariablePoolId sceKernelCreateVpl(string Name, HleMemoryManager.Partitions PartitionId, VplAttribute Attribute, int Size, void *Options)
        {
            var VariablePool = new VariablePool()
            {
                Info = new SceKernelVplInfo()
                {
                    Attribute = Attribute,
                    FreeSize  = Size,
                }
            };

            /*
             * if (Attribute.HasFlag(VplAttribute.PSP_VPL_ATTR_ADDR_HIGH))
             * {
             *      HleState.MemoryManager.GetPartition(PartitionId).Allocate(Size)
             * } else {
             * }
             */
            VariablePool.Init();

            return(VariablePoolList.Create(VariablePool));

            /*
             * throw(new NotImplementedException());
             * const PSP_VPL_ATTR_MASK      = 0x41FF;  // Anything outside this mask is an illegal attr.
             * const PSP_VPL_ATTR_ADDR_HIGH = 0x4000;  // Create the vpl in high memory.
             * const PSP_VPL_ATTR_EXT       = 0x8000;  // Extend the vpl memory area (exact purpose is unknown).
             * //new MemorySegment
             * logWarning("sceKernelCreateVpl('%s', %d, %d, %d)", name, part, attr, size);
             * VariablePool variablePool;
             * if (attr & PSP_VPL_ATTR_ADDR_HIGH) {
             *      variablePool = new VariablePool(hleEmulatorState.moduleManager.get!SysMemUserForUser()._allocateMemorySegmentHigh(part, dupStr(name), size));
             * } else {
             *      variablePool = new VariablePool(hleEmulatorState.moduleManager.get!SysMemUserForUser()._allocateMemorySegmentLow(part, dupStr(name), size));
             * }
             * logWarning("%s", variablePool);
             * return uniqueIdFactory.add(variablePool);
             */
        }
Example #10
0
        public bool Analyze()
        {
            Lexems    = new List <ILexem>();
            Variables = new VariablePool();
            Constants = new ConstantPool();

            int row = 0;

            foreach (var line in sourceCode)
            {
                row++;
                //  List<LexicalUnit> tempList = new List<LexicalUnit>();

                for (int i = 0; i < line.Length;)
                {
                    State.Execute(tos[0], ref row, line, null, ref i);
                }

                Lexems.Add(new Lexem(row, "¶", 3));
            }

            return(true);
        }
Example #11
0
 public int sceKernelFreeVpl(CpuThreadState CpuThreadState, VariablePool VariablePool, PspPointer Data)
 {
     VariablePool.Free(CpuThreadState, Data);
     return 0;
 }
Example #12
0
        public VariablePoolId sceKernelCreateVpl(string Name, HleMemoryManager.Partitions PartitionId, VplAttribute Attribute, int Size, void* Options)
        {
            var VariablePool = new VariablePool()
            {
                Info = new SceKernelVplInfo()
                {
                    Attribute = Attribute,
                    FreeSize = Size,
                }
            };

            /*
            if (Attribute.HasFlag(VplAttribute.PSP_VPL_ATTR_ADDR_HIGH))
            {
                HleState.MemoryManager.GetPartition(PartitionId).Allocate(Size)
            } else {
            }
            */
            VariablePool.Init();

            return VariablePoolList.Create(VariablePool);

            /*
            throw(new NotImplementedException());
            const PSP_VPL_ATTR_MASK      = 0x41FF;  // Anything outside this mask is an illegal attr.
            const PSP_VPL_ATTR_ADDR_HIGH = 0x4000;  // Create the vpl in high memory.
            const PSP_VPL_ATTR_EXT       = 0x8000;  // Extend the vpl memory area (exact purpose is unknown).
            //new MemorySegment
            logWarning("sceKernelCreateVpl('%s', %d, %d, %d)", name, part, attr, size);
            VariablePool variablePool;
            if (attr & PSP_VPL_ATTR_ADDR_HIGH) {
                variablePool = new VariablePool(hleEmulatorState.moduleManager.get!SysMemUserForUser()._allocateMemorySegmentHigh(part, dupStr(name), size));
            } else {
                variablePool = new VariablePool(hleEmulatorState.moduleManager.get!SysMemUserForUser()._allocateMemorySegmentLow(part, dupStr(name), size));
            }
            logWarning("%s", variablePool);
            return uniqueIdFactory.add(variablePool);
            */
        }
Example #13
0
 public int sceKernelAllocateVplCB(CpuThreadState CpuThreadState, VariablePool VariablePool, int Size,
                                   PspPointer *AddressPointer, uint *Timeout)
 {
     VariablePool.Allocate(CpuThreadState, Size, AddressPointer, Timeout, HandleCallbacks: true);
     return(0);
 }
Example #14
0
 public int sceKernelReferVplStatus(VariablePool VariablePool, SceKernelVplInfo *Info)
 {
     *Info = VariablePool.Info;
     return(0);
 }
Example #15
0
 public int sceKernelFreeVpl(CpuThreadState CpuThreadState, VariablePool VariablePool, PspPointer Data)
 {
     VariablePool.Free(CpuThreadState, Data);
     return(0);
 }
        public static Variable GetVariable(Address _variable_address)
        {
            VariablePool varpool = GetPool(_variable_address.Parent);

            return(varpool.Get(_variable_address.Name));
        }
Example #17
0
		public VariablePoolId sceKernelCreateVpl(string Name, HleMemoryManager.Partitions PartitionId, VplAttributeEnum Attribute, int Size, void* Options)
		{
			var VariablePool = new VariablePool(this)
			{
				PartitionId= PartitionId,
				Info = new SceKernelVplInfo()
				{
					Attribute = Attribute,
					PoolSize = Size,
					FreeSize = Size,
				}
			};

			VariablePool.Init();

			var VariablePoolId = VariablePoolList.Create(VariablePool);

			return VariablePoolId;
		}
Example #18
0
        public VariablePool sceKernelCreateVpl(string Name, MemoryPartitions PartitionId, VplAttributeEnum Attribute, int Size, void* Options)
        {
            var VariablePool = new VariablePool(this)
            {
                PartitionId= PartitionId,
                Info = new SceKernelVplInfo()
                {
                    Attribute = Attribute,
                    PoolSize = Size,
                    FreeSize = Size,
                }
            };

            VariablePool.Init();

            return VariablePool;
        }
Example #19
0
 public int sceKernelAllocateVplCB(CpuThreadState CpuThreadState, VariablePool VariablePool, int Size, PspPointer* AddressPointer, uint* Timeout)
 {
     VariablePool.Allocate(CpuThreadState, Size, AddressPointer, Timeout, HandleCallbacks: true);
     return 0;
 }
Example #20
0
 public int sceKernelTryAllocateVpl(CpuThreadState CpuThreadState, VariablePool VariablePool, int Size, PspPointer* AddressPointer)
 {
     if (VariablePool.TryAllocate(CpuThreadState, Size, AddressPointer))
     {
         return 0;
     }
     else
     {
         return (int)SceKernelErrors.ERROR_KERNEL_NO_MEMORY;
     }
 }
Example #21
0
 public int sceKernelReferVplStatus(VariablePool VariablePool, SceKernelVplInfo* Info)
 {
     *Info = VariablePool.Info;
     return 0;
 }
Example #22
0
 public int sceKernelDeleteVpl(VariablePool VariablePool)
 {
     VariablePool.RemoveUid(InjectContext);
     return 0;
 }
Example #23
0
 public int sceKernelDeleteVpl(VariablePool VariablePool)
 {
     VariablePool.RemoveUid(InjectContext);
     return(0);
 }
Example #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);
        }