mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-15 15:01:07 +00:00
@@ -130,15 +130,8 @@ where
|
||||
let identifier = self.bindings.remove(0);
|
||||
let pointer = context
|
||||
.current_function()
|
||||
.borrow()
|
||||
.get_stack_pointer(identifier.inner.as_str())
|
||||
.ok_or_else(|| {
|
||||
anyhow::anyhow!(
|
||||
"{} Assignment to an undeclared variable `{}`",
|
||||
identifier.location,
|
||||
identifier.inner,
|
||||
)
|
||||
})?;
|
||||
.borrow_mut()
|
||||
.get_stack_pointer(context, identifier.inner.clone());
|
||||
context.build_store(pointer, value.access(context)?)?;
|
||||
return Ok(());
|
||||
}
|
||||
@@ -165,15 +158,8 @@ where
|
||||
|
||||
let binding_pointer = context
|
||||
.current_function()
|
||||
.borrow()
|
||||
.get_stack_pointer(binding.inner.as_str())
|
||||
.ok_or_else(|| {
|
||||
anyhow::anyhow!(
|
||||
"{} Assignment to an undeclared variable `{}`",
|
||||
binding.location,
|
||||
binding.inner,
|
||||
)
|
||||
})?;
|
||||
.borrow_mut()
|
||||
.get_stack_pointer(context, binding.inner.clone());
|
||||
let value = context.build_load(
|
||||
field_pointer,
|
||||
format!("assignment_binding_{index}_value").as_str(),
|
||||
|
||||
@@ -123,11 +123,8 @@ impl Expression {
|
||||
|
||||
let pointer = context
|
||||
.current_function()
|
||||
.borrow()
|
||||
.get_stack_pointer(&id)
|
||||
.ok_or_else(|| {
|
||||
anyhow::anyhow!("{} Undeclared variable `{}`", identifier.location, id)
|
||||
})?;
|
||||
.borrow_mut()
|
||||
.get_stack_pointer(context, id.clone());
|
||||
|
||||
let constant = context.current_function().borrow().yul().get_constant(&id);
|
||||
|
||||
|
||||
@@ -212,6 +212,7 @@ where
|
||||
function_type,
|
||||
self.result.len(),
|
||||
Some(inkwell::module::Linkage::External),
|
||||
1024,
|
||||
)?;
|
||||
revive_llvm_context::PolkaVMFunction::set_attributes(
|
||||
context.llvm(),
|
||||
@@ -244,7 +245,7 @@ where
|
||||
context
|
||||
.current_function()
|
||||
.borrow_mut()
|
||||
.insert_stack_pointer(identifier.inner, pointer);
|
||||
.insert_stack_pointer(context, identifier.inner);
|
||||
}
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } => {
|
||||
for (index, identifier) in self.result.into_iter().enumerate() {
|
||||
@@ -264,25 +265,24 @@ where
|
||||
context
|
||||
.current_function()
|
||||
.borrow_mut()
|
||||
.insert_stack_pointer(identifier.inner.clone(), pointer);
|
||||
.insert_stack_pointer(context, identifier.inner.clone());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let argument_types: Vec<_> = self
|
||||
.arguments
|
||||
.iter()
|
||||
.map(|argument| {
|
||||
let yul_type = argument.r#type.to_owned().unwrap_or_default();
|
||||
yul_type.into_llvm(context)
|
||||
})
|
||||
.collect();
|
||||
//let argument_types: Vec<_> = self
|
||||
// .arguments
|
||||
// .iter()
|
||||
// .map(|argument| {
|
||||
// let yul_type = argument.r#type.to_owned().unwrap_or_default();
|
||||
// yul_type.into_llvm(context)
|
||||
// })
|
||||
// .collect();
|
||||
for (index, argument) in self.arguments.iter().enumerate() {
|
||||
let pointer = context.build_alloca(argument_types[index], argument.inner.as_str());
|
||||
context
|
||||
let pointer = context
|
||||
.current_function()
|
||||
.borrow_mut()
|
||||
.insert_stack_pointer(argument.inner.clone(), pointer);
|
||||
.insert_stack_pointer(context, argument.inner.clone());
|
||||
context.build_store(
|
||||
pointer,
|
||||
context.current_function().borrow().get_nth_param(index),
|
||||
|
||||
@@ -104,11 +104,10 @@ where
|
||||
context.set_debug_location(self.location.line, 0, None)?;
|
||||
let identifier_type = identifier.r#type.clone().unwrap_or_default();
|
||||
let r#type = identifier_type.into_llvm(context);
|
||||
let pointer = context.build_alloca(r#type, identifier.inner.as_str());
|
||||
context
|
||||
let pointer = context
|
||||
.current_function()
|
||||
.borrow_mut()
|
||||
.insert_stack_pointer(identifier.inner.clone(), pointer);
|
||||
.insert_stack_pointer(context, identifier.inner.clone());
|
||||
|
||||
let value = if let Some(expression) = self.expression {
|
||||
match expression.into_llvm(context)? {
|
||||
@@ -140,15 +139,11 @@ where
|
||||
.to_owned()
|
||||
.unwrap_or_default()
|
||||
.into_llvm(context);
|
||||
let pointer = context.build_alloca(
|
||||
yul_type.as_basic_type_enum(),
|
||||
format!("binding_{index}_pointer").as_str(),
|
||||
);
|
||||
context.build_store(pointer, yul_type.const_zero())?;
|
||||
context
|
||||
let pointer = context
|
||||
.current_function()
|
||||
.borrow_mut()
|
||||
.insert_stack_pointer(binding.inner.to_owned(), pointer);
|
||||
.insert_stack_pointer(context, binding.inner.to_owned());
|
||||
context.build_store(pointer, yul_type.const_zero())?;
|
||||
}
|
||||
|
||||
let expression = match self.expression.take() {
|
||||
@@ -203,14 +198,7 @@ where
|
||||
let pointer = context
|
||||
.current_function()
|
||||
.borrow_mut()
|
||||
.get_stack_pointer(binding.inner.as_str())
|
||||
.ok_or_else(|| {
|
||||
anyhow::anyhow!(
|
||||
"{} Assignment to an undeclared variable `{}`",
|
||||
binding.location,
|
||||
binding.inner
|
||||
)
|
||||
})?;
|
||||
.get_stack_pointer(context, binding.inner.to_owned());
|
||||
context.build_store(pointer, value)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +70,11 @@ impl Type {
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
match self {
|
||||
Self::Bool => context.integer_type(revive_common::BIT_LENGTH_BOOLEAN),
|
||||
Self::Int(bitlength) => context.integer_type(bitlength),
|
||||
//Self::Bool => context.integer_type(revive_common::BIT_LENGTH_BOOLEAN),
|
||||
//Self::Int(bitlength) => context.integer_type(bitlength),
|
||||
Self::UInt(bitlength) => context.integer_type(bitlength),
|
||||
Self::Custom(_) => context.word_type(),
|
||||
//Self::Custom(_) => context.word_type(),
|
||||
_ => unreachable!("no other YUL type is supported"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user