start working on supporting operations
This commit is contained in:
29
src/translator/operation/operation.c
Normal file
29
src/translator/operation/operation.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 William Bell
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "operation.h"
|
||||
#include <stddef.h>
|
||||
|
||||
size_t translate_operation(Translated *translated, ParsedOperation *operation,
|
||||
ArErr *err) {
|
||||
set_registers(translated, 1);
|
||||
uint64_t first = push_instruction_byte(translated, OP_LOAD_ADDITION_FUNCTION);
|
||||
push_instruction_byte(translated, OP_INIT_CALL);
|
||||
push_instruction_code(translated, operation->to_operate_on.size);
|
||||
|
||||
for (size_t i = 0; i < operation->to_operate_on.size; i++) {
|
||||
translate_parsed(translated, darray_get(&operation->to_operate_on, i), err);
|
||||
push_instruction_byte(translated, OP_INSERT_ARG);
|
||||
push_instruction_code(translated, i);
|
||||
}
|
||||
|
||||
push_instruction_byte(translated, OP_SOURCE_LOCATION);
|
||||
push_instruction_code(translated, operation->line);
|
||||
push_instruction_code(translated, operation->column);
|
||||
push_instruction_code(translated, operation->length);
|
||||
push_instruction_byte(translated, OP_CALL);
|
||||
return first;
|
||||
}
|
||||
Reference in New Issue
Block a user