aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-04-03 15:10:28 +0100
committerMichael Williamson <mike@zwobble.org>2026-04-03 15:10:28 +0100
commit3cf219dfd616900fabc0e7e17dc37faf882b3b34 (patch)
tree39282c7addd83d6f97ee19b94ae6f1619cc7efba
parente6a3252233241bceaf26afb4975681f343c85632 (diff)
Update generated code
-rw-r--r--patio-to-cranelift/src/lib.rs82
1 files changed, 27 insertions, 55 deletions
diff --git a/patio-to-cranelift/src/lib.rs b/patio-to-cranelift/src/lib.rs
index 58d379d2..e83dd455 100644
--- a/patio-to-cranelift/src/lib.rs
+++ b/patio-to-cranelift/src/lib.rs
@@ -58,19 +58,15 @@ fn declare_compilation_unit_element(
element: &PatioCompilationUnitElement,
context: &mut CompilerContext,
) {
- match element.value_compilation_unit_element_value_type() {
+ match element.value_type() {
PatioCompilationUnitElementValue::PatioFunctionDeclaration => {
- let function_declaration = element
- .value_compilation_unit_element_value_as_patio_function_declaration()
- .unwrap();
+ let function_declaration = element.value_as_patio_function_declaration().unwrap();
declare_function_declaration(function_declaration, context);
}
PatioCompilationUnitElementValue::PatioFunctionDefinition => {
- let function_definition = element
- .value_compilation_unit_element_value_as_patio_function_definition()
- .unwrap();
+ let function_definition = element.value_as_patio_function_definition().unwrap();
declare_function_definition(&function_definition, context);
}
@@ -87,13 +83,11 @@ fn define_compilation_unit_element(
element: &PatioCompilationUnitElement,
context: &mut CompilerContext,
) {
- match element.value_compilation_unit_element_value_type() {
+ match element.value_type() {
PatioCompilationUnitElementValue::PatioFunctionDeclaration => {}
PatioCompilationUnitElementValue::PatioFunctionDefinition => {
- let function_definition = element
- .value_compilation_unit_element_value_as_patio_function_definition()
- .unwrap();
+ let function_definition = element.value_as_patio_function_definition().unwrap();
define_function_definition(&function_definition, context);
}
@@ -189,84 +183,64 @@ fn compile_instruction(
instruction: PatioInstruction<'_>,
context: &mut CompilerFunctionContext<'_>,
) {
- match instruction.value_instruction_value_type() {
+ match instruction.value_type() {
PatioInstructionValue::PatioBlock => {
- let block = instruction
- .value_instruction_value_as_patio_block()
- .unwrap();
+ let block = instruction.value_as_patio_block().unwrap();
compile_block(block, context);
}
PatioInstructionValue::PatioBoolToInt => {
- let bool_to_int = instruction
- .value_instruction_value_as_patio_bool_to_int()
- .unwrap();
+ let bool_to_int = instruction.value_as_patio_bool_to_int().unwrap();
compile_bool_to_int(bool_to_int, context);
}
PatioInstructionValue::PatioCall => {
- let call = instruction.value_instruction_value_as_patio_call().unwrap();
+ let call = instruction.value_as_patio_call().unwrap();
compile_call(call, context);
}
PatioInstructionValue::PatioIf => {
- let if_ = instruction.value_instruction_value_as_patio_if().unwrap();
+ let if_ = instruction.value_as_patio_if().unwrap();
compile_if(if_, context);
}
PatioInstructionValue::PatioIntAdd => {
- let int_add = instruction
- .value_instruction_value_as_patio_int_add()
- .unwrap();
+ let int_add = instruction.value_as_patio_int_add().unwrap();
compile_int_add(int_add, context);
}
PatioInstructionValue::PatioIntEquals => {
- let int_equals = instruction
- .value_instruction_value_as_patio_int_equals()
- .unwrap();
+ let int_equals = instruction.value_as_patio_int_equals().unwrap();
compile_int_equals(int_equals, context);
}
PatioInstructionValue::PatioIntNotEqual => {
- let int_not_equal = instruction
- .value_instruction_value_as_patio_int_not_equal()
- .unwrap();
+ let int_not_equal = instruction.value_as_patio_int_not_equal().unwrap();
compile_int_not_equal(int_not_equal, context);
}
PatioInstructionValue::PatioIntSub => {
- let int_sub = instruction
- .value_instruction_value_as_patio_int_sub()
- .unwrap();
+ let int_sub = instruction.value_as_patio_int_sub().unwrap();
compile_int_sub(int_sub, context);
}
PatioInstructionValue::PatioIntToBool => {
- let int_to_bool = instruction
- .value_instruction_value_as_patio_int_to_bool()
- .unwrap();
+ let int_to_bool = instruction.value_as_patio_int_to_bool().unwrap();
compile_int_to_bool(int_to_bool, context);
}
PatioInstructionValue::PatioLocalStore => {
- let local_store = instruction
- .value_instruction_value_as_patio_local_store()
- .unwrap();
+ let local_store = instruction.value_as_patio_local_store().unwrap();
compile_local_store(local_store, context);
}
PatioInstructionValue::PatioReturn => {
- let return_ = instruction
- .value_instruction_value_as_patio_return()
- .unwrap();
+ let return_ = instruction.value_as_patio_return().unwrap();
compile_return(return_, context);
}
PatioInstructionValue::PatioReturnVoid => {
- let return_void = instruction
- .value_instruction_value_as_patio_return_void()
- .unwrap();
+ let return_void = instruction.value_as_patio_return_void().unwrap();
compile_return_void(return_void, context);
}
@@ -466,9 +440,9 @@ fn compile_operand(
operand: PatioOperand<'_>,
context: &mut CompilerFunctionContext<'_>,
) -> cranelift::prelude::Value {
- match operand.value_operand_value_type() {
+ match operand.value_type() {
PatioOperandValue::PatioBoolConst => {
- let bool_const = operand.value_operand_value_as_patio_bool_const().unwrap();
+ let bool_const = operand.value_as_patio_bool_const().unwrap();
let integer_value = if bool_const.value() { 1 } else { 0 };
context
@@ -478,18 +452,18 @@ fn compile_operand(
}
PatioOperandValue::PatioIntConst => {
- let int_const = operand.value_operand_value_as_patio_int_const().unwrap();
+ let int_const = operand.value_as_patio_int_const().unwrap();
let cranelift_int_type = cranelift_int_type(&context.target_triple);
compile_int_value(int_const.value(), cranelift_int_type, context)
}
PatioOperandValue::PatioInt32Const => {
- let int_32_const = operand.value_operand_value_as_patio_int_32_const().unwrap();
+ let int_32_const = operand.value_as_patio_int_32_const().unwrap();
compile_int_value(int_32_const.value(), CRANELIFT_INT_32_TYPE, context)
}
PatioOperandValue::PatioLocalRef => {
- let local_ref = operand.value_operand_value_as_patio_local_ref().unwrap();
+ let local_ref = operand.value_as_patio_local_ref().unwrap();
let cranelift_variable = context.var(local_ref.name());
context.function_builder.use_var(cranelift_variable)
}
@@ -509,11 +483,9 @@ fn compile_int_value(
cranelift_type: cranelift::prelude::Type,
context: &mut CompilerFunctionContext<'_>,
) -> cranelift::prelude::Value {
- match int_value.value_int_value_type() {
+ match int_value.value_type() {
PatioIntValueValue::PatioIntValueLiteral => {
- let literal = int_value
- .value_int_value_as_patio_int_value_literal()
- .unwrap();
+ let literal = int_value.value_as_patio_int_value_literal().unwrap();
context
.function_builder
@@ -567,7 +539,7 @@ fn cranelift_signature<'a>(
}
}
- if return_type.value_patio_type_type() != PatioTypeValue::PatioVoidType {
+ if return_type.value_type() != PatioTypeValue::PatioVoidType {
let cranelift_return_type = patio_type_to_cranelift_type(return_type, &target_triple);
let returns = cranelift::prelude::AbiParam::new(cranelift_return_type);
signature.returns.push(returns);
@@ -590,7 +562,7 @@ fn patio_type_to_cranelift_type(
patio_type: PatioType,
target_triple: &target_lexicon::Triple,
) -> cranelift::prelude::Type {
- match patio_type.value_patio_type_type() {
+ match patio_type.value_type() {
PatioTypeValue::PatioBoolType => CRANELIFT_BOOL_TYPE,
PatioTypeValue::PatioByteType => CRANELIFT_BYTE_TYPE,