public OpCodeListItem(OpCodeList list, AOpCode data) { this.list = list; this.prev = null; this.next = null; this.data = data; }
public OpCodeListItem(OpCodeList list, OpCodeListItem prev, OpCodeListItem next, AOpCode data) { this.list = list; this.prev = prev; this.next = next; this.data = data; }
/*--------------------------------------------------------------------*/ // TODO: add some tests to ensure, that the given item is from this list public OpCodeListItem Append(OpCodeListItem item) { if (item == null) { return(null); } // emty list if (numItems == 0) { head = tail = item; item.Prev = null; item.Next = null; } else { OpCodeListItem tmp = tail; tail = item; item.Prev = tmp; tmp.Next = item; item.Next = null; } item.List = this; // new item appended numItems++; current = item; return(item); }
public OpCodeListItem(OpCodeList list) { this.list = list; this.prev = null; this.next = null; this.data = null; }
public OpCodeList() { this.head = null; this.tail = null; this.current = null; this.numItems = 0; }
/*--------------------------------------------------------------*/ // wasEnd == 1 -> END or EXIT // wasEnd == 2 -> SUBEND public void SubEval(ScriptState st) { if (reg_R.TypeOf() != ValueTypeID.TYPE_PROGRAMREF) { throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_NOCODE)); } // set up the subprogram code pointers //sti->code = (list_head_t *) r->value.program.code; reg_PC = ((OpCodeList)reg_R.GetObjectValue()).First(); // evaluate code programState = ProgramStateID.RUNNING; for (; ;) { EvalStep(st); if (programState != ProgramStateID.RUNNING) { break; } } //*wasEnd = st->done; GetVal(); }
public void DumpCodePart(OpCodeList codePart, int id) { if (codePart == null) { return; } Console.WriteLine(" Dumping code part {0}:", id); codePart.Rewind(); OpCodeListItem item = codePart.Next(); int opCodeID = 0; while (item != null) { //Console.WriteLine(">> item = {0}", item.GetType().ToString()); //Console.WriteLine(">> item.Data = {0}", item.Data.GetType().ToString()); AOpCode opcode = item.Data; Console.WriteLine(" [Li:{0} Po:{1} ID:{2}] {3}", opcode.Line, opcode.LinePosition, opCodeID++, opcode.ToString()); item = codePart.Next(); } Console.WriteLine(" End of code part {0}", id); }
/*--------------------------------------------------------------------*/ public OpCodeListItem Last() { // go to the last item in the list current = tail; // return the current item return(current); }
/*--------------------------------------------------------------------*/ public void EmptyList() { // TODO: Add some list-items traversal and cleanup this.head = null; this.tail = null; this.current = null; this.numItems = 0; }
/*--------------------------------------------------------------------*/ public void Rewind() { if (numItems == 0) { current = null; } else { current = head; } }
public EvaluatorState(ScriptState state) { this.state = state; stack = new Stack(); reg_R = new UndefinedValue(); reg_PC = null; reg_FP = -1; globals = new Hashtable(128); codeParts = new List <OpCodeList>(); programState = ProgramStateID.RUNNING; runLevel = 0; }
/*--------------------------------------------------------------------*/ // TODO: add some tests to ensure, that the given item is from this list public void Disconnect(OpCodeListItem item) { OpCodeListItem prev, next; prev = item.Prev; next = item.Next; if (prev != null) { if (next != null) { prev.Next = next; // item between two other items removed next.Prev = prev; } else { this.tail = prev; // item at the end of the list removed prev.Next = null; } } else { if (next != null) { this.head = next; // first item removed next.Prev = null; } else { this.head = null; // last item in the list removed this.tail = null; } } // item disconnected from the list item.Prev = null; item.Next = null; item.List = null; // item removed this.numItems--; // reset the current list item pointer if (item == this.current) { Rewind(); } }
/*--------------------------------------------------------------*/ private AOpCode DispatchOpCode() { AOpCode opCode; if (reg_PC != null) { opCode = reg_PC.Data; reg_PC = reg_PC.Next; return(opCode); } else { return(null); } }
/*--------------------------------------------------------------------*/ public OpCodeListItem Prev() { // is the list empty? if (numItems == 0) { Rewind(); return(null); } // return the current item OpCodeListItem item = current; // read the next one, if we have one if (current != null) { current = current.Prev; } // return what we found... return(item); }
/*--------------------------------------------------------------------*/ public void Delete(OpCodeListItem item) { Disconnect(item); }