/// <summary> /// Performs initialization of data structure for a newly created thread /// It sets up the environment for the first method that runs the thread /// </summary> /// <param name="threadID">Thread id, which is the guid of the thread object</param> /// <param name="startingObject">The object from which the thread is started</param> /// <param name="startingMethod">The thread function</param> private void InitializeThread(int threadID, VMValue_object startingObject, CILMethod startingMethod) { this.threadID = threadID; currentMethod = startingMethod; syncState = SyncState.RUNNING; localVariableBlocks.Push(new VMLocalVariableBlock(this, startingMethod)); if(startingObject != null) localVariableBlocks.Peek().AddArgumentFront(startingObject); pc = currentMethod.GetFirstInstruction(); }
public VMValue_object MakeNullValue() { VMValue_object ret = new VMValue_object(nextguid, null, -1); allValues.Add(nextguid, ret); nextguid++; return ret; }
public VMValue_threadstart MakeThreadStartValue(VMValue_object obj, VMValue_ftn method) { int guid = nextguid++; VMValue_threadstart ret = new VMValue_threadstart(guid, this, obj.GUID, method.GUID); allValues.Add(guid, ret); return ret; }
/// <summary> /// Make a new value of the same type of the given value /// The given value is not modified after the operation, only its type is used /// </summary> /// <param name="value">The given value to get the type</param> /// <returns>A new value of the same type of the given value</returns> public VMValue MakeValue(VMValue value) { VMValue ret; if(value is VMValue_int32) { ret = new VMValue_int32(nextguid, 0); allValues.Add(nextguid, ret); nextguid++; return ret; } else if(value is VMValue_int64) { ret = new VMValue_int64(nextguid, 0); allValues.Add(nextguid, ret); nextguid++; return ret; } else if(value is VMValue_double) { ret = new VMValue_double(nextguid, 0); allValues.Add(nextguid, ret); nextguid++; return ret; } else if(value is VMValue_object) { ret = new VMValue_object(nextguid, ((VMValue_object)value).ClassType, -1); allValues.Add(nextguid, ret); nextguid++; return ret; } else if(value is VMValue_array) { ret = new VMValue_array(nextguid, -1); allValues.Add(nextguid, ret); nextguid++; return ret; } else throw new Exception("Unknown value type to make a value"); }
public override VMValue Duplicate() { VMValue ret = new VMValue_object(); ret.CopyInternalData(this); return ret; }