// Use this for initialization void Start() { int INSTRUCTION_TYPE_LENGTH = System.Enum.GetValues(typeof(InstructionType)).Length; _instructionItemList = new GameObject[INSTRUCTION_TYPE_LENGTH]; for (int idx = 0; idx < INSTRUCTION_TYPE_LENGTH; ++idx) { InstructionType it = (InstructionType)System.Enum.GetValues(typeof(InstructionType)).GetValue(idx); GameObject iil = _instructionItemList [idx] = Object.Instantiate(rawInstructionItem0); iil.transform.SetParent(gameObject.transform); iil.transform.localScale = Vector3.one; iil.name = it.ToString(); InstructionSourceBehaviour isb = iil.GetComponent <InstructionSourceBehaviour> (); if (isb != null) { UnityEngine.UI.Text text = isb.text.GetComponent <UnityEngine.UI.Text>(); text.text = it.ToString(); } } rawInstructionItem0.SetActive(false); foreach (GameObject instructionItem in _instructionItemList) { instructionItem.SetActive(true); } }
/// <summary> /// Executes the instruction. /// Uses the String-Format of the type to determine the method which should be used. /// </summary> /// <returns>true when successful, false otherwise</returns> public bool Execute() { // Get the type of this object (=Instruction) Type thisType = this.GetType(); // Get the method by the String (type.ToString()) and also look for private and protected methods -> BindingFlags MethodInfo method = thisType.GetMethod(type.ToString(), BindingFlags.Instance | BindingFlags.NonPublic); // Invoke the method return((bool)method.Invoke(this, null)); }
public Instruction(InstructionType type) { Type = type; #if DEBUG TypeName = type.ToString(); #endif }
public override string ToString() { var s = new StringBuilder(); s.Append($"Instruction: {_type}"); if (_type.ToString().Length < 3) { s.Append('\t'); } switch (_valueSize) { case 1: s.Append("\tParamType: U32Int\tParam: "); if (_type.IsSigned()) { s.Append(BitConverter.ToInt32(_value)); } else { s.Append(BitConverter.ToUInt32(_value)); } break; case 2: s.Append($"\tParamType: U64Int\tParam: {BitConverter.ToUInt64(_value)}"); break; } return(s.ToString()); }
public override string ToString() { string toString = Type.ToString(); toString += Register == Register.None ? "" : " " + Register.ToString(); toString += Offset == 0 ? "" : " " + Offset.ToString(); return(toString); }
public string print() { var sb = new StringBuilder(); sb.Append(inst.ToString()); sb.Append(' '); sb.AppendJoin(", ", args); return(sb.ToString()); }
public override string ToString() { string b = Type.ToString() + " "; if (Type == InstructionType.CALL) { return(b + FuncName); } else if (Type == InstructionType.PUSHCONST) { return(b + Value); } else if (Type == InstructionType.PULLCACHE || Type == InstructionType.TOCACHE) { return(b + CacheNumber); } else { return(b + VarNumber.ToString()); } }
public void Print() { if (Type == InstructionType.Function || Type == InstructionType.Line) { return; } if (Type == InstructionType.Label) { Console.ForegroundColor = ConsoleColor.DarkGreen; } Console.Write("{0:X4} {1,-15} ", Offset, Type.ToString().ToLower()); foreach (var operand in Operands) { operand.Print(); } Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Gray; }
public override string ToString() { string retValue = "Instruction"; switch (InstructionType) { case InstructionType.INC: retValue = String.Format("{0} ({1:0.000}kPa/s, {2:0.00}s)", InstructionType.ToString(), MAX_PRESSURE * Argument / 255, ((double)Steps) / UPDATE_RATE); break; case InstructionType.DEC: retValue = String.Format("{0} (-{1:0.000}kPa/s, {2:0.00}s)", InstructionType.ToString(), MAX_PRESSURE * Argument / 255, ((double)Steps) / UPDATE_RATE); break; case InstructionType.STEP: retValue = String.Format("{0} ({1:0.000}kPa, {2:0.00}s)", InstructionType.ToString(), MAX_PRESSURE * Argument / 255, ((double)Steps) / UPDATE_RATE); break; case InstructionType.NOP: retValue = String.Format("{0} ({1:0.00}s)", InstructionType.ToString(), ((double)Steps) / UPDATE_RATE);; break; } return(retValue); }
public static System.Xaml.XamlNodeType ToWpf(this InstructionType nodeType) { return((System.Xaml.XamlNodeType)Enum.Parse(typeof(XamlNodeType), nodeType.ToString())); }