aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormax99x <max99x@gmail.com>2011-07-06 16:37:28 +0300
committermax99x <max99x@gmail.com>2011-07-06 16:37:28 +0300
commitdedb83b9e15591893e1b30220c721e447518f5d9 (patch)
tree87068307ade1fbcff662fcef5e943d944f4f7374 /src
parent13ac46b2c9be4aa17319c450a15ed96b71e091d7 (diff)
parente84f1845f1a96ecfda4f1ffc0ba2052dc7c8c86d (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src')
-rw-r--r--src/analyzer.js2
-rw-r--r--src/intertyper.js10
-rw-r--r--src/jsifier.js16
-rw-r--r--src/library.js9
-rw-r--r--src/modules.js1
-rw-r--r--src/parseTools.js2
-rw-r--r--src/settings.js1
7 files changed, 37 insertions, 4 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 4f069695..0cb1b160 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -29,7 +29,7 @@ function analyzer(data) {
substrate.addActor('Gatherer', {
processItem: function(item) {
// Single-liners
- ['globalVariable', 'functionStub', 'unparsedFunction'].forEach(function(intertype) {
+ ['globalVariable', 'functionStub', 'unparsedFunction', 'alias'].forEach(function(intertype) {
var temp = splitter(item.items, function(item) { return item.intertype == intertype });
item.items = temp.leftIn;
item[intertype + 's'] = temp.splitOut;
diff --git a/src/intertyper.js b/src/intertyper.js
index 972b5de6..b6ff89f5 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -375,7 +375,15 @@ function intertyper(data, parseFunctions, baseLineNum) {
}
if (item.tokens[2].text == 'alias') {
- return null; // TODO: handle this. See raytrace.cpp
+ cleanOutTokensSet(LLVM.LINKAGES, item.tokens, 3);
+ cleanOutTokensSet(LLVM.VISIBILITIES, item.tokens, 3);
+ return [{
+ intertype: 'alias',
+ ident: toNiceIdent(item.tokens[0].text),
+ aliasee: toNiceIdent(item.tokens[4].text),
+ type: item.tokens[3].text,
+ lineNum: item.lineNum
+ }];
}
if (item.tokens[2].text == 'type') {
var fields = [];
diff --git a/src/jsifier.js b/src/jsifier.js
index 1b83b991..486eeb02 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -221,6 +221,21 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
}
});
+ // alias
+ substrate.addActor('Alias', {
+ processItem: function(item) {
+ item.intertype = 'GlobalVariableStub';
+ var ret = [item];
+ item.JS = 'var ' + item.ident + ';';
+ // Set the actual value in a postset, since it may be a global variable. TODO: handle alias of alias (needs ordering)
+ ret.push({
+ intertype: 'GlobalVariablePostSet',
+ JS: item.ident + ' = ' + item.aliasee + ';'
+ });
+ return ret;
+ }
+ });
+
var moduleFunctions = set(data.unparsedFunctions.map(function(func) { return func.ident }));
var addedLibraryItems = {};
@@ -830,6 +845,7 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
substrate.addItems(values(data.globalVariables), 'GlobalVariable');
substrate.addItems(data.functions, 'FunctionSplitter');
substrate.addItems(data.functionStubs, 'FunctionStub');
+ substrate.addItems(data.aliass, 'Alias');
return finalCombiner(substrate.solve());
}
diff --git a/src/library.js b/src/library.js
index d6c727b9..bf1f28f8 100644
--- a/src/library.js
+++ b/src/library.js
@@ -802,7 +802,7 @@ var Library = {
stat__deps: ['open', 'fstat'],
stat: function(filename, ptr) {
if (typeof window === 'undefined') {
- // d8 hangs if you try to read a folder.
+ // XXX d8 hangs if you try to read a folder.
// http://code.google.com/p/v8/issues/detail?id=1533
return 0;
}
@@ -2011,6 +2011,13 @@ var Library = {
return ret + boundary - (ret % boundary);
},
+ posix_memalign__deps: ['memalign'],
+ posix_memalign: function(memptr, alignment, size) {
+ var ptr = _memalign(alignment, size);
+ {{{ makeSetValue('memptr', '0', 'ptr', 'i8*') }}}
+ return 0;
+ },
+
// ==========================================================================
// dirent.h
// ==========================================================================
diff --git a/src/modules.js b/src/modules.js
index 91758609..0b00107c 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -6,6 +6,7 @@ var LLVM = {
LINKAGES: set('private', 'linker_private', 'linker_private_weak', 'linker_private_weak_def_auto', 'internal',
'available_externally', 'linkonce', 'common', 'weak', 'appending', 'extern_weak', 'linkonce_odr',
'weak_odr', 'externally_visible', 'dllimport', 'dllexport', 'unnamed_addr'),
+ VISIBILITIES: set('default', 'hidden', 'protected'),
PARAM_ATTR: set('noalias', 'signext', 'zeroext', 'inreg', 'sret', 'nocapture', 'nest'),
CALLING_CONVENTIONS: set('ccc', 'fastcc', 'coldcc', 'cc10')
};
diff --git a/src/parseTools.js b/src/parseTools.js
index 8c8389fb..afd57543 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -473,7 +473,7 @@ function IEEEUnHex(stringy) {
stringy = stringy.substr(2); // leading '0x';
if (stringy.replace(/0/g, '') === '') return 0;
while (stringy.length < 16) stringy = '0' + stringy;
- assert(stringy.length === 16, 'Can only undex 16-digit double numbers, nothing platform-specific');
+ assert(stringy.length === 16, 'Can only unhex 16-digit double numbers, nothing platform-specific');
var top = eval('0x' + stringy[0]);
var neg = !!(top & 8); // sign
if (neg) {
diff --git a/src/settings.js b/src/settings.js
index 437d61b5..544cc7c2 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -46,6 +46,7 @@ USE_TYPED_ARRAYS = 0; // Try to use typed arrays for the heap
// simply because double stores are not necessarily 64-bit aligned, and we can only access
// 64-bit aligned values with a 64-bit typed array. Likewise int64s are stored as int32's,
// which is potentially very dangerous!
+ // TODO: require compiling with -malign-double, which does align doubles
SKIP_STACK_IN_SMALL = 1; // When enabled, does not push/pop the stack at all in
// functions that have no basic stack usage. But, they
// may allocate stack later, and in a loop, this can be