PageRenderTime 3ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/source/core/backend/Backend.ooc

http://github.com/nddrylliog/oc
Unknown | 34 lines | 30 code | 4 blank | 0 comment | 0 complexity | 639a17649296fd856573d5f54de47ac9 MD5 | raw file
 1import ast/[Module, Access, Var]
 2import middle/Resolver
 3import frontend/BuildParams
 4
 5/**
 6 * Interface for pluggable backends in oc-c89
 7 */
 8Backend: abstract class {
 9    
10    /**
11     * Given the full AST of a module and a set of build parameters, process
12     * should compile the AST into the desired result.
13     * 
14     * A C backend might produce C files, then call a C compiler to produce
15     * a library/executable, for instance.
16     * 
17     * A bytecode backend might produce backend and save it in files.
18     * 
19     * An interpreter backend might simply interpret the module.
20     */
21    process: abstract func (module: Module, params: BuildParams)
22    
23    /**
24     * Override this method to have a backend-specific way to resolve variable
25     * accesses.
26     * 
27     * For example, a C backend might automatically be aware of C types from
28     * parsing header files, and allow resolving of those names automatically.
29     */
30    resolveAccess: func (acc: Access, task: Task, suggest: Func (Var)) {
31        "resolveAccess(%s) in %s" printfln(acc toString(), class name)
32    }
33
34}