Skip to content

Commit

Permalink
Fix parsing complex map types and addresses with ByStr20 with type (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
saeed-zil authored Nov 12, 2024
1 parent 9bb7684 commit c29cfae
Show file tree
Hide file tree
Showing 3 changed files with 1,052 additions and 8 deletions.
56 changes: 48 additions & 8 deletions src/simplified_representation/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ impl AstConverting for SrEmitter {
_mode: TreeTraversalMode,
_node: &NodeAddressTypeField,
) -> Result<TraversalResult, String> {
unimplemented!();
Ok(TraversalResult::Continue)
}
fn emit_address_type(
&mut self,
_mode: TreeTraversalMode,
_node: &NodeAddressType,
) -> Result<TraversalResult, String> {
unimplemented!();
Ok(TraversalResult::Continue)
}

fn emit_full_expression(
Expand Down Expand Up @@ -609,16 +609,56 @@ impl AstConverting for SrEmitter {
}
fn emit_type_map_value_arguments(
&mut self,
_mode: TreeTraversalMode,
_node: &NodeTypeMapValueArguments,
mode: TreeTraversalMode,
node: &NodeTypeMapValueArguments,
) -> Result<TraversalResult, String> {
unimplemented!();
match mode {
TreeTraversalMode::Enter => {
match node {
NodeTypeMapValueArguments::EnclosedTypeMapValue(_) => todo!(),
NodeTypeMapValueArguments::GenericMapValueArgument(g) => {
g.visit(self)?;
let identifier = self.pop_ir_identifier()?;
self.stack
.push(StackObject::TypeDefinition(identifier.into()));
}
NodeTypeMapValueArguments::MapKeyValueType(_, _) => todo!(),
};
}
TreeTraversalMode::Exit => (),
}
Ok(TraversalResult::SkipChildren)
}
fn emit_type_map_value_allowing_type_arguments(
&mut self,
_mode: TreeTraversalMode,
_node: &NodeTypeMapValueAllowingTypeArguments,
mode: TreeTraversalMode,
node: &NodeTypeMapValueAllowingTypeArguments,
) -> Result<TraversalResult, String> {
Ok(TraversalResult::Continue)
match mode {
TreeTraversalMode::Enter => {
match node {
NodeTypeMapValueAllowingTypeArguments::TypeMapValueNoArgs(m) => {
m.visit(self)?;
}
NodeTypeMapValueAllowingTypeArguments::TypeMapValueWithArgs(m, args) => {
m.visit(self)?;
let identifier = self.pop_ir_identifier()?;
self.stack
.push(StackObject::TypeDefinition(identifier.into()));
if !args.is_empty() {
let mut main_type = self.pop_type_definition()?;
for arg in args {
let _ = arg.visit(self)?;
let sub_type = self.pop_type_definition()?;
main_type.push_sub_type(sub_type);
}
self.stack.push(StackObject::TypeDefinition(main_type));
}
}
};
}
TreeTraversalMode::Exit => (),
}
Ok(TraversalResult::SkipChildren)
}
}
Loading

0 comments on commit c29cfae

Please sign in to comment.