all files / lib/languages/ language.js

52.17% Statements 36/69
50% Branches 15/30
40% Functions 8/20
52.17% Lines 36/69
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123                                                           194×           194× 187×   194× 187×   194×     32638×     308×                                                                                              
(function() {
  var Language, _, _ref, _ref1, _ref2;
 
  _ = (_ref = (_ref1 = (_ref2 = typeof window !== "undefined" && window !== null ? window._ : void 0) != null ? _ref2 : typeof self !== "undefined" && self !== null ? self._ : void 0) != null ? _ref1 : typeof global !== "undefined" && global !== null ? global._ : void 0) != null ? _ref : require('lodash');
 
  module.exports = Language = (function() {
    Language.prototype.name = 'Abstract Language';
 
    Language.prototype.id = 'abstract-language';
 
    Language.prototype.parserID = 'abstract-parser';
 
    Language.prototype.runtimeGlobals = {};
 
    Language.prototype.thisValue = 'this';
 
    Language.prototype.thisValueAccess = 'this.';
 
    Language.prototype.wrappedCodeIndentLen = 0;
 
    function Language() {}
 
    Language.prototype.obviouslyCannotTranspile = function(rawCode) {
      return false;
    };
 
    Language.prototype.hasChangedASTs = function(a, b) {
      return true;
    };
 
    Language.prototype.hasChangedLineNumbers = function(a, b) {
      if (!String.prototype.trimRight) {
        String.prototype.trimRight = function() {
          return String(this).replace(/\s\s*$/, '');
        };
      }
      a = a.replace(/^[ \t]+\/\/.*/g, '').trimRight();
      b = b.replace(/^[ \t]+\/\/.*/g, '').trimRight();
      return a.split('\n').length !== b.split('\n').length;
    };
 
    Language.prototype.replaceLoops = function(rawCode) {
      console.warn("Simple loop not implemented for " + this.name);
      return [rawCode, []];
    };
 
    Language.prototype.lint = function(rawCode, aether) {
      return [];
    };
 
    Language.prototype.beautify = function(rawCode, aether) {
      return rawCode;
    };
 
    Language.prototype.wrap = function(rawCode, aether) {
      if (this.wrappedCodePrefix == null) {
        this.wrappedCodePrefix = '';
      }
      if (this.wrappedCodeSuffix == null) {
        this.wrappedCodeSuffix = '';
      }
      return this.wrappedCodePrefix + rawCode + this.wrappedCodeSuffix;
    };
 
    Language.prototype.removeWrappedIndent = function(range) {
      return range;
    };
 
    Language.prototype.hackCommonMistakes = function(rawCode, aether) {
      return rawCode;
    };
 
    Language.prototype.parse = function(code, aether) {
      throw new Error("parse() not implemented for " + this.id + ".");
    };
 
    Language.prototype.convertToNativeType = function(obj) {
      return obj;
    };
 
    Language.prototype.cloneObj = function(obj, cloneFn) {
      var k, result, v;
      if (cloneFn == null) {
        cloneFn = function(o) {
          return o;
        };
      }
      if (_.isArray(obj)) {
        result = (function() {
          var _i, _len, _results;
          _results = [];
          for (_i = 0, _len = obj.length; _i < _len; _i++) {
            v = obj[_i];
            _results.push(cloneFn(v));
          }
          return _results;
        })();
      } else if (_.isObject(obj)) {
        result = {};
        for (k in obj) {
          v = obj[k];
          result[k] = cloneFn(v);
        }
      } else {
        result = cloneFn(obj);
      }
      return result;
    };
 
    Language.prototype.pryOpenCall = function(call, val, finder) {
      return null;
    };
 
    Language.prototype.rewriteFunctionID = function(fid) {
      return fid;
    };
 
    return Language;
 
  })();
 
}).call(this);