Exemple #1
0
int main (int argc, char const *argv[]) {
  void *literals[] = {
    (void *) "the answer is:",
    (void *) "print",
    (void *) 30,
    (void *) 2
  };
  
  byte instructions[] = {
    PUSH_SELF,
    PUSH_STRING, 0,
    CALL,        1, 1,
    PUSH_NUMBER, 2,
    PUSH_NUMBER, 3,
    ADD,
    SET_LOCAL,   0,
    PUSH_BOOL,   0,
    JUMP_UNLESS, 6,
    PUSH_SELF,
    GET_LOCAL,   0,
    CALL,        1, 1,
    RETURN
  };
  
  init_runtime();
  run(literals, instructions);
  destroy_runtime();
  
  return 0;
}
Exemple #2
0
Fichier : vm.c Projet : napile/vm
int main (int argc, char const *argv[]) {
  void *literals[] = LITERALS;
  byte instructions[] = INSTRUCTIONS;
  
  init_runtime();
  run(literals, instructions);
  destroy_runtime();
  
  return 0;
}