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

pull/12/head
Ibrahim Numanagić 2022-02-23 17:39:57 -08:00
commit ba11b44c9d
4 changed files with 25 additions and 22 deletions

View File

@ -66,13 +66,11 @@ if(bdwgc_ADDED)
endif()
CPMAddPackage(
GITHUB_REPOSITORY "llvm-mirror/openmp"
VERSION 9.0
GIT_TAG release_90
# GITHUB_REPOSITORY "exaloop/openmp"
# VERSION 12.0.1
# GIT_TAG v12.0.1
OPTIONS "OPENMP_ENABLE_LIBOMPTARGET OFF"
NAME openmp
GITHUB_REPOSITORY "exaloop/openmp"
VERSION 13.0.0-fb9fc3c
OPTIONS "CMAKE_BUILD_TYPE Release"
"OPENMP_ENABLE_LIBOMPTARGET OFF"
"OPENMP_STANDALONE_BUILD ON")
CPMAddPackage(

View File

@ -120,7 +120,8 @@ const std::string DictLiteralAttribute::AttributeName = "dictLiteralAttribute";
std::unique_ptr<Attribute> DictLiteralAttribute::clone(util::CloneVisitor &cv) const {
std::vector<DictLiteralAttribute::KeyValuePair> elementsCloned;
for (auto &val : elements)
elementsCloned.push_back({cv.clone(val.key), cv.clone(val.value)});
elementsCloned.push_back(
{cv.clone(val.key), val.value ? cv.clone(val.value) : nullptr});
return std::make_unique<DictLiteralAttribute>(elementsCloned);
}
@ -128,14 +129,20 @@ std::unique_ptr<Attribute>
DictLiteralAttribute::forceClone(util::CloneVisitor &cv) const {
std::vector<DictLiteralAttribute::KeyValuePair> elementsCloned;
for (auto &val : elements)
elementsCloned.push_back({cv.forceClone(val.key), cv.forceClone(val.value)});
elementsCloned.push_back(
{cv.forceClone(val.key), val.value ? cv.forceClone(val.value) : nullptr});
return std::make_unique<DictLiteralAttribute>(elementsCloned);
}
std::ostream &DictLiteralAttribute::doFormat(std::ostream &os) const {
std::vector<std::string> strings;
for (auto &val : elements)
strings.push_back(fmt::format(FMT_STRING("{}:{}"), *val.key, *val.value));
for (auto &val : elements) {
if (val.value) {
strings.push_back(fmt::format(FMT_STRING("{}:{}"), *val.key, *val.value));
} else {
strings.push_back(fmt::format(FMT_STRING("**{}"), *val.key));
}
}
fmt::print(os, FMT_STRING("dict([{}])"),
fmt::join(strings.begin(), strings.end(), ","));
return os;
@ -148,8 +155,7 @@ PartialFunctionAttribute::clone(util::CloneVisitor &cv) const {
std::vector<Value *> argsCloned;
for (auto *val : args)
argsCloned.push_back(cv.clone(val));
return std::make_unique<PartialFunctionAttribute>(cast<Func>(cv.clone(func)),
argsCloned);
return std::make_unique<PartialFunctionAttribute>(name, argsCloned);
}
std::unique_ptr<Attribute>
@ -157,15 +163,14 @@ PartialFunctionAttribute::forceClone(util::CloneVisitor &cv) const {
std::vector<Value *> argsCloned;
for (auto *val : args)
argsCloned.push_back(cv.forceClone(val));
return std::make_unique<PartialFunctionAttribute>(cast<Func>(cv.forceClone(func)),
argsCloned);
return std::make_unique<PartialFunctionAttribute>(name, argsCloned);
}
std::ostream &PartialFunctionAttribute::doFormat(std::ostream &os) const {
std::vector<std::string> strings;
for (auto *val : args)
strings.push_back(val ? fmt::format(FMT_STRING("{}"), *val) : "...");
fmt::print(os, FMT_STRING("{}({})"), func->getName(),
fmt::print(os, FMT_STRING("{}({})"), name,
fmt::join(strings.begin(), strings.end(), ","));
return os;
}

View File

@ -177,7 +177,9 @@ private:
/// Attribute attached to IR structures corresponding to dict literals
struct DictLiteralAttribute : public Attribute {
struct KeyValuePair {
/// the key in the literal
Value *key;
/// the value in the literal, or null if key is being star-unpacked
Value *value;
};
@ -200,15 +202,15 @@ private:
struct PartialFunctionAttribute : public Attribute {
static const std::string AttributeName;
/// function being called
Func *func;
/// base name of the function being used in the partial
std::string name;
/// partial arguments, or null if none
/// e.g. "f(a, ..., b)" has elements [a, null, b]
std::vector<Value *> args;
PartialFunctionAttribute(Func *func, std::vector<Value *> args)
: func(func), args(std::move(args)) {}
PartialFunctionAttribute(const std::string &name, std::vector<Value *> args)
: name(name), args(std::move(args)) {}
std::unique_ptr<Attribute> clone(util::CloneVisitor &cv) const override;
std::unique_ptr<Attribute> forceClone(util::CloneVisitor &cv) const override;

View File

@ -874,8 +874,6 @@ void LLVMVisitor::visit(const InternalFunc *x) {
}
}
if (!result)
internalFuncMatchesIgnoreArgs<RecordType>("__new__", x);
seqassert(result, "internal function {} not found", *x);
B->CreateRet(result);
}