mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-31 11:08:18 +00:00
xmake initial build, uint -> uint32_t (stdlib test 03 fails with xmake, possible due to newer c and c++ versions)
This commit is contained in:
parent
c348af161c
commit
6c19722d9e
11 changed files with 64 additions and 46 deletions
|
|
@ -19,9 +19,9 @@ void analyze(Bytefile *bf, std::vector<size_t> &&add_publics) {
|
|||
uint16_t mock_builtin_begin_counter = 0;
|
||||
|
||||
int current_stack_depth = 0;
|
||||
const uint globals_count = bf->global_area_size;
|
||||
uint current_locals_count = 0;
|
||||
uint current_args_count = 0;
|
||||
const uint32_t globals_count = bf->global_area_size;
|
||||
uint32_t current_locals_count = 0;
|
||||
uint32_t current_args_count = 0;
|
||||
bool is_in_closure = false;
|
||||
uint16_t *current_begin_counter = nullptr;
|
||||
int func_end_found = 0;
|
||||
|
|
@ -55,7 +55,7 @@ void analyze(Bytefile *bf, std::vector<size_t> &&add_publics) {
|
|||
|
||||
auto const check_correct_var = [&saved_current_ip, bf, &globals_count,
|
||||
¤t_locals_count, ¤t_args_count,
|
||||
&is_in_closure](uint8_t l, uint id) {
|
||||
&is_in_closure](uint8_t l, uint32_t id) {
|
||||
if (l > 3) {
|
||||
ip_failure(saved_current_ip, bf, "unexpected variable category");
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ void analyze(Bytefile *bf, std::vector<size_t> &&add_publics) {
|
|||
is_in_closure = (cmd == Cmd::CBEGIN);
|
||||
break;
|
||||
case Cmd::CLOSURE: {
|
||||
/*uint closure_offset = */ ip_read_int_unsafe(
|
||||
/*uint32_t closure_offset = */ ip_read_int_unsafe(
|
||||
¤t_ip); // closure offset
|
||||
size_t args_count = ip_read_int_unsafe(¤t_ip); // args count
|
||||
extra_stack_during_opr = args_count;
|
||||
|
|
@ -286,7 +286,7 @@ void analyze(Bytefile *bf, std::vector<size_t> &&add_publics) {
|
|||
// }
|
||||
} break;
|
||||
case Cmd::CALLC: {
|
||||
uint args_count = ip_read_int_unsafe(¤t_ip);
|
||||
uint32_t args_count = ip_read_int_unsafe(¤t_ip);
|
||||
current_stack_depth -= args_count + 1; // + closure itself
|
||||
if (current_stack_depth < 0) {
|
||||
ip_failure(saved_current_ip, bf, "not enough elements in stack");
|
||||
|
|
@ -295,8 +295,8 @@ void analyze(Bytefile *bf, std::vector<size_t> &&add_publics) {
|
|||
// NOTE: can't check args == cbegin args
|
||||
} break;
|
||||
case Cmd::CALL: {
|
||||
uint call_offset = ip_read_int_unsafe(¤t_ip); // call offset
|
||||
uint args_count = ip_read_int_unsafe(¤t_ip);
|
||||
uint32_t call_offset = ip_read_int_unsafe(¤t_ip); // call offset
|
||||
uint32_t args_count = ip_read_int_unsafe(¤t_ip);
|
||||
current_stack_depth -= args_count;
|
||||
if (current_stack_depth < 0) {
|
||||
ip_failure(saved_current_ip, bf, "not enough elements in stack");
|
||||
|
|
@ -309,11 +309,11 @@ void analyze(Bytefile *bf, std::vector<size_t> &&add_publics) {
|
|||
|
||||
if (is_command_name(bf->code_ptr + call_offset, bf, Cmd::BUILTIN)) {
|
||||
if (args_count !=
|
||||
*(uint *)(bf->code_ptr + call_offset + 1 + sizeof(uint32_t))) {
|
||||
*(uint32_t *)(bf->code_ptr + call_offset + 1 + sizeof(uint32_t))) {
|
||||
ip_failure(saved_current_ip, bf, "wrong builtin call argument count");
|
||||
}
|
||||
} else if (is_command_name(bf->code_ptr + call_offset, bf, Cmd::BEGIN)) {
|
||||
if (args_count != *(uint *)(bf->code_ptr + call_offset + 1)) {
|
||||
if (args_count != *(uint32_t *)(bf->code_ptr + call_offset + 1)) {
|
||||
ip_failure(saved_current_ip, bf, "wrong call argument count");
|
||||
}
|
||||
} else {
|
||||
|
|
@ -352,7 +352,7 @@ void analyze(Bytefile *bf, std::vector<size_t> &&add_publics) {
|
|||
// add end to behave like end
|
||||
++func_end_found;
|
||||
|
||||
/*uint args_count = */ ip_read_int_unsafe(¤t_ip);
|
||||
/*uint32_t args_count = */ ip_read_int_unsafe(¤t_ip);
|
||||
|
||||
// NOTE: args checks done in corresponding CALL/CALLC
|
||||
} break;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,11 @@ int main(int argc, char **argv) {
|
|||
else if (strcmp(argv[1], "-p") == 0) {
|
||||
do_print = true;
|
||||
} else {
|
||||
#ifdef WITH_CHECK
|
||||
failure("wrong execution option (acceptable options - '-i')");
|
||||
#else
|
||||
failure("wrong execution option (acceptable options - '-i', '-v', '-vi')");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (argc < 3) {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ static inline void call_Barray(size_t elem_count) {
|
|||
s_push(array);
|
||||
}
|
||||
|
||||
void call_builtin(uint builtin_id, uint args_count) {
|
||||
void call_builtin(uint32_t builtin_id, uint32_t args_count) {
|
||||
#ifndef WITH_CHECK
|
||||
if (builtin_id >= BUILTIN_NONE) {
|
||||
s_failure(&s, "invalid builtin");
|
||||
|
|
@ -211,7 +211,7 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
}
|
||||
|
||||
case CMD_BASIC_JMP: { // JMP 0x%.8x
|
||||
uint jmp_p = ip_read_int(&s.ip);
|
||||
uint32_t jmp_p = ip_read_int(&s.ip);
|
||||
|
||||
#ifndef WITH_CHECK
|
||||
if (jmp_p >= s.bf->code_size) {
|
||||
|
|
@ -284,7 +284,7 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
case CMD_CTRL:
|
||||
switch (l) {
|
||||
case CMD_CTRL_CJMPz: { // CJMPz 0x%.8x
|
||||
uint jmp_p = ip_read_int(&s.ip);
|
||||
uint32_t jmp_p = ip_read_int(&s.ip);
|
||||
|
||||
#ifndef WITH_CHECK
|
||||
if (jmp_p >= s.bf->code_size) {
|
||||
|
|
@ -298,7 +298,7 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
}
|
||||
|
||||
case CMD_CTRL_CJMPnz: { // CJMPnz 0x%.8x
|
||||
uint jmp_p = ip_read_int(&s.ip);
|
||||
uint32_t jmp_p = ip_read_int(&s.ip);
|
||||
|
||||
#ifndef WITH_CHECK
|
||||
if (jmp_p >= s.bf->code_size) {
|
||||
|
|
@ -312,12 +312,12 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
}
|
||||
|
||||
case CMD_CTRL_BEGIN: { // BEGIN %d %d // function begin
|
||||
uint args_sz = ip_read_int(&s.ip);
|
||||
uint32_t args_sz = ip_read_int(&s.ip);
|
||||
// #ifdef WITH_CHECK
|
||||
uint locals_sz = ip_read_half_int(&s.ip);
|
||||
uint max_additional_stack_sz = ip_read_half_int(&s.ip);
|
||||
uint32_t locals_sz = ip_read_half_int(&s.ip);
|
||||
uint32_t max_additional_stack_sz = ip_read_half_int(&s.ip);
|
||||
// #else
|
||||
// uint locals_sz = ip_read_int(&s.ip);
|
||||
// uint32_t locals_sz = ip_read_int(&s.ip);
|
||||
// #endif
|
||||
#ifndef WITH_CHECK
|
||||
if (s.fp != NULL && s.call_ip == NULL) {
|
||||
|
|
@ -336,12 +336,12 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
|
||||
case CMD_CTRL_CBEGIN: { // CBEGIN %d %d
|
||||
// NOTE: example not found, no checks done
|
||||
uint args_sz = ip_read_int(&s.ip);
|
||||
uint32_t args_sz = ip_read_int(&s.ip);
|
||||
// #ifdef WITH_CHECK
|
||||
uint locals_sz = ip_read_half_int(&s.ip);
|
||||
uint max_additional_stack_sz = ip_read_half_int(&s.ip);
|
||||
uint32_t locals_sz = ip_read_half_int(&s.ip);
|
||||
uint32_t max_additional_stack_sz = ip_read_half_int(&s.ip);
|
||||
// #else
|
||||
// uint locals_sz = ip_read_int(&s.ip);
|
||||
// uint32_t locals_sz = ip_read_int(&s.ip);
|
||||
// #endif
|
||||
#ifndef WITH_CHECK
|
||||
if (s.fp != NULL && s.call_ip == NULL) {
|
||||
|
|
@ -403,7 +403,7 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
}
|
||||
|
||||
case CMD_CTRL_CALL: { // CALL 0x%.8x %d // call function
|
||||
uint call_p = ip_read_int(&s.ip);
|
||||
uint32_t call_p = ip_read_int(&s.ip);
|
||||
ip_read_int(&s.ip); // args count
|
||||
|
||||
call_happened = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue