module volt.semantic.lookup
Lookup Semantics

Functions that encode the semantic code for looking up symbols.

Code Map

//! Functions that encode the semantic code for looking up symbols.
module volt.semantic.lookup;


//! Look up an identifier in a scope and its parent scopes. Returns the
//! store or null if no match was found.
fn lookup(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Store { }
//! Look up a QualifiedName chain, the first identifier is looked up
//! globaly, and the result is treated as a scope to lookup the next one
//! should there be more identifiers.
fn lookup(lp: LanguagePass, _scope: ir.Scope, qn: ir.QualifiedName) ir.Store { }
//! Look up an identifier in the given scope only. Doesn't check parent
//! scopes, parent classes, imports, or anywhere else but the given scope.
fn lookupInGivenScopeOnly(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Store { }
//! Look up an identifier in this scope, in parent scopes (in the case of
//! classes), and in any imports for this scope.
fn lookupAsThisScope(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string, current: ir.Scope) ir.Store { }
//! Lookup in this scope and parent class scopes, if any.
fn lookupOnlyThisScopeAndClassParents(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Store { }
//! Lookup up as identifier in this scope, and any public imports.
fn lookupAsImportScope(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Store { }
//! Lookup an identifier in multiple scopes, as import scopes.
fn lookupAsImportScopes(lp: LanguagePass, scopes: ir.Scope[], loc: const(Location), name: string) ir.Store { }
//! This function is used to retrive cached versions of helper functions.
fn lookupFunction(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Function { }
//! Helper functions that looksup a type and throws compiler errors if it
//! is not found or the found identifier is not a type.
fn lookupType(lp: LanguagePass, _scope: ir.Scope, id: ir.QualifiedName) ir.Type { }
fn lookupType(lp: LanguagePass, _scope: ir.Scope, id: ir.QualifiedName, store: ir.Store) ir.Type { }
//! Resolves a store making sure the node it points to is resolved, the
//! function returns the store that a alias is pointing to. Not the alias
//! itself.
fn ensureResolved(lp: LanguagePass, s: ir.Store) ir.Store { }
//! Get the module in the bottom of the given _scope chain.
fn getModuleFromScope(loc: const(Location), _scope: ir.Scope) ir.Module { }
//! Return the first class scope and the class going down the chain of
//! containing scopes (_scope.parent field).
fn getFirstClass(_scope: ir.Scope, outScope: ir.Scope, outClass: ir.Class) bool { }
fn lookup(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Store

Look up an identifier in a scope and its parent scopes. Returns the store or null if no match was found.

Parameters

lp

LanguagePass.

_scope

The scope to look in.

loc

Location, for error messages.

name

The string to lookup.

fn lookup(lp: LanguagePass, _scope: ir.Scope, qn: ir.QualifiedName) ir.Store

Look up a QualifiedName chain, the first identifier is looked up globaly, and the result is treated as a scope to lookup the next one should there be more identifiers.

Parameters

lp

LanguagePass.

_scope

The scope to look in.

qn

QualifiedName to get idents from.

fn lookupInGivenScopeOnly(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Store

Look up an identifier in the given scope only. Doesn't check parent scopes, parent classes, imports, or anywhere else but the given scope.

Parameters

lp

LanguagePass.

_scope

The scope to look in.

loc

Location, for error messages.

name

The string to lookup.

fn lookupAsThisScope(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string, current: ir.Scope) ir.Store

Look up an identifier in this scope, in parent scopes (in the case of classes), and in any imports for this scope.

A usable scope for this function is retrieved from the getFirstThisable function.

@todo actually lookup imports.

Parameters

lp

LanguagePass.

_scope

The scope to look in.

loc

Location, for error messages.

name

The string to lookup.

current

The scope where the lookup took place.

fn lookupOnlyThisScopeAndClassParents(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Store

Lookup in this scope and parent class scopes, if any.

Does not consult imports of any kind.

Parameters

lp

LanguagePass.

_scope

The scope to look in.

loc

Location, for error messages.

name

The string to lookup.

Return

The store or null if no match was found.

fn lookupAsImportScope(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Store

Lookup up as identifier in this scope, and any public imports.

Used for rebinding imports.

Parameters

lp

LanguagePass.

_scope

The scope to look in.

loc

Location, for error messages.

name

The string to lookup.

Return

The store or null if no match was found.

fn lookupAsImportScopes(lp: LanguagePass, scopes: ir.Scope[], loc: const(Location), name: string) ir.Store

Lookup an identifier in multiple scopes, as import scopes.

fn lookupFunction(lp: LanguagePass, _scope: ir.Scope, loc: const(Location), name: string) ir.Function

This function is used to retrive cached versions of helper functions.

Parameters

lp

LanguagePass.

_scope

The scope to look in.

loc

Location, for error messages.

name

The string to lookup.

Return

The found function or null.

fn lookupType(lp: LanguagePass, _scope: ir.Scope, id: ir.QualifiedName) ir.Type

Helper functions that looksup a type and throws compiler errors if it is not found or the found identifier is not a type.

Parameters

lp

LanguagePass.

_scope

The scope to look in.

id

Return

The found type or null.

fn ensureResolved(lp: LanguagePass, s: ir.Store) ir.Store

Resolves a store making sure the node it points to is resolved, the function returns the store that a alias is pointing to. Not the alias itself.

fn getModuleFromScope(loc: const(Location), _scope: ir.Scope) ir.Module

Get the module in the bottom of the given _scope chain.

Throws

  • CompilerPanic if no module at bottom of chain.

fn getFirstClass(_scope: ir.Scope, outScope: ir.Scope, outClass: ir.Class) bool

Return the first class scope and the class going down the chain of containing scopes (_scope.parent field).

Return

True if we found a thisable type and its scope and type.

fn getTopScope(loc: const(Location), _scope: ir.Scope) ir.Scope

Given a scope, get the oldest parent -- this is the module of that scope.

Return

Throws

  • CompilerPanic if no module at bottom of chain.

fn getFirstThisable(_scope: ir.Scope, outScope: ir.Scope, outType: ir.Type) bool

Return the first scope and type that is thisable going down the chain of containing scopes (_scope.parent field).

Return

True if we found a thisable type and its scope and type.

fn getClassParentsScope(lp: LanguagePass, _scope: ir.Scope, outScope: ir.Scope, outClass: ir.Class) bool

Get the parents scope of the given scope if its a class scope.

Return

If the is a class and had a parents scope.

fn checkAccess(loc: const(Location), name: string, store: ir.Store, classParentLookup: bool)

Check that the contents of store can be accessed (e.g. not private)

fn ensureFunction(_scope: ir.Scope, loc: const(Location), name: string, store: ir.Store) ir.Function

Ensure that the given store is not null and that it is non-overloaded Function.

Return

            The function pointed to by the store.

Throws

  • CompilerError Raises error should this not be the case.

fn ensureType(_scope: ir.Scope, loc: const(Location), name: string, store: ir.Store) ir.Type

Ensures that the given store is not null, and that the store node is a type.

Return

            The type pointed to by the store.

Throws

  • CompilerError Raises error should this not be the case.

fn ensureScope(_scope: ir.Scope, loc: const(Location), name: string, store: ir.Store) ir.Scope

Ensures that the given store is not null, and that the store node has or is a scope.

Return

            The scope of store type or the scope itself.

Throws

  • CompilerError Raises error should this not be the case.