mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-05-01 09:57:55 +00:00
@@ -121,11 +121,6 @@ where
|
||||
) -> anyhow::Result<()> {
|
||||
context.set_debug_location(self.location.line, 0, None)?;
|
||||
|
||||
let value = match self.initializer.into_llvm(context, None)? {
|
||||
Some(value) => value,
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
if self.bindings.len() == 1 {
|
||||
let identifier = self.bindings.remove(0);
|
||||
let pointer = context
|
||||
@@ -139,9 +134,27 @@ where
|
||||
identifier.inner,
|
||||
)
|
||||
})?;
|
||||
context.build_store(pointer, value.access(context)?)?;
|
||||
|
||||
let mut assignment_pointer = Some(pointer.value);
|
||||
let value = match self
|
||||
.initializer
|
||||
.into_llvm(context, &mut assignment_pointer)?
|
||||
{
|
||||
Some(value) => value,
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
if assignment_pointer.is_some() {
|
||||
context.build_store(pointer, value.access(context)?)?;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let value = match self.initializer.into_llvm(context, &mut None)? {
|
||||
Some(value) => value,
|
||||
None => return Ok(()),
|
||||
};
|
||||
let value = value.access(context)?;
|
||||
let llvm_type = value.into_struct_value().get_type();
|
||||
let tuple_pointer = context.build_alloca(llvm_type, "assignment_pointer");
|
||||
|
||||
@@ -184,7 +184,7 @@ where
|
||||
block.into_llvm(context)?;
|
||||
}
|
||||
Statement::Expression(expression) => {
|
||||
expression.into_llvm(context, None)?;
|
||||
expression.into_llvm(context, &mut None)?;
|
||||
}
|
||||
Statement::VariableDeclaration(statement) => statement.into_llvm(context)?,
|
||||
Statement::Assignment(statement) => statement.into_llvm(context)?,
|
||||
|
||||
@@ -118,7 +118,7 @@ impl FunctionCall {
|
||||
pub fn into_llvm<'ctx, D>(
|
||||
mut self,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
assignment_pointer: Option<inkwell::values::PointerValue<'ctx>>,
|
||||
assignment_pointer: &mut Option<inkwell::values::PointerValue<'ctx>>,
|
||||
) -> anyhow::Result<Option<inkwell::values::BasicValueEnum<'ctx>>>
|
||||
where
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
@@ -130,7 +130,7 @@ impl FunctionCall {
|
||||
let mut values = Vec::with_capacity(self.arguments.len());
|
||||
for argument in self.arguments.into_iter().rev() {
|
||||
let value = argument
|
||||
.into_llvm(context, None)?
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists")
|
||||
.access(context)?;
|
||||
values.push(value);
|
||||
@@ -417,8 +417,8 @@ impl FunctionCall {
|
||||
revive_llvm_context::polkavm_evm_memory::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
assignment_pointer,
|
||||
)
|
||||
.map(Some)
|
||||
}
|
||||
Name::MStore => {
|
||||
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
|
||||
@@ -994,7 +994,7 @@ impl FunctionCall {
|
||||
for expression in self.arguments.drain(0..N).rev() {
|
||||
arguments.push(
|
||||
expression
|
||||
.into_llvm(context, None)?
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists")
|
||||
.access(context)?,
|
||||
);
|
||||
@@ -1014,7 +1014,11 @@ impl FunctionCall {
|
||||
{
|
||||
let mut arguments = Vec::with_capacity(N);
|
||||
for expression in self.arguments.drain(0..N).rev() {
|
||||
arguments.push(expression.into_llvm(context, None)?.expect("Always exists"));
|
||||
arguments.push(
|
||||
expression
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists"),
|
||||
);
|
||||
}
|
||||
arguments.reverse();
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ impl Expression {
|
||||
pub fn into_llvm<'ctx, D>(
|
||||
self,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
assignment_pointer: Option<inkwell::values::PointerValue<'ctx>>,
|
||||
assignment_pointer: &mut Option<inkwell::values::PointerValue<'ctx>>,
|
||||
) -> anyhow::Result<Option<revive_llvm_context::PolkaVMArgument<'ctx>>>
|
||||
where
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
|
||||
@@ -76,7 +76,7 @@ where
|
||||
context.set_basic_block(condition_block);
|
||||
let condition = self
|
||||
.condition
|
||||
.into_llvm(context, None)?
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists")
|
||||
.access(context)?
|
||||
.into_int_value();
|
||||
|
||||
@@ -55,7 +55,7 @@ where
|
||||
fn into_llvm(self, context: &mut revive_llvm_context::PolkaVMContext<D>) -> anyhow::Result<()> {
|
||||
let condition = self
|
||||
.condition
|
||||
.into_llvm(context, None)?
|
||||
.into_llvm(context, &mut None)?
|
||||
.expect("Always exists")
|
||||
.access(context)?
|
||||
.into_int_value();
|
||||
|
||||
@@ -123,7 +123,7 @@ where
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm(self, context: &mut revive_llvm_context::PolkaVMContext<D>) -> anyhow::Result<()> {
|
||||
let scrutinee = self.expression.into_llvm(context, None)?;
|
||||
let scrutinee = self.expression.into_llvm(context, &mut None)?;
|
||||
|
||||
if self.cases.is_empty() {
|
||||
if let Some(block) = self.default {
|
||||
|
||||
@@ -110,8 +110,9 @@ where
|
||||
.borrow_mut()
|
||||
.insert_stack_pointer(identifier.inner.clone(), pointer);
|
||||
|
||||
let mut assignment_pointer = Some(pointer.value);
|
||||
let value = if let Some(expression) = self.expression {
|
||||
match expression.into_llvm(context, None)? {
|
||||
match expression.into_llvm(context, &mut assignment_pointer)? {
|
||||
Some(mut value) => {
|
||||
if let Some(constant) = value.constant.take() {
|
||||
context
|
||||
@@ -128,7 +129,9 @@ where
|
||||
} else {
|
||||
r#type.const_zero().as_basic_value_enum()
|
||||
};
|
||||
context.build_store(pointer, value)?;
|
||||
if assignment_pointer.is_some() {
|
||||
context.build_store(pointer, value)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -156,7 +159,7 @@ where
|
||||
None => return Ok(()),
|
||||
};
|
||||
let location = expression.location();
|
||||
let expression = match expression.into_llvm(context, None)? {
|
||||
let expression = match expression.into_llvm(context, &mut None)? {
|
||||
Some(expression) => expression,
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user