Merge branch 'auto-class-deduction' of github.com:exaloop/codon into auto-class-deduction

pull/12/head
Ibrahim Numanagić 2022-02-07 16:53:36 -08:00
commit 68a3c1ff98
6 changed files with 15 additions and 13 deletions

View File

@ -74,8 +74,8 @@ else()
-Wl,--no-whole-archive)
endif()
if(ASAN)
target_compile_options(codonrt PRIVATE "-fno-omit-frame-pointer" "-fsanitize=address")
target_link_libraries(codonrt PRIVATE "-fno-omit-frame-pointer" "-fsanitize=address")
target_compile_options(codonrt PRIVATE "-fno-omit-frame-pointer" "-fsanitize=address" "-fsanitize-recover=address")
target_link_libraries(codonrt PRIVATE "-fno-omit-frame-pointer" "-fsanitize=address" "-fsanitize-recover=address")
endif()
add_custom_command(TARGET codonrt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:omp> ${CMAKE_BINARY_DIR})
@ -297,8 +297,8 @@ if(CODON_JUPYTER)
target_link_libraries(codonc PRIVATE xeus-static)
endif()
if(ASAN)
target_compile_options(codonc PRIVATE "-fno-omit-frame-pointer" "-fsanitize=address")
target_link_libraries(codonc PRIVATE "-fno-omit-frame-pointer" "-fsanitize=address")
target_compile_options(codonc PRIVATE "-fno-omit-frame-pointer" "-fsanitize=address" "-fsanitize-recover=address")
target_link_libraries(codonc PRIVATE "-fno-omit-frame-pointer" "-fsanitize=address" "-fsanitize-recover=address")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
set_source_files_properties(codon_rules.cpp codon/parser/peg/peg.cpp PROPERTIES COMPILE_FLAGS "-O2")

View File

@ -771,7 +771,8 @@ int CallableTrait::unify(Type *typ, Unification *us) {
if (args[gi++]->unify(pf->args[pi + 1].get(), us) == -1)
return -1;
if (us && us->realizator && pf->canRealize()) {
// Realize if possible to allow deduction of return type [and possible unification!]
// Realize if possible to allow deduction of return type [and possible
// unification!]
auto rf = us->realizator->realize(pf);
pf->unify(rf.get(), us);
}

View File

@ -24,8 +24,8 @@ SimplifyContext::SimplifyContext(std::string filename, Cache *cache)
allowTypeOf(true), substitutions(nullptr) {}
SimplifyContext::Base::Base(std::string name, std::shared_ptr<Expr> ast, int attributes)
: name(move(name)), ast(move(ast)), attributes(attributes),
deducedMembers(nullptr), selfName() {}
: name(move(name)), ast(move(ast)), attributes(attributes), deducedMembers(nullptr),
selfName() {}
std::shared_ptr<SimplifyItem> SimplifyContext::add(SimplifyItem::Kind kind,
const std::string &name,

View File

@ -569,8 +569,7 @@ void SimplifyVisitor::visit(FunctionStmt *stmt) {
if (typeAst && (typeAst->isId("type") || typeAst->isId("TypeVar")) && deflt &&
deflt->getNone())
deflt = N<IdExpr>("NoneType");
args.emplace_back(
Param{std::string(stars, '*') + name, typeAst, deflt, a.generic});
args.emplace_back(Param{std::string(stars, '*') + name, typeAst, deflt, a.generic});
if (a.generic) {
if (a.type->getIndex() && a.type->getIndex()->expr->isId("Static"))
ctx->add(SimplifyItem::Var, varName, name);

View File

@ -1397,7 +1397,8 @@ ExprPtr TypecheckVisitor::transformCall(CallExpr *expr, const types::TypePtr &in
// endswith(calleeFn->ast->name, ".__new__:0")) {
// seqassert(expr->type->getRecord(), "expected a partial record");
// auto r = expr->type->getRecord();
// expr->type = std::make_shared<PartialType>(r, ctx->cache->partials[r->name].first,
// expr->type = std::make_shared<PartialType>(r,
// ctx->cache->partials[r->name].first,
// ctx->cache->partials[r->name].second);
// }
return nullptr;
@ -1648,7 +1649,8 @@ std::string TypecheckVisitor::generatePartialStub(const std::vector<char> &mask,
ctx->cache->partials[typeName] = {fn->generalize(0)->getFunc(), mask};
generateTupleStub(tupleSize + 2, typeName, {}, false);
}
// LOG("[p] {} -> {}", typeName, ctx->cache->partials[typeName].first->debugString(1));
// LOG("[p] {} -> {}", typeName,
// ctx->cache->partials[typeName].first->debugString(1));
return typeName;
}

View File

@ -32,8 +32,8 @@ types::TypePtr TypecheckVisitor::realize(types::TypePtr typ) {
} else if (auto c = typ->getClass()) {
auto t = realizeType(c.get());
if (auto p = typ->getPartial()) {
// if (auto rt = realize(p->func))
// unify(rt, p->func);
// if (auto rt = realize(p->func))
// unify(rt, p->func);
return std::make_shared<PartialType>(t->getRecord(), p->func, p->known);
}
return t;