Stubs for arrays access expressions in passes

This commit is contained in:
Pranav Gaddamadugu 2023-10-08 11:27:47 -04:00 committed by Pranav Gaddamadugu
parent c94acdebbd
commit eb420b6544
4 changed files with 14 additions and 0 deletions

View File

@ -62,6 +62,11 @@ impl<'a> ExpressionVisitor<'a> for CheckUniqueNodeIds<'a> {
fn visit_access(&mut self, input: &'a AccessExpression, _: &Self::AdditionalInput) -> Self::Output {
match input {
AccessExpression::Array(ArrayAccess { array, index, id, .. }) => {
self.visit_expression(array, &Default::default());
self.visit_expression(index, &Default::default());
self.check(*id);
}
AccessExpression::AssociatedConstant(AssociatedConstant { ty, name, id, .. }) => {
self.check_ty(ty);
self.visit_identifier(name, &Default::default());

View File

@ -492,6 +492,7 @@ impl<'a> CodeGenerator<'a> {
fn visit_access(&mut self, input: &'a AccessExpression) -> (String, String) {
match input {
AccessExpression::Array(array) => todo!(),
AccessExpression::Member(access) => self.visit_member_access(access),
AccessExpression::AssociatedConstant(constant) => self.visit_associated_constant(constant),
AccessExpression::AssociatedFunction(function) => self.visit_associated_function(function),

View File

@ -18,6 +18,7 @@ use crate::DeadCodeEliminator;
use leo_ast::{
AccessExpression,
ArrayAccess,
AssociatedFunction,
Expression,
ExpressionReconstructor,
@ -37,6 +38,12 @@ impl ExpressionReconstructor for DeadCodeEliminator<'_> {
fn reconstruct_access(&mut self, input: AccessExpression) -> (Expression, Self::AdditionalOutput) {
(
Expression::Access(match input {
AccessExpression::Array(array) => AccessExpression::Array(ArrayAccess {
array: Box::new(self.reconstruct_expression(*array.array).0),
index: Box::new(self.reconstruct_expression(*array.index).0),
span: array.span,
id: array.id,
}),
AccessExpression::AssociatedFunction(function) => {
// If the associated function manipulates a mapping, mark the statement as necessary.
match (&function.ty, function.name.name) {

View File

@ -42,6 +42,7 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
fn visit_access(&mut self, input: &'a AccessExpression, expected: &Self::AdditionalInput) -> Self::Output {
match input {
AccessExpression::Array(array) => todo!(),
AccessExpression::AssociatedFunction(access) => {
// Check core struct name and function.
if let Some(core_instruction) = self.get_core_function_call(&access.ty, &access.name) {