See More

// Copyright 2010 The Emscripten Authors. All rights reserved. // Emscripten is available under two separate licenses, the MIT license and the // University of Illinois/NCSA Open Source License. Both these licenses can be // found in the LICENSE file. // // Various tools for parsing LLVM. Utilities of various sorts, that are // specific to Emscripten (and hence not in utility.js). //"use strict"; // Does simple 'macro' substitution, using Django-like syntax, // {{{ code }}} will be replaced with |eval(code)|. // NOTE: Be careful with that ret check. If ret is |0|, |ret ? ret.toString() : ''| would result in ''! function processMacros(text) { return text.replace(/{{{([^}]|}(?!}))+}}}/g, function(str) { str = str.substr(3, str.length-6); var ret = eval(str); return ret !== null ? ret.toString() : ''; }); } // Simple #if/else/endif preprocessing for a file. Checks if the // ident checked is true in our global. // Also handles #include x.js (similar to C #include ) // Param filenameHint can be passed as a description to identify the file that is being processed, used // to locate errors for reporting and for html files to stop expansion between . function preprocess(text, filenameHint) { var fileExt = (filenameHint) ? filenameHint.split('.').pop().toLowerCase() : ""; var isHtml = (fileExt === 'html' || fileExt === 'htm') ? true : false; var inStyle = false; var lines = text.split('\n'); var ret = ''; var showStack = []; for (var i = 0; i < lines.length; i++) { var line = lines[i]; try { if (line[line.length-1] === '\r') { line = line.substr(0, line.length-1); // Windows will have '\r' left over from splitting over '\r\n' } if (isHtml && line.indexOf('