fn generate_field(&mut self, ast: &Ast, node: NodeId) -> Result<ExpressionResult, Error> {
      let (name, _) = ast.node_pair(node);
      let name = ast.string(name).unwrap();
      let struct_data = self
         .struct_data
         .as_deref()
         .ok_or_else(|| ast.error(node, ErrorKind::FieldOutsideOfImpl))?;
      let field_id = struct_data
         .get_field(name)
         .ok_or_else(|| ast.error(node, ErrorKind::FieldDoesNotExist(Rc::clone(name))))?;
      // Unwrapping is OK here because fields are not allowed outside of functions, and each
      // function with `StructData` passed in assigns to `receiver` at the start of its
      // code generation.
      let receiver = struct_data.receiver.unwrap();
      self.generate_variable_load(receiver);
      self.chunk.emit((Opcode::GetField, field_id));
      Ok(ExpressionResult::Present)
   }
/// Generates code for a field lookup.
Generates code for a field lookup.
Generates code for a field lookup .
fn generate_field(&mut self, ast: &Ast, node: NodeId) -> Result<ExpressionResult, Error> {
      let (name, _) = ast.node_pair(node);
      let name = ast.string(name).unwrap();
      let struct_data = self
         .struct_data
         .as_deref()
         .ok_or_else(|| ast.error(node, ErrorKind::FieldOutsideOfImpl))?;
      let field_id = struct_data
         .get_field(name)
         .ok_or_else(|| ast.error(node, ErrorKind::FieldDoesNotExist(Rc::clone(name))))?;
      // Unwrapping is OK here because fields are not allowed outside of functions, and each
      // function with `StructData` passed in assigns to `receiver` at the start of its
      // code generation.
      let receiver = struct_data.receiver.unwrap();
      self.generate_variable_load(receiver);
      self.chunk.emit((Opcode::GetField, field_id));
      Ok(ExpressionResult::Present)
   }
fn generate_field ( & mut self , ast : & Ast , node : NodeId ) -> Result < ExpressionResult , Error > { let ( name , _ ) = ast . node_pair ( node ) ; let name = ast . string ( name ) . unwrap ( ) ; let struct_data = self . struct_data . as_deref ( ) . ok_or_else ( | | ast . error ( node , ErrorKind :: FieldOutsideOfImpl ) ) ? ; let field_id = struct_data . get_field ( name ) . ok_or_else ( | | ast . error ( node , ErrorKind :: FieldDoesNotExist ( Rc :: clone ( name ) ) ) ) ? ; // Unwrapping is OK here because fields are not allowed outside of functions, and each // function with `StructData` passed in assigns to `receiver` at the start of its // code generation. let receiver = struct_data . receiver . unwrap ( ) ; self . generate_variable_load ( receiver ) ; self . chunk . emit ( ( Opcode :: GetField , field_id ) ) ; Ok ( ExpressionResult :: Present ) }
Generates code for a field lookup.
Generates code for a field lookup .
&mut self
ast
&Ast
node
NodeId