aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-21 09:01:12 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-29 13:01:58 -0700
commitec9707170f4e6c8f016c2e2ea27a53abf1326410 (patch)
treebe61cbf107ce5c8eb507e794f7781c3be95e9d15 /src
parent17248eb417685f37a94bc8857d3d6e513364cc9d (diff)
work towards le32 varargs
Diffstat (limited to 'src')
-rw-r--r--src/intertyper.js12
-rw-r--r--src/jsifier.js3
-rw-r--r--src/library.js40
3 files changed, 55 insertions, 0 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 57e3011d..445c37f4 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -336,6 +336,8 @@ function intertyper(data, sidePass, baseLineNums) {
return 'InsertValue';
if (tokensLength >= 3 && token0Text == 'phi')
return 'Phi';
+ if (tokensLength >= 3 && token0Text == 'va_arg')
+ return 'va_arg';
if (tokensLength >= 3 && token0Text == 'landingpad')
return 'Landingpad';
if (token0Text == 'fence')
@@ -817,6 +819,16 @@ function intertyper(data, sidePass, baseLineNums) {
this.forwardItem(item, 'Reintegrator');
}
});
+ // 'phi'
+ substrate.addActor('va_arg', {
+ processItem: function(item) {
+ item.intertype = 'va_arg';
+ var segments = splitTokenList(item.tokens.slice(1));
+ item.type = segments[1][0].text;
+ item.value = parseLLVMSegment(segments[0]);
+ this.forwardItem(item, 'Reintegrator');
+ }
+ });
// mathops
substrate.addActor('Mathops', {
processItem: function(item) {
diff --git a/src/jsifier.js b/src/jsifier.js
index 5fcf6b18..a2ed7f92 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1295,6 +1295,9 @@ function JSify(data, functionsOnly, givenFunctions) {
return RuntimeGenerator.stackAlloc(getFastValue(calcAllocatedSize(item.allocatedType), '*', item.allocatedNum));
}
});
+ makeFuncLineActor('va_arg', function(item) {
+ return makeGetValue(item.value.ident, 0, item.type);
+ });
makeFuncLineActor('mathop', processMathop);
diff --git a/src/library.js b/src/library.js
index 9b63084f..c62b6a05 100644
--- a/src/library.js
+++ b/src/library.js
@@ -3612,6 +3612,8 @@ LibraryManager.library = {
asprintf: function(s, format, varargs) {
return _sprintf(-s, format, varargs);
},
+
+#if TARGET_X86
vfprintf: 'fprintf',
vsnprintf: 'snprintf',
vprintf: 'printf',
@@ -3620,6 +3622,44 @@ LibraryManager.library = {
vscanf: 'scanf',
vfscanf: 'fscanf',
vsscanf: 'sscanf',
+#endif
+
+#if TARGET_LE32
+ vfprintf__deps: ['fprintf'],
+ vfprintf: function(s, f, varargs) {
+ return _fprintf(s, f, {{{ makeGetValue('varargs', 0, '*') }}});
+ },
+ vsnprintf__deps: ['snprintf'],
+ vsnprintf: function(s, n, format, varargs) {
+ return _snprintf(s, n, format, {{{ makeGetValue('varargs', 0, '*') }}});
+ },
+ vprintf__deps: ['printf'],
+ vprintf: function(format, varargs) {
+ return _printf(format, {{{ makeGetValue('varargs', 0, '*') }}});
+ },
+ vsprintf__deps: ['sprintf'],
+ vsprintf: function(s, format, varargs) {
+ return _sprintf(s, format, {{{ makeGetValue('varargs', 0, '*') }}});
+ },
+ vasprintf__deps: ['asprintf'],
+ vasprintf: function(s, format, varargs) {
+ return _asprintf(s, format, {{{ makeGetValue('varargs', 0, '*') }}});
+ },
+ vscanf__deps: ['scanf'],
+ vscanf: function(format, varargs) {
+ return _scanf(format, {{{ makeGetValue('varargs', 0, '*') }}});
+ },
+ vfscanf__deps: ['fscanf'],
+ vfscanf: function(s, format, varargs) {
+ return _fscanf(s, format, {{{ makeGetValue('varargs', 0, '*') }}});
+ },
+ vsscanf__deps: ['sscanf'],
+ vsscanf: function(s, format, varargs) {
+ return _sscanf(s, format, {{{ makeGetValue('varargs', 0, '*') }}});
+ },
+ // TODO: others
+#endif
+
fopen64: 'fopen',
__01fopen64_: 'fopen',
__01freopen64_: 'freopen',