Module: dfmc-back-end-protocol Author: Jonathan Bachrach, Keith Playford Synopsis: Compiler-front-end independent back-end Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND define abstract open class () constant slot mangler = make(); end class; define abstract open class () end class; define abstract open class () end class; define constant $back-end-registry = make(); define thread variable *cached-back-end* :: false-or() = #f; define thread variable *cached-back-end-name* :: false-or() = #f; define class () constant slot back-end-class :: , required-init-keyword: back-end-class:; constant slot back-end-type :: , required-init-keyword: back-end-type:; constant slot target-architecture :: false-or(), required-init-keyword: target-architecture:; constant slot target-os :: false-or(), required-init-keyword: target-os:; end; define function register-back-end (class :: , type :: , architecture :: false-or(), os :: false-or()) => (); add!($back-end-registry, make(, back-end-class: class, back-end-type: type, target-architecture: architecture, target-os: os)); end; define function find-back-end (type :: , architecture :: , os :: ) => (entry); choose(method (x) x.back-end-type == type & (~ x.target-architecture | x.target-architecture == architecture) & (~ x.target-os | x.target-os == os) end, $back-end-registry) end; define function find-back-end-object (name :: , architecture :: , os :: ) => (back-end) if (name ~== *cached-back-end-name*) let entries = find-back-end(name, architecture, os); if (~ empty?(entries)) *cached-back-end* := make(back-end-class(first(entries))); *cached-back-end-name* := name; else error("Invalid back-end %s", name); end; end; *cached-back-end* end; define sideways method current-back-end () => (back-end) if (current-library-description()) let name = current-back-end-name(); let arch = current-processor-name(); let os = current-os-name(); find-back-end-object(name, arch, os) end; end;