Skip to content

Commit

Permalink
Fix related compilation warnings, release hello world test code and b…
Browse files Browse the repository at this point in the history
…ytecode.
  • Loading branch information
ax-6 committed Jan 8, 2025
1 parent 3d864a6 commit 2b7347d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions prototype/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4769,6 +4769,8 @@ void BytecodeGenerator::HandleStmt(StmtNode* stmt,
body_code.push_back(Bytecode(_AQVM_OPERATOR_GOTO, body_name_ptr_index));
size_t void_name_index = global_memory_.Add(0x01, 3, "$0");
size_t void_name_ptr_index = global_memory_.Add(0x06, 8);
code.push_back(Bytecode(_AQVM_OPERATOR_PTR, void_name_index,
void_name_ptr_index));
code.push_back(Bytecode(_AQVM_OPERATOR_IF, condition_index,
body_name_ptr_index, void_name_ptr_index));
break;
Expand Down
4 changes: 4 additions & 0 deletions prototype/hello-world.aq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int print(char* str){}
void main(){
print("Hello World!");
}
Binary file added prototype/hello-world.aqbc
Binary file not shown.
16 changes: 8 additions & 8 deletions prototype/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,12 +1059,12 @@ int DIV(size_t result, size_t operand1, size_t operand2) {
GetUint64tData(operand1) / GetUint64tData(operand2));
break;
case 0x04:
SetFloatData(result,
GetUint64tData(operand1) / GetUint64tData(operand2));
SetFloatData(result, (double)GetUint64tData(operand1) /
(double)GetUint64tData(operand2));
break;
case 0x05:
SetDoubleData(result,
GetUint64tData(operand1) / GetUint64tData(operand2));
SetDoubleData(result, (double)GetUint64tData(operand1) /
(double)GetUint64tData(operand2));
break;
case 0x06:
SetUint64tData(result,
Expand Down Expand Up @@ -2464,13 +2464,13 @@ int THROW() { return 0; }
int WIDE() { return 0; }

void print(InternalObject args, size_t return_value) {
SetIntData(return_value, printf((char*)GetPtrData(*args.index)));
SetIntData(return_value, printf("%s", (char*)GetPtrData(*args.index)));
}

unsigned int hash(const char* str) {
unsigned long hash = 5381;
int c;
while (c = *str++) {
while ((c = *str++)) {
hash = ((hash << 5) + hash) + c;
}
return hash % 1024;
Expand All @@ -2495,7 +2495,7 @@ void* AddFunction(void* location) {
void* origin_location = location;
size_t all_size =
is_big_endian ? *(uint64_t*)location : SwapUint64t(*(uint64_t*)location);
printf("AddFunction Size: %lu\n", all_size);
printf("AddFunction Size: %zu\n", all_size);
size_t commands_size = all_size;
location = (void*)((uintptr_t)location + 8);
struct FuncList* table = &func_table[hash(location)];
Expand Down Expand Up @@ -2886,7 +2886,7 @@ int main(int argc, char* argv[]) {
bytecode_file = (void*)((uintptr_t)bytecode_file + memory->size / 2);
}

printf("Memory size: %lu\n", *(uint8_t*)bytecode_file);
printf("Memory size: %hhu\n", *(uint8_t*)bytecode_file);

while (bytecode_file < bytecode_end) {
printf("AddFunction\n");
Expand Down

0 comments on commit 2b7347d

Please sign in to comment.