[macruby-changes] [3770] MacRuby/trunk/compiler.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 16 13:14:02 PDT 2010
Revision: 3770
http://trac.macosforge.org/projects/ruby/changeset/3770
Author: lsansonetti at apple.com
Date: 2010-03-16 13:14:02 -0700 (Tue, 16 Mar 2010)
Log Message:
-----------
compile strings as utf8-style buffers and not unichar buffers
Modified Paths:
--------------
MacRuby/trunk/compiler.cpp
Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- 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);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100316/e1d0f639/attachment.html>
More information about the macruby-changes
mailing list