UNPKG

calcium-lang

Version:
40 lines (39 loc) 1.05 kB
import { InternalType } from "../type"; /** * saves variables, functions, and so on in a specific scope */ export default class Namespace { readonly parent?: Namespace | undefined; readonly isClassScope: boolean; /** * saves by key value pairs */ private dict; /** * * @param parent nesting scope */ constructor(parent?: Namespace | undefined, isClassScope?: boolean); /** * searches an attribute in a class scope * @param key attribute's name * @returns */ get(key: string): InternalType | undefined; /** * searches identifier and return its value * @param key identifier */ lookUp(key: string): InternalType | undefined; /** * * @param key identifier * @param value right hand side of assignment */ register(key: string, value: InternalType): void; /** * the parent scope of a function or a method. * When this namespace is not a class scope, then returns this. */ get nestingScope(): Namespace; }