~ubuntu-branches/ubuntu/vivid/emscripten/vivid-proposed

« back to all changes in this revision

Viewing changes to src/relooper/emscripten/glue.js

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140119141240-nfiw0p8033oitpfz
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
 
  var RBUFFER_SIZE = 20*1024*1024;
 
2
  var RBUFFER_SIZE = RELOOPER_BUFFER_SIZE;
3
3
  var rbuffer = _malloc(RBUFFER_SIZE);
4
4
  _rl_set_output_buffer(rbuffer, RBUFFER_SIZE);
5
5
 
6
 
  var TBUFFER_SIZE = 10*1024*1024;
 
6
  var TBUFFER_SIZE = RELOOPER_BUFFER_SIZE/2;
7
7
  var tbuffer = _malloc(TBUFFER_SIZE);
8
8
 
9
9
  var VBUFFER_SIZE = 256;
13
13
  RelooperGlue['init'] = function() {
14
14
    this.r = _rl_new_relooper();
15
15
  },
 
16
  RelooperGlue['cleanup'] = function() {
 
17
    _rl_delete_relooper(this.r);
 
18
  },
16
19
  RelooperGlue['addBlock'] = function(text, branchVar) {
17
20
    assert(this.r);
18
 
    assert(text.length+1 < TBUFFER_SIZE);
19
 
    writeStringToMemory(text, tbuffer);
 
21
    assert(text.length+1 < TBUFFER_SIZE, 'buffer too small, increase RELOOPER_BUFFER_SIZE');
 
22
    writeAsciiToMemory(text, tbuffer);
20
23
    if (branchVar) {
21
 
      assert(branchVar.length+1 < VBUFFER_SIZE);
22
 
      writeStringToMemory(branchVar, vbuffer);
 
24
      assert(branchVar.length+1 < VBUFFER_SIZE, 'buffer too small, increase RELOOPER_BUFFER_SIZE');
 
25
      writeAsciiToMemory(branchVar, vbuffer);
23
26
    }
24
27
    var b = _rl_new_block(tbuffer, branchVar ? vbuffer : 0);
25
28
    _rl_relooper_add_block(this.r, b);
28
31
  RelooperGlue['addBranch'] = function(from, to, condition, code) {
29
32
    assert(this.r);
30
33
    if (condition) {
31
 
      assert(condition.length+1 < TBUFFER_SIZE/2);
32
 
      writeStringToMemory(condition, tbuffer);
 
34
      assert(condition.length+1 < TBUFFER_SIZE/2, 'buffer too small, increase RELOOPER_BUFFER_SIZE');
 
35
      writeAsciiToMemory(condition, tbuffer);
33
36
      condition = tbuffer;
34
37
    } else {
35
38
      condition = 0; // allow undefined, null, etc. as inputs
36
39
    }
37
40
    if (code) {
38
 
      assert(code.length+1 < TBUFFER_SIZE/2);
39
 
      writeStringToMemory(code, tbuffer + TBUFFER_SIZE/2);
 
41
      assert(code.length+1 < TBUFFER_SIZE/2, 'buffer too small, increase RELOOPER_BUFFER_SIZE');
 
42
      writeAsciiToMemory(code, tbuffer + TBUFFER_SIZE/2);
40
43
      code = tbuffer + TBUFFER_SIZE/2;
41
44
    } else {
42
45
      code = 0; // allow undefined, null, etc. as inputs