diff options
author | Jeff Terrace <jterrace@gmail.com> | 2011-10-13 10:43:19 -0400 |
---|---|---|
committer | Jeff Terrace <jterrace@gmail.com> | 2011-10-13 10:43:19 -0400 |
commit | 8db994d1596ff691c2d603ebc6206bdfc73b2a4d (patch) | |
tree | ec5039d20cb6f5e89a6b1debad8738783029d919 | |
parent | 51f9ca6e1c4ea9a164145e418f47374271e2f58a (diff) | |
parent | 3f227142c58c4a5543f6ba3f39ee35765304aa88 (diff) |
Merge branch 'master' of https://github.com/kripken/emscripten
-rw-r--r-- | src/intertyper.js | 3 | ||||
-rw-r--r-- | src/library_sdl.js | 43 | ||||
-rw-r--r-- | src/parseTools.js | 12 | ||||
-rw-r--r-- | tests/cases/complexphi.ll | 27 |
4 files changed, 83 insertions, 2 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 74f38e3a..9fd03bbc 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -619,7 +619,8 @@ function intertyper(data, parseFunctions, baseLineNum) { item.type = item.tokens[1].text; Types.needAnalysis[item.type] = 0; item.functionType = ''; - while (['@', '%'].indexOf(item.tokens[2].text[0]) == -1 && !(item.tokens[2].text in PARSABLE_LLVM_FUNCTIONS)) { + while (['@', '%'].indexOf(item.tokens[2].text[0]) == -1 && !(item.tokens[2].text in PARSABLE_LLVM_FUNCTIONS) && + item.tokens[2].text != 'null') { // We cannot compile assembly. If you hit this, perhaps tell the compiler not // to generate arch-specific code? |-U__i386__ -U__x86_64__| might help, it undefines // the standard archs. diff --git a/src/library_sdl.js b/src/library_sdl.js index 57a98e64..af94301a 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -105,6 +105,9 @@ mergeInto(LibraryManager.library, { }, structs: { + Rect: Runtime.generateStructInfo([ + ['i16', 'x'], ['i16', 'y'], ['i16', 'w'], ['i16', 'h'], + ]), PixelFormat: Runtime.generateStructInfo([ ['void*', 'palette'], ['i8', 'BitsPerPixel'], ['i8', 'BytesPerPixel'], ['i8', 'Rloss'], ['i8', 'Gloss'], ['i8', 'Bloss'], ['i8', 'Aloss'], @@ -377,6 +380,28 @@ mergeInto(LibraryManager.library, { return 0; }, + SDL_FillRect: function(surf, rect, color) { + var surfData = SDL.surfaces[surf]; + var c1 = color & 0xff; + var c2 = (color >> 8) & 0xff; + var c3 = (color >> 16) & 0xff; + var rx = {{{ makeGetValue('rect + SDL.structs.Rect.x', '0', 'i16') }}}; + var ry = {{{ makeGetValue('rect + SDL.structs.Rect.y', '0', 'i16') }}}; + var rw = {{{ makeGetValue('rect + SDL.structs.Rect.w', '0', 'i16') }}}; + var rh = {{{ makeGetValue('rect + SDL.structs.Rect.h', '0', 'i16') }}}; + var data = surfData.image.data; + var width = surfData.width; + for (var y = ry; y < ry + rh; y++) { + var base = y*width*4; + for (var x = rx; x < rx + rw; x++) { + var start = x*4 + base; + data[start] = c1; + data[start+1] = c2; + data[start+2] = c3; + } + } + }, + SDL_BlitSurface__deps: ['SDL_UpperBlit'], SDL_BlitSurface: function(src, srcrect, dst, dstrect) { return _SDL_Blit(src, srcrect, dst, dstrect); @@ -415,6 +440,11 @@ mergeInto(LibraryManager.library, { return 1; }, + SDL_MapRGB: function(fmt, r, g, b) { + // Canvas screens are always RGBA + return r + (g << 8) + (b << 16); + }, + // SDL_Image IMG_Load: function(filename) { @@ -490,5 +520,18 @@ mergeInto(LibraryManager.library, { SDL_LockAudio: function() {}, SDL_UnlockAudio: function() {}, + + SDL_CreateMutex: function() { return 0 }, + SDL_LockMutex: function() {}, + SDL_UnlockMutex: function() {}, + SDL_DestroyMutex: function() {}, + + SDL_CreateCond: function() { return 0 }, + SDL_CondSignal: function() {}, + SDL_CondWait: function() {}, + SDL_DestroyCond: function() {}, + +//SDL_CreateYUVOverlay +//SDL_CreateThread, SDL_WaitThread etc }); diff --git a/src/parseTools.js b/src/parseTools.js index 7d62b34d..f9ef419a 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1074,6 +1074,10 @@ function handleOverflow(text, bits) { } } +function makeLLVMStruct(values) { // TODO: Use this everywhere + return '{ ' + values.map(function(value, i) { return 'f' + i + ': ' + value }).join(', ') + ' }' +} + // From parseLLVMSegment function finalizeLLVMParameter(param, noIndexizeFunctions) { var ret; @@ -1083,10 +1087,16 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) { return toNiceIdentCarefully(param); } else if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { ret = finalizeLLVMFunctionCall(param, noIndexizeFunctions); + } else if (param.ident == 'zeroinitializer') { + if (isStructType(param.type)) { + return makeLLVMStruct(zeros(Types.types[param.type].fields.length)); + } else { + return '0'; + } } else if (param.intertype == 'value') { ret = parseNumerical(param.ident); } else if (param.intertype == 'structvalue') { - ret = param.values.map(function(value) { return finalizeLLVMParameter(value, noIndexizeFunctions) }); + ret = makeLLVMStruct(param.values.map(function(value) { return finalizeLLVMParameter(value, noIndexizeFunctions) })); } else if (param.intertype === 'blockaddress') { return finalizeBlockAddress(param); } else if (param.intertype === 'type') { diff --git a/tests/cases/complexphi.ll b/tests/cases/complexphi.ll new file mode 100644 index 00000000..6f64af06 --- /dev/null +++ b/tests/cases/complexphi.ll @@ -0,0 +1,27 @@ +; ModuleID = '/dev/shm/tmp/src.cpp.o' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" +target triple = "i386-pc-linux-gnu" + +@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] + +; [#uses=0] +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + %comp = alloca { i32, i32 }, align 4 ; [#uses=1] + store i32 0, i32* %retval + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32] [debug line = 5:13] + br label %cond.end + +cond.null: + br label %cond.end + +cond.end: ; preds = %cond.false, %cond.true + %cond = phi { i32, i32 } [ { i32 5, i32 6 }, %entry ], [ zeroinitializer, %cond.null ] ; [#uses=1] + store { i32, i32 } %cond, { i32, i32 }* %comp + ret i32 0 ; [debug line = 6:13] +} + +; [#uses=1] +declare i32 @printf(i8*, ...) + |