Skip to content

Account For Statements Between Functions #1

@cernec1999

Description

@cernec1999

Consider this code:

function funFun() {
  with (player) {
    this.chat = "hi";
  };

  temp.fn = function() {
    temp.sum = 0;
    for (temp.i = 1; temp.i < 10; temp.i++) {
      temp.sum += temp.i;
    }
    return temp.sum;
  };
  echo(temp.fn());
}

echo("FooBar");

function onCreated() {
  setTimer(1);
  temp.baz = function(temp.i) {echo(temp.i*2);};
  temp.baz(5);
  funFun();
}

function onTimeOut() {
  echo("Hi!");
  setTimer(1);
}

graphviz-3

echo("FooBar"); is clearly between functions, and should be executed by the GS2 engine, but it is unreachable in the compiler output.

The corrected output would make the jmp at instruction 0 go to 76 instead of 150. Also, in the CFG, there is an additional return which is unreachable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions