Class: Loxxy::Ast::LoxClassStmt

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

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, aSuperclassName, theMethods) ⇒ LoxClassStmt

Returns a new instance of LoxClassStmt.

Parameters:



20
21
22
23
24
25
# File 'lib/loxxy/ast/lox_class_stmt.rb', line 20

def initialize(aPosition, aName, aSuperclassName, theMethods)
  super(aPosition, [])
  @name = aName.dup
  @superclass = aSuperclassName
  @body = theMethods
end

Instance Attribute Details

#bodyArray<Ast::LoxFunStmt> (readonly)

Returns the methods.

Returns:



15
16
17
# File 'lib/loxxy/ast/lox_class_stmt.rb', line 15

def body
  @body
end

#nameString (readonly)

Returns the class name.

Returns:

  • (String)

    the class name



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

def name
  @name
end

#superclassAst::LoxVariableExpr (readonly)

Returns variable referencing the superclass (if any).

Returns:



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

def superclass
  @superclass
end

Instance Method Details

#accept(visitor) ⇒ Object

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

Parameters:



29
30
31
# File 'lib/loxxy/ast/lox_class_stmt.rb', line 29

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