From daeddc461166692743368eb9e68aa041f3994714 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 22 Jan 2018 11:28:02 +1100 Subject: src/l*lib.js: Use lualib.lua_assert from standard library --- src/liolib.js | 4 ++-- src/lstrlib.js | 6 +++--- src/ltablib.js | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/liolib.js b/src/liolib.js index 6a5e895..bd78f87 100644 --- a/src/liolib.js +++ b/src/liolib.js @@ -1,6 +1,5 @@ "use strict"; -const assert = require('assert'); const fs = require('fs'); const { @@ -32,6 +31,7 @@ const { luaL_setmetatable, luaL_testudata } = require('./lauxlib.js'); +const lualib = require('./lualib.js'); const { to_luastring } = require("./fengaricore.js"); const IO_PREFIX = "_IO_"; @@ -72,7 +72,7 @@ const tofile = function(L) { let p = tolstream(L); if (isclosed(p)) luaL_error(L, to_luastring("attempt to use a closed file")); - assert(p.f); + lualib.lua_assert(p.f); return p.f; }; diff --git a/src/lstrlib.js b/src/lstrlib.js index 5477750..33076ef 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -1,11 +1,11 @@ "use strict"; -const assert = require('assert'); const sprintf = require('sprintf-js').sprintf; const lauxlib = require('./lauxlib.js'); const lua = require('./lua.js'); const luaconf = require('./luaconf.js'); +const lualib = require('./lualib.js'); const {luastring_indexOf, to_jsstring, to_luastring} = require("./fengaricore.js"); const sL_ESC = '%'; @@ -724,7 +724,7 @@ const unpackint = function(L, str, islittle, size, issigned) { }; const unpacknum = function(L, b, islittle, size) { - assert(b.length >= size); + lualib.lua_assert(b.length >= size); let dv = new DataView(new ArrayBuffer(size)); for (let i = 0; i < size; i++) @@ -1148,7 +1148,7 @@ const prepstate = function(ms, L, s, ls, p, lp) { const reprepstate = function(ms) { ms.level = 0; - assert(ms.matchdepth === MAXCCALLS); + lualib.lua_assert(ms.matchdepth === MAXCCALLS); }; const find_subarray = function(arr, subarr, from_index) { diff --git a/src/ltablib.js b/src/ltablib.js index a24a275..6d3eeb2 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -1,10 +1,9 @@ "use strict"; -const assert = require('assert'); - const lua = require('./lua.js'); const lauxlib = require('./lauxlib.js'); const luaconf = require('./luaconf.js'); +const lualib = require('./lualib.js'); const {to_luastring} = require("./fengaricore.js"); /* @@ -234,7 +233,7 @@ const partition = function(L, lo, up) { const choosePivot = function(lo, up, rnd) { let r4 = Math.floor((up - lo) / 4); /* range/4 */ let p = rnd % (r4 * 2) + (lo + r4); - assert(lo + r4 <= p && p <= up - r4); + lualib.lua_assert(lo + r4 <= p && p <= up - r4); return p; }; -- cgit v1.2.3-70-g09d2