34 lines
651 B
C
34 lines
651 B
C
#include "../include/common.h"
|
|
#include "../include/chunk.h"
|
|
#include "../include/debug.h"
|
|
#include "../include/vm.h"
|
|
|
|
int main(void){
|
|
initVM();
|
|
|
|
Chunk chunk;
|
|
initChunk(&chunk);
|
|
|
|
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);
|
|
|
|
disassembleChunk(&chunk,"Test Chunk");
|
|
int res = interpret(&chunk);
|
|
(void) res;
|
|
freeVM();
|
|
freeChunk(&chunk);
|
|
|
|
return 0;
|
|
}
|