Exemple #1
0
        public VirtualMachine()
        {
            ReturnAddresses = new List<int>();
            FunctionCallList = new List<CodeBlock>();
            CurrentEnvironment = new Environment();
            ByteCode = new CodeMemory();
            Errors = new List<string>();
            State = VmStateTypes.NOT_READY;

            Features = new Dictionary<string, List<string>>();
            Requirements = new Dictionary<string, List<string>>();
            Globals = new Dictionary<string, Value>();
            Primitives = new Dictionary<string, Action<VirtualMachine, Instruction, List<Value>>>();
            PrimitivesArity = new Dictionary<string, List<Value>>();
            Environments = new List<Environment>();
            ClosureStack = new List<Environment>();
            Environments.Add(CurrentEnvironment);
        }
Exemple #2
0
 public void RaiseHalt(String reason)
 {
     State = VmStateTypes.HALTED;
     DebugText = reason;
 }
Exemple #3
0
 public void Run()
 {
     ContinueExecution = true;
     while (ByteCode.IsValidInstruction && ContinueExecution) {
         State = VmStateTypes.PROCESSING;
         OpCodes.Process(this, ByteCode.CurrentInstruction);
         if (this.Errors.Count() > 0) {
             State = VmStateTypes.ABORTED;
             break;
         }
         if (State == VmStateTypes.DEBUG) {
             break;
         }
         if (this.KillTickLimit > 0 && this.Ticks >= this.KillTickLimit) {
             this.RaiseError("Processing time limits exceeded.");
             State = VmStateTypes.KILLED;
             break;
         }
         if (this.SleepTickLimit > 0 && (this.Ticks % this.SleepTickLimit) == 0) {
             State = VmStateTypes.SLEEPING;
             break;
         }
         State = VmStateTypes.END_OF_EXECUTION;
     }
 }
Exemple #4
0
 public void RaiseDebug(String reason)
 {
     State = VmStateTypes.DEBUG;
     DebugText = reason;
 }