aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Croteau <jcroteau@gmail.com>2014-02-19 04:19:43 -0800
committerJoel Croteau <jcroteau@gmail.com>2014-02-19 04:21:33 -0800
commita28fad120298fee2b120c47aa0b6d29bf3ff0830 (patch)
tree368281faa461a4bab2d1c8e3aaf817220b35fdeb
parentc84c6eda17a6ac5e9c56bbc76839c472238a97c4 (diff)
Correct syntax of allocate function
Fix mistaken syntax for use of allocate and restore original, very strange syntax.
-rw-r--r--src/library.js14
-rw-r--r--src/preamble.js16
2 files changed, 20 insertions, 10 deletions
diff --git a/src/library.js b/src/library.js
index 698763b6..9f5a7dd7 100644
--- a/src/library.js
+++ b/src/library.js
@@ -6443,7 +6443,19 @@ LibraryManager.library = {
// var indexes = Runtime.calculateStructAlignment({ fields: ['i32', 'i32'] });
var me = _localeconv;
if (!me.ret) {
- me.ret = allocate([allocate(intArrayFromString('.'), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL)], 'i8*', ALLOC_NORMAL); // Allocate strings in lconv, still don't allocate chars
+ // These are defaults from the "C" locale
+ me.ret = allocate(
+ [allocate(intArrayFromString('.'), 'i8', ALLOC_NORMAL),0,0,0, // decimal_point
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // thousands_sep
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // grouping
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // int_curr_symbol
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // currency_symbol
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_decimal_point
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_thousands_sep
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_grouping
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // positive_sign
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0], // negative_sign
+ 'i8*', ALLOC_NORMAL); // Allocate strings in lconv, still don't allocate chars
}
return me.ret;
},
diff --git a/src/preamble.js b/src/preamble.js
index 0be5b4de..1c9de066 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -529,18 +529,17 @@ function allocate(slab, types, allocator, ptr) {
}
#endif
- var index = 0, byteIndex = 0, type, typeSize, previousType;
- while ((singleType ? index : byteIndex) < size) {
- var curr = slab[index];
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
if (typeof curr === 'function') {
curr = Runtime.getFunctionIndex(curr);
}
- type = singleType || types[byteIndex];
+ type = singleType || types[i];
if (type === 0) {
- index++;
- byteIndex++;
+ i++;
continue;
}
#if ASSERTIONS
@@ -551,15 +550,14 @@ function allocate(slab, types, allocator, ptr) {
if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
#endif
- setValue(ret+byteIndex, curr, type);
+ setValue(ret+i, curr, type);
// no need to look up size unless type changes, so cache it
if (previousType !== type) {
typeSize = Runtime.getNativeTypeSize(type);
previousType = type;
}
- index++;
- byteIndex += typeSize;
+ i += typeSize;
}
return ret;