MultiTypeSymbolTable

Usage

use MultiTypeSymbolTable;

or

import MultiTypeSymbolTable;
const mtLogger = new Logger(logLevel, logChannel)
class SymTab

symbol table

var registry = new owned RegTab()

Similar to the Symbol Table but for register object tracking

var tab: map(string, shared AbstractSymEntry)

Map indexed by strings

var serverid = "id_" + generateToken(8) + "_"
var nid = 0
proc nextName(): string

Gives out symbol names.

proc addEntry(name: string, shape: int ...?N, type t): borrowed SymEntry(t, N) throws  where isSupportedType(t)

Takes args and creates a new SymEntry.

Arguments
  • name : string – name of the array

  • shape : int – length of array in each dimension

  • t – type of array

Returns

borrow of newly created SymEntry(t)

proc addEntry(name: string, shape: ?ND*int, type t): borrowed SymEntry(t, ND) throws
proc addEntry(name: string, shape: int ...?N, type t): borrowed SymEntry(t, N) throws  where !isSupportedType(t)
proc addEntry(name: string, in entry: shared AbstractSymEntry): borrowed AbstractSymEntry throws

Takes an already created AbstractSymEntry and creates a new AbstractSymEntry.

Arguments
  • name : string – name of the array

  • entry : AbstractSymEntry – AbstractSymEntry to convert

Returns

borrow of newly created AbstractSymEntry

proc addEntry(name: string, shape: int ...?ND, dtype: DType): borrowed AbstractSymEntry throws

Creates a symEntry from array name, length, and DType

Arguments
  • name : string – name of the array

  • shape : int – length of array in each dimension

  • dtype – type of array

Returns

borrow of newly created GenSymEntry

proc addEntry(name: string, shape: ?ND*int, dtype: DType): borrowed AbstractSymEntry throws
proc deleteEntry(name: string): bool throws

Removes an unregistered entry from the symTable

Arguments

name : string – name of the array

Returns

bool indicating whether the deletion occurred

proc clear() throws

Clears all unregistered entries from the symTable

proc lookup(name: string): borrowed AbstractSymEntry throws
  • Returns the AbstractSymEntry associated with the provided name, if the AbstractSymEntry exists

  • arg name

    string to index/query in the sym table

  • type name

    string

  • returns

    AbstractSymEntry or throws on error

  • throws

    unkownSymbolError(name)

proc checkTable(name: string, calling_func = "check") throws
  • checks to see if a symbol is defined if it is not it throws an exception

proc pretty() throws
  • Prints the SymTable in a pretty format (name,SymTable[name])

proc memUsed(): int
  • returns

    total bytes in arrays in the symbol table

proc dump(name: string): string throws

Attempts to format and return sym entries mapped to the provided string into JSON format. Pass __AllSymbols__ to process the entire sym table.

Arguments

name : string – name of entry to be processed

proc info(names: string): string throws

Returns verbose attributes of the sym entries at the given string, if the string is a JSON formmated list of entry names. Pass __AllSymbols__ to process all sym entries in the sym table. Pass __RegisteredSymbols__ to process all registered sym entries.

Returns: name, dtype, size, ndim, shape, item size, and registration status for each entry in names

Arguments

names : string – list containing names of entries to be processed

Returns

JSON formatted list containing info for each entry in names

proc parseJson(names: string): [] string throws

Convert JSON formmated list of entry names into a [] string object

Arguments

names : string – JSON formatted list containing entry names

Returns

[] string of entry names

proc getEntries(infoList): [] string throws

Returns an array of JSON formatted strings for each entry in infoList (tab, registry, or [names])

Arguments

infoList : domain(string) or [] string for registry and [names] – Iterable containing sym entries to be returned by info

Returns

array of JSON formatted strings

proc getEntries(infoList: map(string, shared AbstractSymEntry)): [] string throws

Returns an array of JSON formatted strings for each entry in infoList (tab, registry, or [names])

Arguments

infoList : map(string, shared GenSymEntry) for tab – Iterable containing sym entries to be returned by info

Returns

array of JSON formatted strings

proc formatEntry(name: string, abstractEntry: borrowed AbstractSymEntry): string throws

Returns formatted string for an info entry.

Arguments
  • name : string – name of entry to be formatted

  • item : AbstractSymEntry – AbstractSymEntry to be formatted (tab[name])

Returns

JSON formatted dictionary

proc attrib(name: string): string throws

Returns raw attributes of the sym entry at the given string, if the string maps to an entry. Returns: name, dtype, size, ndim, shape, and item size

Arguments

name : string – name of entry to be processed

Returns

s (string) containing info

proc datastr(name: string, thresh: int): string throws

Attempts to find a sym entry mapped to the provided string, then returns the data in the entry up to the specified threshold. Arrays of size less than threshold will be printed in their entirety. Arrays of size greater than or equal to threshold will print the first 3 and last 3 elements

Arguments
  • name : string – name of entry to be processed

  • thresh : int – threshold for data to return

Returns

s (string) containing the array data

proc datarepr(name: string, thresh: int): string throws

Attempts to find a sym entry mapped to the provided string, then returns the data in the entry up to the specified threshold. This method returns the data in form “array([<DATA>])”. Arrays of size less than threshold will be printed in their entirety. Arrays of size greater than or equal to threshold will print the first 3 and last 3 elements

Arguments
  • name : string – name of entry to be processed

  • thresh : int – threshold for data to return

Returns

s (string) containing the array data

proc contains(name: string): bool

Attempts to find a sym entry mapped to the provided string, then returns a boolean value signfying the provided string’s sym entry existance

Arguments

name : string – name of entry to be checked

Returns

bool signifying existance of the sym entry

proc findAll(pattern: string): [] string throws

Attempts to find all sym entries that match the provided regex string, then returns a string array of matching names

Arguments

pattern : string – regex string to search for

Returns

string array containing matching entry names

proc getGenericTypedArrayEntry(name: string, st: borrowed SymTab): borrowed GenSymEntry throws
  • Convenience proc to retrieve GenSymEntry from SymTab

  • Performs conversion from AbstractSymEntry to GenSymEntry

  • You can pass a logger from the calling function for better error reporting.

proc getSegStringEntry(name: string, st: borrowed SymTab): borrowed SegStringSymEntry throws
  • Convenience proc to retrieve SegStringSymEntry from SymTab

  • Performs conversion from AbstractySymEntry to SegStringSymEntry

  • You can pass a logger from the calling function for better error reporting.