curry.backends.generic.compiler module

class curry.backends.generic.compiler.CompilerBase(interp, iroot)[source]

Bases: ABC

CODE_TYPE = None
EXCLUDED_METADATA = None
HOIST_DEPTH = None
compile()[source]

Performs compilation.

Returns:

A target object containing the generated object code.

compileArgs(exprs)[source]

The arguments of a node as primary expressions, one level down.

compileE(expr, primary=False)[source]

Compile an expression into a string. For primary expressions, the string evaluates to a value (boxed or unboxed). For non-primary expressions, it contains comma-separated arguments that may be passed to the Node constructor or Node->forward_to.

The walk runs on the trampoline (utility.trampoline): the case of a node with arguments is a generator that yields the walk of each argument, so the depth of the expression costs no frame of Python. A nested call per level ran out of frames at about 4000 elements of a literal list under maxrecursion (issue #125). The symbols are imported in the order of the recursive walk: the node’s own before those of its arguments.

compileEx(icy)[source]

Compiles an ICurry object.

Updates the TargetObject and returns a new ICurry ‘interface’ object in which each function body has been replaced with IMaterial.

Parameters:

icy – An IPackage, IModule, or IFunction to compile.

Returns:

The ICurry interface.

compileF(iobj, h_stepfunc, linesF)[source]
compileS(stmt)[source]

Compile a statement into nested lists of target code lines.

declareDataType(itype)[source]
declareSymbol(isymbol)[source]
hoist(text, primary)[source]

The text of a primary node, or the name of a temporary that holds it. A backend with HOIST_DEPTH moves a node at that nesting under the statement, and at every multiple of it, into a temporary assigned before the statement (vEmitHoisted), so the nesting of the generated text stays bounded whatever the depth of the expression. The Python backend needs it: the parser of Python refuses more than 200 nested parentheses, and a literal list of 1200 elements is one nested call (issue #125).

hoisting()[source]

Collects the lines hoisted out of the statement compiled inside the context (see hoist): a list, complete when the context ends, that the caller emits before the statement.

importDataType(symbol)[source]

Import a symbol into the taget object by name.

importSymbol(symbol)[source]

Import a symbol into the taget object by name.

internBackendFunction(func)[source]
internMetadata(metadata)[source]
internStringLiteral(string)[source]
internValueSetLiteral(values)[source]
isExternal(iobj)[source]
next_private_symbolname(kind, suffix=None)[source]
property root_isa_module
property symtab
abstractmethod vBackendFunctionKey()
abstractmethod vEmitConstructorInfotab()
abstractmethod vEmitDataType()
abstractmethod vEmitFooter()
abstractmethod vEmitFunctionInfotab()
abstractmethod vEmitHeader()
vEmitHoisted(name, text)[source]

The lines that assign the hoisted text to the temporary name.

abstractmethod vEmitImported()
abstractmethod vEmitMetadata()
abstractmethod vEmitModuleDefinition()
abstractmethod vEmitModuleImport()
abstractmethod vEmitStepfuncEntry()
abstractmethod vEmitStepfuncHeader()
abstractmethod vEmitStringLiteral()
abstractmethod vEmitSynthesizedStepfunc()
abstractmethod vEmitValueSetLiteral()
abstractmethod vEmit_compileE_ICall()
abstractmethod vEmit_compileE_ILiteral()
abstractmethod vEmit_compileE_IOr()
abstractmethod vEmit_compileE_IPartialCall()
abstractmethod vEmit_compileE_IString()
abstractmethod vEmit_compileE_IUnboxedLiteral()
abstractmethod vEmit_compileE_IVar()
abstractmethod vEmit_compileE_IVarAccess()
abstractmethod vEmit_compileS_ICaseCons()
abstractmethod vEmit_compileS_ICaseLit()
abstractmethod vEmit_compileS_IExempt()
abstractmethod vEmit_compileS_IFreeDecl()
abstractmethod vEmit_compileS_INodeAssign()
abstractmethod vEmit_compileS_IReturn()
abstractmethod vEmit_compileS_IVarAssign()
abstractmethod vEmit_compileS_IVarDecl()
vGetSymbolName(iobj, kind)[source]
abstractmethod vIsBuiltin()
abstractmethod vIsSynthesized()
class curry.backends.generic.compiler.SymbolTable[source]

Bases: dict

insert(name, kind, descr)[source]
make_defined(name)[source]
class curry.backends.generic.compiler.TargetObject(codetype, unitname)[source]

Bases: object

SECTIONS = ('.header', '.imports', '.stepfuncs.link', '.infotabs.link', '.datatypes.link', '.strings', '.valuesets', '.primitives', '.metadata', '.stepfuncs', '.infotabs', '.datatypes', '.moduledef', '.moduleimp', '.footer')
curry.backends.generic.compiler.decode(name)[source]

Decode an encoded Curry identifier string.

curry.backends.generic.compiler.demangle(symbolname)[source]
curry.backends.generic.compiler.encode(name)[source]

Encode a Curry identifier string to alphnumeric.

curry.backends.generic.compiler.mangle(parts, kind)[source]