Commit a3d1cbb3 authored by Marius Wachtler's avatar Marius Wachtler

Don't abort when generating a call of a known type which is not callable.

fixes #1046
parent 5fd4fe6e
...@@ -141,10 +141,7 @@ public: ...@@ -141,10 +141,7 @@ public:
} }
virtual CompilerVariable* call(IREmitter& emitter, const OpInfo& info, VAR* var, struct ArgPassSpec argspec, virtual CompilerVariable* call(IREmitter& emitter, const OpInfo& info, VAR* var, struct ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args, const std::vector<CompilerVariable*>& args,
const std::vector<BoxedString*>* keyword_names) { const std::vector<BoxedString*>* keyword_names);
printf("call not defined for %s\n", debugName().c_str());
abort();
}
virtual CompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) { virtual CompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) {
printf("len not defined for %s\n", debugName().c_str()); printf("len not defined for %s\n", debugName().c_str());
abort(); abort();
...@@ -172,10 +169,7 @@ public: ...@@ -172,10 +169,7 @@ public:
abort(); abort();
} }
CompilerType* callType(struct ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types, CompilerType* callType(struct ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<llvm::StringRef>* keyword_names) override { const std::vector<llvm::StringRef>* keyword_names) override;
printf("callType not defined for %s\n", debugName().c_str());
abort();
}
BoxedClass* guaranteedClass() override { BoxedClass* guaranteedClass() override {
ASSERT((CompilerType*)getConcreteType() != this, "%s", debugName().c_str()); ASSERT((CompilerType*)getConcreteType() != this, "%s", debugName().c_str());
return getConcreteType()->guaranteedClass(); return getConcreteType()->guaranteedClass();
...@@ -490,6 +484,23 @@ std::vector<CompilerVariable*> _ValuedCompilerType<V>::unpack(IREmitter& emitter ...@@ -490,6 +484,23 @@ std::vector<CompilerVariable*> _ValuedCompilerType<V>::unpack(IREmitter& emitter
return r; return r;
} }
template <typename V>
CompilerType* _ValuedCompilerType<V>::callType(struct ArgPassSpec argspec, const std::vector<CompilerType*>& arg_types,
const std::vector<llvm::StringRef>* keyword_names) {
return UNKNOWN;
}
template <typename V>
CompilerVariable* _ValuedCompilerType<V>::call(IREmitter& emitter, const OpInfo& info, VAR* var,
struct ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
const std::vector<BoxedString*>* keyword_names) {
assert((CompilerType*)this != UNKNOWN);
ConcreteCompilerVariable* converted = makeConverted(emitter, var, UNKNOWN);
auto r = UNKNOWN->call(emitter, info, converted, argspec, args, keyword_names);
converted->decvref(emitter);
return r;
}
} // namespace pyston } // namespace pyston
#endif #endif
...@@ -42,3 +42,24 @@ def f2(): ...@@ -42,3 +42,24 @@ def f2():
for i in xrange(100): for i in xrange(100):
f2() f2()
# make sure we don't abort when calling a type which is not callable
def f(call):
i = 1
f = 1.0
l = 1l
s = "str"
t = (1,)
if call:
i()
f()
l()
s()
t()
try:
for i in range(10000):
f(i == 9999)
except TypeError, e:
print e
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