Commit eb871acd authored by Joris Vankerschaver's avatar Joris Vankerschaver

Add modified str to IR generator.

parent 2aa6fe48
......@@ -1705,7 +1705,7 @@ private:
// end code for handling of softspace
llvm::Value* v = emitter.createCall(unw_info, g.funcs.str, converted->getValue());
llvm::Value* v = emitter.createCall(unw_info, g.funcs.strOrUnicode, converted->getValue());
v = emitter.getBuilder()->CreateBitCast(v, g.llvm_value_type_ptr);
auto s = new ConcreteCompilerVariable(STR, v, true);
r = dest->callattr(emitter, getOpInfoForNode(node, unw_info), &write_str, flags, ArgPassSpec(1), { s },
......
......@@ -206,6 +206,7 @@ void initGlobalFuncs(GlobalState& g) {
GET(importStar);
GET(repr);
GET(str);
GET(strOrUnicode);
GET(exceptionMatches);
GET(yield);
GET(getiterHelper);
......
......@@ -38,7 +38,7 @@ struct GlobalFuncs {
*decodeUTF8StringPtr;
llvm::Value* getattr, *setattr, *delattr, *delitem, *delGlobal, *nonzero, *binop, *compare, *augbinop, *unboxedLen,
*getitem, *getclsattr, *getGlobal, *setitem, *unaryop, *import, *importFrom, *importStar, *repr, *str,
*exceptionMatches, *yield, *getiterHelper, *hasnext;
*strOrUnicode, *exceptionMatches, *yield, *getiterHelper, *hasnext;
llvm::Value* unpackIntoArray, *raiseAttributeError, *raiseAttributeErrorStr, *raiseNotIterableError,
*assertNameDefined, *assertFail;
......
......@@ -100,6 +100,7 @@ void force() {
FORCE(assertNameDefined);
FORCE(assertFail);
FORCE(strOrUnicode);
FORCE(printFloat);
FORCE(listAppendInternal);
FORCE(getSysStdout);
......
......@@ -2028,6 +2028,14 @@ extern "C" BoxedString* str(Box* obj) {
return static_cast<BoxedString*>(obj);
}
extern "C" BoxedString* strOrUnicode(Box* obj) {
// Like str, but returns unicode objects unchanged.
if (obj->cls == unicode_cls) {
return static_cast<BoxedString*>(obj);
}
return str(obj);
}
extern "C" BoxedString* repr(Box* obj) {
static StatCounter slowpath_repr("slowpath_repr");
slowpath_repr.log();
......
......@@ -61,6 +61,7 @@ extern "C" BoxedString* str(Box* obj);
extern "C" BoxedString* repr(Box* obj);
extern "C" BoxedString* reprOrNull(Box* obj); // similar to repr, but returns NULL on exception
extern "C" BoxedString* strOrNull(Box* obj); // similar to str, but returns NULL on exception
extern "C" BoxedString* strOrUnicode(Box* obj);
extern "C" bool exceptionMatches(Box* obj, Box* cls);
extern "C" BoxedInt* hash(Box* obj);
extern "C" Box* abs_(Box* obj);
......
......@@ -49,11 +49,9 @@ import gc
for i in xrange(100):
print repr(BaseException().__unicode__())
gc.collect()
# TODO / FIXME: For some reason, uncommenting the loop below will cause printing unicode
# to fail!!!
# do some allocations:
# for j in xrange(100):
# [None] * j
for j in xrange(100):
[None] * j
print u'' in ''
print '' in u''
......
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