@@ -1225,34 +1225,42 @@ class IRGeneratorImpl : public IRGenerator {
12251225 }
12261226 }
12271227
1228+ CompilerVariable* evalConstObj (Box* o) {
1229+ if (o->cls == none_cls)
1230+ return emitter.getNone ();
1231+ else if (o->cls == ellipsis_cls)
1232+ return getEllipsis ();
1233+
1234+ llvm::Value* rtn = embedRelocatablePtr (o, g.llvm_value_type_ptr );
1235+ emitter.setType (rtn, RefType::BORROWED);
1236+
1237+ if (o->cls == int_cls)
1238+ return makeUnboxedInt (emitter, rtn);
1239+ else if (o->cls == float_cls)
1240+ return makeUnboxedFloat (emitter, rtn);
1241+ else if (o->cls == complex_cls)
1242+ return new ConcreteCompilerVariable (BOXED_COMPLEX, rtn);
1243+ else if (o->cls == long_cls)
1244+ return new ConcreteCompilerVariable (LONG, rtn);
1245+ else if (o->cls == str_cls)
1246+ return new ConcreteCompilerVariable (STR, rtn);
1247+ else if (o->cls == unicode_cls)
1248+ return new ConcreteCompilerVariable (typeFromClass (unicode_cls), rtn);
1249+ else if (o->cls == tuple_cls) {
1250+ auto * tuple = (BoxedTuple*)o;
1251+ std::vector<CompilerVariable*> elts;
1252+ for (int i = 0 ; i < tuple->size (); ++i) {
1253+ elts.push_back (evalConstObj (tuple->elts [i]));
1254+ }
1255+ return makeTuple (elts, new ConcreteCompilerVariable (BOXED_TUPLE, rtn));
1256+ } else
1257+ RELEASE_ASSERT (0 , " " );
1258+ }
1259+
12281260 CompilerVariable* evalVReg (int vreg, bool is_kill = true ) {
12291261 assert (vreg != VREG_UNDEFINED);
1230- if (vreg < 0 ) {
1231- Box* o = irstate->getCode ()->code_constants .getConstant (vreg);
1232-
1233- if (o->cls == none_cls)
1234- return emitter.getNone ();
1235- else if (o->cls == ellipsis_cls)
1236- return getEllipsis ();
1237-
1238- llvm::Value* rtn = embedRelocatablePtr (o, g.llvm_value_type_ptr );
1239- emitter.setType (rtn, RefType::BORROWED);
1240-
1241- if (o->cls == int_cls)
1242- return makeUnboxedInt (emitter, rtn);
1243- else if (o->cls == float_cls)
1244- return makeUnboxedFloat (emitter, rtn);
1245- else if (o->cls == complex_cls)
1246- return new ConcreteCompilerVariable (BOXED_COMPLEX, rtn);
1247- else if (o->cls == long_cls)
1248- return new ConcreteCompilerVariable (LONG, rtn);
1249- else if (o->cls == str_cls)
1250- return new ConcreteCompilerVariable (STR, rtn);
1251- else if (o->cls == unicode_cls)
1252- return new ConcreteCompilerVariable (typeFromClass (unicode_cls), rtn);
1253- else
1254- RELEASE_ASSERT (0 , " " );
1255- }
1262+ if (vreg < 0 )
1263+ return evalConstObj (irstate->getCode ()->code_constants .getConstant (vreg));
12561264 CompilerVariable* rtn = symbol_table[vreg];
12571265 if (is_kill) {
12581266 symbol_table[vreg] = NULL ;
0 commit comments