Class: Loxxy::Ast::LoxFunStmt

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

Overview

rubocop: disable Style/AccessorGrouping

Instance Attribute Summary collapse

Attributes inherited from LoxNode

#position

Instance Method Summary collapse

Methods inherited from LoxNode

#done!

Constructor Details

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

Returns a new instance of LoxFunStmt.

Parameters:

  • aPosition (Rley::Lexical::Position)

    Position of the entry in the input stream.

  • aName (String)
  • arguments (Array<String>)
  • body (Ast::LoxBlockStmt)


18
19
20
21
22
23
24
# File 'lib/loxxy/ast/lox_fun_stmt.rb', line 18

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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#is_methodObject

Returns the value of attribute is_method.



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

def is_method
  @is_method
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

Instance Method Details

#accept(visitor) ⇒ Object

Part of the 'visitee' role in Visitor design pattern.

Parameters:



28
29
30
# File 'lib/loxxy/ast/lox_fun_stmt.rb', line 28

def accept(visitor)
  visitor.visit_fun_stmt(self)
end