clox/tests/01_main.c

34 lines
651 B
C
Raw Normal View History

2024-08-31 17:41:43 +00:00
#include "../include/common.h"
#include "../include/chunk.h"
#include "../include/debug.h"
2024-09-01 22:43:28 +00:00
#include "../include/vm.h"
2024-08-31 17:41:43 +00:00
int main(void){
2024-09-01 22:43:28 +00:00
initVM();
2024-08-31 17:41:43 +00:00
Chunk chunk;
initChunk(&chunk);
2024-08-31 20:54:46 +00:00
2024-09-02 22:15:41 +00:00
int constant = addConstant(&chunk,1.25);
writeChunk(&chunk, OP_CONSTANT,1);
writeChunk(&chunk,constant,1);
constant = addConstant(&chunk,10);
writeChunk(&chunk, OP_CONSTANT,2);
writeChunk(&chunk,constant,2);
writeChunk(&chunk, OP_DIVIDE, 3);
writeChunk(&chunk, OP_RETURN,5);
2024-08-31 17:41:43 +00:00
disassembleChunk(&chunk,"Test Chunk");
2024-09-02 22:15:41 +00:00
int res = interpret(&chunk);
(void) res;
2024-09-01 22:43:28 +00:00
freeVM();
2024-08-31 17:41:43 +00:00
freeChunk(&chunk);
return 0;
}