/* * YASM module loader for Win32 * * Copyright (C) 2003 Peter Johnson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include /*@unused@*/ RCSID("$IdPath$"); #include #include "yasm-module.h" typedef struct module { module_type type; /* module type */ const char *keyword; /* module keyword */ const char *symbol; /* module symbol */ void *data; /* associated data */ } module; extern yasm_arch yasm_x86_LTX_arch; extern yasm_arch yasm_lc3b_LTX_arch; extern yasm_dbgfmt yasm_null_LTX_dbgfmt; extern yasm_objfmt yasm_bin_LTX_objfmt; extern yasm_objfmt yasm_coff_LTX_objfmt; extern yasm_objfmt yasm_win32_LTX_objfmt; extern yasm_objfmt yasm_dbg_LTX_objfmt; extern yasm_objfmt yasm_elf_LTX_objfmt; extern yasm_optimizer yasm_basic_LTX_optimizer; extern yasm_parser yasm_nasm_LTX_parser; extern yasm_preproc yasm_nasm_LTX_preproc; extern yasm_preproc yasm_raw_LTX_preproc; extern yasm_preproc yasm_yapp_LTX_preproc; static module modules[] = { {MODULE_ARCH, "x86", "arch", &yasm_x86_LTX_arch}, {MODULE_ARCH, "lc3b", "arch", &yasm_lc3b_LTX_arch}, {MODULE_DBGFMT, "null", "dbgfmt", &yasm_null_LTX_dbgfmt}, {MODULE_OBJFMT, "bin", "objfmt", &yasm_bin_LTX_objfmt}, {MODULE_OBJFMT, "coff", "objfmt", &yasm_coff_LTX_objfmt}, {MODULE_OBJFMT, "dbg", "objfmt", &yasm_dbg_LTX_objfmt}, {MODULE_OBJFMT, "win32", "objfmt", &yasm_win32_LTX_objfmt}, {MODULE_OBJFMT, "elf", "objfmt", &yasm_elf_LTX_objfmt}, {MODULE_OPTIMIZER, "basic", "optimizer", &yasm_basic_LTX_optimizer}, {MODULE_PARSER, "nasm", "parser", &yasm_nasm_LTX_parser}, {MODULE_PREPROC, "nasm", "preproc", &yasm_nasm_LTX_preproc}, {MODULE_PREPROC, "raw", "preproc", &yasm_raw_LTX_preproc}, }; static /*@dependent@*/ /*@null@*/ module * load_module(module_type type, const char *keyword) { int i; /* Look for the module. */ for (i=0; iname, arch->keyword); break; case MODULE_DBGFMT: dbgfmt = modules[i].data; printfunc(dbgfmt->name, dbgfmt->keyword); break; case MODULE_OBJFMT: objfmt = modules[i].data; printfunc(objfmt->name, objfmt->keyword); break; case MODULE_OPTIMIZER: optimizer = modules[i].data; printfunc(optimizer->name, optimizer->keyword); break; case MODULE_PARSER: parser = modules[i].data; printfunc(parser->name, parser->keyword); break; case MODULE_PREPROC: preproc = modules[i].data; printfunc(preproc->name, preproc->keyword); break; } } } }