Class: Loxxy::Ast::LoxFunStmt

Inherits:
LoxNode
  • Object
show all
Defined in:
lib/loxxy/ast/lox_fun_stmt.rb

Overview

A parse tree node that represents a Lox function declaration.

Instance Attribute Summary collapse

Attributes inherited from LoxNode

#position

Instance Method Summary collapse

Methods inherited from LoxNode

#accept, #done!

Methods included from ASTVisitee

#define_accept, #snake_case

Constructor Details

#initialize(aPosition, aName, paramList, aBody) ⇒ LoxFunStmt

Constructor for a parse node that represents a Lox function declaration

Parameters:

  • aPosition (Rley::Lexical::Position)

    Position of the entry in the input stream.

  • aName (String)

    the function name

  • paramList (Array<String>)

    the parameter names

  • aBody (Ast::LoxBlockStmt)

    the parse tree representing the function's body



26
27
28
29
30
31
32
# File 'lib/loxxy/ast/lox_fun_stmt.rb', line 26

def initialize(aPosition, aName, paramList, aBody)
  super(aPosition)
  @name = aName.dup
  @params = paramList
  @body = aBody
  @is_method = false
end

Instance Attribute Details

#bodyAst::LoxBlockStmt (readonly)

Returns the parse tree representing the function's body.

Returns:



16
17
18
# File 'lib/loxxy/ast/lox_fun_stmt.rb', line 16

def body
  @body
end

#is_methodBoolean

Returns true if the function is a method.

Returns:

  • (Boolean)

    true if the function is a method



19
20
21
# File 'lib/loxxy/ast/lox_fun_stmt.rb', line 19

def is_method
  @is_method
end

#nameString (readonly)

Returns the function name.

Returns:

  • (String)

    the function name



10
11
12
# File 'lib/loxxy/ast/lox_fun_stmt.rb', line 10

def name
  @name
end

#paramsArray<String> (readonly)

Returns the parameter names.

Returns:

  • (Array<String>)

    the parameter names



13
14
15
# File 'lib/loxxy/ast/lox_fun_stmt.rb', line 13

def params
  @params
end