Commit 3420ef7e authored by Kevin Modzelewski's avatar Kevin Modzelewski

Turn on -Winconsistent-missing-override

parent 923df348
...@@ -138,7 +138,6 @@ COMMON_CXXFLAGS += -fexceptions -fno-rtti ...@@ -138,7 +138,6 @@ COMMON_CXXFLAGS += -fexceptions -fno-rtti
COMMON_CXXFLAGS += -Wno-invalid-offsetof # allow the use of "offsetof", and we'll just have to make sure to only use it legally. COMMON_CXXFLAGS += -Wno-invalid-offsetof # allow the use of "offsetof", and we'll just have to make sure to only use it legally.
COMMON_CXXFLAGS += -DENABLE_INTEL_JIT_EVENTS=$(ENABLE_INTEL_JIT_EVENTS) COMMON_CXXFLAGS += -DENABLE_INTEL_JIT_EVENTS=$(ENABLE_INTEL_JIT_EVENTS)
COMMON_CXXFLAGS += -I$(DEPS_DIR)/pypa-install/include COMMON_CXXFLAGS += -I$(DEPS_DIR)/pypa-install/include
COMMON_CXXFLAGS += -Wno-inconsistent-missing-override
ifeq ($(ENABLE_VALGRIND),0) ifeq ($(ENABLE_VALGRIND),0)
COMMON_CXXFLAGS += -DNVALGRIND COMMON_CXXFLAGS += -DNVALGRIND
......
...@@ -24,9 +24,9 @@ class YieldVisitor : public NoopASTVisitor { ...@@ -24,9 +24,9 @@ class YieldVisitor : public NoopASTVisitor {
public: public:
YieldVisitor() : containsYield(false) {} YieldVisitor() : containsYield(false) {}
virtual bool visit_functiondef(AST_FunctionDef*) { return true; } bool visit_functiondef(AST_FunctionDef*) override { return true; }
virtual bool visit_yield(AST_Yield*) { bool visit_yield(AST_Yield*) override {
containsYield = true; containsYield = true;
return true; return true;
} }
...@@ -55,25 +55,25 @@ static bool isCompilerCreatedName(const std::string& name) { ...@@ -55,25 +55,25 @@ static bool isCompilerCreatedName(const std::string& name) {
class ModuleScopeInfo : public ScopeInfo { class ModuleScopeInfo : public ScopeInfo {
public: public:
virtual ScopeInfo* getParent() { return NULL; } ScopeInfo* getParent() override { return NULL; }
virtual bool createsClosure() { return false; } bool createsClosure() override { return false; }
virtual bool takesClosure() { return false; } bool takesClosure() override { return false; }
bool passesThroughClosure() override { return false; } bool passesThroughClosure() override { return false; }
virtual bool refersToGlobal(const std::string& name) { bool refersToGlobal(const std::string& name) override {
if (isCompilerCreatedName(name)) if (isCompilerCreatedName(name))
return false; return false;
// assert(name[0] != '#' && "should test this"); // assert(name[0] != '#' && "should test this");
return true; return true;
} }
virtual bool refersToClosure(const std::string name) { return false; } bool refersToClosure(const std::string name) override { return false; }
virtual bool saveInClosure(const std::string name) { return false; } bool saveInClosure(const std::string name) override { return false; }
virtual const std::unordered_set<std::string>& getClassDefLocalNames() { RELEASE_ASSERT(0, ""); } const std::unordered_set<std::string>& getClassDefLocalNames() override { RELEASE_ASSERT(0, ""); }
}; };
struct ScopingAnalysis::ScopeNameUsage { struct ScopingAnalysis::ScopeNameUsage {
...@@ -120,17 +120,19 @@ public: ...@@ -120,17 +120,19 @@ public:
assert(usage); assert(usage);
} }
virtual ~ScopeInfoBase() { delete this->usage; } ~ScopeInfoBase() override { delete this->usage; }
virtual ScopeInfo* getParent() { return parent; } ScopeInfo* getParent() override { return parent; }
virtual bool createsClosure() { return usage->referenced_from_nested.size() > 0; } bool createsClosure() override { return usage->referenced_from_nested.size() > 0; }
virtual bool takesClosure() { return usage->got_from_closure.size() > 0 || usage->passthrough_accesses.size() > 0; } bool takesClosure() override {
return usage->got_from_closure.size() > 0 || usage->passthrough_accesses.size() > 0;
}
bool passesThroughClosure() override { return usage->passthrough_accesses.size() > 0 && !createsClosure(); } bool passesThroughClosure() override { return usage->passthrough_accesses.size() > 0 && !createsClosure(); }
virtual bool refersToGlobal(const std::string& name) { bool refersToGlobal(const std::string& name) override {
// HAX // HAX
if (isCompilerCreatedName(name)) if (isCompilerCreatedName(name))
return false; return false;
...@@ -139,20 +141,20 @@ public: ...@@ -139,20 +141,20 @@ public:
return true; return true;
return usage->written.count(name) == 0 && usage->got_from_closure.count(name) == 0; return usage->written.count(name) == 0 && usage->got_from_closure.count(name) == 0;
} }
virtual bool refersToClosure(const std::string name) { bool refersToClosure(const std::string name) override {
// HAX // HAX
if (isCompilerCreatedName(name)) if (isCompilerCreatedName(name))
return false; return false;
return usage->got_from_closure.count(name) != 0; return usage->got_from_closure.count(name) != 0;
} }
virtual bool saveInClosure(const std::string name) { bool saveInClosure(const std::string name) override {
// HAX // HAX
if (isCompilerCreatedName(name)) if (isCompilerCreatedName(name))
return false; return false;
return usage->referenced_from_nested.count(name) != 0; return usage->referenced_from_nested.count(name) != 0;
} }
virtual const std::unordered_set<std::string>& getClassDefLocalNames() { const std::unordered_set<std::string>& getClassDefLocalNames() override {
RELEASE_ASSERT(usage->node->type == AST_TYPE::ClassDef, ""); RELEASE_ASSERT(usage->node->type == AST_TYPE::ClassDef, "");
return usage->written; return usage->written;
} }
...@@ -177,7 +179,7 @@ public: ...@@ -177,7 +179,7 @@ public:
void doRead(const std::string& name) { cur->read.insert(name); } void doRead(const std::string& name) { cur->read.insert(name); }
virtual bool visit_name(AST_Name* node) { bool visit_name(AST_Name* node) override {
switch (node->ctx_type) { switch (node->ctx_type) {
case AST_TYPE::Load: case AST_TYPE::Load:
doRead(node->id); doRead(node->id);
...@@ -193,55 +195,55 @@ public: ...@@ -193,55 +195,55 @@ public:
return true; return true;
} }
virtual bool visit_assert(AST_Assert* node) { return false; } bool visit_assert(AST_Assert* node) override { return false; }
virtual bool visit_assign(AST_Assign* node) { return false; } bool visit_assign(AST_Assign* node) override { return false; }
virtual bool visit_augassign(AST_AugAssign* node) { return false; } bool visit_augassign(AST_AugAssign* node) override { return false; }
virtual bool visit_attribute(AST_Attribute* node) { return false; } bool visit_attribute(AST_Attribute* node) override { return false; }
virtual bool visit_binop(AST_BinOp* node) { return false; } bool visit_binop(AST_BinOp* node) override { return false; }
virtual bool visit_boolop(AST_BoolOp* node) { return false; } bool visit_boolop(AST_BoolOp* node) override { return false; }
virtual bool visit_break(AST_Break* node) { return false; } bool visit_break(AST_Break* node) override { return false; }
virtual bool visit_call(AST_Call* node) { return false; } bool visit_call(AST_Call* node) override { return false; }
virtual bool visit_compare(AST_Compare* node) { return false; } bool visit_compare(AST_Compare* node) override { return false; }
virtual bool visit_comprehension(AST_comprehension* node) { return false; } bool visit_comprehension(AST_comprehension* node) override { return false; }
// virtual bool visit_classdef(AST_ClassDef *node) { return false; } // bool visit_classdef(AST_ClassDef *node) override { return false; }
virtual bool visit_continue(AST_Continue* node) { return false; } bool visit_continue(AST_Continue* node) override { return false; }
virtual bool visit_dict(AST_Dict* node) { return false; } bool visit_dict(AST_Dict* node) override { return false; }
virtual bool visit_dictcomp(AST_DictComp* node) { return false; } bool visit_dictcomp(AST_DictComp* node) override { return false; }
virtual bool visit_excepthandler(AST_ExceptHandler* node) { return false; } bool visit_excepthandler(AST_ExceptHandler* node) override { return false; }
virtual bool visit_expr(AST_Expr* node) { return false; } bool visit_expr(AST_Expr* node) override { return false; }
virtual bool visit_for(AST_For* node) { return false; } bool visit_for(AST_For* node) override { return false; }
// virtual bool visit_functiondef(AST_FunctionDef *node) { return false; } // bool visit_functiondef(AST_FunctionDef *node) override { return false; }
// virtual bool visit_global(AST_Global *node) { return false; } // bool visit_global(AST_Global *node) override { return false; }
virtual bool visit_if(AST_If* node) { return false; } bool visit_if(AST_If* node) override { return false; }
virtual bool visit_ifexp(AST_IfExp* node) { return false; } bool visit_ifexp(AST_IfExp* node) override { return false; }
virtual bool visit_index(AST_Index* node) { return false; } bool visit_index(AST_Index* node) override { return false; }
virtual bool visit_keyword(AST_keyword* node) { return false; } bool visit_keyword(AST_keyword* node) override { return false; }
virtual bool visit_list(AST_List* node) { return false; } bool visit_list(AST_List* node) override { return false; }
virtual bool visit_listcomp(AST_ListComp* node) { return false; } bool visit_listcomp(AST_ListComp* node) override { return false; }
// virtual bool visit_module(AST_Module *node) { return false; } // bool visit_module(AST_Module *node) override { return false; }
// virtual bool visit_name(AST_Name *node) { return false; } // bool visit_name(AST_Name *node) override { return false; }
virtual bool visit_num(AST_Num* node) { return false; } bool visit_num(AST_Num* node) override { return false; }
virtual bool visit_pass(AST_Pass* node) { return false; } bool visit_pass(AST_Pass* node) override { return false; }
virtual bool visit_print(AST_Print* node) { return false; } bool visit_print(AST_Print* node) override { return false; }
virtual bool visit_raise(AST_Raise* node) { return false; } bool visit_raise(AST_Raise* node) override { return false; }
virtual bool visit_repr(AST_Repr* node) { return false; } bool visit_repr(AST_Repr* node) override { return false; }
virtual bool visit_return(AST_Return* node) { return false; } bool visit_return(AST_Return* node) override { return false; }
virtual bool visit_slice(AST_Slice* node) { return false; } bool visit_slice(AST_Slice* node) override { return false; }
virtual bool visit_str(AST_Str* node) { return false; } bool visit_str(AST_Str* node) override { return false; }
virtual bool visit_subscript(AST_Subscript* node) { return false; } bool visit_subscript(AST_Subscript* node) override { return false; }
virtual bool visit_tryexcept(AST_TryExcept* node) { return false; } bool visit_tryexcept(AST_TryExcept* node) override { return false; }
virtual bool visit_tryfinally(AST_TryFinally* node) { return false; } bool visit_tryfinally(AST_TryFinally* node) override { return false; }
virtual bool visit_tuple(AST_Tuple* node) { return false; } bool visit_tuple(AST_Tuple* node) override { return false; }
virtual bool visit_unaryop(AST_UnaryOp* node) { return false; } bool visit_unaryop(AST_UnaryOp* node) override { return false; }
virtual bool visit_while(AST_While* node) { return false; } bool visit_while(AST_While* node) override { return false; }
virtual bool visit_with(AST_With* node) { return false; } bool visit_with(AST_With* node) override { return false; }
virtual bool visit_yield(AST_Yield* node) { return false; } bool visit_yield(AST_Yield* node) override { return false; }
virtual bool visit_branch(AST_Branch* node) { return false; } bool visit_branch(AST_Branch* node) override { return false; }
virtual bool visit_jump(AST_Jump* node) { return false; } bool visit_jump(AST_Jump* node) override { return false; }
virtual bool visit_delete(AST_Delete* node) { bool visit_delete(AST_Delete* node) override {
for (auto t : node->targets) { for (auto t : node->targets) {
if (t->type == AST_TYPE::Name) { if (t->type == AST_TYPE::Name) {
doWrite(ast_cast<AST_Name>(t)->id); doWrite(ast_cast<AST_Name>(t)->id);
...@@ -250,7 +252,7 @@ public: ...@@ -250,7 +252,7 @@ public:
return false; return false;
} }
virtual bool visit_global(AST_Global* node) { bool visit_global(AST_Global* node) override {
for (int i = 0; i < node->names.size(); i++) { for (int i = 0; i < node->names.size(); i++) {
const std::string& name = node->names[i]; const std::string& name = node->names[i];
cur->forced_globals.insert(name); cur->forced_globals.insert(name);
...@@ -258,7 +260,7 @@ public: ...@@ -258,7 +260,7 @@ public:
return true; return true;
} }
virtual bool visit_classdef(AST_ClassDef* node) { bool visit_classdef(AST_ClassDef* node) override {
if (node == orig_node) { if (node == orig_node) {
for (AST_stmt* s : node->body) for (AST_stmt* s : node->body)
s->accept(this); s->accept(this);
...@@ -276,7 +278,7 @@ public: ...@@ -276,7 +278,7 @@ public:
} }
} }
virtual bool visit_functiondef(AST_FunctionDef* node) { bool visit_functiondef(AST_FunctionDef* node) override {
if (node == orig_node) { if (node == orig_node) {
for (AST_expr* e : node->args->args) for (AST_expr* e : node->args->args)
e->accept(this); e->accept(this);
...@@ -300,7 +302,7 @@ public: ...@@ -300,7 +302,7 @@ public:
} }
} }
virtual bool visit_generatorexp(AST_GeneratorExp* node) { bool visit_generatorexp(AST_GeneratorExp* node) override {
if (node == orig_node) { if (node == orig_node) {
bool first = true; bool first = true;
for (AST_comprehension* c : node->generators) { for (AST_comprehension* c : node->generators) {
...@@ -320,7 +322,7 @@ public: ...@@ -320,7 +322,7 @@ public:
return true; return true;
} }
virtual bool visit_lambda(AST_Lambda* node) { bool visit_lambda(AST_Lambda* node) override {
if (node == orig_node) { if (node == orig_node) {
for (AST_expr* e : node->args->args) for (AST_expr* e : node->args->args)
e->accept(this); e->accept(this);
...@@ -339,7 +341,7 @@ public: ...@@ -339,7 +341,7 @@ public:
return true; return true;
} }
virtual bool visit_import(AST_Import* node) { bool visit_import(AST_Import* node) override {
for (int i = 0; i < node->names.size(); i++) { for (int i = 0; i < node->names.size(); i++) {
AST_alias* alias = node->names[i]; AST_alias* alias = node->names[i];
if (alias->asname.size()) if (alias->asname.size())
...@@ -350,7 +352,7 @@ public: ...@@ -350,7 +352,7 @@ public:
return true; return true;
} }
virtual bool visit_importfrom(AST_ImportFrom* node) { bool visit_importfrom(AST_ImportFrom* node) override {
for (int i = 0; i < node->names.size(); i++) { for (int i = 0; i < node->names.size(); i++) {
AST_alias* alias = node->names[i]; AST_alias* alias = node->names[i];
if (alias->asname.size()) if (alias->asname.size())
......
...@@ -36,8 +36,8 @@ namespace pyston { ...@@ -36,8 +36,8 @@ namespace pyston {
class NullTypeAnalysis : public TypeAnalysis { class NullTypeAnalysis : public TypeAnalysis {
public: public:
virtual ConcreteCompilerType* getTypeAtBlockStart(const std::string& name, CFGBlock* block); ConcreteCompilerType* getTypeAtBlockStart(const std::string& name, CFGBlock* block) override;
virtual ConcreteCompilerType* getTypeAtBlockEnd(const std::string& name, CFGBlock* block); ConcreteCompilerType* getTypeAtBlockEnd(const std::string& name, CFGBlock* block) override;
BoxedClass* speculatedExprClass(AST_expr*) override { return NULL; } BoxedClass* speculatedExprClass(AST_expr*) override { return NULL; }
}; };
...@@ -168,7 +168,7 @@ private: ...@@ -168,7 +168,7 @@ private:
} }
} }
virtual void* visit_attribute(AST_Attribute* node) { void* visit_attribute(AST_Attribute* node) override {
CompilerType* t = getType(node->value); CompilerType* t = getType(node->value);
CompilerType* rtn = t->getattrType(&node->attr, false); CompilerType* rtn = t->getattrType(&node->attr, false);
...@@ -190,7 +190,7 @@ private: ...@@ -190,7 +190,7 @@ private:
return rtn; return rtn;
} }
virtual void* visit_clsattribute(AST_ClsAttribute* node) { void* visit_clsattribute(AST_ClsAttribute* node) override {
CompilerType* t = getType(node->value); CompilerType* t = getType(node->value);
CompilerType* rtn = t->getattrType(&node->attr, true); CompilerType* rtn = t->getattrType(&node->attr, true);
if (VERBOSITY() >= 2 && rtn == UNDEF) { if (VERBOSITY() >= 2 && rtn == UNDEF) {
...@@ -207,7 +207,7 @@ private: ...@@ -207,7 +207,7 @@ private:
return type == STR || type == INT || type == FLOAT || type == LIST || type == DICT; return type == STR || type == INT || type == FLOAT || type == LIST || type == DICT;
} }
virtual void* visit_augbinop(AST_AugBinOp* node) { void* visit_augbinop(AST_AugBinOp* node) override {
CompilerType* left = getType(node->left); CompilerType* left = getType(node->left);
CompilerType* right = getType(node->right); CompilerType* right = getType(node->right);
if (!hasFixedBinops(left) || !hasFixedBinops(right)) if (!hasFixedBinops(left) || !hasFixedBinops(right))
...@@ -236,7 +236,7 @@ private: ...@@ -236,7 +236,7 @@ private:
return rtn; return rtn;
} }
virtual void* visit_binop(AST_BinOp* node) { void* visit_binop(AST_BinOp* node) override {
CompilerType* left = getType(node->left); CompilerType* left = getType(node->left);
CompilerType* right = getType(node->right); CompilerType* right = getType(node->right);
if (!hasFixedBinops(left) || !hasFixedBinops(right)) if (!hasFixedBinops(left) || !hasFixedBinops(right))
...@@ -265,7 +265,7 @@ private: ...@@ -265,7 +265,7 @@ private:
return rtn; return rtn;
} }
virtual void* visit_boolop(AST_BoolOp* node) { void* visit_boolop(AST_BoolOp* node) override {
int n = node->values.size(); int n = node->values.size();
CompilerType* rtn = NULL; CompilerType* rtn = NULL;
...@@ -280,7 +280,7 @@ private: ...@@ -280,7 +280,7 @@ private:
return rtn; return rtn;
} }
virtual void* visit_call(AST_Call* node) { void* visit_call(AST_Call* node) override {
CompilerType* func = getType(node->func); CompilerType* func = getType(node->func);
std::vector<CompilerType*> arg_types; std::vector<CompilerType*> arg_types;
...@@ -316,7 +316,7 @@ private: ...@@ -316,7 +316,7 @@ private:
return rtn_type; return rtn_type;
} }
virtual void* visit_compare(AST_Compare* node) { void* visit_compare(AST_Compare* node) override {
if (node->ops.size() == 1) { if (node->ops.size() == 1) {
CompilerType* left = getType(node->left); CompilerType* left = getType(node->left);
CompilerType* right = getType(node->comparators[0]); CompilerType* right = getType(node->comparators[0]);
...@@ -342,7 +342,7 @@ private: ...@@ -342,7 +342,7 @@ private:
} }
} }
virtual void* visit_dict(AST_Dict* node) { void* visit_dict(AST_Dict* node) override {
// Get all the sub-types, even though they're not necessary to // Get all the sub-types, even though they're not necessary to
// determine the expression type, so that things like speculations // determine the expression type, so that things like speculations
// can be processed. // can be processed.
...@@ -354,11 +354,11 @@ private: ...@@ -354,11 +354,11 @@ private:
return DICT; return DICT;
} }
virtual void* visit_index(AST_Index* node) { return getType(node->value); } void* visit_index(AST_Index* node) override { return getType(node->value); }
virtual void* visit_lambda(AST_Lambda* node) { return typeFromClass(function_cls); } void* visit_lambda(AST_Lambda* node) override { return typeFromClass(function_cls); }
virtual void* visit_langprimitive(AST_LangPrimitive* node) { void* visit_langprimitive(AST_LangPrimitive* node) override {
switch (node->opcode) { switch (node->opcode) {
case AST_LangPrimitive::ISINSTANCE: case AST_LangPrimitive::ISINSTANCE:
return BOOL; return BOOL;
...@@ -377,7 +377,7 @@ private: ...@@ -377,7 +377,7 @@ private:
} }
} }
virtual void* visit_list(AST_List* node) { void* visit_list(AST_List* node) override {
// Get all the sub-types, even though they're not necessary to // Get all the sub-types, even though they're not necessary to
// determine the expression type, so that things like speculations // determine the expression type, so that things like speculations
// can be processed. // can be processed.
...@@ -388,7 +388,7 @@ private: ...@@ -388,7 +388,7 @@ private:
return LIST; return LIST;
} }
virtual void* visit_name(AST_Name* node) { void* visit_name(AST_Name* node) override {
if (scope_info->refersToGlobal(node->id)) { if (scope_info->refersToGlobal(node->id)) {
if (node->id == "xrange") { if (node->id == "xrange") {
// printf("TODO guard here and return the classobj\n"); // printf("TODO guard here and return the classobj\n");
...@@ -412,7 +412,7 @@ private: ...@@ -412,7 +412,7 @@ private:
return t; return t;
} }
virtual void* visit_num(AST_Num* node) { void* visit_num(AST_Num* node) override {
switch (node->num_type) { switch (node->num_type) {
case AST_Num::INT: case AST_Num::INT:
return INT; return INT;
...@@ -426,15 +426,15 @@ private: ...@@ -426,15 +426,15 @@ private:
abort(); abort();
} }
virtual void* visit_repr(AST_Repr* node) { return STR; } void* visit_repr(AST_Repr* node) override { return STR; }
virtual void* visit_set(AST_Set* node) { return SET; } void* visit_set(AST_Set* node) override { return SET; }
virtual void* visit_slice(AST_Slice* node) { return SLICE; } void* visit_slice(AST_Slice* node) override { return SLICE; }
virtual void* visit_str(AST_Str* node) { return STR; } void* visit_str(AST_Str* node) override { return STR; }
virtual void* visit_subscript(AST_Subscript* node) { void* visit_subscript(AST_Subscript* node) override {
CompilerType* val = getType(node->value); CompilerType* val = getType(node->value);
CompilerType* slice = getType(node->slice); CompilerType* slice = getType(node->slice);
static std::string name("__getitem__"); static std::string name("__getitem__");
...@@ -444,7 +444,7 @@ private: ...@@ -444,7 +444,7 @@ private:
return getitem_type->callType(ArgPassSpec(1), args, NULL); return getitem_type->callType(ArgPassSpec(1), args, NULL);
} }
virtual void* visit_tuple(AST_Tuple* node) { void* visit_tuple(AST_Tuple* node) override {
std::vector<CompilerType*> elt_types; std::vector<CompilerType*> elt_types;
for (int i = 0; i < node->elts.size(); i++) { for (int i = 0; i < node->elts.size(); i++) {
elt_types.push_back(getType(node->elts[i])); elt_types.push_back(getType(node->elts[i]));
...@@ -452,7 +452,7 @@ private: ...@@ -452,7 +452,7 @@ private:
return makeTupleType(elt_types); return makeTupleType(elt_types);
} }
virtual void* visit_unaryop(AST_UnaryOp* node) { void* visit_unaryop(AST_UnaryOp* node) override {
CompilerType* operand = getType(node->operand); CompilerType* operand = getType(node->operand);
// TODO this isn't the exact behavior // TODO this isn't the exact behavior
...@@ -462,29 +462,29 @@ private: ...@@ -462,29 +462,29 @@ private:
return attr_type->callType(ArgPassSpec(0), arg_types, NULL); return attr_type->callType(ArgPassSpec(0), arg_types, NULL);
} }
virtual void* visit_yield(AST_Yield*) { return UNKNOWN; } void* visit_yield(AST_Yield*) override { return UNKNOWN; }
virtual void visit_assert(AST_Assert* node) { void visit_assert(AST_Assert* node) override {
getType(node->test); getType(node->test);
if (node->msg) if (node->msg)
getType(node->msg); getType(node->msg);
} }
virtual void visit_assign(AST_Assign* node) { void visit_assign(AST_Assign* node) override {
CompilerType* t = getType(node->value); CompilerType* t = getType(node->value);
for (int i = 0; i < node->targets.size(); i++) { for (int i = 0; i < node->targets.size(); i++) {
_doSet(node->targets[i], t); _doSet(node->targets[i], t);
} }
} }
virtual void visit_branch(AST_Branch* node) { void visit_branch(AST_Branch* node) override {
if (EXPAND_UNNEEDED) { if (EXPAND_UNNEEDED) {
getType(node->test); getType(node->test);
} }
} }
virtual void visit_classdef(AST_ClassDef* node) { void visit_classdef(AST_ClassDef* node) override {
for (auto d : node->decorator_list) { for (auto d : node->decorator_list) {
getType(d); getType(d);
} }
...@@ -499,7 +499,7 @@ private: ...@@ -499,7 +499,7 @@ private:
_doSet(node->name, t); _doSet(node->name, t);
} }
virtual void visit_delete(AST_Delete* node) { void visit_delete(AST_Delete* node) override {
for (AST_expr* target : node->targets) { for (AST_expr* target : node->targets) {
switch (target->type) { switch (target->type) {
case AST_TYPE::Subscript: case AST_TYPE::Subscript:
...@@ -517,14 +517,14 @@ private: ...@@ -517,14 +517,14 @@ private:
} }
} }
virtual void visit_expr(AST_Expr* node) { void visit_expr(AST_Expr* node) override {
if (EXPAND_UNNEEDED) { if (EXPAND_UNNEEDED) {
if (node->value != NULL) if (node->value != NULL)
getType(node->value); getType(node->value);
} }
} }
virtual void visit_functiondef(AST_FunctionDef* node) { void visit_functiondef(AST_FunctionDef* node) override {
for (auto d : node->decorator_list) { for (auto d : node->decorator_list) {
getType(d); getType(d);
} }
...@@ -536,9 +536,10 @@ private: ...@@ -536,9 +536,10 @@ private:
_doSet(node->name, typeFromClass(function_cls)); _doSet(node->name, typeFromClass(function_cls));
} }
virtual void visit_global(AST_Global* node) {} void visit_global(AST_Global* node) override {}
virtual void visit_alias(AST_alias* node) { // not part of the visitor api:
void _visit_alias(AST_alias* node) {
const std::string* name = &node->name; const std::string* name = &node->name;
if (node->asname.size()) if (node->asname.size())
name = &node->asname; name = &node->asname;
...@@ -546,22 +547,22 @@ private: ...@@ -546,22 +547,22 @@ private:
_doSet(*name, UNKNOWN); _doSet(*name, UNKNOWN);
} }
virtual void visit_import(AST_Import* node) { void visit_import(AST_Import* node) override {
for (AST_alias* alias : node->names) for (AST_alias* alias : node->names)
visit_alias(alias); _visit_alias(alias);
} }
virtual void visit_importfrom(AST_ImportFrom* node) { void visit_importfrom(AST_ImportFrom* node) override {
for (AST_alias* alias : node->names) for (AST_alias* alias : node->names)
visit_alias(alias); _visit_alias(alias);
} }
virtual void visit_invoke(AST_Invoke* node) { node->stmt->accept_stmt(this); } void visit_invoke(AST_Invoke* node) override { node->stmt->accept_stmt(this); }
virtual void visit_jump(AST_Jump* node) {} void visit_jump(AST_Jump* node) override {}
virtual void visit_pass(AST_Pass* node) {} void visit_pass(AST_Pass* node) override {}
virtual void visit_print(AST_Print* node) { void visit_print(AST_Print* node) override {
if (node->dest) if (node->dest)
getType(node->dest); getType(node->dest);
...@@ -572,7 +573,7 @@ private: ...@@ -572,7 +573,7 @@ private:
} }
} }
virtual void visit_raise(AST_Raise* node) { void visit_raise(AST_Raise* node) override {
if (EXPAND_UNNEEDED) { if (EXPAND_UNNEEDED) {
if (node->arg0) if (node->arg0)
getType(node->arg0); getType(node->arg0);
...@@ -583,14 +584,14 @@ private: ...@@ -583,14 +584,14 @@ private:
} }
} }
virtual void visit_return(AST_Return* node) { void visit_return(AST_Return* node) override {
if (EXPAND_UNNEEDED) { if (EXPAND_UNNEEDED) {
if (node->value != NULL) if (node->value != NULL)
getType(node->value); getType(node->value);
} }
} }
virtual void visit_unreachable(AST_Unreachable* node) {} void visit_unreachable(AST_Unreachable* node) override {}
public: public:
static void propagate(CFGBlock* block, const TypeMap& starting, TypeMap& ending, ExprTypeMap& expr_types, static void propagate(CFGBlock* block, const TypeMap& starting, TypeMap& ending, ExprTypeMap& expr_types,
...@@ -614,11 +615,11 @@ private: ...@@ -614,11 +615,11 @@ private:
speculation(speculation) {} speculation(speculation) {}
public: public:
virtual ConcreteCompilerType* getTypeAtBlockEnd(const std::string& name, CFGBlock* block) { ConcreteCompilerType* getTypeAtBlockEnd(const std::string& name, CFGBlock* block) override {
assert(block->successors.size() > 0); assert(block->successors.size() > 0);
return getTypeAtBlockStart(name, block->successors[0]); return getTypeAtBlockStart(name, block->successors[0]);
} }
virtual ConcreteCompilerType* getTypeAtBlockStart(const std::string& name, CFGBlock* block) { ConcreteCompilerType* getTypeAtBlockStart(const std::string& name, CFGBlock* block) override {
CompilerType* base = starting_types[block][name]; CompilerType* base = starting_types[block][name];
ASSERT(base != NULL, "%s %d", name.c_str(), block->idx); ASSERT(base != NULL, "%s %d", name.c_str(), block->idx);
...@@ -627,7 +628,7 @@ public: ...@@ -627,7 +628,7 @@ public:
return rtn; return rtn;
} }
virtual BoxedClass* speculatedExprClass(AST_expr* call) { return type_speculations[call]; } BoxedClass* speculatedExprClass(AST_expr* call) override { return type_speculations[call]; }
static bool merge(CompilerType* lhs, CompilerType*& rhs) { static bool merge(CompilerType* lhs, CompilerType*& rhs) {
assert(lhs); assert(lhs);
......
...@@ -93,8 +93,8 @@ public: ...@@ -93,8 +93,8 @@ public:
return rtn; return rtn;
} }
virtual CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types, CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
std::vector<CompilerType*> new_args(arg_types); std::vector<CompilerType*> new_args(arg_types);
new_args.insert(new_args.begin(), obj_type); new_args.insert(new_args.begin(), obj_type);
...@@ -102,11 +102,11 @@ public: ...@@ -102,11 +102,11 @@ public:
return function_type->callType(new_argspec, new_args, keyword_names); return function_type->callType(new_argspec, new_args, keyword_names);
} }
std::string debugName() { std::string debugName() override {
return "instanceMethod(" + obj_type->debugName() + " ; " + function_type->debugName() + ")"; return "instanceMethod(" + obj_type->debugName() + " ; " + function_type->debugName() + ")";
} }
virtual void drop(IREmitter& emitter, VAR* var) { void drop(IREmitter& emitter, VAR* var) override {
checkVar(var); checkVar(var);
RawInstanceMethod* val = var->getValue(); RawInstanceMethod* val = var->getValue();
val->obj->decvref(emitter); val->obj->decvref(emitter);
...@@ -114,10 +114,9 @@ public: ...@@ -114,10 +114,9 @@ public:
delete val; delete val;
} }
virtual CompilerVariable* call(IREmitter& emitter, const OpInfo& info, CompilerVariable* call(IREmitter& emitter, const OpInfo& info, ValuedCompilerVariable<RawInstanceMethod*>* var,
ValuedCompilerVariable<RawInstanceMethod*>* var, ArgPassSpec argspec, ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
const std::vector<CompilerVariable*>& args, const std::vector<const std::string*>* keyword_names) override {
const std::vector<const std::string*>* keyword_names) {
std::vector<CompilerVariable*> new_args; std::vector<CompilerVariable*> new_args;
new_args.push_back(var->getValue()->obj); new_args.push_back(var->getValue()->obj);
new_args.insert(new_args.end(), args.begin(), args.end()); new_args.insert(new_args.end(), args.begin(), args.end());
...@@ -126,10 +125,10 @@ public: ...@@ -126,10 +125,10 @@ public:
return var->getValue()->func->call(emitter, info, new_argspec, new_args, keyword_names); return var->getValue()->func->call(emitter, info, new_argspec, new_args, keyword_names);
} }
virtual bool canConvertTo(ConcreteCompilerType* other_type) { return other_type == UNKNOWN; } bool canConvertTo(ConcreteCompilerType* other_type) override { return other_type == UNKNOWN; }
virtual ConcreteCompilerType* getConcreteType() { return typeFromClass(instancemethod_cls); } ConcreteCompilerType* getConcreteType() override { return typeFromClass(instancemethod_cls); }
virtual ConcreteCompilerType* getBoxType() { return getConcreteType(); } ConcreteCompilerType* getBoxType() override { return getConcreteType(); }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) { ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) override {
checkVar(var); checkVar(var);
assert(other_type == UNKNOWN || other_type == typeFromClass(instancemethod_cls)); assert(other_type == UNKNOWN || other_type == typeFromClass(instancemethod_cls));
...@@ -147,7 +146,7 @@ public: ...@@ -147,7 +146,7 @@ public:
return new ConcreteCompilerVariable(other_type, boxed, true); return new ConcreteCompilerVariable(other_type, boxed, true);
} }
virtual CompilerVariable* dup(VAR* var, DupCache& cache) { CompilerVariable* dup(VAR* var, DupCache& cache) override {
checkVar(var); checkVar(var);
CompilerVariable* rtn = cache[var]; CompilerVariable* rtn = cache[var];
...@@ -196,28 +195,28 @@ CompilerVariable* ConcreteCompilerType::dup(ConcreteCompilerVariable* v, DupCach ...@@ -196,28 +195,28 @@ CompilerVariable* ConcreteCompilerType::dup(ConcreteCompilerVariable* v, DupCach
class UnknownType : public ConcreteCompilerType { class UnknownType : public ConcreteCompilerType {
public: public:
llvm::Type* llvmType() { return g.llvm_value_type_ptr; } llvm::Type* llvmType() override { return g.llvm_value_type_ptr; }
virtual std::string debugName() { return "AnyBox"; } std::string debugName() override { return "AnyBox"; }
virtual void drop(IREmitter& emitter, VAR* var) { emitter.getGC()->dropPointer(emitter, var->getValue()); } void drop(IREmitter& emitter, VAR* var) override { emitter.getGC()->dropPointer(emitter, var->getValue()); }
virtual void grab(IREmitter& emitter, VAR* var) { emitter.getGC()->grabPointer(emitter, var->getValue()); } void grab(IREmitter& emitter, VAR* var) override { emitter.getGC()->grabPointer(emitter, var->getValue()); }
virtual bool isFitBy(BoxedClass* c) { return true; } bool isFitBy(BoxedClass* c) override { return true; }
virtual CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool cls_only); const std::string* attr, bool cls_only) override;
virtual CompilerVariable* call(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* call(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, ArgPassSpec argspec,
ArgPassSpec argspec, const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names); const std::vector<const std::string*>* keyword_names) override;
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool clsonly, ArgPassSpec argspec, const std::string* attr, bool clsonly, ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names); const std::vector<const std::string*>* keyword_names) override;
virtual ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var); ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) override;
void setattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, const std::string* attr, void setattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, const std::string* attr,
CompilerVariable* v) { CompilerVariable* v) override {
llvm::Constant* ptr = getStringConstantPtr(*attr + '\0'); llvm::Constant* ptr = getStringConstantPtr(*attr + '\0');
ConcreteCompilerVariable* converted = v->makeConverted(emitter, UNKNOWN); ConcreteCompilerVariable* converted = v->makeConverted(emitter, UNKNOWN);
// g.funcs.setattr->dump(); // g.funcs.setattr->dump();
...@@ -240,7 +239,8 @@ public: ...@@ -240,7 +239,8 @@ public:
converted->decvref(emitter); converted->decvref(emitter);
} }
void delattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, const std::string* attr) { void delattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr) override {
llvm::Constant* ptr = getStringConstantPtr(*attr + '\0'); llvm::Constant* ptr = getStringConstantPtr(*attr + '\0');
// TODO // TODO
...@@ -260,7 +260,7 @@ public: ...@@ -260,7 +260,7 @@ public:
} }
} }
virtual llvm::Value* makeClassCheck(IREmitter& emitter, ConcreteCompilerVariable* var, BoxedClass* cls) { llvm::Value* makeClassCheck(IREmitter& emitter, ConcreteCompilerVariable* var, BoxedClass* cls) override {
assert(var->getValue()->getType() == g.llvm_value_type_ptr); assert(var->getValue()->getType() == g.llvm_value_type_ptr);
static_assert(offsetof(Box, cls) % sizeof(void*) == 0, ""); static_assert(offsetof(Box, cls) % sizeof(void*) == 0, "");
...@@ -273,15 +273,15 @@ public: ...@@ -273,15 +273,15 @@ public:
return rtn; return rtn;
} }
virtual CompilerType* getattrType(const std::string* attr, bool cls_only) { return UNKNOWN; } CompilerType* getattrType(const std::string* attr, bool cls_only) override { return UNKNOWN; }
virtual CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types, CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
return UNKNOWN; return UNKNOWN;
} }
virtual BoxedClass* guaranteedClass() { return NULL; } BoxedClass* guaranteedClass() override { return NULL; }
virtual ConcreteCompilerType* getBoxType() { return this; } ConcreteCompilerType* getBoxType() override { return this; }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var, ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var,
ConcreteCompilerType* other_type) { ConcreteCompilerType* other_type) override {
if (other_type == this) { if (other_type == this) {
var->incvref(); var->incvref();
return var; return var;
...@@ -290,7 +290,7 @@ public: ...@@ -290,7 +290,7 @@ public:
abort(); abort();
} }
virtual ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) { ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) override {
bool do_patchpoint = ENABLE_ICGENERICS && !info.isInterpreted(); bool do_patchpoint = ENABLE_ICGENERICS && !info.isInterpreted();
llvm::Value* rtn; llvm::Value* rtn;
if (do_patchpoint) { if (do_patchpoint) {
...@@ -307,8 +307,8 @@ public: ...@@ -307,8 +307,8 @@ public:
return new ConcreteCompilerVariable(INT, rtn, true); return new ConcreteCompilerVariable(INT, rtn, true);
} }
virtual CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
CompilerVariable* slice) { CompilerVariable* slice) override {
ConcreteCompilerVariable* converted_slice = slice->makeConverted(emitter, slice->getBoxType()); ConcreteCompilerVariable* converted_slice = slice->makeConverted(emitter, slice->getBoxType());
bool do_patchpoint = ENABLE_ICGETITEMS && !info.isInterpreted(); bool do_patchpoint = ENABLE_ICGETITEMS && !info.isInterpreted();
...@@ -664,18 +664,18 @@ private: ...@@ -664,18 +664,18 @@ private:
AbstractFunctionType(const std::vector<Sig*>& sigs) : sigs(sigs) {} AbstractFunctionType(const std::vector<Sig*>& sigs) : sigs(sigs) {}
public: public:
virtual std::string debugName() { return "<AbstractFunctionType>"; } std::string debugName() override { return "<AbstractFunctionType>"; }
virtual ConcreteCompilerType* getConcreteType() { return UNKNOWN; } ConcreteCompilerType* getConcreteType() override { return UNKNOWN; }
virtual ConcreteCompilerType* getBoxType() { return UNKNOWN; } ConcreteCompilerType* getBoxType() override { return UNKNOWN; }
virtual bool canConvertTo(ConcreteCompilerType* other_type) { return other_type == UNKNOWN; } bool canConvertTo(ConcreteCompilerType* other_type) override { return other_type == UNKNOWN; }
virtual CompilerType* getattrType(const std::string* attr, bool cls_only) { return UNDEF; } CompilerType* getattrType(const std::string* attr, bool cls_only) override { return UNDEF; }
virtual CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types, CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
RELEASE_ASSERT(!argspec.has_starargs, ""); RELEASE_ASSERT(!argspec.has_starargs, "");
RELEASE_ASSERT(!argspec.has_kwargs, ""); RELEASE_ASSERT(!argspec.has_kwargs, "");
RELEASE_ASSERT(argspec.num_keywords == 0, ""); RELEASE_ASSERT(argspec.num_keywords == 0, "");
...@@ -701,7 +701,7 @@ public: ...@@ -701,7 +701,7 @@ public:
return UNDEF; return UNDEF;
} }
virtual BoxedClass* guaranteedClass() { return NULL; } BoxedClass* guaranteedClass() override { return NULL; }
static CompilerType* fromRT(BoxedFunction* rtfunc, bool stripfirst) { static CompilerType* fromRT(BoxedFunction* rtfunc, bool stripfirst) {
std::vector<Sig*> sigs; std::vector<Sig*> sigs;
...@@ -742,18 +742,18 @@ class IntType : public ConcreteCompilerType { ...@@ -742,18 +742,18 @@ class IntType : public ConcreteCompilerType {
public: public:
IntType() {} IntType() {}
llvm::Type* llvmType() { return g.i64; } llvm::Type* llvmType() override { return g.i64; }
virtual bool isFitBy(BoxedClass* c) { return false; } bool isFitBy(BoxedClass* c) override { return false; }
virtual void drop(IREmitter& emitter, ConcreteCompilerVariable* var) { void drop(IREmitter& emitter, ConcreteCompilerVariable* var) override {
// pass // pass
} }
virtual void grab(IREmitter& emitter, ConcreteCompilerVariable* var) { void grab(IREmitter& emitter, ConcreteCompilerVariable* var) override {
// pass // pass
} }
virtual CompilerType* getattrType(const std::string* attr, bool cls_only) { CompilerType* getattrType(const std::string* attr, bool cls_only) override {
/* /*
static std::vector<AbstractFunctionType::Sig*> sigs; static std::vector<AbstractFunctionType::Sig*> sigs;
if (sigs.size() == 0) { if (sigs.size() == 0) {
...@@ -784,39 +784,39 @@ public: ...@@ -784,39 +784,39 @@ public:
return BOXED_INT->getattrType(attr, cls_only); return BOXED_INT->getattrType(attr, cls_only);
} }
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool clsonly, ArgPassSpec argspec, const std::string* attr, bool clsonly, ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_INT); ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_INT);
CompilerVariable* rtn = converted->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names); CompilerVariable* rtn = converted->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names);
converted->decvref(emitter); converted->decvref(emitter);
return rtn; return rtn;
} }
virtual CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool cls_only) { const std::string* attr, bool cls_only) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_INT); ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_INT);
CompilerVariable* rtn = converted->getattr(emitter, info, attr, cls_only); CompilerVariable* rtn = converted->getattr(emitter, info, attr, cls_only);
converted->decvref(emitter); converted->decvref(emitter);
return rtn; return rtn;
} }
virtual void setattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, void setattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr,
CompilerVariable* v) { CompilerVariable* v) override {
llvm::CallSite call = emitter.createCall2(info.exc_info, g.funcs.raiseAttributeErrorStr, llvm::CallSite call = emitter.createCall2(info.exc_info, g.funcs.raiseAttributeErrorStr,
getStringConstantPtr("int\0"), getStringConstantPtr(*attr + '\0')); getStringConstantPtr("int\0"), getStringConstantPtr(*attr + '\0'));
call.setDoesNotReturn(); call.setDoesNotReturn();
} }
virtual void delattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr) { void delattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr) override {
llvm::CallSite call = emitter.createCall2(info.exc_info, g.funcs.raiseAttributeErrorStr, llvm::CallSite call = emitter.createCall2(info.exc_info, g.funcs.raiseAttributeErrorStr,
getStringConstantPtr("int\0"), getStringConstantPtr(*attr + '\0')); getStringConstantPtr("int\0"), getStringConstantPtr(*attr + '\0'));
call.setDoesNotReturn(); call.setDoesNotReturn();
} }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var, ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var,
ConcreteCompilerType* other_type) { ConcreteCompilerType* other_type) override {
if (other_type == this) { if (other_type == this) {
var->incvref(); var->incvref();
return var; return var;
...@@ -829,21 +829,21 @@ public: ...@@ -829,21 +829,21 @@ public:
} }
} }
virtual CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, VAR* var, CompilerVariable* slice) { CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, VAR* var, CompilerVariable* slice) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_INT); ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_INT);
CompilerVariable* rtn = converted->getitem(emitter, info, slice); CompilerVariable* rtn = converted->getitem(emitter, info, slice);
converted->decvref(emitter); converted->decvref(emitter);
return rtn; return rtn;
} }
virtual ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) { ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) override {
llvm::CallSite call llvm::CallSite call
= emitter.createCall(info.exc_info, g.funcs.raiseNotIterableError, getStringConstantPtr("int")); = emitter.createCall(info.exc_info, g.funcs.raiseNotIterableError, getStringConstantPtr("int"));
call.setDoesNotReturn(); call.setDoesNotReturn();
return new ConcreteCompilerVariable(INT, llvm::UndefValue::get(g.i64), true); return new ConcreteCompilerVariable(INT, llvm::UndefValue::get(g.i64), true);
} }
virtual ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) { ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) override {
llvm::Value* cmp = emitter.getBuilder()->CreateICmpNE(var->getValue(), llvm::ConstantInt::get(g.i64, 0, false)); llvm::Value* cmp = emitter.getBuilder()->CreateICmpNE(var->getValue(), llvm::ConstantInt::get(g.i64, 0, false));
return boolFromI1(emitter, cmp); return boolFromI1(emitter, cmp);
} }
...@@ -941,7 +941,7 @@ public: ...@@ -941,7 +941,7 @@ public:
} }
} }
virtual ConcreteCompilerType* getBoxType() { return BOXED_INT; } ConcreteCompilerType* getBoxType() override { return BOXED_INT; }
Box* deserializeFromFrame(const FrameVals& vals) override { Box* deserializeFromFrame(const FrameVals& vals) override {
assert(vals.size() == 1); assert(vals.size() == 1);
...@@ -959,18 +959,18 @@ class FloatType : public ConcreteCompilerType { ...@@ -959,18 +959,18 @@ class FloatType : public ConcreteCompilerType {
public: public:
FloatType() {} FloatType() {}
llvm::Type* llvmType() { return g.double_; } llvm::Type* llvmType() override { return g.double_; }
virtual bool isFitBy(BoxedClass* c) { return false; } bool isFitBy(BoxedClass* c) override { return false; }
virtual void drop(IREmitter& emitter, ConcreteCompilerVariable* var) { void drop(IREmitter& emitter, ConcreteCompilerVariable* var) override {
// pass // pass
} }
virtual void grab(IREmitter& emitter, ConcreteCompilerVariable* var) { void grab(IREmitter& emitter, ConcreteCompilerVariable* var) override {
// pass // pass
} }
virtual CompilerType* getattrType(const std::string* attr, bool cls_only) { CompilerType* getattrType(const std::string* attr, bool cls_only) override {
static std::vector<AbstractFunctionType::Sig*> sigs; static std::vector<AbstractFunctionType::Sig*> sigs;
if (sigs.size() == 0) { if (sigs.size() == 0) {
AbstractFunctionType::Sig* float_sig = new AbstractFunctionType::Sig(); AbstractFunctionType::Sig* float_sig = new AbstractFunctionType::Sig();
...@@ -1002,39 +1002,39 @@ public: ...@@ -1002,39 +1002,39 @@ public:
return BOXED_FLOAT->getattrType(attr, cls_only); return BOXED_FLOAT->getattrType(attr, cls_only);
} }
virtual CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool cls_only) { const std::string* attr, bool cls_only) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_FLOAT); ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_FLOAT);
CompilerVariable* rtn = converted->getattr(emitter, info, attr, cls_only); CompilerVariable* rtn = converted->getattr(emitter, info, attr, cls_only);
converted->decvref(emitter); converted->decvref(emitter);
return rtn; return rtn;
} }
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool clsonly, ArgPassSpec argspec, const std::string* attr, bool clsonly, ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_FLOAT); ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_FLOAT);
CompilerVariable* rtn = converted->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names); CompilerVariable* rtn = converted->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names);
converted->decvref(emitter); converted->decvref(emitter);
return rtn; return rtn;
} }
virtual void setattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, void setattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr,
CompilerVariable* v) { CompilerVariable* v) override {
llvm::CallSite call = emitter.createCall2(info.exc_info, g.funcs.raiseAttributeErrorStr, llvm::CallSite call = emitter.createCall2(info.exc_info, g.funcs.raiseAttributeErrorStr,
getStringConstantPtr("float\0"), getStringConstantPtr(*attr + '\0')); getStringConstantPtr("float\0"), getStringConstantPtr(*attr + '\0'));
call.setDoesNotReturn(); call.setDoesNotReturn();
} }
virtual void delattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr) { void delattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr) override {
llvm::CallSite call = emitter.createCall2(info.exc_info, g.funcs.raiseAttributeErrorStr, llvm::CallSite call = emitter.createCall2(info.exc_info, g.funcs.raiseAttributeErrorStr,
getStringConstantPtr("float\0"), getStringConstantPtr(*attr + '\0')); getStringConstantPtr("float\0"), getStringConstantPtr(*attr + '\0'));
call.setDoesNotReturn(); call.setDoesNotReturn();
} }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var, ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var,
ConcreteCompilerType* other_type) { ConcreteCompilerType* other_type) override {
if (other_type == this) { if (other_type == this) {
var->incvref(); var->incvref();
return var; return var;
...@@ -1047,7 +1047,7 @@ public: ...@@ -1047,7 +1047,7 @@ public:
} }
} }
virtual ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) { ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) override {
llvm::Value* cmp = emitter.getBuilder()->CreateFCmpUNE(var->getValue(), llvm::ConstantFP::get(g.double_, 0)); llvm::Value* cmp = emitter.getBuilder()->CreateFCmpUNE(var->getValue(), llvm::ConstantFP::get(g.double_, 0));
return boolFromI1(emitter, cmp); return boolFromI1(emitter, cmp);
} }
...@@ -1161,7 +1161,7 @@ public: ...@@ -1161,7 +1161,7 @@ public:
return rtn; return rtn;
} }
virtual ConcreteCompilerType* getBoxType() { return BOXED_FLOAT; } ConcreteCompilerType* getBoxType() override { return BOXED_FLOAT; }
Box* deserializeFromFrame(const FrameVals& vals) override { Box* deserializeFromFrame(const FrameVals& vals) override {
assert(vals.size() == 1); assert(vals.size() == 1);
...@@ -1196,7 +1196,7 @@ private: ...@@ -1196,7 +1196,7 @@ private:
KnownClassobjType(BoxedClass* cls) : cls(cls) { assert(cls); } KnownClassobjType(BoxedClass* cls) : cls(cls) { assert(cls); }
public: public:
virtual std::string debugName() { return "class '" + *getNameOfClass(cls) + "'"; } std::string debugName() override { return "class '" + *getNameOfClass(cls) + "'"; }
void assertMatches(BoxedClass* cls) override { assert(cls == this->cls); } void assertMatches(BoxedClass* cls) override { assert(cls == this->cls); }
...@@ -1208,8 +1208,8 @@ public: ...@@ -1208,8 +1208,8 @@ public:
return rtn; return rtn;
} }
virtual CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types, CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
RELEASE_ASSERT(!argspec.has_starargs, ""); RELEASE_ASSERT(!argspec.has_starargs, "");
RELEASE_ASSERT(!argspec.has_kwargs, ""); RELEASE_ASSERT(!argspec.has_kwargs, "");
RELEASE_ASSERT(argspec.num_keywords == 0, ""); RELEASE_ASSERT(argspec.num_keywords == 0, "");
...@@ -1248,15 +1248,15 @@ private: ...@@ -1248,15 +1248,15 @@ private:
} }
public: public:
llvm::Type* llvmType() { return g.llvm_value_type_ptr; } llvm::Type* llvmType() override { return g.llvm_value_type_ptr; }
std::string debugName() { std::string debugName() override {
assert(cls); assert(cls);
// TODO add getTypeName // TODO add getTypeName
return "NormalType(" + *getNameOfClass(cls) + ")"; return "NormalType(" + *getNameOfClass(cls) + ")";
} }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var, ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var,
ConcreteCompilerType* other_type) { ConcreteCompilerType* other_type) override {
if (other_type == this) { if (other_type == this) {
var->incvref(); var->incvref();
return var; return var;
...@@ -1266,12 +1266,12 @@ public: ...@@ -1266,12 +1266,12 @@ public:
// return (new ConcreteCompilerVariable(UNKNOWN, var->getValue(), false))->split(emitter); // return (new ConcreteCompilerVariable(UNKNOWN, var->getValue(), false))->split(emitter);
} }
virtual void drop(IREmitter& emitter, VAR* var) { emitter.getGC()->dropPointer(emitter, var->getValue()); } void drop(IREmitter& emitter, VAR* var) override { emitter.getGC()->dropPointer(emitter, var->getValue()); }
virtual void grab(IREmitter& emitter, VAR* var) { emitter.getGC()->grabPointer(emitter, var->getValue()); } void grab(IREmitter& emitter, VAR* var) override { emitter.getGC()->grabPointer(emitter, var->getValue()); }
virtual bool isFitBy(BoxedClass* c) { return c == cls; } bool isFitBy(BoxedClass* c) override { return c == cls; }
virtual CompilerType* getattrType(const std::string* attr, bool cls_only) { CompilerType* getattrType(const std::string* attr, bool cls_only) override {
if (cls->is_constant && !cls->instancesHaveAttrs() && cls->hasGenericGetattr()) { if (cls->is_constant && !cls->instancesHaveAttrs() && cls->hasGenericGetattr()) {
Box* rtattr = cls->getattr(*attr); Box* rtattr = cls->getattr(*attr);
if (rtattr == NULL) if (rtattr == NULL)
...@@ -1289,13 +1289,13 @@ public: ...@@ -1289,13 +1289,13 @@ public:
return UNKNOWN; return UNKNOWN;
} }
virtual CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types, CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
return UNKNOWN; return UNKNOWN;
} }
CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool cls_only) { const std::string* attr, bool cls_only) override {
// printf("%s.getattr %s\n", debugName().c_str(), attr->c_str()); // printf("%s.getattr %s\n", debugName().c_str(), attr->c_str());
if (cls->is_constant && !cls->instancesHaveAttrs() && cls->hasGenericGetattr()) { if (cls->is_constant && !cls->instancesHaveAttrs() && cls->hasGenericGetattr()) {
Box* rtattr = cls->getattr(*attr); Box* rtattr = cls->getattr(*attr);
...@@ -1320,17 +1320,18 @@ public: ...@@ -1320,17 +1320,18 @@ public:
} }
void setattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, const std::string* attr, void setattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, const std::string* attr,
CompilerVariable* v) { CompilerVariable* v) override {
return UNKNOWN->setattr(emitter, info, var, attr, v); return UNKNOWN->setattr(emitter, info, var, attr, v);
} }
void delattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, const std::string* attr) { void delattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr) override {
return UNKNOWN->delattr(emitter, info, var, attr); return UNKNOWN->delattr(emitter, info, var, attr);
} }
virtual CompilerVariable* call(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* call(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, ArgPassSpec argspec,
ArgPassSpec argspec, const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, UNKNOWN); ConcreteCompilerVariable* converted = var->makeConverted(emitter, UNKNOWN);
CompilerVariable* rtn = converted->call(emitter, info, argspec, args, keyword_names); CompilerVariable* rtn = converted->call(emitter, info, argspec, args, keyword_names);
converted->decvref(emitter); converted->decvref(emitter);
...@@ -1456,10 +1457,10 @@ public: ...@@ -1456,10 +1457,10 @@ public:
return rtn; return rtn;
} }
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool clsonly, ArgPassSpec argspec, const std::string* attr, bool clsonly, ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
ConcreteCompilerVariable* called_constant ConcreteCompilerVariable* called_constant
= tryCallattrConstant(emitter, info, var, attr, clsonly, argspec, args, keyword_names); = tryCallattrConstant(emitter, info, var, attr, clsonly, argspec, args, keyword_names);
if (called_constant) if (called_constant)
...@@ -1498,7 +1499,7 @@ public: ...@@ -1498,7 +1499,7 @@ public:
return rtn; return rtn;
} }
virtual CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, VAR* var, CompilerVariable* slice) { CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, VAR* var, CompilerVariable* slice) override {
static const std::string attr("__getitem__"); static const std::string attr("__getitem__");
ConcreteCompilerVariable* called_constant ConcreteCompilerVariable* called_constant
= tryCallattrConstant(emitter, info, var, &attr, true, ArgPassSpec(1, 0, 0, 0), { slice }, NULL, false); = tryCallattrConstant(emitter, info, var, &attr, true, ArgPassSpec(1, 0, 0, 0), { slice }, NULL, false);
...@@ -1508,7 +1509,7 @@ public: ...@@ -1508,7 +1509,7 @@ public:
return UNKNOWN->getitem(emitter, info, var, slice); return UNKNOWN->getitem(emitter, info, var, slice);
} }
virtual ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) { ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) override {
static const std::string attr("__len__"); static const std::string attr("__len__");
ConcreteCompilerVariable* called_constant ConcreteCompilerVariable* called_constant
= tryCallattrConstant(emitter, info, var, &attr, true, ArgPassSpec(0, 0, 0, 0), {}, NULL); = tryCallattrConstant(emitter, info, var, &attr, true, ArgPassSpec(0, 0, 0, 0), {}, NULL);
...@@ -1518,7 +1519,7 @@ public: ...@@ -1518,7 +1519,7 @@ public:
return UNKNOWN->len(emitter, info, var); return UNKNOWN->len(emitter, info, var);
} }
virtual ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) { ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) override {
static const std::string attr("__nonzero__"); static const std::string attr("__nonzero__");
ConcreteCompilerVariable* called_constant ConcreteCompilerVariable* called_constant
= tryCallattrConstant(emitter, info, var, &attr, true, ArgPassSpec(0, 0, 0, 0), {}, NULL); = tryCallattrConstant(emitter, info, var, &attr, true, ArgPassSpec(0, 0, 0, 0), {}, NULL);
...@@ -1543,9 +1544,9 @@ public: ...@@ -1543,9 +1544,9 @@ public:
return rtn; return rtn;
} }
virtual BoxedClass* guaranteedClass() { return cls; } BoxedClass* guaranteedClass() override { return cls; }
virtual ConcreteCompilerType* getBoxType() { return this; } ConcreteCompilerType* getBoxType() override { return this; }
Box* deserializeFromFrame(const FrameVals& vals) override { Box* deserializeFromFrame(const FrameVals& vals) override {
assert(vals.size() == 1); assert(vals.size() == 1);
...@@ -1557,24 +1558,24 @@ ConcreteCompilerType* STR, *BOXED_INT, *BOXED_FLOAT, *BOXED_BOOL, *NONE; ...@@ -1557,24 +1558,24 @@ ConcreteCompilerType* STR, *BOXED_INT, *BOXED_FLOAT, *BOXED_BOOL, *NONE;
class ClosureType : public ConcreteCompilerType { class ClosureType : public ConcreteCompilerType {
public: public:
llvm::Type* llvmType() { return g.llvm_closure_type_ptr; } llvm::Type* llvmType() override { return g.llvm_closure_type_ptr; }
std::string debugName() { return "closure"; } std::string debugName() override { return "closure"; }
CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool cls_only) { const std::string* attr, bool cls_only) override {
assert(!cls_only); assert(!cls_only);
llvm::Value* bitcast = emitter.getBuilder()->CreateBitCast(var->getValue(), g.llvm_value_type_ptr); llvm::Value* bitcast = emitter.getBuilder()->CreateBitCast(var->getValue(), g.llvm_value_type_ptr);
return ConcreteCompilerVariable(UNKNOWN, bitcast, true).getattr(emitter, info, attr, cls_only); return ConcreteCompilerVariable(UNKNOWN, bitcast, true).getattr(emitter, info, attr, cls_only);
} }
void setattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, const std::string* attr, void setattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, const std::string* attr,
CompilerVariable* v) { CompilerVariable* v) override {
llvm::Value* bitcast = emitter.getBuilder()->CreateBitCast(var->getValue(), g.llvm_value_type_ptr); llvm::Value* bitcast = emitter.getBuilder()->CreateBitCast(var->getValue(), g.llvm_value_type_ptr);
ConcreteCompilerVariable(UNKNOWN, bitcast, true).setattr(emitter, info, attr, v); ConcreteCompilerVariable(UNKNOWN, bitcast, true).setattr(emitter, info, attr, v);
} }
virtual ConcreteCompilerType* getConcreteType() { return this; } ConcreteCompilerType* getConcreteType() override { return this; }
virtual ConcreteCompilerType* getBoxType() { return this; } ConcreteCompilerType* getBoxType() override { return this; }
void drop(IREmitter& emitter, VAR* var) override {} void drop(IREmitter& emitter, VAR* var) override {}
void grab(IREmitter& emitter, VAR* var) override {} void grab(IREmitter& emitter, VAR* var) override {}
...@@ -1588,16 +1589,16 @@ ConcreteCompilerType* CLOSURE = &_CLOSURE; ...@@ -1588,16 +1589,16 @@ ConcreteCompilerType* CLOSURE = &_CLOSURE;
class GeneratorType : public ConcreteCompilerType { class GeneratorType : public ConcreteCompilerType {
public: public:
llvm::Type* llvmType() { return g.llvm_generator_type_ptr; } llvm::Type* llvmType() override { return g.llvm_generator_type_ptr; }
std::string debugName() { return "generator"; } std::string debugName() override { return "generator"; }
virtual ConcreteCompilerType* getConcreteType() { return this; } ConcreteCompilerType* getConcreteType() override { return this; }
virtual ConcreteCompilerType* getBoxType() { return GENERATOR; } ConcreteCompilerType* getBoxType() override { return GENERATOR; }
virtual void drop(IREmitter& emitter, VAR* var) { void drop(IREmitter& emitter, VAR* var) override {
// pass // pass
} }
virtual void grab(IREmitter& emitter, VAR* var) { void grab(IREmitter& emitter, VAR* var) override {
// pass // pass
} }
...@@ -1610,49 +1611,49 @@ ConcreteCompilerType* GENERATOR = &_GENERATOR; ...@@ -1610,49 +1611,49 @@ ConcreteCompilerType* GENERATOR = &_GENERATOR;
class StrConstantType : public ValuedCompilerType<const std::string*> { class StrConstantType : public ValuedCompilerType<const std::string*> {
public: public:
std::string debugName() { return "str_constant"; } std::string debugName() override { return "str_constant"; }
void assertMatches(const std::string* v) override {} void assertMatches(const std::string* v) override {}
virtual ConcreteCompilerType* getConcreteType() { return STR; } ConcreteCompilerType* getConcreteType() override { return STR; }
virtual ConcreteCompilerType* getBoxType() { return STR; } ConcreteCompilerType* getBoxType() override { return STR; }
virtual void drop(IREmitter& emitter, VAR* var) { void drop(IREmitter& emitter, VAR* var) override {
// pass // pass
} }
virtual void grab(IREmitter& emitter, VAR* var) { void grab(IREmitter& emitter, VAR* var) override {
// pass // pass
} }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) { ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) override {
assert(other_type == STR || other_type == UNKNOWN); assert(other_type == STR || other_type == UNKNOWN);
llvm::Value* boxed = emitter.getBuilder()->CreateCall(g.funcs.boxStringPtr, llvm::Value* boxed = emitter.getBuilder()->CreateCall(g.funcs.boxStringPtr,
embedConstantPtr(var->getValue(), g.llvm_str_type_ptr)); embedConstantPtr(var->getValue(), g.llvm_str_type_ptr));
return new ConcreteCompilerVariable(other_type, boxed, true); return new ConcreteCompilerVariable(other_type, boxed, true);
} }
virtual bool canConvertTo(ConcreteCompilerType* other) { return (other == STR || other == UNKNOWN); } bool canConvertTo(ConcreteCompilerType* other) override { return (other == STR || other == UNKNOWN); }
virtual CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr,
bool cls_only) { bool cls_only) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, STR); ConcreteCompilerVariable* converted = var->makeConverted(emitter, STR);
CompilerVariable* rtn = converted->getattr(emitter, info, attr, cls_only); CompilerVariable* rtn = converted->getattr(emitter, info, attr, cls_only);
converted->decvref(emitter); converted->decvref(emitter);
return rtn; return rtn;
} }
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, bool clsonly,
bool clsonly, ArgPassSpec argspec, const std::vector<CompilerVariable*>& args, ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, STR); ConcreteCompilerVariable* converted = var->makeConverted(emitter, STR);
CompilerVariable* rtn = converted->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names); CompilerVariable* rtn = converted->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names);
converted->decvref(emitter); converted->decvref(emitter);
return rtn; return rtn;
} }
virtual CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, VAR* var, CompilerVariable* slice) { CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, VAR* var, CompilerVariable* slice) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, STR); ConcreteCompilerVariable* converted = var->makeConverted(emitter, STR);
CompilerVariable* rtn = converted->getitem(emitter, info, slice); CompilerVariable* rtn = converted->getitem(emitter, info, slice);
converted->decvref(emitter); converted->decvref(emitter);
...@@ -1671,7 +1672,7 @@ public: ...@@ -1671,7 +1672,7 @@ public:
return makeBool(var->getValue()->size() != 0); return makeBool(var->getValue()->size() != 0);
} }
virtual CompilerVariable* dup(VAR* var, DupCache& cache) { CompilerVariable* dup(VAR* var, DupCache& cache) override {
CompilerVariable*& rtn = cache[var]; CompilerVariable*& rtn = cache[var];
if (rtn == NULL) { if (rtn == NULL) {
...@@ -1702,7 +1703,7 @@ CompilerVariable* makeStr(const std::string* s) { ...@@ -1702,7 +1703,7 @@ CompilerVariable* makeStr(const std::string* s) {
class VoidType : public ConcreteCompilerType { class VoidType : public ConcreteCompilerType {
public: public:
llvm::Type* llvmType() { return g.void_; } llvm::Type* llvmType() override { return g.void_; }
Box* deserializeFromFrame(const FrameVals& vals) override { abort(); } Box* deserializeFromFrame(const FrameVals& vals) override { abort(); }
}; };
...@@ -1715,24 +1716,24 @@ ConcreteCompilerType* typeFromClass(BoxedClass* c) { ...@@ -1715,24 +1716,24 @@ ConcreteCompilerType* typeFromClass(BoxedClass* c) {
class BoolType : public ConcreteCompilerType { class BoolType : public ConcreteCompilerType {
public: public:
std::string debugName() { return "bool"; } std::string debugName() override { return "bool"; }
llvm::Type* llvmType() { llvm::Type* llvmType() override {
if (BOOLS_AS_I64) if (BOOLS_AS_I64)
return g.i64; return g.i64;
else else
return g.i1; return g.i1;
} }
virtual bool isFitBy(BoxedClass* c) { return false; } bool isFitBy(BoxedClass* c) override { return false; }
virtual void drop(IREmitter& emitter, VAR* var) { void drop(IREmitter& emitter, VAR* var) override {
// pass // pass
} }
virtual void grab(IREmitter& emitter, VAR* var) { void grab(IREmitter& emitter, VAR* var) override {
// pass // pass
} }
virtual ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) { ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) override {
var->incvref(); var->incvref();
return var; return var;
} }
...@@ -1741,8 +1742,8 @@ public: ...@@ -1741,8 +1742,8 @@ public:
return (other_type == UNKNOWN || other_type == BOXED_BOOL || other_type == BOOL); return (other_type == UNKNOWN || other_type == BOXED_BOOL || other_type == BOOL);
} }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var, ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var,
ConcreteCompilerType* other_type) { ConcreteCompilerType* other_type) override {
if (other_type == BOOL) { if (other_type == BOOL) {
var->incvref(); var->incvref();
return var; return var;
...@@ -1753,22 +1754,22 @@ public: ...@@ -1753,22 +1754,22 @@ public:
return new ConcreteCompilerVariable(other_type, boxed, true); return new ConcreteCompilerVariable(other_type, boxed, true);
} }
virtual CompilerType* getattrType(const std::string* attr, bool cls_only) { CompilerType* getattrType(const std::string* attr, bool cls_only) override {
return BOXED_BOOL->getattrType(attr, cls_only); return BOXED_BOOL->getattrType(attr, cls_only);
} }
virtual CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr,
bool cls_only) { bool cls_only) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_BOOL); ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_BOOL);
CompilerVariable* rtn = converted->getattr(emitter, info, attr, cls_only); CompilerVariable* rtn = converted->getattr(emitter, info, attr, cls_only);
converted->decvref(emitter); converted->decvref(emitter);
return rtn; return rtn;
} }
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
const std::string* attr, bool clsonly, ArgPassSpec argspec, const std::string* attr, bool clsonly, ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_BOOL); ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_BOOL);
CompilerVariable* rtn = converted->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names); CompilerVariable* rtn = converted->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names);
converted->decvref(emitter); converted->decvref(emitter);
...@@ -1783,7 +1784,7 @@ public: ...@@ -1783,7 +1784,7 @@ public:
return rtn; return rtn;
} }
virtual ConcreteCompilerType* getBoxType() { return BOXED_BOOL; } ConcreteCompilerType* getBoxType() override { return BOXED_BOOL; }
Box* deserializeFromFrame(const FrameVals& vals) override { Box* deserializeFromFrame(const FrameVals& vals) override {
assert(vals.size() == 1); assert(vals.size() == 1);
...@@ -1826,18 +1827,18 @@ public: ...@@ -1826,18 +1827,18 @@ public:
} }
} }
std::string debugName() { return name; } std::string debugName() override { return name; }
virtual void drop(IREmitter& emitter, VAR* var) { void drop(IREmitter& emitter, VAR* var) override {
const std::vector<CompilerVariable*>* elts = var->getValue(); const std::vector<CompilerVariable*>* elts = var->getValue();
for (int i = 0; i < elts->size(); i++) { for (int i = 0; i < elts->size(); i++) {
(*elts)[i]->decvref(emitter); (*elts)[i]->decvref(emitter);
} }
} }
virtual void grab(IREmitter& emitter, VAR* var) { RELEASE_ASSERT(0, ""); } void grab(IREmitter& emitter, VAR* var) override { RELEASE_ASSERT(0, ""); }
virtual CompilerVariable* dup(VAR* var, DupCache& cache) { CompilerVariable* dup(VAR* var, DupCache& cache) override {
CompilerVariable*& rtn = cache[var]; CompilerVariable*& rtn = cache[var];
if (rtn == NULL) { if (rtn == NULL) {
...@@ -1854,11 +1855,11 @@ public: ...@@ -1854,11 +1855,11 @@ public:
return rtn; return rtn;
} }
virtual bool canConvertTo(ConcreteCompilerType* other_type) { bool canConvertTo(ConcreteCompilerType* other_type) override {
return (other_type == UNKNOWN || other_type == BOXED_TUPLE); return (other_type == UNKNOWN || other_type == BOXED_TUPLE);
} }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) { ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) override {
assert(other_type == UNKNOWN || other_type == BOXED_TUPLE); assert(other_type == UNKNOWN || other_type == BOXED_TUPLE);
VEC* v = var->getValue(); VEC* v = var->getValue();
...@@ -1894,13 +1895,13 @@ public: ...@@ -1894,13 +1895,13 @@ public:
return new ConcreteCompilerVariable(other_type, rtn, true); return new ConcreteCompilerVariable(other_type, rtn, true);
} }
virtual ConcreteCompilerType* getBoxType() { return BOXED_TUPLE; } ConcreteCompilerType* getBoxType() override { return BOXED_TUPLE; }
virtual ConcreteCompilerType* getConcreteType() { return BOXED_TUPLE; } ConcreteCompilerType* getConcreteType() override { return BOXED_TUPLE; }
static TupleType* make(const std::vector<CompilerType*>& elt_types) { return new TupleType(elt_types); } static TupleType* make(const std::vector<CompilerType*>& elt_types) { return new TupleType(elt_types); }
virtual CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, VAR* var, CompilerVariable* slice) { CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, VAR* var, CompilerVariable* slice) override {
if (slice->getType() == INT) { if (slice->getType() == INT) {
llvm::Value* v = static_cast<ConcreteCompilerVariable*>(slice)->getValue(); llvm::Value* v = static_cast<ConcreteCompilerVariable*>(slice)->getValue();
assert(v->getType() == g.i64); assert(v->getType() == g.i64);
...@@ -1923,11 +1924,11 @@ public: ...@@ -1923,11 +1924,11 @@ public:
// return getConstantInt(var->getValue()->size(), g.i64); // return getConstantInt(var->getValue()->size(), g.i64);
} }
virtual ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) { ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) override {
return new ConcreteCompilerVariable(INT, getConstantInt(var->getValue()->size(), g.i64), true); return new ConcreteCompilerVariable(INT, getConstantInt(var->getValue()->size(), g.i64), true);
} }
virtual CompilerType* getattrType(const std::string* attr, bool cls_only) { CompilerType* getattrType(const std::string* attr, bool cls_only) override {
return BOXED_TUPLE->getattrType(attr, cls_only); return BOXED_TUPLE->getattrType(attr, cls_only);
} }
...@@ -1939,9 +1940,9 @@ public: ...@@ -1939,9 +1940,9 @@ public:
return rtn; return rtn;
} }
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, bool clsonly,
bool clsonly, ArgPassSpec argspec, const std::vector<CompilerVariable*>& args, ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
return makeConverted(emitter, var, getConcreteType()) return makeConverted(emitter, var, getConcreteType())
->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names); ->callattr(emitter, info, attr, clsonly, argspec, args, keyword_names);
} }
...@@ -1997,7 +1998,7 @@ CompilerVariable* makeTuple(const std::vector<CompilerVariable*>& elts) { ...@@ -1997,7 +1998,7 @@ CompilerVariable* makeTuple(const std::vector<CompilerVariable*>& elts) {
class UndefType : public ConcreteCompilerType { class UndefType : public ConcreteCompilerType {
public: public:
std::string debugName() { return "undefType"; } std::string debugName() override { return "undefType"; }
llvm::Type* llvmType() override { llvm::Type* llvmType() override {
// Something that no one else uses... // Something that no one else uses...
...@@ -2005,14 +2006,14 @@ public: ...@@ -2005,14 +2006,14 @@ public:
return llvm::Type::getInt16Ty(g.context); return llvm::Type::getInt16Ty(g.context);
} }
virtual CompilerVariable* call(IREmitter& emitter, const OpInfo& info, VAR* var, ArgPassSpec argspec, CompilerVariable* call(IREmitter& emitter, const OpInfo& info, VAR* var, ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
return undefVariable(); return undefVariable();
} }
virtual void drop(IREmitter& emitter, VAR* var) {} void drop(IREmitter& emitter, VAR* var) override {}
virtual void grab(IREmitter& emitter, VAR* var) {} void grab(IREmitter& emitter, VAR* var) override {}
virtual CompilerVariable* dup(VAR* v, DupCache& cache) { CompilerVariable* dup(VAR* v, DupCache& cache) override {
// TODO copied from UnknownType // TODO copied from UnknownType
auto& rtn = cache[v]; auto& rtn = cache[v];
if (rtn == NULL) { if (rtn == NULL) {
...@@ -2022,27 +2023,27 @@ public: ...@@ -2022,27 +2023,27 @@ public:
} }
return rtn; return rtn;
} }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) { ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) override {
llvm::Value* v = llvm::UndefValue::get(other_type->llvmType()); llvm::Value* v = llvm::UndefValue::get(other_type->llvmType());
return new ConcreteCompilerVariable(other_type, v, true); return new ConcreteCompilerVariable(other_type, v, true);
} }
virtual CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr,
bool cls_only) { bool cls_only) override {
return undefVariable(); return undefVariable();
} }
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, const std::string* attr, bool clsonly,
bool clsonly, ArgPassSpec argspec, const std::vector<CompilerVariable*>& args, ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
return undefVariable(); return undefVariable();
} }
virtual CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types, CompilerType* callType(ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
return UNDEF; return UNDEF;
} }
virtual ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, VAR* var) { ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, VAR* var) override {
return new ConcreteCompilerVariable(BOOL, llvm::UndefValue::get(BOOL->llvmType()), true); return new ConcreteCompilerVariable(BOOL, llvm::UndefValue::get(BOOL->llvmType()), true);
} }
...@@ -2051,15 +2052,15 @@ public: ...@@ -2051,15 +2052,15 @@ public:
return undefVariable(); return undefVariable();
} }
virtual ConcreteCompilerType* getBoxType() { return UNKNOWN; } ConcreteCompilerType* getBoxType() override { return UNKNOWN; }
virtual ConcreteCompilerType* getConcreteType() { return this; } ConcreteCompilerType* getConcreteType() override { return this; }
virtual CompilerType* getattrType(const std::string* attr, bool cls_only) { return UNDEF; } CompilerType* getattrType(const std::string* attr, bool cls_only) override { return UNDEF; }
virtual bool canConvertTo(ConcreteCompilerType* other_type) { return true; } bool canConvertTo(ConcreteCompilerType* other_type) override { return true; }
virtual BoxedClass* guaranteedClass() { return NULL; } BoxedClass* guaranteedClass() override { return NULL; }
Box* deserializeFromFrame(const FrameVals& vals) override { Box* deserializeFromFrame(const FrameVals& vals) override {
assert(vals.size() == 1); assert(vals.size() == 1);
......
...@@ -165,9 +165,9 @@ template <class V> class ValuedCompilerType : public _ValuedCompilerType<V> { pu ...@@ -165,9 +165,9 @@ template <class V> class ValuedCompilerType : public _ValuedCompilerType<V> { pu
template <> class ValuedCompilerType<llvm::Value*> : public _ValuedCompilerType<llvm::Value*> { template <> class ValuedCompilerType<llvm::Value*> : public _ValuedCompilerType<llvm::Value*> {
public: public:
virtual llvm::Type* llvmType() = 0; virtual llvm::Type* llvmType() = 0;
virtual std::string debugName(); std::string debugName() override;
void assertMatches(llvm::Value* v) override final { void assertMatches(llvm::Value* v) override {
if (v->getType() != llvmType()) { if (v->getType() != llvmType()) {
v->getType()->dump(); v->getType()->dump();
llvmType()->dump(); llvmType()->dump();
...@@ -181,13 +181,13 @@ public: ...@@ -181,13 +181,13 @@ public:
abort(); abort();
} }
virtual CompilerVariable* dup(ConcreteCompilerVariable* v, DupCache& cache); CompilerVariable* dup(ConcreteCompilerVariable* v, DupCache& cache) override;
virtual ConcreteCompilerType* getConcreteType() { return this; } ConcreteCompilerType* getConcreteType() override { return this; }
virtual bool canConvertTo(ConcreteCompilerType* other_type) { return other_type == this || other_type == UNKNOWN; } bool canConvertTo(ConcreteCompilerType* other_type) override { return other_type == this || other_type == UNKNOWN; }
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var, ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var,
ConcreteCompilerType* other_type); ConcreteCompilerType* other_type) override;
void serializeToFrame(VAR* var, std::vector<llvm::Value*>& stackmap_args) override final; void serializeToFrame(VAR* var, std::vector<llvm::Value*>& stackmap_args) override;
int numFrameArgs() override final { return 1; } int numFrameArgs() override { return 1; }
}; };
class CompilerVariable { class CompilerVariable {
...@@ -273,8 +273,8 @@ private: ...@@ -273,8 +273,8 @@ private:
V value; V value;
protected: protected:
virtual void drop(IREmitter& emitter) { type->drop(emitter, this); } void drop(IREmitter& emitter) override { type->drop(emitter, this); }
virtual void grab(IREmitter& emmitter) { type->grab(emmitter, this); } void grab(IREmitter& emmitter) override { type->grab(emmitter, this); }
public: public:
ValuedCompilerVariable(T* type, V value, bool grabbed) : CompilerVariable(grabbed), type(type), value(value) { ValuedCompilerVariable(T* type, V value, bool grabbed) : CompilerVariable(grabbed), type(type), value(value) {
...@@ -282,8 +282,8 @@ public: ...@@ -282,8 +282,8 @@ public:
type->assertMatches(value); type->assertMatches(value);
#endif #endif
} }
virtual T* getType() { return type; } T* getType() override { return type; }
virtual V getValue() { return value; } V getValue() { return value; }
ConcreteCompilerType* getConcreteType() override { return type->getConcreteType(); } ConcreteCompilerType* getConcreteType() override { return type->getConcreteType(); }
ConcreteCompilerType* getBoxType() override { return type->getBoxType(); } ConcreteCompilerType* getBoxType() override { return type->getBoxType(); }
...@@ -315,20 +315,20 @@ public: ...@@ -315,20 +315,20 @@ public:
ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info) override { ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info) override {
return type->nonzero(emitter, info, this); return type->nonzero(emitter, info, this);
} }
virtual CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, const std::string* attr, bool cls_only) { CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, const std::string* attr, bool cls_only) override {
return type->getattr(emitter, info, this, attr, cls_only); return type->getattr(emitter, info, this, attr, cls_only);
} }
virtual void setattr(IREmitter& emitter, const OpInfo& info, const std::string* attr, CompilerVariable* v) { void setattr(IREmitter& emitter, const OpInfo& info, const std::string* attr, CompilerVariable* v) override {
type->setattr(emitter, info, this, attr, v); type->setattr(emitter, info, this, attr, v);
} }
virtual void delattr(IREmitter& emitter, const OpInfo& info, const std::string* attr) { void delattr(IREmitter& emitter, const OpInfo& info, const std::string* attr) override {
type->delattr(emitter, info, this, attr); type->delattr(emitter, info, this, attr);
} }
virtual CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, const std::string* attr, bool clsonly, CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, const std::string* attr, bool clsonly,
struct ArgPassSpec argspec, const std::vector<CompilerVariable*>& args, struct ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
const std::vector<const std::string*>* keyword_names) { const std::vector<const std::string*>* keyword_names) override {
return type->callattr(emitter, info, this, attr, clsonly, argspec, args, keyword_names); return type->callattr(emitter, info, this, attr, clsonly, argspec, args, keyword_names);
} }
CompilerVariable* call(IREmitter& emitter, const OpInfo& info, struct ArgPassSpec argspec, CompilerVariable* call(IREmitter& emitter, const OpInfo& info, struct ArgPassSpec argspec,
......
...@@ -2244,7 +2244,7 @@ private: ...@@ -2244,7 +2244,7 @@ private:
} }
public: public:
void addFrameStackmapArgs(PatchpointInfo* pp, std::vector<llvm::Value*>& stackmap_args) { void addFrameStackmapArgs(PatchpointInfo* pp, std::vector<llvm::Value*>& stackmap_args) override {
int initial_args = stackmap_args.size(); int initial_args = stackmap_args.size();
if (ENABLE_FRAME_INTROSPECTION) { if (ENABLE_FRAME_INTROSPECTION) {
// TODO: don't need to use a sorted symbol table if we're explicitly recording the names! // TODO: don't need to use a sorted symbol table if we're explicitly recording the names!
......
...@@ -221,7 +221,7 @@ public: ...@@ -221,7 +221,7 @@ public:
return MayAlias; return MayAlias;
} }
virtual AliasResult alias(const Location& LocA, const Location& LocB) { AliasResult alias(const Location& LocA, const Location& LocB) override {
if (VERBOSITY("opt.aa") >= 2 && depth == 0) { if (VERBOSITY("opt.aa") >= 2 && depth == 0) {
cast<Instruction>(LocA.Ptr)->getParent()->dump(); cast<Instruction>(LocA.Ptr)->getParent()->dump();
} }
...@@ -245,7 +245,7 @@ public: ...@@ -245,7 +245,7 @@ public:
// There are multiple (overloaded) "getModRefInfo" functions in AliasAnalysis, and apparently // There are multiple (overloaded) "getModRefInfo" functions in AliasAnalysis, and apparently
// this means you need to add this line: // this means you need to add this line:
using AliasAnalysis::getModRefInfo; using AliasAnalysis::getModRefInfo;
virtual ModRefResult getModRefInfo(ImmutableCallSite CS, const Location& Loc) { ModRefResult getModRefInfo(ImmutableCallSite CS, const Location& Loc) override {
ModRefResult base = AliasAnalysis::getModRefInfo(CS, Loc); ModRefResult base = AliasAnalysis::getModRefInfo(CS, Loc);
if (!CS.getCalledFunction()) if (!CS.getCalledFunction())
return base; return base;
...@@ -308,7 +308,7 @@ public: ...@@ -308,7 +308,7 @@ public:
return ModRefResult(mask & base); return ModRefResult(mask & base);
} }
virtual void* getAdjustedAnalysisPointer(const void* ID) { void* getAdjustedAnalysisPointer(const void* ID) override {
if (ID == &AliasAnalysis::ID) if (ID == &AliasAnalysis::ID)
return (AliasAnalysis*)this; return (AliasAnalysis*)this;
return this; return this;
......
...@@ -1088,7 +1088,7 @@ public: ...@@ -1088,7 +1088,7 @@ public:
curblock = normal_dest; curblock = normal_dest;
} }
virtual bool visit_classdef(AST_ClassDef* node) { bool visit_classdef(AST_ClassDef* node) override {
// Remap in place: see note in visit_functiondef for why. // Remap in place: see note in visit_functiondef for why.
// Decorators are evaluated before the defaults: // Decorators are evaluated before the defaults:
...@@ -1104,7 +1104,7 @@ public: ...@@ -1104,7 +1104,7 @@ public:
return true; return true;
} }
virtual bool visit_functiondef(AST_FunctionDef* node) { bool visit_functiondef(AST_FunctionDef* node) override {
// As much as I don't like it, for now we're remapping these in place. // As much as I don't like it, for now we're remapping these in place.
// This is because we do certain analyses pre-remapping, and associate the // This is because we do certain analyses pre-remapping, and associate the
// results with the node. We can either do some refactoring and have a way // results with the node. We can either do some refactoring and have a way
...@@ -1128,7 +1128,7 @@ public: ...@@ -1128,7 +1128,7 @@ public:
return true; return true;
} }
virtual bool visit_global(AST_Global* node) { bool visit_global(AST_Global* node) override {
push_back(node); push_back(node);
return true; return true;
} }
...@@ -1142,7 +1142,7 @@ public: ...@@ -1142,7 +1142,7 @@ public:
} }
} }
virtual bool visit_import(AST_Import* node) { bool visit_import(AST_Import* node) override {
for (AST_alias* a : node->names) { for (AST_alias* a : node->names) {
AST_LangPrimitive* import = new AST_LangPrimitive(AST_LangPrimitive::IMPORT_NAME); AST_LangPrimitive* import = new AST_LangPrimitive(AST_LangPrimitive::IMPORT_NAME);
import->args.push_back(new AST_Num()); import->args.push_back(new AST_Num());
...@@ -1182,7 +1182,7 @@ public: ...@@ -1182,7 +1182,7 @@ public:
return true; return true;
} }
virtual bool visit_importfrom(AST_ImportFrom* node) { bool visit_importfrom(AST_ImportFrom* node) override {
RELEASE_ASSERT(node->level == 0, ""); RELEASE_ASSERT(node->level == 0, "");
AST_LangPrimitive* import = new AST_LangPrimitive(AST_LangPrimitive::IMPORT_NAME); AST_LangPrimitive* import = new AST_LangPrimitive(AST_LangPrimitive::IMPORT_NAME);
...@@ -1227,7 +1227,7 @@ public: ...@@ -1227,7 +1227,7 @@ public:
return true; return true;
} }
virtual bool visit_pass(AST_Pass* node) { return true; } bool visit_pass(AST_Pass* node) override { return true; }
bool visit_assert(AST_Assert* node) override { bool visit_assert(AST_Assert* node) override {
AST_Branch* br = new AST_Branch(); AST_Branch* br = new AST_Branch();
...@@ -1280,7 +1280,7 @@ public: ...@@ -1280,7 +1280,7 @@ public:
return true; return true;
} }
virtual bool visit_assign(AST_Assign* node) { bool visit_assign(AST_Assign* node) override {
AST_expr* remapped_value = remapExpr(node->value); AST_expr* remapped_value = remapExpr(node->value);
for (AST_expr* target : node->targets) { for (AST_expr* target : node->targets) {
...@@ -1289,7 +1289,7 @@ public: ...@@ -1289,7 +1289,7 @@ public:
return true; return true;
} }
virtual bool visit_augassign(AST_AugAssign* node) { bool visit_augassign(AST_AugAssign* node) override {
// augassign is pretty tricky; "x" += "y" mostly textually maps to // augassign is pretty tricky; "x" += "y" mostly textually maps to
// "x" = "x" =+ "y" (using "=+" to represent an augbinop) // "x" = "x" =+ "y" (using "=+" to represent an augbinop)
// except that "x" only gets evaluated once. So it's something like // except that "x" only gets evaluated once. So it's something like
...@@ -1382,7 +1382,7 @@ public: ...@@ -1382,7 +1382,7 @@ public:
return true; return true;
} }
virtual bool visit_delete(AST_Delete* node) { bool visit_delete(AST_Delete* node) override {
for (auto t : node->targets) { for (auto t : node->targets) {
AST_Delete* astdel = new AST_Delete(); AST_Delete* astdel = new AST_Delete();
astdel->lineno = node->lineno; astdel->lineno = node->lineno;
...@@ -1418,7 +1418,7 @@ public: ...@@ -1418,7 +1418,7 @@ public:
return true; return true;
} }
virtual bool visit_expr(AST_Expr* node) { bool visit_expr(AST_Expr* node) override {
AST_Expr* remapped = new AST_Expr(); AST_Expr* remapped = new AST_Expr();
remapped->lineno = node->lineno; remapped->lineno = node->lineno;
remapped->col_offset = node->col_offset; remapped->col_offset = node->col_offset;
...@@ -1427,7 +1427,7 @@ public: ...@@ -1427,7 +1427,7 @@ public:
return true; return true;
} }
virtual bool visit_print(AST_Print* node) { bool visit_print(AST_Print* node) override {
AST_expr* dest = remapExpr(node->dest); AST_expr* dest = remapExpr(node->dest);
int i = 0; int i = 0;
...@@ -1464,7 +1464,7 @@ public: ...@@ -1464,7 +1464,7 @@ public:
return true; return true;
} }
virtual bool visit_return(AST_Return* node) { bool visit_return(AST_Return* node) override {
if (root_type != AST_TYPE::FunctionDef && root_type != AST_TYPE::Lambda) { if (root_type != AST_TYPE::FunctionDef && root_type != AST_TYPE::Lambda) {
raiseExcHelper(SyntaxError, "'return' outside function"); raiseExcHelper(SyntaxError, "'return' outside function");
} }
...@@ -1476,7 +1476,7 @@ public: ...@@ -1476,7 +1476,7 @@ public:
return true; return true;
} }
virtual bool visit_if(AST_If* node) { bool visit_if(AST_If* node) override {
if (!curblock) if (!curblock)
return true; return true;
...@@ -1531,7 +1531,7 @@ public: ...@@ -1531,7 +1531,7 @@ public:
return true; return true;
} }
virtual bool visit_break(AST_Break* node) { bool visit_break(AST_Break* node) override {
if (!curblock) if (!curblock)
return true; return true;
...@@ -1549,7 +1549,7 @@ public: ...@@ -1549,7 +1549,7 @@ public:
return true; return true;
} }
virtual bool visit_continue(AST_Continue* node) { bool visit_continue(AST_Continue* node) override {
if (!curblock) if (!curblock)
return true; return true;
...@@ -1568,7 +1568,7 @@ public: ...@@ -1568,7 +1568,7 @@ public:
return true; return true;
} }
virtual bool visit_while(AST_While* node) { bool visit_while(AST_While* node) override {
if (!curblock) if (!curblock)
return true; return true;
...@@ -1629,7 +1629,7 @@ public: ...@@ -1629,7 +1629,7 @@ public:
return true; return true;
} }
virtual bool visit_for(AST_For* node) { bool visit_for(AST_For* node) override {
if (!curblock) if (!curblock)
return true; return true;
...@@ -1867,7 +1867,7 @@ public: ...@@ -1867,7 +1867,7 @@ public:
return true; return true;
} }
virtual bool visit_with(AST_With* node) { bool visit_with(AST_With* node) override {
char ctxmgrname_buf[80]; char ctxmgrname_buf[80];
snprintf(ctxmgrname_buf, 80, "#ctxmgr_%p", node); snprintf(ctxmgrname_buf, 80, "#ctxmgr_%p", node);
char exitname_buf[80]; char exitname_buf[80];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment