#ifndef SCRIPT_H
#define SCRIPT_H

#include <stdbool.h>

#include "ByteCode.h"
#include "Object.h"

#define SCRIPT_STACK_SIZE 1000
#define SCRIPT_ERROR_SIZE 256

typedef struct Script {
    char error[SCRIPT_ERROR_SIZE];
    ByteCode* code;
    int readIndex;
    Object returnValue;
    Object stack[SCRIPT_STACK_SIZE];
    int stackIndex;
    int stackVarIndex;
    int line;
} Script;

Script* sInit(ByteCode* code);
void sDelete(Script* sc);

void sRun(Script* sc);

typedef bool (*ObjectPrinter)(Object*);
void sSetPrinter(ObjectPrinter p);

void sPrintCode(Script* sc);

#endif