2021-07-08 02:24:24 -07:00
|
|
|
#include "chunk.h"
|
2021-07-22 01:09:11 -07:00
|
|
|
#include "common.h"
|
2021-07-08 02:24:24 -07:00
|
|
|
#include "debug.h"
|
2021-07-22 01:09:11 -07:00
|
|
|
#include "vm.h"
|
|
|
|
|
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
initVM();
|
2021-07-08 02:24:24 -07:00
|
|
|
|
|
|
|
Chunk chunk;
|
|
|
|
initChunk(&chunk);
|
|
|
|
|
|
|
|
int constant = addConstant(&chunk, 1.2);
|
|
|
|
writeChunk(&chunk, OP_CONSTANT, 123);
|
|
|
|
writeChunk(&chunk, constant, 123);
|
2021-07-29 23:56:42 -07:00
|
|
|
|
|
|
|
constant = addConstant(&chunk, 3.4);
|
|
|
|
writeChunk(&chunk, OP_CONSTANT, 123);
|
|
|
|
writeChunk(&chunk, constant, 123);
|
|
|
|
|
|
|
|
writeChunk(&chunk, OP_ADD, 123);
|
|
|
|
|
|
|
|
constant = addConstant(&chunk, 5.6);
|
|
|
|
writeChunk(&chunk, OP_CONSTANT, 123);
|
|
|
|
writeChunk(&chunk, constant, 123);
|
|
|
|
|
|
|
|
writeChunk(&chunk, OP_DIVIDE, 123);
|
2021-07-29 23:38:20 -07:00
|
|
|
writeChunk(&chunk, OP_NEGATE, 123);
|
2021-07-08 02:24:24 -07:00
|
|
|
|
|
|
|
writeChunk(&chunk, OP_RETURN, 123);
|
|
|
|
|
|
|
|
disassembleChunk(&chunk, "test chunk");
|
2021-07-22 01:09:11 -07:00
|
|
|
interpret(&chunk);
|
|
|
|
freeVM();
|
2021-07-08 02:24:24 -07:00
|
|
|
freeChunk(&chunk);
|
|
|
|
return 0;
|
|
|
|
}
|