diff --git a/codon/compiler/compiler.cpp b/codon/compiler/compiler.cpp index 7bcd147e..054e76f4 100644 --- a/codon/compiler/compiler.cpp +++ b/codon/compiler/compiler.cpp @@ -99,26 +99,26 @@ Compiler::parse(bool isCode, const std::string &file, const std::string &code, ast::TypecheckVisitor::apply(cache.get(), std::move(transformed)); t3.log(); - std::unordered_map wxt; - std::unordered_map> wx; - for (auto &[r, t] : cache->_timings) { - if (auto f = cache->typeCtx->find(r)) { - auto n = f->type->getFunc()->ast->name; - wx[n][r] = t; - wxt[n] += t; - } else { - wx["?"][r] = t; - wxt["?"] += t; - } - } - std::vector> q(wxt.begin(), wxt.end()); - sort(q.begin(), q.end(), - [](const auto &a, const auto &b) { return b.second < a.second; }); - double s = 0; - for (auto &[k, v] : q) { - s += v; - LOG_TIME(" [->] {:60} = {:10.3f} / {:10.3f}", k, v, s); - } + // std::unordered_map wxt; + // std::unordered_map> wx; + // for (auto &[r, t] : cache->_timings) { + // if (auto f = cache->typeCtx->find(r)) { + // auto n = f->type->getFunc()->ast->name; + // wx[n][r] = t; + // wxt[n] += t; + // } else { + // wx["?"][r] = t; + // wxt["?"] += t; + // } + // } + // std::vector> q(wxt.begin(), wxt.end()); + // sort(q.begin(), q.end(), + // [](const auto &a, const auto &b) { return b.second < a.second; }); + // double s = 0; + // for (auto &[k, v] : q) { + // s += v; + // LOG_TIME(" [->] {:60} = {:10.3f} / {:10.3f}", k, v, s); + // } if (codon::getLogger().flags & codon::Logger::FLAG_USER) { auto fo = fopen("_dump_typecheck.sexp", "w"); diff --git a/codon/parser/ast/stmt.cpp b/codon/parser/ast/stmt.cpp index b2490c19..e3668219 100644 --- a/codon/parser/ast/stmt.cpp +++ b/codon/parser/ast/stmt.cpp @@ -414,8 +414,6 @@ void FunctionStmt::parseDecorators() { std::vector newDecorators; for (auto &d : decorators) { if (d->isId(Attr::Attribute)) { - if (decorators.size() != 1) - E(Error::FN_SINGLE_DECORATOR, decorators[1], Attr::Attribute); attributes.isAttribute = true; } else if (d->isId(Attr::LLVM)) { attributes.set(Attr::LLVM); diff --git a/codon/parser/visitors/simplify/function.cpp b/codon/parser/visitors/simplify/function.cpp index 54d084db..ae6691c7 100644 --- a/codon/parser/visitors/simplify/function.cpp +++ b/codon/parser/visitors/simplify/function.cpp @@ -120,8 +120,14 @@ void SimplifyVisitor::visit(FunctionStmt *stmt) { auto [isAttr, attrName] = getDecorator(stmt->decorators[i]); if (!attrName.empty()) { stmt->attributes.set(attrName); - if (isAttr) + if (isAttr) { + const auto &otherAttr = + ctx->cache->functions[ctx->cache->overloads[attrName][0].name] + .ast->attributes.customAttr; + for (const auto &a : otherAttr) + stmt->attributes.set(a); stmt->decorators[i] = nullptr; // remove it from further consideration + } } } diff --git a/codon/parser/visitors/typecheck/infer.cpp b/codon/parser/visitors/typecheck/infer.cpp index 77f7d997..7c4d1243 100644 --- a/codon/parser/visitors/typecheck/infer.cpp +++ b/codon/parser/visitors/typecheck/infer.cpp @@ -81,6 +81,7 @@ StmtPtr TypecheckVisitor::inferTypes(StmtPtr result, bool isToplevel) { if (f.second.type && f.second.realizations.empty() && (attr.has(Attr::ForceRealize) || attr.has(Attr::Export) || (attr.has(Attr::C) && !attr.has(Attr::CVarArg)))) { + LOG("force-realize {}", f.first); seqassert(f.second.type->canRealize(), "cannot realize {}", f.first); realize(ctx->instantiate(f.second.type)->getFunc()); seqassert(!f.second.realizations.empty(), "cannot realize {}", f.first); @@ -409,7 +410,8 @@ types::TypePtr TypecheckVisitor::realizeFunc(types::FuncType *type, bool force) realizations[key] = realizations[type->realizedName()]; } - LOG("[realize] {} {}", type->realizedName(), ctx->realizationBases.back().iteration); + // LOG("[realize] {} {}", type->realizedName(), + // ctx->realizationBases.back().iteration); if (force) realizations[type->realizedName()]->ast = r->ast;