aboutsummaryrefslogtreecommitdiff
path: root/src/parser.js
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-04 11:34:49 -0700
committeralon@honor <none@none>2010-09-04 11:34:49 -0700
commit33a2d0ee30dcff26951432581849ffe9e23e928a (patch)
treeb884de8cdce60efc8db266e44ec6e83e595d5180 /src/parser.js
parent62dd7f4bb734017e0a855fee79494cdf6959ae8c (diff)
zeroinitialize support for global structs
Diffstat (limited to 'src/parser.js')
-rw-r--r--src/parser.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/parser.js b/src/parser.js
index 31c29ae1..204e1925 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -1856,11 +1856,13 @@ function JSify(data) {
// Gets an entire constant expression
function parseConst(value, type) {
- //print('//yyyyy ' + JSON.stringify(value) + ',' + type);
+ print('//yyyyy ' + JSON.stringify(value) + ',' + type);
if (isNumberType(type)) {
return makePointer(value.text);
} else if (pointingLevels(type) == 1) {
return makePointer(value.text);
+ } else if (value.text == 'zeroinitializer') {
+ return JSON.stringify(makeEmptyStruct(type));
} else if (value.text[0] == '"') {
value.text = value.text.substr(1, value.text.length-2);
return makePointer('intArrayFromString("' + value.text + '")');
@@ -1911,6 +1913,7 @@ function JSify(data) {
substrate.addZyme('GlobalConstant', {
selectItem: function(item) { return item.intertype == 'globalConstant' && !item.JS },
processItem: function(item) {
+ print('// zz global Cons: ' + dump(item) + ' :: ' + dump(item.value));
if (item.ident == '_llvm_global_ctors') {
item.JS = '\n__globalConstructor__ = function() {\n' +
item.ctors.map(function(ctor) { return ' ' + toNiceIdent(ctor) + '();' }).join('\n') +
@@ -1918,11 +1921,8 @@ function JSify(data) {
} else if (item.type.text == 'external') {
item.JS = 'var ' + item.ident + ' = ' + '0; /* external value? */';
} else {
-//print('// cheeckit ' + dump(item));
- // VAR
- //item.JS = 'var ' + item.ident + ' = ' + parseConst(item.value) + ';';
// GETTER - lazy loading, fixes issues with ordering
- item.JS = 'this.__defineGetter__("' + item.ident + '", function() { return ' + parseConst(item.value) + ' });';
+ item.JS = 'this.__defineGetter__("' + item.ident + '", function() { return ' + parseConst(item.value, item.type.text) + ' });';
}
item.__result__ = true;
return [item];