diff options
Diffstat (limited to 'gcc/d/d-compiler.cc')
-rw-r--r-- | gcc/d/d-compiler.cc | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/gcc/d/d-compiler.cc b/gcc/d/d-compiler.cc index 3eb3a76..e18f5d3 100644 --- a/gcc/d/d-compiler.cc +++ b/gcc/d/d-compiler.cc @@ -1,5 +1,5 @@ /* d-compiler.cc -- D frontend interface to the gcc back-end. - Copyright (C) 2020-2024 Free Software Foundation, Inc. + Copyright (C) 2020-2025 Free Software Foundation, Inc. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "dmd/compiler.h" +#include "dmd/errors.h" #include "dmd/expression.h" #include "dmd/identifier.h" #include "dmd/module.h" @@ -46,9 +47,9 @@ Compiler::paintAsType (UnionExp *, Expression *expr, Type *type) Type *tb = type->toBasetype (); - if (expr->type->isintegral ()) + if (expr->type->isIntegral ()) cst = build_integer_cst (expr->toInteger (), build_ctype (expr->type)); - else if (expr->type->isfloating ()) + else if (expr->type->isFloating ()) cst = build_float_cst (expr->toReal (), expr->type); else if (expr->op == EXP::arrayLiteral) { @@ -60,13 +61,13 @@ Compiler::paintAsType (UnionExp *, Expression *expr, Type *type) for (size_t i = 0; i < elements->length; i++) { Expression *e = (*elements)[i]; - if (e->type->isintegral ()) + if (e->type->isIntegral ()) { tree value = build_integer_cst (e->toInteger (), build_ctype (e->type)); CONSTRUCTOR_APPEND_ELT (elms, size_int (i), value); } - else if (e->type->isfloating ()) + else if (e->type->isFloating ()) { tree value = build_float_cst (e->toReal (), e->type); CONSTRUCTOR_APPEND_ELT (elms, size_int (i), value); @@ -164,7 +165,39 @@ Compiler::onParseModule (Module *m) driver intends on compiling the import. */ bool -Compiler::onImport (Module *) +Compiler::onImport (Module *m) { - return false; + if (!includeImports) + return false; + + if (m->filetype != FileType::d && m->filetype != FileType::c) + return false; + + /* All imports modules are included except those in the runtime library. */ + ModuleDeclaration *md = m->md; + if (md && md->id) + { + if (md->packages.length >= 1) + { + if (!strcmp (md->packages.ptr[0]->toChars (), "core") + || !strcmp (md->packages.ptr[0]->toChars (), "std") + || !strcmp (md->packages.ptr[0]->toChars (), "gcc") + || !strcmp (md->packages.ptr[0]->toChars (), "etc")) + return false; + } + else if (!strcmp (md->id->toChars (), "object")) + return false; + } + else if (m->ident) + { + if (!strcmp (m->ident->toChars (), "object")) + return false; + } + + /* This import will be compiled. */ + if (global.params.v.verbose) + message ("compileimport (%s)", m->srcfile.toChars ()); + + compiledImports.push (m); + return true; } |