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

« back to all changes in this revision

Viewing changes to src/intertyper.js

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
360
360
            warn('Ignoring module asm: ' + item.tokens[2].text);
361
361
            return '/dev/null';
362
362
          }
 
363
          if (token0Text == 'attributes')
 
364
            return '/dev/null';
363
365
        }
364
366
        if (tokensLength >= 3 && (token0Text == 'call' || token1Text == 'call'))
365
367
          return 'Call';
366
 
        if (token0Text == 'target')
 
368
        if (token0Text == 'target') {
 
369
          if (token1Text == 'triple') {
 
370
            var triple = item.tokens[3].text;
 
371
            triple = triple.substr(1, triple.length-2);
 
372
            var expected = TARGET_LE32 ? 'le32-unknown-nacl' : 'i386-pc-linux-gnu';
 
373
            if (triple !== expected) {
 
374
              warn('using an unexpected LLVM triple: ' + [triple, ' !== ', expected] + ' (are you using emcc for everything and not clang?)');
 
375
            }
 
376
          }
367
377
          return '/dev/null';
 
378
        }
368
379
        if (token0Text == ';')
369
380
          return '/dev/null';
370
381
        if (tokensLength >= 3 && token0Text == 'invoke')
502
513
      } else {
503
514
        // variable
504
515
        var ident = item.tokens[0].text;
505
 
        var private_ = findTokenText(item, 'private') >= 0;
 
516
        var private_ = findTokenText(item, 'private') >= 0 || findTokenText(item, 'internal') >= 0;
 
517
        var named = findTokenText(item, 'unnamed_addr') < 0;
506
518
        cleanOutTokens(LLVM.GLOBAL_MODIFIERS, item.tokens, [2, 3]);
507
519
        var external = false;
508
520
        if (item.tokens[2].text === 'external') {
516
528
          type: item.tokens[2].text,
517
529
          external: external,
518
530
          private_: private_,
 
531
          named: named,
519
532
          lineNum: item.lineNum
520
533
        };
521
534
        if (!NAMED_GLOBALS) {
694
707
    var tokensLeft = item.tokens.slice(2);
695
708
    item.ident = eatLLVMIdent(tokensLeft);
696
709
    if (item.ident == 'asm') {
 
710
      if (ASM_JS) {
 
711
        Types.hasInlineJS = true;
 
712
        warnOnce('inline JavaScript (asm, EM_ASM) will cause the code to no longer fall in the asm.js subset of JavaScript, which can reduce performance - consider using emscripten_run_script');
 
713
      }
 
714
      assert(TARGET_LE32, 'inline js is only supported in le32');
697
715
      // Inline assembly is just JavaScript that we paste into the code
698
716
      item.intertype = 'value';
699
717
      if (tokensLeft[0].text == 'sideeffect') tokensLeft.splice(0, 1);
700
718
      item.ident = tokensLeft[0].text.substr(1, tokensLeft[0].text.length-2) || ';'; // use ; for empty inline assembly
 
719
      assert((item.tokens[5].text.match(/=/g) || []).length <= 1, 'we only support at most 1 exported variable from inline js: ' + item.ident);
 
720
      var i = 0;
 
721
      var params = [], args = [];
 
722
      splitTokenList(tokensLeft[3].item.tokens).map(function(element) {
 
723
        var ident = toNiceIdent(element[1].text);
 
724
        var type = element[0].text;
 
725
        params.push('$' + (i++));
 
726
        args.push(ident);
 
727
      });
 
728
      if (item.assignTo) item.ident = 'return ' + item.ident;
 
729
      item.ident = '(function(' + params + ') { ' + item.ident + ' })(' + args + ');';
701
730
      return { forward: null, ret: [item], item: item };
702
731
    } 
703
732
    if (item.ident.substr(-2) == '()') {