コード例 #1
0
 /// <summary>
 ///		Sets the return value as a given value.
 /// </summary>
 /// <param name="value">Value to move into return value.</param>
 public void SetReturnValue(RuntimeObject value)
 {
     SetObjectValue(_registers[(int)Register.Return], _process.AllocateObjectIndex(value));
 }
コード例 #2
0
 public void SetLocalVariable(string identifier, RuntimeObject value)
 {
     RuntimeValue localValue = ResolveLocal(identifier);
     SetObjectValue(localValue, _process.AllocateObjectIndex(value));
 }
コード例 #3
0
 public void SetGlobalVariable(string identifier, RuntimeObject value)
 {
     RuntimeValue globalValue = _process.MemoryHeap[((VariableSymbol)_process.GlobalScope.FindSymbol(identifier, SymbolType.Variable)).MemoryIndex];
     SetObjectValue(globalValue, _process.AllocateObjectIndex(value));
 }
コード例 #4
0
 public void SetArrayElement(int memoryIndex, int offset, RuntimeObject value)
 {
     SetObjectValue(_process.MemoryHeap[memoryIndex + offset], _process.AllocateObjectIndex(value));
 }
コード例 #5
0
        public void PassParameter(RuntimeObject value)
        {
            int index = _process.AllocateObjectIndex(value);
            RuntimeValue stackValue = new RuntimeValue(RuntimeValueType.Object);
            SetObjectValue(stackValue, index);

            _runtimeStack.Push(stackValue);
            _passedParameterCount++;
            _passedParameterMask.Add(new DataTypeValue(DataType.Object, false, false));
        }
コード例 #6
0
        /// <summary>
        ///		Allocates an Object index in the Object heap and returns its index.
        /// </summary>
        /// <param name="Object">Object to allocate index for.</param>
        /// <returns>Allocated index.</returns>
        public int AllocateObjectIndex(RuntimeObject objectToIndex)
        {
            // First element is reserved to capture null-to-zero-cast-to-object (XD) errors.
            for (int i = 1; i < _objectHeap.Length; i++)
                if (_objectHeap[i] == null || _objectHeap[i] == objectToIndex)
                {
                    _objectHeap[i] = objectToIndex;
                    return i;
                }
                else if (objectToIndex is NativeObject && _objectHeap[i] is NativeObject && ((NativeObject)objectToIndex).Object == ((NativeObject)_objectHeap[i]).Object)
                    return i;

            // See if we can clean up a bit :S.
            CollectGarbage(); // Desperatly try and free some space :S.
            if (_lastCollectionObjectCount == 0)
            {
                Array.Resize(ref _objectHeap, _objectHeap.Length * 2); // Double the size.
                return AllocateObjectIndex(objectToIndex);
            }
            else
                return AllocateObjectIndex(objectToIndex);
        }