mirror of https://github.com/exaloop/codon.git
clang-format
parent
2bf3709d33
commit
f0a21fa3ef
|
@ -771,7 +771,8 @@ int CallableTrait::unify(Type *typ, Unification *us) {
|
||||||
if (args[gi++]->unify(pf->args[pi + 1].get(), us) == -1)
|
if (args[gi++]->unify(pf->args[pi + 1].get(), us) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
if (us && us->realizator && pf->canRealize()) {
|
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);
|
auto rf = us->realizator->realize(pf);
|
||||||
pf->unify(rf.get(), us);
|
pf->unify(rf.get(), us);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ SimplifyContext::SimplifyContext(std::string filename, Cache *cache)
|
||||||
allowTypeOf(true), substitutions(nullptr) {}
|
allowTypeOf(true), substitutions(nullptr) {}
|
||||||
|
|
||||||
SimplifyContext::Base::Base(std::string name, std::shared_ptr<Expr> ast, int attributes)
|
SimplifyContext::Base::Base(std::string name, std::shared_ptr<Expr> ast, int attributes)
|
||||||
: name(move(name)), ast(move(ast)), attributes(attributes),
|
: name(move(name)), ast(move(ast)), attributes(attributes), deducedMembers(nullptr),
|
||||||
deducedMembers(nullptr), selfName() {}
|
selfName() {}
|
||||||
|
|
||||||
std::shared_ptr<SimplifyItem> SimplifyContext::add(SimplifyItem::Kind kind,
|
std::shared_ptr<SimplifyItem> SimplifyContext::add(SimplifyItem::Kind kind,
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
|
|
|
@ -569,8 +569,7 @@ void SimplifyVisitor::visit(FunctionStmt *stmt) {
|
||||||
if (typeAst && (typeAst->isId("type") || typeAst->isId("TypeVar")) && deflt &&
|
if (typeAst && (typeAst->isId("type") || typeAst->isId("TypeVar")) && deflt &&
|
||||||
deflt->getNone())
|
deflt->getNone())
|
||||||
deflt = N<IdExpr>("NoneType");
|
deflt = N<IdExpr>("NoneType");
|
||||||
args.emplace_back(
|
args.emplace_back(Param{std::string(stars, '*') + name, typeAst, deflt, a.generic});
|
||||||
Param{std::string(stars, '*') + name, typeAst, deflt, a.generic});
|
|
||||||
if (a.generic) {
|
if (a.generic) {
|
||||||
if (a.type->getIndex() && a.type->getIndex()->expr->isId("Static"))
|
if (a.type->getIndex() && a.type->getIndex()->expr->isId("Static"))
|
||||||
ctx->add(SimplifyItem::Var, varName, name);
|
ctx->add(SimplifyItem::Var, varName, name);
|
||||||
|
|
|
@ -1397,7 +1397,8 @@ ExprPtr TypecheckVisitor::transformCall(CallExpr *expr, const types::TypePtr &in
|
||||||
// endswith(calleeFn->ast->name, ".__new__:0")) {
|
// endswith(calleeFn->ast->name, ".__new__:0")) {
|
||||||
// seqassert(expr->type->getRecord(), "expected a partial record");
|
// seqassert(expr->type->getRecord(), "expected a partial record");
|
||||||
// auto r = expr->type->getRecord();
|
// 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);
|
// ctx->cache->partials[r->name].second);
|
||||||
// }
|
// }
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1648,7 +1649,8 @@ std::string TypecheckVisitor::generatePartialStub(const std::vector<char> &mask,
|
||||||
ctx->cache->partials[typeName] = {fn->generalize(0)->getFunc(), mask};
|
ctx->cache->partials[typeName] = {fn->generalize(0)->getFunc(), mask};
|
||||||
generateTupleStub(tupleSize + 2, typeName, {}, false);
|
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;
|
return typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ types::TypePtr TypecheckVisitor::realize(types::TypePtr typ) {
|
||||||
} else if (auto c = typ->getClass()) {
|
} else if (auto c = typ->getClass()) {
|
||||||
auto t = realizeType(c.get());
|
auto t = realizeType(c.get());
|
||||||
if (auto p = typ->getPartial()) {
|
if (auto p = typ->getPartial()) {
|
||||||
// if (auto rt = realize(p->func))
|
// if (auto rt = realize(p->func))
|
||||||
// unify(rt, p->func);
|
// unify(rt, p->func);
|
||||||
return std::make_shared<PartialType>(t->getRecord(), p->func, p->known);
|
return std::make_shared<PartialType>(t->getRecord(), p->func, p->known);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
|
Loading…
Reference in New Issue