module volt.lowerer.image
Lowering Passes

Holds ImageGatherer and various code for dealing with per image things.

Code Map

//! Holds ImageGatherer and various code for dealing with per image
//! things.
module volt.lowerer.image;


//! Collects various things that needs to emitted per image.
class ImageGatherer : NullVisitor, Pass
{
public:
	lp: LanguagePass;
	thisModule: ir.Module;
	thisModuleTorNum: u32;
	emittedMain: bool;
	mainVolt: ir.Function;
	mainC: ir.Function;
	prefix: string;
	//! Array literals to be assigned to the global variables.
	globalConstructors: ir.ArrayLiteral;
	//! Array literals to be assigned to the global variables.
	globalDestructors: ir.ArrayLiteral;
	//! Array literals to be assigned to the global variables.
	localConstructors: ir.ArrayLiteral;
	//! Array literals to be assigned to the global variables.
	localDestructors: ir.ArrayLiteral;


public:
	this(lp: LanguagePass) { }
	//! Collect the tors from m and emit extern(C) main if needed.
	fn transform(m: ir.Module) { }
	//! Nothing to do.
	fn close() { }
	//! The emitting code is run on leave.
	fn leave(m: ir.Module) Status { }
	//! Collect any local/global constructors and find main function.
	fn enter(func: ir.Function) Status { }
	//! Helper function that creates a variable and adds it to thisModule.
	fn emitVariable(arr: ir.ArrayLiteral, name: string) { }
	//! Sets the correct mangled name on the tor and adds it to the
	//! ArrayLiteral.
	fn handleTor(arr: ir.ArrayLiteral, name: string, func: ir.Function) { }
	fn setLocations(loc: Location) { }
}

//! If func is the main function, add a C main next to it.
fn lowerCMain(lp: LanguagePass, mod: ir.Module, func: ir.Function) { }
fn lowerCMain(lp: LanguagePass, mod: ir.Module, func: ir.Function)

If func is the main function, add a C main next to it.

class ImageGatherer : NullVisitor, Pass

This class collects global & local constructors and destructors and builds arrays that the runtime loops over. It also emits stub code need for the native volt main to work, this is done by calling into the runtime.

globalConstructors: ir.ArrayLiteral

Array literals to be assigned to the global variables.

globalDestructors: ir.ArrayLiteral

Array literals to be assigned to the global variables.

localConstructors: ir.ArrayLiteral

Array literals to be assigned to the global variables.

localDestructors: ir.ArrayLiteral

Array literals to be assigned to the global variables.

fn transform(m: ir.Module)

Collect the tors from m and emit extern(C) main if needed.

fn close()

Nothing to do.

fn leave(m: ir.Module) Status

The emitting code is run on leave.

fn enter(func: ir.Function) Status

Collect any local/global constructors and find main function.

fn emitVariable(arr: ir.ArrayLiteral, name: string)

Helper function that creates a variable and adds it to thisModule.

fn handleTor(arr: ir.ArrayLiteral, name: string, func: ir.Function)

Sets the correct mangled name on the tor and adds it to the ArrayLiteral.