Class: Loxxy::Ast::LoxFunStmt

Inherits:
LoxCompoundExpr show all
Defined in:
lib/loxxy/ast/lox_fun_stmt.rb

Overview

rubocop: disable Style/AccessorGrouping

Instance Attribute Summary collapse

Attributes inherited from LoxCompoundExpr

#subnodes

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)


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

def initialize(aPosition, aName, paramList, aBody)
  super(aPosition, [])
  @name = aName
  @params = paramList
  @body = aBody
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

#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:



26
27
28
# File 'lib/loxxy/ast/lox_fun_stmt.rb', line 26

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