mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-23 00:18:24 +00:00
arns
This commit is contained in:
parent
64dd61be3a
commit
1dfad6e1b6
|
@ -131,7 +131,7 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
info!("functions:\n{:#?}", self.functions);
|
info!("functions:\n{:#?}", self.functions);
|
||||||
|
|
||||||
// implement them.
|
// implement them.
|
||||||
for (_, function) in &self.functions {
|
for function in self.functions.values() {
|
||||||
self.compile_function(function)?;
|
self.compile_function(function)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let value = self
|
let value = self
|
||||||
.compile_expression(&value, variables, scope_info)?
|
.compile_expression(value, variables, scope_info)?
|
||||||
.expect("should have result");
|
.expect("should have result");
|
||||||
|
|
||||||
variables.insert(
|
variables.insert(
|
||||||
|
@ -265,7 +265,7 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
}
|
}
|
||||||
Statement::Mutate { name, value, .. } => {
|
Statement::Mutate { name, value, .. } => {
|
||||||
let value = self
|
let value = self
|
||||||
.compile_expression(&value, variables, scope_info)?
|
.compile_expression(value, variables, scope_info)?
|
||||||
.expect("should have result");
|
.expect("should have result");
|
||||||
|
|
||||||
let var = variables
|
let var = variables
|
||||||
|
@ -277,7 +277,7 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
Statement::Return(ret) => {
|
Statement::Return(ret) => {
|
||||||
if let Some(ret) = ret {
|
if let Some(ret) = ret {
|
||||||
let value = self
|
let value = self
|
||||||
.compile_expression(&ret, variables, scope_info)?
|
.compile_expression(ret, variables, scope_info)?
|
||||||
.expect("should have result");
|
.expect("should have result");
|
||||||
self.builder.build_return(Some(&value));
|
self.builder.build_return(Some(&value));
|
||||||
} else {
|
} else {
|
||||||
|
@ -397,7 +397,7 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
scope_info: &HashMap<String, Vec<TypeExp>>,
|
scope_info: &HashMap<String, Vec<TypeExp>>,
|
||||||
) -> Result<Option<BasicValueEnum<'ctx>>> {
|
) -> Result<Option<BasicValueEnum<'ctx>>> {
|
||||||
Ok(match &*expr.value {
|
Ok(match &*expr.value {
|
||||||
Expression::Variable { name } => Some(self.compile_variable(&name, variables)?),
|
Expression::Variable { name } => Some(self.compile_variable(name, variables)?),
|
||||||
Expression::Literal(term) => Some(self.compile_literal(term)?),
|
Expression::Literal(term) => Some(self.compile_literal(term)?),
|
||||||
Expression::Call { function, args } => {
|
Expression::Call { function, args } => {
|
||||||
self.compile_call(function, args, variables, scope_info)?
|
self.compile_call(function, args, variables, scope_info)?
|
||||||
|
|
|
@ -92,7 +92,7 @@ fn type_inference_scope(
|
||||||
} => {
|
} => {
|
||||||
new_vars.insert(name.value.clone());
|
new_vars.insert(name.value.clone());
|
||||||
|
|
||||||
let exp_type = type_inference_expression(&value, &mut scope_vars, storage, None)?;
|
let exp_type = type_inference_expression(value, &mut scope_vars, storage, None)?;
|
||||||
|
|
||||||
if !scope_vars.contains_key(&name.value) {
|
if !scope_vars.contains_key(&name.value) {
|
||||||
scope_vars.insert(name.value.clone(), vec![]);
|
scope_vars.insert(name.value.clone(), vec![]);
|
||||||
|
@ -121,7 +121,7 @@ fn type_inference_scope(
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let exp_type = type_inference_expression(&value, &mut scope_vars, storage, None)?;
|
let exp_type = type_inference_expression(value, &mut scope_vars, storage, None)?;
|
||||||
let var = scope_vars.get_mut(&name.value).unwrap().last_mut().unwrap();
|
let var = scope_vars.get_mut(&name.value).unwrap().last_mut().unwrap();
|
||||||
|
|
||||||
if var.is_none() {
|
if var.is_none() {
|
||||||
|
@ -142,7 +142,7 @@ fn type_inference_scope(
|
||||||
else_body_scope_type_info,
|
else_body_scope_type_info,
|
||||||
} => {
|
} => {
|
||||||
type_inference_expression(
|
type_inference_expression(
|
||||||
&condition,
|
condition,
|
||||||
&mut scope_vars,
|
&mut scope_vars,
|
||||||
storage,
|
storage,
|
||||||
Some(TypeExp::Boolean),
|
Some(TypeExp::Boolean),
|
||||||
|
|
Loading…
Reference in a new issue