diff options
31 files changed, 819 insertions, 316 deletions
@@ -92,4 +92,5 @@ a license to everyone to use it as detailed in LICENSE.) * Michael Lelli <toadking@toadking.com> * Yu Kobayashi <yukoba@accelart.jp> * Pin Zhang <zhangpin04@gmail.com> +* Nick Bray <ncbray@chromium.org> (copyright owned by Google, Inc.) @@ -462,6 +462,12 @@ Options that are modified or new in %s include: memory initialization data embedded inside JavaScript as text. (default is off) + -Wno-warn-absolute-paths If not specified, the compiler will warn about any + uses of absolute paths in -I and -L command line + directives. Pass this flag on the command line + to hide these warnings and acknowledge that the + explicit use of absolute paths is intentional. + The target file, if specified (-o <target>), defines what will be generated: @@ -735,6 +741,12 @@ try: absolute_warning_shown = False + # Scan for warning suppression message in advance from other cmdline flags, so that it works even if -I or -L directives are present before this. + for i in range(len(newargs)): + if newargs[i] == '-Wno-warn-absolute-paths': + newargs[i] = '' + absolute_warning_shown = True + settings_changes = [] def validate_arg_level(level_string, max_level, err_msg): @@ -879,7 +891,7 @@ try: elif newargs[i].startswith(('-I', '-L')): path_name = newargs[i][2:] if not absolute_warning_shown and os.path.isabs(path_name): - logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not + logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass \'-Wno-warn-absolute-paths\' to emcc to hide this warning.') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not absolute_warning_shown = True newargs = [ arg for arg in newargs if arg is not '' ] @@ -1285,6 +1297,11 @@ try: 'wctob.c', 'wctomb.c', ]], + ['stdlib', [ + 'ecvt.c', + 'fcvt.c', + 'gcvt.c', + ]], ['string', [ 'wcpcpy.c', 'wcpncpy.c', diff --git a/emscripten.py b/emscripten.py index ab68fcaa..aa47e4f1 100755 --- a/emscripten.py +++ b/emscripten.py @@ -11,7 +11,6 @@ headers, for the libc implementation in JS). import os, sys, json, optparse, subprocess, re, time, multiprocessing, string -from tools import shared from tools import jsrun, cache as cache_module, tempfiles from tools.response_file import read_response_file @@ -26,6 +25,7 @@ def get_configuration(): if hasattr(get_configuration, 'configuration'): return get_configuration.configuration + from tools import shared configuration = shared.Configuration(environ=os.environ) get_configuration.configuration = configuration return configuration @@ -469,6 +469,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, } ''' % (sig, i, args, arg_coercions, jsret)) + from tools import shared asm_setup += '\n' + shared.JS.make_invoke(sig) + '\n' basic_funcs.append('invoke_%s' % sig) @@ -807,7 +808,7 @@ WARNING: You should normally never use this! Use emcc instead. ''' if len(positional) != 1: - raise RuntimeError('Must provide exactly one positional argument.') + raise RuntimeError('Must provide exactly one positional argument. Got ' + str(len(positional)) + ': "' + '", "'.join(positional) + '"') keywords.infile = os.path.abspath(positional[0]) if isinstance(keywords.outfile, basestring): keywords.outfile = open(keywords.outfile, 'w') diff --git a/scons-tools/emscripten.py b/scons-tools/emscripten.py index 473c51ad..b4912aaa 100755 --- a/scons-tools/emscripten.py +++ b/scons-tools/emscripten.py @@ -24,6 +24,7 @@ def build_version_file(env): EMSCRIPTEN_DEPENDENCIES = [
env.Glob('${EMSCRIPTEN_HOME}/src/*.js'),
+ env.Glob('${EMSCRIPTEN_HOME}/src/embind/*.js'),
env.Glob('${EMSCRIPTEN_HOME}/tools/*.py'),
'${EMSCRIPTEN_HOME}/emscripten.py',
]
@@ -141,7 +142,7 @@ def emscripten(env, target_js, source_bc): [global_emscripten_min_js] = env.JSOptimizer(
buildName('global.min.js'),
closure_js,
- JS_OPTIMIZER_PASSES=['simplifyExpressionsPost', 'compress', 'last'])
+ JS_OPTIMIZER_PASSES=['simplifyExpressionsPost', 'minifyWhitespace', 'last'])
[emscripten_iteration_js] = env.WrapInModule(
buildName('iteration.js'),
@@ -155,8 +156,6 @@ def emscripten(env, target_js, source_bc): buildName('min.js'),
global_emscripten_min_js)
- env.InstallAs(buildName('js'), emscripten_js)
-
return [emscripten_iteration_js, emscripten_js, emscripten_min_js]
LIBC_SOURCES = [
@@ -265,9 +264,9 @@ def generate(env): )
env.Replace(
- CC='${LLVM_ROOT}/${CLANG}',
- CXX='${LLVM_ROOT}/${CLANGXX}',
- AR='${LLVM_ROOT}/${LLVM_LINK}',
+ CC=os.path.join('${LLVM_ROOT}', '${CLANG}'),
+ CXX=os.path.join('${LLVM_ROOT}', '${CLANGXX}'),
+ AR=os.path.join('${LLVM_ROOT}', '${LLVM_LINK}'),
ARCOM='$AR -o $TARGET $SOURCES',
OBJSUFFIX='.bc',
LIBPREFIX='',
@@ -301,6 +300,12 @@ def generate(env): '__IEEE_LITTLE_ENDIAN',
])
+ env.Append(
+ CPPPATH=[
+ env.Dir('${EMSCRIPTEN_HOME}/system/include'),
+ ]
+ )
+
env['BUILDERS']['Emscripten'] = Builder(
action='$PYTHON ${EMSCRIPTEN_HOME}/emscripten.py $EMSCRIPTEN_FLAGS $_EMSCRIPTEN_SETTINGS_FLAGS --temp-dir=$EMSCRIPTEN_TEMP_DIR --compiler $JS_ENGINE --relooper=third-party/relooper.js $SOURCE > $TARGET',
target_scanner=EmscriptenScanner)
diff --git a/scons-tools/llvm.py b/scons-tools/llvm.py index f272bd16..2dc65dd3 100755 --- a/scons-tools/llvm.py +++ b/scons-tools/llvm.py @@ -1,5 +1,6 @@ from SCons.Scanner.Prog import scan from SCons.Builder import Builder +import os def exists(env): return True @@ -23,11 +24,11 @@ def generate(env): LLVM_LINK='llvm-link') env['BUILDERS']['LLVMDis'] = Builder( - action='${LLVM_ROOT}/$LLVM_DIS -o=$TARGET $SOURCE') + action=os.path.join('${LLVM_ROOT}', '$LLVM_DIS') + ' -o=$TARGET $SOURCE') env['BUILDERS']['LLVMOpt'] = Builder( - action='${LLVM_ROOT}/$LLVM_OPT $LLVM_OPT_FLAGS $LLVM_OPT_PASSES -o=$TARGET $SOURCE') + action=os.path.join('${LLVM_ROOT}', '$LLVM_OPT') + ' $LLVM_OPT_FLAGS $LLVM_OPT_PASSES -o=$TARGET $SOURCE') env['BUILDERS']['LLVMLink'] = Builder( - action='${LLVM_ROOT}/$LLVM_LINK -o=$TARGET $SOURCES', + action=os.path.join('${LLVM_ROOT}', '$LLVM_LINK') + ' -o=$TARGET $SOURCES', emitter=add_libraries) diff --git a/src/intertyper.js b/src/intertyper.js index abfbdacb..dd6e5522 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -700,6 +700,12 @@ function intertyper(data, sidePass, baseLineNums) { item.intertype = 'value'; if (tokensLeft[0].text == 'sideeffect') tokensLeft.splice(0, 1); item.ident = tokensLeft[0].text.substr(1, tokensLeft[0].text.length-2) || ';'; // use ; for empty inline assembly + var i = 0; + splitTokenList(tokensLeft[3].item.tokens).map(function(element) { + var ident = toNiceIdent(element[1].text); + var type = element[0].text; + item.ident = item.ident.replace(new RegExp('\\$' + i++, 'g'), ident); + }); return { forward: null, ret: [item], item: item }; } if (item.ident.substr(-2) == '()') { diff --git a/src/library.js b/src/library.js index a73d4dc9..591d4350 100644 --- a/src/library.js +++ b/src/library.js @@ -56,7 +56,7 @@ LibraryManager.library = { // to modify the filesystem freely before run() is called. ignorePermissions: true, - ErrnoError: function (errno) { + ErrnoError: function(errno) { this.errno = errno; for (var key in ERRNO_CODES) { if (ERRNO_CODES[key] === errno) { @@ -75,19 +75,19 @@ LibraryManager.library = { // // nodes // - hashName: function (parentid, name) { + hashName: function(parentid, name) { var hash = 0; for (var i = 0; i < name.length; i++) { hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0; } return (parentid + hash) % FS.name_table.length; }, - hashAddNode: function (node) { + hashAddNode: function(node) { var hash = FS.hashName(node.parent.id, node.name); node.name_next = FS.name_table[hash]; FS.name_table[hash] = node; }, - hashRemoveNode: function (node) { + hashRemoveNode: function(node) { var hash = FS.hashName(node.parent.id, node.name); if (FS.name_table[hash] === node) { FS.name_table[hash] = node.name_next; @@ -102,7 +102,7 @@ LibraryManager.library = { } } }, - lookupNode: function (parent, name) { + lookupNode: function(parent, name) { var err = FS.mayLookup(parent); if (err) { throw new FS.ErrnoError(err); @@ -116,7 +116,7 @@ LibraryManager.library = { // if we failed to find it in the cache, call into the VFS return VFS.lookup(parent, name); }, - createNode: function (parent, name, mode, rdev) { + createNode: function(parent, name, mode, rdev) { var node = { id: FS.nextInode++, name: name, @@ -136,12 +136,12 @@ LibraryManager.library = { var readMode = {{{ cDefine('S_IRUGO') }}} | {{{ cDefine('S_IXUGO') }}}; var writeMode = {{{ cDefine('S_IWUGO') }}}; Object.defineProperty(node, 'read', { - get: function () { return (node.mode & readMode) === readMode; }, - set: function (val) { val ? node.mode |= readMode : node.mode &= ~readMode; } + get: function() { return (node.mode & readMode) === readMode; }, + set: function(val) { val ? node.mode |= readMode : node.mode &= ~readMode; } }); Object.defineProperty(node, 'write', { - get: function () { return (node.mode & writeMode) === writeMode; }, - set: function (val) { val ? node.mode |= writeMode : node.mode &= ~writeMode; } + get: function() { return (node.mode & writeMode) === writeMode; }, + set: function(val) { val ? node.mode |= writeMode : node.mode &= ~writeMode; } }); // TODO add: // isFolder @@ -149,31 +149,31 @@ LibraryManager.library = { FS.hashAddNode(node); return node; }, - destroyNode: function (node) { + destroyNode: function(node) { FS.hashRemoveNode(node); }, - isRoot: function (node) { + isRoot: function(node) { return node === node.parent; }, - isMountpoint: function (node) { + isMountpoint: function(node) { return node.mounted; }, - isFile: function (mode) { + isFile: function(mode) { return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFREG') }}}; }, - isDir: function (mode) { + isDir: function(mode) { return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFDIR') }}}; }, - isLink: function (mode) { + isLink: function(mode) { return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFLNK') }}}; }, - isChrdev: function (mode) { + isChrdev: function(mode) { return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFCHR') }}}; }, - isBlkdev: function (mode) { + isBlkdev: function(mode) { return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFBLK') }}}; }, - isFIFO: function (mode) { + isFIFO: function(mode) { return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFIFO') }}}; }, @@ -183,7 +183,7 @@ LibraryManager.library = { cwd: function() { return FS.currentPath; }, - lookupPath: function (path, opts) { + lookupPath: function(path, opts) { path = PATH.resolve(FS.currentPath, path); opts = opts || { recurse_count: 0 }; @@ -192,7 +192,7 @@ LibraryManager.library = { } // split the path - var parts = PATH.normalizeArray(path.split('/').filter(function (p) { + var parts = PATH.normalizeArray(path.split('/').filter(function(p) { return !!p; }), false); @@ -236,7 +236,7 @@ LibraryManager.library = { return { path: current_path, node: current }; }, - getPath: function (node) { + getPath: function(node) { var path; while (true) { if (FS.isRoot(node)) { @@ -268,7 +268,7 @@ LibraryManager.library = { '"xa+"': {{{ cDefine('O_APPEND') }}} | {{{ cDefine('O_CREAT') }}} | {{{ cDefine('O_RDWR') }}} | {{{ cDefine('O_EXCL') }}} }, // convert the 'r', 'r+', etc. to it's corresponding set of O_* flags - modeStringToFlags: function (str) { + modeStringToFlags: function(str) { var flags = FS.flagModes[str]; if (typeof flags === 'undefined') { throw new Error('Unknown file open mode: ' + str); @@ -276,7 +276,7 @@ LibraryManager.library = { return flags; }, // convert O_* bitmask to a string for nodePermissions - flagsToPermissionString: function (flag) { + flagsToPermissionString: function(flag) { var accmode = flag & {{{ cDefine('O_ACCMODE') }}}; var perms = ['r', 'w', 'rw'][accmode]; if ((flag & {{{ cDefine('O_TRUNC') }}})) { @@ -284,7 +284,7 @@ LibraryManager.library = { } return perms; }, - nodePermissions: function (node, perms) { + nodePermissions: function(node, perms) { if (FS.ignorePermissions) { return 0; } @@ -298,10 +298,10 @@ LibraryManager.library = { } return 0; }, - mayLookup: function (dir) { + mayLookup: function(dir) { return FS.nodePermissions(dir, 'x'); }, - mayMknod: function (mode) { + mayMknod: function(mode) { switch (mode & {{{ cDefine('S_IFMT') }}}) { case {{{ cDefine('S_IFREG') }}}: case {{{ cDefine('S_IFCHR') }}}: @@ -313,7 +313,7 @@ LibraryManager.library = { return ERRNO_CODES.EINVAL; } }, - mayCreate: function (dir, name) { + mayCreate: function(dir, name) { try { var node = FS.lookupNode(dir, name); return ERRNO_CODES.EEXIST; @@ -321,7 +321,7 @@ LibraryManager.library = { } return FS.nodePermissions(dir, 'wx'); }, - mayDelete: function (dir, name, isdir) { + mayDelete: function(dir, name, isdir) { var node; try { node = FS.lookupNode(dir, name); @@ -346,7 +346,7 @@ LibraryManager.library = { } return 0; }, - mayOpen: function (node, flags) { + mayOpen: function(node, flags) { if (!node) { return ERRNO_CODES.ENOENT; } @@ -371,7 +371,7 @@ LibraryManager.library = { // however, once opened, the stream's operations are overridden with // the operations of the device its underlying node maps back to. chrdev_stream_ops: { - open: function (stream) { + open: function(stream) { var device = FS.getDevice(stream.node.rdev); // override node's stream ops with the device's stream.stream_ops = device.stream_ops; @@ -380,23 +380,23 @@ LibraryManager.library = { stream.stream_ops.open(stream); } }, - llseek: function () { + llseek: function() { throw new FS.ErrnoError(ERRNO_CODES.ESPIPE); } }, - major: function (dev) { + major: function(dev) { return ((dev) >> 8); }, - minor: function (dev) { + minor: function(dev) { return ((dev) & 0xff); }, - makedev: function (ma, mi) { + makedev: function(ma, mi) { return ((ma) << 8 | (mi)); }, - registerDevice: function (dev, ops) { + registerDevice: function(dev, ops) { FS.devices[dev] = { stream_ops: ops }; }, - getDevice: function (dev) { + getDevice: function(dev) { return FS.devices[dev]; }, @@ -404,7 +404,7 @@ LibraryManager.library = { // streams // MAX_OPEN_FDS: 4096, - nextfd: function (fd_start, fd_end) { + nextfd: function(fd_start, fd_end) { fd_start = fd_start || 1; fd_end = fd_end || FS.MAX_OPEN_FDS; for (var fd = fd_start; fd <= fd_end; fd++) { @@ -414,46 +414,46 @@ LibraryManager.library = { } throw new FS.ErrnoError(ERRNO_CODES.EMFILE); }, - getStream: function (fd) { + getStream: function(fd) { return FS.streams[fd]; }, - createStream: function (stream, fd_start, fd_end) { + createStream: function(stream, fd_start, fd_end) { var fd = FS.nextfd(fd_start, fd_end); stream.fd = fd; // compatibility Object.defineProperty(stream, 'object', { - get: function () { return stream.node; }, - set: function (val) { stream.node = val; } + get: function() { return stream.node; }, + set: function(val) { stream.node = val; } }); Object.defineProperty(stream, 'isRead', { - get: function () { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_WRONLY') }}}; } + get: function() { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_WRONLY') }}}; } }); Object.defineProperty(stream, 'isWrite', { - get: function () { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_RDONLY') }}}; } + get: function() { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_RDONLY') }}}; } }); Object.defineProperty(stream, 'isAppend', { - get: function () { return (stream.flags & {{{ cDefine('O_APPEND') }}}); } + get: function() { return (stream.flags & {{{ cDefine('O_APPEND') }}}); } }); FS.streams[fd] = stream; return stream; }, - closeStream: function (fd) { + closeStream: function(fd) { FS.streams[fd] = null; }, // // general // - createDefaultDirectories: function () { + createDefaultDirectories: function() { VFS.mkdir('/tmp', 0777); }, - createDefaultDevices: function () { + createDefaultDevices: function() { // create /dev VFS.mkdir('/dev', 0777); // setup /dev/null FS.registerDevice(FS.makedev(1, 3), { - read: function () { return 0; }, - write: function () { return 0; } + read: function() { return 0; }, + write: function() { return 0; } }); VFS.mkdev('/dev/null', 0666, FS.makedev(1, 3)); // setup /dev/tty and /dev/tty1 @@ -468,7 +468,7 @@ LibraryManager.library = { VFS.mkdir('/dev/shm', 0777); VFS.mkdir('/dev/shm/tmp', 0777); }, - createStandardStreams: function () { + createStandardStreams: function() { // TODO deprecate the old functionality of a single // input / output callback and that utilizes FS.createDevice // and instead require a unique set of stream ops @@ -506,14 +506,14 @@ LibraryManager.library = { {{{ makeSetValue(makeGlobalUse('_stderr'), 0, 'stderr.fd', 'void*') }}}; assert(stderr.fd === 3, 'invalid handle for stderr (' + stderr.fd + ')'); }, - staticInit: function () { + staticInit: function() { FS.root = FS.createNode(null, '/', {{{ cDefine('S_IFDIR') }}} | 0777, 0); VFS.mount(MEMFS, {}, '/'); FS.createDefaultDirectories(); FS.createDefaultDevices(); }, - init: function (input, output, error) { + init: function(input, output, error) { assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)'); FS.init.initialized = true; @@ -524,7 +524,7 @@ LibraryManager.library = { FS.createStandardStreams(); }, - quit: function () { + quit: function() { FS.init.initialized = false; for (var i = 0; i < FS.streams.length; i++) { var stream = FS.streams[i]; @@ -538,24 +538,24 @@ LibraryManager.library = { // // compatibility // - getMode: function (canRead, canWrite) { + getMode: function(canRead, canWrite) { var mode = 0; if (canRead) mode |= {{{ cDefine('S_IRUGO') }}} | {{{ cDefine('S_IXUGO') }}}; if (canWrite) mode |= {{{ cDefine('S_IWUGO') }}}; return mode; }, - joinPath: function (parts, forceRelative) { + joinPath: function(parts, forceRelative) { var path = PATH.join.apply(null, parts); if (forceRelative && path[0] == '/') path = path.substr(1); return path; }, - absolutePath: function (relative, base) { + absolutePath: function(relative, base) { return PATH.resolve(base, relative); }, - standardizePath: function (path) { + standardizePath: function(path) { return PATH.normalize(path); }, - findObject: function (path, dontResolveLastLink) { + findObject: function(path, dontResolveLastLink) { var ret = FS.analyzePath(path, dontResolveLastLink); if (ret.exists) { return ret.object; @@ -564,7 +564,7 @@ LibraryManager.library = { return null; } }, - analyzePath: function (path, dontResolveLastLink) { + analyzePath: function(path, dontResolveLastLink) { // operate from within the context of the symlink's target try { var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); @@ -592,12 +592,12 @@ LibraryManager.library = { }; return ret; }, - createFolder: function (parent, name, canRead, canWrite) { + createFolder: function(parent, name, canRead, canWrite) { var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name); var mode = FS.getMode(canRead, canWrite); return VFS.mkdir(path, mode); }, - createPath: function (parent, path, canRead, canWrite) { + createPath: function(parent, path, canRead, canWrite) { parent = typeof parent === 'string' ? parent : FS.getPath(parent); var parts = path.split('/').reverse(); while (parts.length) { @@ -613,12 +613,12 @@ LibraryManager.library = { } return current; }, - createFile: function (parent, name, properties, canRead, canWrite) { + createFile: function(parent, name, properties, canRead, canWrite) { var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name); var mode = FS.getMode(canRead, canWrite); return VFS.create(path, mode); }, - createDataFile: function (parent, name, data, canRead, canWrite) { + createDataFile: function(parent, name, data, canRead, canWrite) { var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name); var mode = FS.getMode(canRead, canWrite); var node = VFS.create(path, mode); @@ -637,7 +637,7 @@ LibraryManager.library = { } return node; }, - createDevice: function (parent, name, input, output) { + createDevice: function(parent, name, input, output) { var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name); var mode = input && output ? 0777 : (input ? 0333 : 0555); if (!FS.createDevice.major) FS.createDevice.major = 64; @@ -645,16 +645,16 @@ LibraryManager.library = { // Create a fake device that a set of stream ops to emulate // the old behavior. FS.registerDevice(dev, { - open: function (stream) { + open: function(stream) { stream.seekable = false; }, - close: function (stream) { + close: function(stream) { // flush any pending line data - if (output.buffer && output.buffer.length) { + if (output && output.buffer && output.buffer.length) { output({{{ charCode('\n') }}}); } }, - read: function (stream, buffer, offset, length, pos /* ignored */) { + read: function(stream, buffer, offset, length, pos /* ignored */) { var bytesRead = 0; for (var i = 0; i < length; i++) { var result; @@ -675,7 +675,7 @@ LibraryManager.library = { } return bytesRead; }, - write: function (stream, buffer, offset, length, pos) { + write: function(stream, buffer, offset, length, pos) { for (var i = 0; i < length; i++) { try { output(buffer[offset+i]); @@ -691,7 +691,7 @@ LibraryManager.library = { }); return VFS.mkdev(path, mode, dev); }, - createLink: function (parent, name, target, canRead, canWrite) { + createLink: function(parent, name, target, canRead, canWrite) { var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name); return VFS.symlink(target, path); }, @@ -833,9 +833,9 @@ LibraryManager.library = { // override each stream op with one that tries to force load the lazy file first var stream_ops = {}; var keys = Object.keys(node.stream_ops); - keys.forEach(function (key) { + keys.forEach(function(key) { var fn = node.stream_ops[key]; - stream_ops[key] = function () { + stream_ops[key] = function() { if (!FS.forceLoadFile(node)) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } @@ -843,7 +843,7 @@ LibraryManager.library = { }; }); // use a custom read function - stream_ops.read = function (stream, buffer, offset, length, position) { + stream_ops.read = function(stream, buffer, offset, length, position) { var contents = stream.node.contents; var size = Math.min(contents.length - position, length); if (contents.slice) { // normal array @@ -911,7 +911,7 @@ LibraryManager.library = { $VFS__deps: ['$FS'], $VFS: { - mount: function (type, opts, mountpoint) { + mount: function(type, opts, mountpoint) { var mount = { type: type, opts: opts, @@ -937,11 +937,11 @@ LibraryManager.library = { } return root; }, - lookup: function (parent, name) { + lookup: function(parent, name) { return parent.node_ops.lookup(parent, name); }, // generic function for all node creation - mknod: function (path, mode, dev) { + mknod: function(path, mode, dev) { var lookup = FS.lookupPath(path, { parent: true }); var parent = lookup.node; var name = PATH.basename(path); @@ -955,21 +955,21 @@ LibraryManager.library = { return parent.node_ops.mknod(parent, name, mode, dev); }, // helpers to create specific types of nodes - create: function (path, mode) { + create: function(path, mode) { mode &= {{{ cDefine('S_IALLUGO') }}}; mode |= {{{ cDefine('S_IFREG') }}}; return VFS.mknod(path, mode, 0); }, - mkdir: function (path, mode) { + mkdir: function(path, mode) { mode &= {{{ cDefine('S_IRWXUGO') }}} | {{{ cDefine('S_ISVTX') }}}; mode |= {{{ cDefine('S_IFDIR') }}}; return VFS.mknod(path, mode, 0); }, - mkdev: function (path, mode, dev) { + mkdev: function(path, mode, dev) { mode |= {{{ cDefine('S_IFCHR') }}}; return VFS.mknod(path, mode, dev); }, - symlink: fun |