symbols

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MinSymbolAllocationSize = 16

No symbol table allocation extent will be smaller than this size. Exported because it is referenced by CLI handlers.

Variables

View Source
var RootSymbolTable = SymbolTable{
	Name: "root",
	// contains filtered or unexported fields
}

RootSymbolTable is the parent of all other tables. It is populated by the initialized structures above.

View Source
var SymbolAllocationSize = 32

SymbolAllocationSize is the number of symbols that are allocated in each bin of a symbol table. Allocation within a bin is faster than creating a new bin, so this value should reflect the most common maximum size of a symbol table. Note that symbol tables are created for each basic block, so the idea value may be smaller than the number of symbols in a program. Exported because it can be set by a caller prior to constructing a symbol table. For example,both the RUN and SERVER RUN commands have command line options to set this value.

Functions

This section is empty.

Types

type SymbolAttribute

type SymbolAttribute struct {
	Readonly bool
	// contains filtered or unexported fields
}

SymbolAttribute is the object that defines information about a symbol. This includes private data that indicates where the value is stored, as well as metadata about the symbol.

type SymbolTable

type SymbolTable struct {
	Name string
	// contains filtered or unexported fields
}

SymbolTable contains an abstract symbol table.

func NewChildSymbolTable

func NewChildSymbolTable(name string, parent *SymbolTable) *SymbolTable

NewChildSymbolTableWithSize generates a new symbol table with an assigned parent table. The table is created with a default capacity.

func NewRootSymbolTable

func NewRootSymbolTable(name string) *SymbolTable

func NewSymbolTable

func NewSymbolTable(name string) *SymbolTable

NewSymbolTable generates a new symbol table.

func (*SymbolTable) AddressOfValue

func (s *SymbolTable) AddressOfValue(index int) *interface{}

Given an index, return the address of the value in that slot.

func (*SymbolTable) Clone

func (s *SymbolTable) Clone(withLock bool) *SymbolTable

Make a copy of the symbol table, retaining the same values as before (in fact, the values are shared between the tables). This is mostly used to create unique symbol and constant maps, which are needed for shallow clones of a compiler.

func (*SymbolTable) Create

func (s *SymbolTable) Create(name string) error

Create creates a symbol name in the table.

func (*SymbolTable) Delete

func (s *SymbolTable) Delete(name string, always bool) error

Delete removes a symbol from the table. Search from the local symbol up the parent tree until you find the symbol to delete. If the always flag is set, this deletes even if the name is marked as a readonly variable ("_" as the first character).

func (*SymbolTable) Format

func (s *SymbolTable) Format(includeBuiltins bool) string

Format formats a symbol table into a string for printing/display.

func (*SymbolTable) FormattedData

func (s *SymbolTable) FormattedData(includeBuiltins bool) [][]string

Format formats a symbol table into a string for printing/display.

func (*SymbolTable) Get

func (s *SymbolTable) Get(name string) (interface{}, bool)

Get retrieves a symbol from the current table or any parent table that exists.

func (*SymbolTable) GetAddress

func (s *SymbolTable) GetAddress(name string) (interface{}, bool)

GetAddress retrieves the address of a symbol values from the current table or any parent table that exists.

func (*SymbolTable) GetLocal

func (s *SymbolTable) GetLocal(name string) (interface{}, bool)

Get retrieves a symbol from the current table.

func (*SymbolTable) GetPackages

func (s *SymbolTable) GetPackages(source *SymbolTable) (count int)

For a given source table, find all the packages in the table and put them in the current table.

func (*SymbolTable) GetValue

func (s *SymbolTable) GetValue(index int) interface{}

Given an index, retrieve a value from the Values list.

func (*SymbolTable) GetWithAttributes

func (s *SymbolTable) GetWithAttributes(name string) (interface{}, *SymbolAttribute, bool)

Get retrieves a symbol from the current table or any parent table that exists.

func (*SymbolTable) ID

func (s *SymbolTable) ID() uuid.UUID

ID returns the unique identifier for this symbol table.

func (*SymbolTable) IsConstant

func (s *SymbolTable) IsConstant(name string) bool

IsConstant determines if a name is a constant or readonly value.

func (*SymbolTable) IsRoot

func (s *SymbolTable) IsRoot() bool

IsRoot determines if the current symbol table is the root table, or is a root table because it has no parent.

func (*SymbolTable) Lock

func (s *SymbolTable) Lock()

Lock locks the symbol table so it cannot be used concurrently.

func (*SymbolTable) Names

func (s *SymbolTable) Names() []string

Names returns an array of strings containing the names of the symbols in the table.

func (*SymbolTable) Package

func (s *SymbolTable) Package() string

Package returns the package for which this symbol table provides symbol information. If there is no package, it returns an empty string.

func (*SymbolTable) Parent

func (s *SymbolTable) Parent() *SymbolTable

Parent retrieves the parent symbol table of this table. If there is no parent table, nil is returned.

func (*SymbolTable) Root

func (s *SymbolTable) Root() *SymbolTable

Root finds the root table for the symbol table, by searching up the tree of tables until it finds the root table.

func (*SymbolTable) ScopeBoundary

func (s *SymbolTable) ScopeBoundary() bool

ScopeBoundary returns a flag indicating if this symbol table represents a boundary for scope checking. It returns true if any traversal searching for symbols should be stopped at this point in the scope list.

func (*SymbolTable) Set

func (s *SymbolTable) Set(name string, v interface{}) error

Set stores a symbol value in the table where it was found.

func (*SymbolTable) SetAlways

func (s *SymbolTable) SetAlways(name string, v interface{})

SetAlways stores a symbol value in the local table. No value in any parent table is affected. This can be used for functions and readonly values.

func (*SymbolTable) SetConstant

func (s *SymbolTable) SetConstant(name string, v interface{}) error

SetConstant stores a constant for readonly use in the symbol table. Because this could be done from many different threads in a REST server mode, use a lock to serialize writes.

func (*SymbolTable) SetGlobal

func (s *SymbolTable) SetGlobal(name string, value interface{}) error

SetGlobal sets a symbol value in the global symbol table.

func (*SymbolTable) SetPackage

func (s *SymbolTable) SetPackage(name string)

SetPackage sets the package name for this symbol table.

func (*SymbolTable) SetParent

func (s *SymbolTable) SetParent(p *SymbolTable) *SymbolTable

SetParent sets the parent of the currnent table to the provided table.

func (*SymbolTable) SetReadOnly

func (s *SymbolTable) SetReadOnly(name string, flag bool) error

SetReadOnly can be used to set the read-only attribute of a symbol. This code locates the symbol anywhere in the scope tree and sets its value. It returns nil if this was successful, else a symbol-not-found error is reported.

func (*SymbolTable) SetScopeBoundary

func (s *SymbolTable) SetScopeBoundary(flag bool)

SetScopeBoundary indicates that this symbol table is meant to be a boundary point beyond which symbol scope cannot be examined.

func (*SymbolTable) SetValue

func (s *SymbolTable) SetValue(index int, v interface{})

Given an index and a value, store the value in the Values list.

func (*SymbolTable) SetWithAttributes

func (s *SymbolTable) SetWithAttributes(name string, v interface{}, newAttr SymbolAttribute) error

SetAlways stores a symbol value in the local table. No value in any parent table is affected. This can be used for functions and readonly values.

func (*SymbolTable) Size

func (s *SymbolTable) Size() int

Size returns the number of symbols in the table.

func (*SymbolTable) Unlock

func (s *SymbolTable) Unlock()

Unlock unlocks the symbol table for concurrent use.

type UndefinedValue

type UndefinedValue struct {
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL