Modified: MacRuby/trunk/compiler.cpp (3769 => 3770)
--- MacRuby/trunk/compiler.cpp 2010-03-16 03:08:19 UTC (rev 3769)
+++ MacRuby/trunk/compiler.cpp 2010-03-16 20:14:02 UTC (rev 3770)
@@ -2807,21 +2807,14 @@
return CallInst::Create(newString3Func, "", bb);
}
else {
- UChar *chars = NULL;
- long chars_len = 0;
- bool need_free = false;
+ const char *cstr = RSTRING_PTR(val);
+ const int cstr_len = RSTRING_LEN(val);
- rb_str_get_uchars(val, &chars, &chars_len, &need_free);
- assert(chars_len > 0);
+ assert(cstr_len > 0);
- GlobalVariable *str_gvar = compile_const_global_ustring(chars,
- chars_len);
+ GlobalVariable *str_gvar = compile_const_global_string(cstr,
+ cstr_len);
- if (need_free) {
- free(chars);
- chars = NULL;
- }
-
std::vector<Value *> idxs;
idxs.push_back(ConstantInt::get(Int32Ty, 0));
idxs.push_back(ConstantInt::get(Int32Ty, 0));
@@ -2831,14 +2824,13 @@
if (newString2Func == NULL) {
newString2Func = cast<Function>(
module->getOrInsertFunction(
- "rb_unicode_str_new",
- RubyObjTy, PointerType::getUnqual(Int16Ty),
- Int32Ty, NULL));
+ "rb_str_new",
+ RubyObjTy, PtrTy, Int32Ty, NULL));
}
std::vector<Value *> params;
params.push_back(load);
- params.push_back(ConstantInt::get(Int32Ty, chars_len));
+ params.push_back(ConstantInt::get(Int32Ty, cstr_len));
return CallInst::Create(newString2Func, params.begin(),
params.end(), "", bb);