Package maelstrom.funge.interpreter.stack

Examples of maelstrom.funge.interpreter.stack.Stack.push()


  public static class Not implements Operator {

    public void perform(Funge funge) {
      Stack stack = funge.getStackStack().getStack();

      stack.push(stack.pop() == 0 ? 1 : 0);
    }

    public String getDescription() {
      return "Pushes the logical not of the first element on the stack";
    }
View Full Code Here


      Stack stack = funge.getStackStack().getStack();

      Long b = stack.pop();
      Long a = stack.pop();

      stack.push(a > b ? 1 : 0);
    }

    public String getDescription() {
      return "Pops one entry from the stack. Pushes a 1 if the entry is greater than 0, pushes a 0 otherwise";
    }
View Full Code Here

  // Adds the two top most numbers on the stack
  public static class Add implements Operator {

    public void perform(Funge funge) {
      Stack stack = funge.getStackStack().getStack();
      stack.push((stack.pop() + stack.pop()));
    }

    public String getDescription() {
      return "Pops b, a off the stack. Pushes a + b";
    }
View Full Code Here

  // Subtracts the two top most numbers on the stack
  public static class Subtract implements Operator {

    public void perform(Funge funge) {
      Stack stack = funge.getStackStack().getStack();
      stack.push(0 - (stack.pop() - stack.pop()));
    }

    public String getDescription() {
      return "Pops b, a off the stack. Pushes a - b";
    }
View Full Code Here

  // Adds the two top most numbers on the stack
  public static class Multiply implements Operator {

    public void perform(Funge funge) {
      Stack stack = funge.getStackStack().getStack();
      stack.push((stack.pop() * stack.pop()));
    }

    public String getDescription() {
      return "Pops b, a off the stack. Pushes a * b";
    }
 
View Full Code Here

      long b = stack.pop();
      long a = stack.pop();

      if (b == 0) {
        stack.push(0);
      } else {
        stack.push(a / b);
      }
    }
View Full Code Here

      long a = stack.pop();

      if (b == 0) {
        stack.push(0);
      } else {
        stack.push(a / b);
      }
    }

    public String getDescription() {
      return "Pops b, a off the stack. Pushes a / b";
View Full Code Here

      long b = stack.pop();
      long a = stack.pop();

      if (b == 0) {
        stack.push(0);
      } else {
        stack.push(a % b);
      }
    }
View Full Code Here

      long a = stack.pop();

      if (b == 0) {
        stack.push(0);
      } else {
        stack.push(a % b);
      }
    }

    public String getDescription() {
      return "Pops b, a off the stack. Pushes a % b";
View Full Code Here

    public void perform(Funge funge) {


      try {
        Stack stack = funge.getStackStack().getStack();
              stack.push(System.in.read());
            } catch (IOException err) {
              //TODO: Handle this exception as per spec
              err.printStackTrace();
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.