Appearance
| 1 | namespace IR is | |
| 2 | use Semantic.Symbols.Symbol | |
| 3 | use Semantic.Symbols.Classy | |
| 4 | use Semantic.Symbols.Function | |
| 5 | ||
| 6 | /// The backend for the build's target. The target is set from the | |
| 7 | /// command line after the container is built, so the choice is made | |
| 8 | /// at each call rather than once. | |
| 9 | class TARGET_BACKEND: Backend is | |
| 10 | _flags: Compiler.GLOBAL_BUILD_FLAGS | |
| 11 | _backends: Collections.Map[Compiler.Target, Backend] | |
| 12 | ||
| 13 | _backend: Backend => _backends[_flags.target] | |
| 14 | ||
| 15 | // The driver installs and resets the backend before anything asks | |
| 16 | // whether code is generated, so for a target with no backend both | |
| 17 | // do nothing. | |
| 18 | _backend_if_any: Backend? => | |
| 19 | if _backends.contains_key(_flags.target) then _backends[_flags.target] else null fi | |
| 20 | ||
| 21 | /// - flags: the build flags the target is read from | |
| 22 | /// - backends: the backend for each target | |
| 23 | init(flags: Compiler.GLOBAL_BUILD_FLAGS, backends: Collections.Map[Compiler.Target, Backend]) is | |
| 24 | _flags = flags | |
| 25 | _backends = backends | |
| 26 | si | |
| 27 | ||
| 28 | install(module_name: string, module_version: string, want_library: bool) is | |
| 29 | _backend_if_any?.install(module_name, module_version, want_library) | |
| 30 | si | |
| 31 | ||
| 32 | reset() is _backend_if_any?.reset() si | |
| 33 | begin_assembly() is _backend.begin_assembly() si | |
| 34 | end_assembly() is _backend.end_assembly() si | |
| 35 | add_resource(name: string, content: ubyte[]) is _backend.add_resource(name, content) si | |
| 36 | write(path: string) is _backend.write(path) si | |
| 37 | begin_body() is _backend.begin_body() si | |
| 38 | begin_body(member: Symbol) is _backend.begin_body(member) si | |
| 39 | write(value: Values.Value) is _backend.write(value) si | |
| 40 | finish_body(function: Function) is _backend.finish_body(function) si | |
| 41 | finish_frame_member_body(frame: Classy, member: FrameMember) is _backend.finish_frame_member_body(frame, member) si | |
| 42 | finish_unit_variant_initializer(variant: Classy) is _backend.finish_unit_variant_initializer(variant) si | |
| 43 | end_body() is _backend.end_body() si | |
| 44 | abandon_bodies() is _backend.abandon_bodies() si | |
| 45 | has_unit_variant_instance(variant: Classy) -> bool => _backend.has_unit_variant_instance(variant) | |
| 46 | mark_entry_point(function: Function) is _backend.mark_entry_point(function) si | |
| 47 | si | |
| 48 | si |