public override void Run() { ValueStorage itemPushed = new ValueStorage(); itemPushed.SetValue(source.GetValue()); parent.m_stack.Add(itemPushed); base.Run(); }
public PushCommand(AsmInterpreter interpreter, string[] lineParts) : base(interpreter, lineParts) { string sourceName = lineParts[1]; ValueStorage vs = null; vs = parent.GetVariableByName(sourceName); if (vs == null) { vs = parent.GetRegisterByName(sourceName); { if (vs == null) { vs = parent.GetStackValueFromTop(sourceName); if (vs == null) { float number = 0.0f; if (float.TryParse(sourceName, out number)) { vs = new ValueStorage(); vs.SetValue(number); parent.m_constants.Add(vs); } } } } } if (vs == null) throw new InvalidOperationException("Invalid push source."); source = vs; }
public IfCommand(AsmInterpreter interpreter, string[] lineParts) : base(interpreter, lineParts) { string comparisonName = lineParts[2]; string operandLeftName = lineParts[1]; string operandRightName = lineParts[3]; ComparisonDelegation delegation = GetComparisonDelegation(comparisonName); if (delegation == null) throw new InvalidOperationException("Invalid comparison operator."); comp = delegation; ValueStorage vs = null; vs = parent.GetVariableByName(operandLeftName); if (vs == null) { vs = parent.GetRegisterByName(operandLeftName); if (vs == null) { vs = parent.GetStackValueFromTop(operandLeftName); if (vs == null) { float number = 0.0f; if (float.TryParse(operandLeftName, out number)) { vs = new ValueStorage(); vs.SetValue(number); parent.m_constants.Add(vs); } } } } if (vs == null) throw new InvalidOperationException("Invalid comparison left operand."); operandLeft = vs; vs = null; vs = parent.GetVariableByName(operandRightName); if (vs == null) { vs = parent.GetRegisterByName(operandRightName); if (vs == null) { vs = parent.GetStackValueFromTop(operandRightName); if (vs == null) { float number = 0.0f; if (float.TryParse(operandRightName, out number)) { vs = new ValueStorage(); vs.SetValue(number); parent.m_constants.Add(vs); } } } } if (vs == null) throw new InvalidOperationException("Invalid comparison right operand."); operandRight = vs; }
public CalculationCommand(AsmInterpreter interpreter, string[] lineParts) : base(interpreter, lineParts) { string operatorName = lineParts[0]; string targetName = lineParts[1]; string sourceName = lineParts[2]; CalculationDelegate delegation = GetCalculationDelegation(operatorName); if (delegation == null) throw new InvalidOperationException("Invalid calculation operator."); calc = delegation; ValueStorage vs = null; vs = parent.GetVariableByName(sourceName); if (vs == null) { vs = parent.GetRegisterByName(sourceName); if (vs == null) { vs = parent.GetStackValueFromTop(sourceName); if (vs == null) { float number = 0.0f; if (float.TryParse(sourceName, out number)) { vs = new ValueStorage(); vs.SetValue(number); parent.m_constants.Add(vs); } } } } if (vs == null) throw new InvalidOperationException("Invalid calculation operand."); operand = vs; vs = parent.GetVariableByName(targetName); if (vs == null) { vs = parent.GetRegisterByName(targetName); if (vs == null) { vs = parent.GetStackValueFromTop(targetName); } } if (vs == null) throw new InvalidOperationException("Invalid calculation target."); target = vs; }
public PopCommand(AsmInterpreter interpreter, string[] lineParts) : base(interpreter, lineParts) { if (lineParts.Length == 2) { string targetName = lineParts[1]; ValueStorage vs = null; vs = parent.GetVariableByName(targetName); if (vs == null) { vs = parent.GetRegisterByName(targetName); } if (vs == null) throw new InvalidOperationException("Invalid pop target."); target = vs; } else { target = null; } }
public AsmInterpreter() { for (int i = 0; i < m_registers.Length; i++) m_registers[i] = new ValueStorage(); }