From f9187ea58319ddc9691eb63ca6366c055ac14fbb Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 5 Sep 2022 10:39:46 -0400 Subject: [PATCH] Created getters for func section --- parser/accessors.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/parser/accessors.go b/parser/accessors.go index b3f394e..28e51d9 100644 --- a/parser/accessors.go +++ b/parser/accessors.go @@ -232,3 +232,45 @@ func (phrase Phrase) Block () (block Block) { return } +// Receiver returns the method receiver, if there is one. Otherwise, it returns +// nil. +func (section FuncSection) Receiver () (receiver *Declaration) { + receiver = section.receiver + return +} + +// InputsLength returns the number of inputs in the function. +func (section FuncSection) InputsLength () (length int) { + length = len(section.inputs) + return +} + +// Input returns the input at index. +func (section FuncSection) Input (index int) (input Declaration) { + input = section.inputs[index] + return +} + +// OutputsLength returns the number of outputs in the function. +func (section FuncSection) OutputsLength () (length int) { + length = len(section.outputs) + return +} + +// Output returns the output at index. +func (section FuncSection) Output (index int) (output FuncOutput) { + output = section.outputs[index] + return +} + +// Root returns the root block of the section. +func (section FuncSection) Root () (root Block) { + root = section.root + return +} + +// External returns whether or not the function is an external function or not. +func (section FuncSection) External () (external bool) { + external = section.external + return +}