module volta.postparse.gatherer
Post Parsing Passes

Module that deals with gatherering symbols into scopes.

Holds the Gatherer class and lots of helper functions

Code Map

//! Module that deals with gatherering symbols into scopes.
module volta.postparse.gatherer;


//! Used to keep track of which level a symbol was found.
enum Where
{
	Module,
	TopLevel,
	Function,
}

//! Populate the scopes with Variables, Aliases, Functions, and Types. Adds
//! Scopes where needed as well.
class Gatherer : NullVisitor, Pass
{
public:
	this(warningsEnabled: bool, errSink: ErrorSink) { }
	fn transform(m: ir.Module) { }
	fn close() { }
	fn transform(m: ir.Module, func: ir.Function, bs: ir.BlockStatement) { }
	fn push(s: ir.Scope, thisType: ir.Type) { }
	fn pop(thisType: ir.Type) { }
	fn push(func: ir.Function) { }
	fn pop(func: ir.Function) { }
	fn push(ti: ir.TemplateInstance) { }
	fn pop(ti: ir.TemplateInstance) { }
	fn pushScopesWithParents(current: ir.Scope) { }
	fn popScopesWithParents(current: ir.Scope) { }
	fn where() Where { }
	fn current() ir.Scope { }
	fn thisType() ir.Type { }
	fn enter(m: ir.Module) Status { }
	fn enter(a: ir.Alias) Status { }
	fn enter(v: ir.Variable) Status { }
	fn enter(c: ir.Class) Status { }
	fn enter(i: ir._Interface) Status { }
	fn enter(s: ir.Struct) Status { }
	fn enter(u: ir.Union) Status { }
	fn enter(e: ir.Enum) Status { }
	fn enter(func: ir.Function) Status { }
	fn enter(ti: ir.TemplateInstance) Status { }
	fn enter(fes: ir.ForeachStatement) Status { }
	fn enter(fs: ir.ForStatement) Status { }
	fn enter(bs: ir.BlockStatement) Status { }
	fn enter(mf: ir.MixinFunction) Status { }
	fn enter(mt: ir.MixinTemplate) Status { }
	fn enter(e: ir.EnumDeclaration) Status { }
	fn visit(td: ir.TemplateDefinition) Status { }
	fn leave(m: ir.Module) Status { }
	fn leave(c: ir.Class) Status { }
	fn leave(i: ir._Interface) Status { }
	fn leave(s: ir.Struct) Status { }
	fn leave(u: ir.Union) Status { }
	fn leave(e: ir.Enum) Status { }
	fn leave(func: ir.Function) Status { }
	fn leave(ti: ir.TemplateInstance) Status { }
	fn leave(bs: ir.BlockStatement) Status { }


protected:
	mWhere: Where[];
	mWhereStack: WhereSink;
	mScopeStack: ScopeSink;
	mTypeStack: TypeSink;
	mFunctionStack: FunctionSink;
	mModule: ir.Module;
	mWarningsEnabled: bool;
	mErrSink: ErrorSink;
}

struct WhereSink
{
public:
	enum MaxSize;


public:
	alias Sink = void delegate(scope (SinkArg));
	alias SinkArg = scope (scope (T)[]);


public:
	fn length() size_t { }
	fn sink(type: T) { }
	fn append(arr: scope (scope (T)[])) { }
	fn append(s: SinkStruct) { }
	fn popLast() T { }
	fn getLast() T { }
	fn get(i: size_t) T { }
	fn set(i: size_t, n: T) { }
	fn setLast(i: T) { }
	fn toSink(sink: Sink) { }
	fn toArray() T[] { }
	fn borrowUnsafe() T[] { }
	fn reset() { }
}

fn findShadowed(_scope: ir.Scope, loc: const(Location), name: string, warningsEnabled: bool) ir.Store { }
fn isValidAccess(access: ir.Access) bool { }
fn gather(current: ir.Scope, e: ir.EnumDeclaration, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, a: ir.Alias, where: Where, errSink: ErrorSink) { }
//! If name is reserved in current, generate an error pointing at n's
//! location.
fn checkInvalid(current: ir.Scope, n: ir.Node, name: string, errSink: ErrorSink) { }
fn checkTemplateRedefinition(current: ir.Scope, name: string, errSink: ErrorSink) { }
fn gather(current: ir.Scope, v: ir.Variable, where: Where, warningsEnabled: bool, errSink: ErrorSink) { }
fn gather(current: ir.Scope, func: ir.Function, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, s: ir.Struct, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, u: ir.Union, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, c: ir.Class, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, e: ir.Enum, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, i: ir._Interface, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, mf: ir.MixinFunction, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, mt: ir.MixinTemplate, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, td: ir.TemplateDefinition, where: Where, errSink: ErrorSink) { }
fn gather(current: ir.Scope, ti: ir.TemplateInstance, where: Where, errSink: ErrorSink) { }
fn addScope(m: ir.Module) { }
fn addScope(current: ir.Scope, func: ir.Function, thisType: ir.Type, errSink: ErrorSink) { }
fn addScope(current: ir.Scope, bs: ir.BlockStatement) { }
fn addScope(current: ir.Scope, td: ir.TemplateDefinition, errSink: ErrorSink) { }
fn addScope(current: ir.Scope, s: ir.Struct, errSink: ErrorSink) { }
fn addScope(current: ir.Scope, u: ir.Union, errSink: ErrorSink) { }
fn addScope(current: ir.Scope, e: ir.Enum, errSink: ErrorSink) { }
fn addScope(current: ir.Scope, c: ir.Class, where: Where, errSink: ErrorSink) { }
fn addScope(current: ir.Scope, i: ir._Interface, errSink: ErrorSink) { }
fn addScope(current: ir.Scope, ti: ir.TemplateInstance, errSink: ErrorSink) { }
enum Where

Used to keep track of which level a symbol was found.

fn checkInvalid(current: ir.Scope, n: ir.Node, name: string, errSink: ErrorSink)

If name is reserved in current, generate an error pointing at n's location.

class Gatherer : NullVisitor, Pass

Populate the scopes with Variables, Aliases, Functions, and Types. Adds Scopes where needed as well.