~ubuntu-branches/ubuntu/trusty/emscripten/trusty-proposed

« back to all changes in this revision

Viewing changes to src/postamble.js

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20140119141240-jg1l42cc158j59tn
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
// === Auto-generated postamble setup entry stuff ===
3
3
 
 
4
if (memoryInitializer) {
 
5
  function applyData(data) {
 
6
#if USE_TYPED_ARRAYS == 2
 
7
    HEAPU8.set(data, STATIC_BASE);
 
8
#else
 
9
    allocate(data, 'i8', ALLOC_NONE, STATIC_BASE);
 
10
#endif
 
11
  }
 
12
  if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
 
13
    applyData(Module['readBinary'](memoryInitializer));
 
14
  } else {
 
15
    addRunDependency('memory initializer');
 
16
    Browser.asyncLoad(memoryInitializer, function(data) {
 
17
      applyData(data);
 
18
      removeRunDependency('memory initializer');
 
19
    }, function(data) {
 
20
      throw 'could not load memory initializer ' + memoryInitializer;
 
21
    });
 
22
  }
 
23
}
 
24
 
4
25
function ExitStatus(status) {
5
26
  this.name = "ExitStatus";
6
27
  this.message = "Program terminated with exit(" + status + ")";
13
34
var preloadStartTime = null;
14
35
var calledMain = false;
15
36
 
 
37
dependenciesFulfilled = function runCaller() {
 
38
  // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
 
39
  if (!Module['calledRun'] && shouldRunNow) run();
 
40
  if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
 
41
}
 
42
 
16
43
Module['callMain'] = Module.callMain = function callMain(args) {
17
44
  assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
18
45
  assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
68
95
      Module['noExitRuntime'] = true;
69
96
      return;
70
97
    } else {
 
98
      if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
71
99
      throw e;
72
100
    }
73
101
  } finally {
89
117
 
90
118
  preRun();
91
119
 
92
 
  if (runDependencies > 0) {
93
 
    // a preRun added a dependency, run will be called later
94
 
    return;
95
 
  }
 
120
  if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
 
121
  if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
96
122
 
97
123
  function doRun() {
 
124
    if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
 
125
    Module['calledRun'] = true;
 
126
 
98
127
    ensureInitRuntime();
99
128
 
100
129
    preMain();
101
130
 
102
 
    calledRun = true;
103
131
    if (Module['_main'] && shouldRunNow) {
104
132
      Module['callMain'](args);
105
133
    }
151
179
  ABORT = true;
152
180
  EXITSTATUS = 1;
153
181
 
154
 
  throw 'abort() at ' + (new Error().stack);
 
182
  throw 'abort() at ' + stackTrace();
155
183
}
156
184
Module['abort'] = Module.abort = abort;
157
185