public bool ExecuteCommand(string command, Stacker stack) { switch (command) { case "!": this.value = !value; return true; case "string": stack.Pop(); stack.InsertTop(new StackObjectString("" + this.value)); return true; } if (stack.GetSize() > 1) if(stack.CheckFromTop(1, this.GetType())) { switch (command) { case "==": EE(stack); return true; case "||": OR(stack); return true; case "&&": AND(stack); return true; } } return false; }
public bool ExecuteCommand(string command, Stacker stack) { if(stack.GetSize() > 1) if (stack.CheckFromTop(1, this.GetType())) { if (command == "+") { Add(stack); return true; } else if (command == "==") { CheckEquals(stack); } } return false; }
public bool ExecuteCommand(string command, Stacker stack) { switch (command) { case "int": this.value = (int)this.value; return true; case "neg": this.value *= -1; return true; case "round": this.value = (float)Math.Round(this.value); return true; case "floor": this.value = (int)this.value; return true; case "abs": this.value = (float)Math.Abs(this.value); return true; case "string": stack.Pop(); stack.InsertTop(new StackObjectString("" + this.value)); return true; } if (stack.GetSize() > 1) if(stack.CheckFromTop(1, this.GetType())) { switch (command) { case "+": Add(stack); break; case "-": Subtract(stack); break; case "*": Multiply(stack); break; case "/": Divide(stack); break; case "%": Modulo(stack); break; case "==": EqualValueCheck(stack); break; case "<": LessThan(stack); break; case ">": //!( <= 5) GreaterThan(stack); break; case "<=": //> LessThanOrEqualTo(stack); break; case ">=": //< GreaterThanOrEqualTo(stack); break; default: return false; } return true; } return false; }