Class: Loxxy::Ast::LoxClassStmt

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

Overview

A parse tree node that represents a Lox class 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, aSuperclassName, theMethods) ⇒ LoxClassStmt

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 class name

  • aSuperclassName (String)

    the super class name

  • theMethods (Array<Loxxy::Ast::LoxFunStmt>)

    the methods



23
24
25
26
27
28
# File 'lib/loxxy/ast/lox_class_stmt.rb', line 23

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:



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

def body
  @body
end

#nameString (readonly)

Returns the class name.

Returns:

  • (String)

    the class name



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

def name
  @name
end

#superclassAst::LoxVariableExpr (readonly)

Returns variable referencing the superclass (if any).

Returns:



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

def superclass
  @superclass
end