Exemple #1
0
  public void execute(long start) throws Exception {
    // Lines number
    this.lines = this.code.size() - 1;

    // Exit
    exit = false;

    // Balance
    double balance = VM.SYS.AGENT.GENERAL.balance;

    try {
      // Code index
      if (start == 0) VM.REGS.RCI = VM.TAGS.getLine("#begin#");
      else VM.REGS.RCI = start;

      // Instruction
      CInstruction i;

      while (VM.REGS.RCI < this.code.size() - 1 && this.steps < 10000 && !exit) {
        // Increase instruction pointer
        VM.REGS.RCI++;

        // Steps
        this.steps++;

        // Load instruction Execute
        i = this.code.get(new Long(VM.REGS.RCI).intValue());

        // Execute
        i.execute();

        // Fee
        this.fee = this.fee + 0.00000001 * this.steps;

        // Out of funds ?
        if (balance < fee) throw new Exception("App run out of funds");
      }
    } catch (Exception ex) {
      throw new Exception("Error on line " + VM.REGS.RCI + " (" + ex.getMessage() + ")");
    }
  }
Exemple #2
0
 public void newTrans() throws Exception {
   this.execute(VM.TAGS.getLine("#transaction#"));
 }