fn generate_function_declaration(
      &mut self,
      ast: &Ast,
      node: NodeId,
   ) -> Result<ExpressionResult, Error> {
      let (name_node, parameters) = ast.node_pair(node);
      let name = ast.string(name_node).unwrap();

      if ast.node_pair(parameters).0 != NodeId::EMPTY {
         return Err(ast.error(
            ast.node_pair(parameters).0,
            ErrorKind::FunctionKindOutsideImpl,
         ));
      }

      // Create the variable before compiling the function, to allow for recursion.
      let variable = self
         .create_variable(name, VariableAllocation::Allocate)
         .map_err(|kind| ast.error(name_node, kind))?;

      let function = self.generate_function(
         ast,
         node,
         GenerateFunctionOptions {
            name: Rc::clone(name),
            call_conv: FunctionCallConv::Bare,
         },
      )?;

      self.chunk.emit((Opcode::CreateClosure, function.id));
      self.generate_variable_sink(variable);

      Ok(ExpressionResult::Absent)
   }
/// Generates code for a bare function declaration.
Generates code for a bare function declaration.
Generates code for a bare function declaration .
fn generate_function_declaration(
      &mut self,
      ast: &Ast,
      node: NodeId,
   ) -> Result<ExpressionResult, Error> {
      let (name_node, parameters) = ast.node_pair(node);
      let name = ast.string(name_node).unwrap();
      if ast.node_pair(parameters).0 != NodeId::EMPTY {
         return Err(ast.error(
            ast.node_pair(parameters).0,
            ErrorKind::FunctionKindOutsideImpl,
         ));
      }
      // Create the variable before compiling the function, to allow for recursion.
      let variable = self
         .create_variable(name, VariableAllocation::Allocate)
         .map_err(|kind| ast.error(name_node, kind))?;
      let function = self.generate_function(
         ast,
         node,
         GenerateFunctionOptions {
            name: Rc::clone(name),
            call_conv: FunctionCallConv::Bare,
         },
      )?;
      self.chunk.emit((Opcode::CreateClosure, function.id));
      self.generate_variable_sink(variable);
      Ok(ExpressionResult::Absent)
   }
fn generate_function_declaration ( & mut self , ast : & Ast , node : NodeId , ) -> Result < ExpressionResult , Error > { let ( name_node , parameters ) = ast . node_pair ( node ) ; let name = ast . string ( name_node ) . unwrap ( ) ; if ast . node_pair ( parameters ) . 0 != NodeId :: EMPTY { return Err ( ast . error ( ast . node_pair ( parameters ) . 0 , ErrorKind :: FunctionKindOutsideImpl , ) ) ; } // Create the variable before compiling the function, to allow for recursion. let variable = self . create_variable ( name , VariableAllocation :: Allocate ) . map_err ( | kind | ast . error ( name_node , kind ) ) ? ; let function = self . generate_function ( ast , node , GenerateFunctionOptions { name : Rc :: clone ( name ) , call_conv : FunctionCallConv :: Bare , } , ) ? ; self . chunk . emit ( ( Opcode :: CreateClosure , function . id ) ) ; self . generate_variable_sink ( variable ) ; Ok ( ExpressionResult :: Absent ) }
Generates code for a bare function declaration.
Generates code for a bare function declaration .
&mut self
ast
&Ast
node
NodeId