From c2b1d402130c1ebd4d421a264b912f7fc0c16ea1 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Thu, 8 Jul 2021 18:06:37 -0400 Subject: [PATCH 01/61] interop: minor cleanup --- racketscript-compiler/racketscript/interop.rkt | 7 +++---- racketscript-compiler/racketscript/private/interop.rkt | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/racketscript-compiler/racketscript/interop.rkt b/racketscript-compiler/racketscript/interop.rkt index 6b3f4c02..ef492c27 100644 --- a/racketscript-compiler/racketscript/interop.rkt +++ b/racketscript-compiler/racketscript/interop.rkt @@ -32,12 +32,11 @@ for/js-object js-object?) -(require (for-syntax (for-template "private/interop.rkt") - racket/base +(require (for-syntax racket/base racket/string syntax/stx - threading - "private/interop.rkt") + threading) + "private/interop.rkt" syntax/parse/define) (begin-for-syntax diff --git a/racketscript-compiler/racketscript/private/interop.rkt b/racketscript-compiler/racketscript/private/interop.rkt index 2ae15788..224f6d9f 100644 --- a/racketscript-compiler/racketscript/private/interop.rkt +++ b/racketscript-compiler/racketscript/private/interop.rkt @@ -15,6 +15,12 @@ ;; + 'object ;; + 'array ;; + 'require + ;; + 'this + ;; + 'typeof + ;; + 'instanceof + ;; + 'string + ;; + 'arguments + ;; + 'operator (define-values (#%js-ffi) (lambda _ (#%app error 'racketscript "can't make JS ffi calls in Racket")))) From c46fee9f6f628794ff89241cd8d4df4ee4100194 Mon Sep 17 00:00:00 2001 From: Vishesh Yadav Date: Tue, 13 Jul 2021 21:53:26 -0700 Subject: [PATCH 02/61] Add hamt.js license Forgot to add the license clause when moved HAMT from NPM package to its own file here. --- .../racketscript/compiler/runtime/core/hamt.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/hamt.js b/racketscript-compiler/racketscript/compiler/runtime/core/hamt.js index 6bec5955..b690cd8d 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/hamt.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/hamt.js @@ -1,4 +1,6 @@ - +// Copyright (C) 2016-2021 Matt Bierner, RacketScript Authors +// +// Original source and copyright clause: https://github.com/mattbierner/hamt_plus const _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function (obj) { return typeof obj; } From 58a16637958dd69d3b7cb7be8fbba66238003859 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Sun, 1 Aug 2021 18:26:19 -0400 Subject: [PATCH 03/61] Swap out Symbol.js with PrimitiveSymbol.js Fixes #249 PrimitiveSymbol extends PrintablePrimative and wraps native JS Symbols. --- .../racketscript/compiler/runtime/core.js | 55 ++++------- .../compiler/runtime/core/marks.js | 35 +++---- .../compiler/runtime/core/primitive_symbol.js | 75 +++++++++++++++ .../compiler/runtime/core/symbol.js | 53 ----------- .../racketscript/compiler/runtime/kernel.js | 93 ++++++++++++------- .../racketscript/compiler/runtime/kernel.rkt | 12 +-- .../racketscript/compiler/transform.rkt | 2 +- 7 files changed, 179 insertions(+), 146 deletions(-) create mode 100644 racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js delete mode 100644 racketscript-compiler/racketscript/compiler/runtime/core/symbol.js diff --git a/racketscript-compiler/racketscript/compiler/runtime/core.js b/racketscript-compiler/racketscript/compiler/runtime/core.js index 126e8980..5d2fe6ef 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core.js @@ -12,8 +12,8 @@ import * as Number from './core/numbers.js'; import * as Pair from './core/pair.js'; import * as Ports from './core/ports.js'; import * as Primitive from './core/primitive.js'; +import * as PrimitiveSymbol from './core/primitive_symbol.js'; import * as Struct from './core/struct.js'; -import * as Symbol from './core/symbol.js'; import * as Values from './core/values.js'; import * as Vector from './core/vector.js'; import * as Marks from './core/marks.js'; @@ -22,7 +22,6 @@ import * as Correlated from './core/correlated.js'; import * as Linklet from './core/linklet.js'; import * as Path from './core/path.js'; - export { Bytes, Number, @@ -30,7 +29,7 @@ export { Pair, Primitive, Struct, - Symbol, + PrimitiveSymbol, Keyword, Values, Vector, @@ -46,10 +45,7 @@ export { Path }; -export { - argumentsToArray, - argumentsSlice -} from './core/lib.js'; +export { argumentsToArray, argumentsSlice } from './core/lib.js'; export { racketCoreError, @@ -64,28 +60,13 @@ export { errMsg } from './core/errors.js'; -export { - attachProcedureArity, - attachProcedureName -} from './core/procedure.js'; +export { attachProcedureArity, attachProcedureName } from './core/procedure.js'; -export { - isEq, - isEqv, - isEqual -} from './core/equality.js'; +export { isEq, isEqv, isEqual } from './core/equality.js'; -export { - hashForEq, - hashForEqv, - hashForEqual -} from './core/hashing.js'; +export { hashForEq, hashForEqv, hashForEqual } from './core/hashing.js'; -export { - display, - write, - print -} from './core/printing.js'; +export { display, write, print } from './core/printing.js'; // ;----------------------------------------------------------------------------- @@ -95,40 +76,40 @@ export function bitwiseNot(a) { class UnsafeUndefined extends PrintablePrimitive { equals(v) { - return (v === this); + return v === this; } /** - * @return {!number} a 32-bit integer - */ + * @return {!number} a 32-bit integer + */ hashForEqual() { return 0; } /** - * @param {!Ports.NativeStringOutputPort} out - */ + * @param {!Ports.NativeStringOutputPort} out + */ displayNativeString(out) { out.consume('#'); } /** - * @param {!Ports.UStringOutputPort} out - */ + * @param {!Ports.UStringOutputPort} out + */ displayUString(out) { out.consume('#'); } /** - * @param {!Ports.NativeStringOutputPort} out - */ + * @param {!Ports.NativeStringOutputPort} out + */ writeNativeString(out) { out.consume('#'); } /** - * @param {!Ports.UStringOutputPort} out - */ + * @param {!Ports.UStringOutputPort} out + */ writeUString(out) { out.consume('#'); } diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/marks.js b/racketscript-compiler/racketscript/compiler/runtime/core/marks.js index f589b3b6..6177189d 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/marks.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/marks.js @@ -1,14 +1,13 @@ // Continuation Marks import * as Pair from './pair.js'; -import * as Symbol from './symbol.js'; +import * as PrimitiveSymbol from './primitive_symbol.js'; import { racketCoreError } from './errors.js'; import { hashForEq as HASH } from './hashing.js'; let __frames; const __prompts = new Map(); const __asyncCallbackWrappers = []; -const __defaultContinuationPromptTag - = makeContinuationPromptTag(Symbol.make('default')); +const __defaultContinuationPromptTag = makeContinuationPromptTag(PrimitiveSymbol.make('default')); /* --------------------------------------------------------------------------*/ @@ -46,11 +45,11 @@ export function AbortCurrentContinuation(promptTag, handlerArgs) { this.promptTag = promptTag; this.handlerArgs = handlerArgs; - this.stack = (new Error()).stack; + this.stack = new Error().stack; if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { - this.stack = (new Error()).stack; + this.stack = new Error().stack; } } AbortCurrentContinuation.prototype = Object.create(Error.prototype); @@ -82,8 +81,7 @@ function getPromptFrame(promptTag) { return promptTag; } const result = __prompts.get(promptTag); - return (result && result[result.length - 1]) - || undefined; + return (result && result[result.length - 1]) || undefined; } export function makeContinuationPromptTag(sym) { @@ -100,8 +98,7 @@ export function callWithContinuationPrompt(proc, promptTag, handler, ...args) { savePrompt(promptTag); return proc(...args); } catch (e) { - if (e instanceof AbortCurrentContinuation && - e.promptTag === promptTag) { + if (e instanceof AbortCurrentContinuation && e.promptTag === promptTag) { return handler(...e.handlerArgs); } throw e; @@ -139,8 +136,10 @@ export function getContinuationMarks(promptTag) { promptTag = promptTag || __defaultContinuationPromptTag; let frames = __frames; const promptFrame = getPromptFrame(promptTag); - if (promptFrame === undefined && - promptTag !== __defaultContinuationPromptTag) { + if ( + promptFrame === undefined && + promptTag !== __defaultContinuationPromptTag + ) { throw racketCoreError('No corresponding tag in continuation!'); } @@ -162,7 +161,7 @@ export function getMarks(framesArr, key, promptTag) { const result = []; for (let ii = 0; ii < framesArr.length; ++ii) { - // FIXME: for-of requires polyfill + // FIXME: for-of requires polyfill const fr = framesArr[ii]; if (keyHash in fr) { if (fr === promptFrame) { @@ -178,11 +177,13 @@ export function getMarks(framesArr, key, promptTag) { // and parameterization and check if that if this needs export function getFirstMark(frames, key, noneV) { const keyHash = HASH(key); - return Pair.listFind(frames, (fr) => { - if (keyHash in fr) { - return fr[keyHash]; - } - }) || noneV; + return ( + Pair.listFind(frames, (fr) => { + if (keyHash in fr) { + return fr[keyHash]; + } + }) || noneV + ); } export function wrapWithContext(fn) { diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js b/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js new file mode 100644 index 00000000..7c6a2379 --- /dev/null +++ b/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js @@ -0,0 +1,75 @@ +import { PrintablePrimitive } from './printable_primitive.js'; + +let counter = 0; + +class PrimitiveSymbol extends PrintablePrimitive { + constructor(name) { + super(name); + + if (name) { + // interned + this.name = name; + this.sym = Symbol.for(name); + } else { + // uninterned + this.sym = Symbol(`_${counter++}`); + } + } + + get isInterned() { + return Boolean(this.name); + } + + get value() { + return this.sym; + } + + equals(s) { + if (s.sym) { + return s.value === this.value; + } + return s === this.value; + } + + le(s) { + if (s === this) { + return false; + } + return this.value < s.value; + } + + /* String printing */ + + [Symbol.toPrimitive](hint) { + if (hint === 'number') { + return 0; + } + return this.toString(); + } + + toString() { + return Symbol.keyFor(this.sym); + } + + displayNativeString(out) { + out.consume(this.toString()); + } + + // Adds the quote character before the value, ex: 'sym + printNativeString(out) { + out.consume("'"); + this.writeNativeString(out); + } +} + +export function make(v) { + return new PrimitiveSymbol(v); +} + +export function makeUninterned() { + return new PrimitiveSymbol(); +} + +export function check(v) { + return v instanceof PrimitiveSymbol; +} diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/symbol.js b/racketscript-compiler/racketscript/compiler/runtime/core/symbol.js deleted file mode 100644 index d13c5cd6..00000000 --- a/racketscript-compiler/racketscript/compiler/runtime/core/symbol.js +++ /dev/null @@ -1,53 +0,0 @@ -import { PrintablePrimitive } from './printable_primitive.js'; -import { internedMake } from './lib.js'; - -class Symbol extends PrintablePrimitive { - constructor(v) { - super(); - this.v = v; - this._cachedHashCode = null; - } - - /** - * @param {!Ports.NativeStringOutputPort} out - */ - displayNativeString(out) { - out.consume(this.v); - } - - equals(v) { - // Symbols are interned by default, and two symbols - // with same name can't be unequal. - // Eg. (define x (gensym)) ;;=> 'g60 - // (equal? x 'g60) ;;=> #f - // TODO: does this handle uninterned symbols? - return v === this; - } - - lt(v) { - if (v === this) { - return false; - } - return this.v < v.v; - } - - /** - * @return {!number} - */ - hashForEqual() { - if (this._cachedHashCode === null) { - this._cachedHashCode = super.hashForEqual(); - } - return this._cachedHashCode; - } -} - - -export const make = internedMake(v => new Symbol(v.toString())); - -// TODO: is it correct to convert toString()? -export const makeUninterned = v => new Symbol(v.toString()); - -export function check(v) { - return (v instanceof Symbol); -} diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.js b/racketscript-compiler/racketscript/compiler/runtime/kernel.js index 71448b1b..dbe49beb 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.js +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.js @@ -9,8 +9,12 @@ export function isImmutable(v) { return v.isImmutable(); } else if (Core.Bytes.check(v) || typeof v === 'string') { return true; - } else if (typeof v === 'number' || typeof v === 'boolean' || - typeof v === 'undefined' || v === null) { + } else if ( + typeof v === 'number' || + typeof v === 'boolean' || + typeof v === 'undefined' || + v === null + ) { return false; } throw Core.racketCoreError('isImmutable not implemented for', v); @@ -33,20 +37,31 @@ export function fprintf(isPrintAsExpression, out, form, ...args) { let lastMatch = ''; const matches = formStr.match(regex); - const numExpected = matches ? - matches.filter(m => !NO_ARG_FORM_RE.test(m)).length : 0; + const numExpected = matches + ? matches.filter(m => !NO_ARG_FORM_RE.test(m)).length + : 0; if (numExpected !== args.length) { - throw Core.racketContractError(`fprintf: format string requires ${numExpected} arguments, ` + - `given ${args.length}; arguments were:`, out, form, ...args); + throw Core.racketContractError( + `fprintf: format string requires ${numExpected} arguments, ` + + `given ${args.length}; arguments were:`, + out, + form, + ...args + ); } // eslint-disable-next-line no-cond-assign while ((reExecResult = regex.exec(formStr)) !== null) { - Core.display(out, formStr.slice(prevIndex + lastMatch.length, reExecResult.index)); + Core.display( + out, + formStr.slice(prevIndex + lastMatch.length, reExecResult.index) + ); prevIndex = reExecResult.index; lastMatch = reExecResult[0]; // eslint-disable-line prefer-destructuring if (/^~\s/.test(lastMatch)) continue; // eslint-disable-line no-continue - switch (lastMatch.charAt(1)) { // eslint-disable-line default-case + switch ( + lastMatch.charAt(1) // eslint-disable-line default-case + ) { case '~': Core.display(out, '~'); continue; // eslint-disable-line no-continue @@ -76,17 +91,17 @@ export function fprintf(isPrintAsExpression, out, form, ...args) { break; case 'b': case 'B': - // TODO: raise exn:fail:contract if the number is not exact. + // TODO: raise exn:fail:contract if the number is not exact. Core.display(out, v.toString(2)); break; case 'o': case 'O': - // TODO: raise exn:fail:contract if the number is not exact. + // TODO: raise exn:fail:contract if the number is not exact. Core.display(out, v.toString(8)); break; case 'x': case 'X': - // TODO: raise exn:fail:contract if the number is not exact. + // TODO: raise exn:fail:contract if the number is not exact. Core.display(out, v.toString(16)); break; default: @@ -119,11 +134,11 @@ export function listToString(charsList) { // Errors /** - * @param {Core.Symbol|Core.UString|String} firstArg + * @param {Core.PrimitiveSymbol|Core.UString|String} firstArg * @param {*[]} rest */ export function error(firstArg, ...rest) { - if (Core.Symbol.check(firstArg)) { + if (Core.PrimitiveSymbol.check(firstArg)) { if (rest.length === 0) { throw Core.racketCoreError(firstArg.toString()); } else { @@ -153,7 +168,7 @@ export function doraise(e) { } /** - * @param {Core.Symbol} name + * @param {Core.PrimitiveSymbol} name * @param {Core.UString|String} expected * @param {*[]} rest */ @@ -163,9 +178,11 @@ export function doraise(e) { // (raise-argument-error name expected bad-pos arg ...) export function argerror(name, expected, ...rest) { let theerr; - if (Core.Symbol.check(name) - && (Core.UString.check(expected) || typeof expected === 'string') - && rest.length >= 1) { + if ( + Core.PrimitiveSymbol.check(name) && + (Core.UString.check(expected) || typeof expected === 'string') && + rest.length >= 1 + ) { theerr = Core.makeArgumentError(name, expected, ...rest); } else { theerr = Core.racketContractError('raise-argument-error: invalid arguments'); @@ -175,7 +192,7 @@ export function argerror(name, expected, ...rest) { } /** - * @param {Core.Symbol} name + * @param {Core.PrimitiveSymbol} name * @param {Core.UString|String} expected * @param {*[]} rest */ @@ -185,9 +202,11 @@ export function argerror(name, expected, ...rest) { // (raise-result-error name expected bad-pos arg ...) export function resulterror(name, expected, ...rest) { let theerr; - if (Core.Symbol.check(name) - && (Core.UString.check(expected) || typeof expected === 'string') - && rest.length >= 1) { + if ( + Core.PrimitiveSymbol.check(name) && + (Core.UString.check(expected) || typeof expected === 'string') && + rest.length >= 1 + ) { theerr = Core.makeResultError(name, expected, ...rest); } else { theerr = Core.racketContractError('raise-result-error: invalid result'); @@ -197,7 +216,7 @@ export function resulterror(name, expected, ...rest) { } /** - * @param {Core.Symbol} name + * @param {Core.PrimitiveSymbol} name * @param {Core.UString|String} msg * @param {Core.UString|String} field * @param {*[]} rest @@ -206,10 +225,13 @@ export function resulterror(name, expected, ...rest) { // so rest must be at least 1 and must be odd bc each field must have matching v export function argserror(name, msg, field, ...rest) { let theerr; - if (Core.Symbol.check(name) - && (Core.UString.check(msg) || typeof msg === 'string') - && (Core.UString.check(field) || typeof field === 'string') - && rest.length >= 1 && rest.length % 2 === 1) { + if ( + Core.PrimitiveSymbol.check(name) && + (Core.UString.check(msg) || typeof msg === 'string') && + (Core.UString.check(field) || typeof field === 'string') && + rest.length >= 1 && + rest.length % 2 === 1 + ) { theerr = Core.makeArgumentsError(name, msg, field, ...rest); } else { theerr = Core.racketContractError('raise-arguments-error: invalid arguments'); @@ -219,7 +241,7 @@ export function argserror(name, msg, field, ...rest) { } /** - * @param {Core.Symbol} name + * @param {Core.PrimitiveSymbol} name * @param {Core.UString|String} msg * @param {*[]} rest */ @@ -228,8 +250,10 @@ export function argserror(name, msg, field, ...rest) { // so ...rst might have additional msg, v ... export function mismatcherror(name, msg, ...rest) { let theerr; - if (Core.Symbol.check(name) - && (Core.UString.check(msg) || typeof msg === 'string')) { + if ( + Core.PrimitiveSymbol.check(name) && + (Core.UString.check(msg) || typeof msg === 'string') + ) { theerr = Core.makeMismatchError(name, msg, ...rest); } else { theerr = Core.racketContractError('error: invalid arguments'); @@ -249,8 +273,12 @@ export function mismatcherror(name, msg, ...rest) { // usage: raise-range-error name, type, v len, i export function outofrangeerror(name, type, v, len, i) { let theerr; - if (typeof name === 'string' && typeof type === 'string' && - typeof len === 'number' && typeof i === 'number') { + if ( + typeof name === 'string' && + typeof type === 'string' && + typeof len === 'number' && + typeof i === 'number' + ) { theerr = Core.makeOutOfRangeError(name, type, v, len, i); } else { theerr = Core.racketContractError('error: invalid arguments'); @@ -264,7 +292,8 @@ export function outofrangeerror(name, type, v, len, i) { export function random(...args) { switch (args.length) { - case 0: return Math.random(); + case 0: + return Math.random(); case 1: if (args[0] > 0) { return Math.floor(Math.random() * args[0]); diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 87478b32..177b2893 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -780,7 +780,7 @@ (apply fprintf out form args) (get-output-string out))) -(define+provide symbol? #js.Core.Symbol.check) +(define+provide symbol? #js.Core.PrimitiveSymbol.check) (define+provide keyword? #js.Core.Keyword.check) (define+provide (make-string k [c #\nul]) @@ -796,14 +796,14 @@ (#js.Core.UString.makeMutable (#js.v.toString))) (define-checked+provide (string->symbol [s string?]) - (#js.Core.Symbol.make s)) + (#js.Core.PrimitiveSymbol.make s)) (define-checked+provide (string->uninterned-symbol [s string?]) - (#js.Core.Symbol.makeUninterned s)) + (#js.Core.PrimitiveSymbol.makeUninterned s)) ;; TODO: implement unreadable symbols (define-checked+provide (string->unreadable-symbol [s string?]) - (#js.Core.Symbol.make s)) + (#js.Core.PrimitiveSymbol.make s)) ; Does not support prefixed forms such as "#b101". (define+provide (string->number s [radix 10]) @@ -822,7 +822,7 @@ (define-checked+provide (symbol-interned? [sym symbol?]) ;;NOTE: We simply check if given symbol is equal to an ;; interned symbol. - (binop === sym (#js.Core.Symbol.make #js.sym.v))) + (#js.sym.isInterned)) (define+provide (symbol=? s v) (#js.s.equals v)) @@ -1265,7 +1265,7 @@ (v-λ (sym) #:unchecked (let ([s (or (and sym #js.sym.v) "")]) (set! __count (binop + __count 1)) - (#js.Core.Symbol.makeUninterned (binop + s __count))))) + (#js.Core.PrimitiveSymbol.makeUninterned (binop + s __count))))) (define+provide (eval-jit-enabled) #f) diff --git a/racketscript-compiler/racketscript/compiler/transform.rkt b/racketscript-compiler/racketscript/compiler/transform.rkt index 4c85c976..baf589b6 100644 --- a/racketscript-compiler/racketscript/compiler/transform.rkt +++ b/racketscript-compiler/racketscript/compiler/transform.rkt @@ -615,7 +615,7 @@ (ILApp (name-in-module 'core 'UString.make) (list (ILValue d)))] [(symbol? d) - (ILApp (name-in-module 'core 'Symbol.make) + (ILApp (name-in-module 'core 'PrimitiveSymbol.make) (list (ILValue (symbol->string d))))] [(keyword? d) (ILApp (name-in-module 'core 'Keyword.make) From e77c948b2c1ba6a064f65849142f07287eaead16 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Sun, 1 Aug 2021 21:33:15 -0400 Subject: [PATCH 04/61] Updates hash equality checks to handle PrimitiveSymbol --- .../compiler/runtime/core/equality.js | 14 ++++++++++---- .../compiler/runtime/core/primitive_symbol.js | 17 ++++++++++++++--- .../racketscript/compiler/runtime/kernel.rkt | 4 +--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/equality.js b/racketscript-compiler/racketscript/compiler/runtime/core/equality.js index 6bb6b80a..3af8dfec 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/equality.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/equality.js @@ -1,4 +1,5 @@ import * as Primitive from './primitive.js'; +import * as PrimitiveSymbol from './primitive_symbol.js'; import * as Char from './char.js'; import * as Bytes from './bytes.js'; @@ -8,6 +9,10 @@ import * as Bytes from './bytes.js'; * @return {!boolean} */ export function isEq(v1, v2) { + // Handle Symbols + if (PrimitiveSymbol.check(v1)) { + return v1.equals(v2); + } return v1 === v2; } @@ -17,12 +22,13 @@ export function isEq(v1, v2) { * @return {!boolean} */ export function isEqv(v1, v2) { - // NOTE: We are not handling special case for Symbol. - // Symbols and keywords are interned, so that's ok. + // Handle Symbols + if (PrimitiveSymbol.check(v1)) { + return v1.equals(v2); + } // TODO: Handle numbers correctly. - return v1 === v2 || - Char.check(v1) && Char.check(v2) && Char.eq(v1, v2); + return v1 === v2 || (Char.check(v1) && Char.check(v2) && Char.eq(v1, v2)); } /** diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js b/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js index 7c6a2379..7165be6e 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js @@ -51,19 +51,23 @@ class PrimitiveSymbol extends PrintablePrimitive { return Symbol.keyFor(this.sym); } + displayUString(out) { + out.consume(Symbol.keyFor(this.sym)); + } + displayNativeString(out) { - out.consume(this.toString()); + out.consume(Symbol.keyFor(this.sym)); } // Adds the quote character before the value, ex: 'sym - printNativeString(out) { + printUString(out) { out.consume("'"); this.writeNativeString(out); } } export function make(v) { - return new PrimitiveSymbol(v); + return new PrimitiveSymbol(v ? v.toString() : ''); } export function makeUninterned() { @@ -73,3 +77,10 @@ export function makeUninterned() { export function check(v) { return v instanceof PrimitiveSymbol; } + +export function isInterned(v) { + if (check(v)) { + return v.isInterned; + } + return false; +} diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 177b2893..58b7fdd3 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -820,9 +820,7 @@ result))) (define-checked+provide (symbol-interned? [sym symbol?]) - ;;NOTE: We simply check if given symbol is equal to an - ;; interned symbol. - (#js.sym.isInterned)) + (#js.Core.PrimitiveSymbol.isInterned sym)) (define+provide (symbol=? s v) (#js.s.equals v)) From 9182e979cb8ab183e9d838591d222dde3ad8ab0b Mon Sep 17 00:00:00 2001 From: DarrenN Date: Sun, 1 Aug 2021 21:37:51 -0400 Subject: [PATCH 05/61] Adds check for PrimitiveSymbol to correctly compute a hash --- .../compiler/runtime/core/raw_hashing.js | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js b/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js index 279a7b3c..5784d5bd 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js @@ -14,14 +14,21 @@ */ export function hash(o) { if (o === null) return 0; + if (o.sym) return hashString(`sym_${o}`); switch (typeof o) { - case 'number': return hashNumber(o); - case 'string': return hashString(o); - case 'boolean': return o ? 1 : -1; - case 'undefined': return 0; + case 'number': + return hashNumber(o); + case 'string': + return hashString(o); + case 'boolean': + return o ? 1 : -1; + case 'undefined': + return 0; case 'object': - case 'function': return hashObjectIdentity(o); - default: return hashString(o.toString()); + case 'function': + return hashObjectIdentity(o); + default: + return hashString(o.toString()); } } @@ -37,9 +44,9 @@ export function hashString(s) { let h = 0; const n = s.length; for (let i = 0; i < n; ++i) { - // Benchmarks of various ways to do this: - // https://run.perf.zone/view/String-Hashing-Performance-1504040177726 - h = ~~(((h << 5) - h) + s.charCodeAt(i)); + // Benchmarks of various ways to do this: + // https://run.perf.zone/view/String-Hashing-Performance-1504040177726 + h = ~~((h << 5) - h + s.charCodeAt(i)); } return h; } @@ -66,8 +73,8 @@ export function hashNumber(n) { // This slightly increases the potential number of collisions // with large numbers and floats, but increases the performance by 20%. if (~~n === n) { - // If `n` is -0, the above check will pass. - // `~~` is here only to convert the potential -0 to 0. + // If `n` is -0, the above check will pass. + // `~~` is here only to convert the potential -0 to 0. return ~~n; } kBufAsF64[0] = n; @@ -114,7 +121,7 @@ export function hashIntArray(a) { let h = 0; const n = a.length; for (let i = 0; i < n; ++i) { - h = ~~(((h << 5) - h) + a[i]); + h = ~~((h << 5) - h + a[i]); } return h; } @@ -134,7 +141,7 @@ export function hashArray(a, valueToIntFn) { let h = 0; const n = a.length; for (let i = 0; i < n; ++i) { - h = ~~(((h << 5) - h) + valueToIntFn(a[i])); + h = ~~((h << 5) - h + valueToIntFn(a[i])); } return h; } From a04b64a994c8aaefc0aa3ef604d2647603535f67 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Mon, 2 Aug 2021 15:04:35 -0400 Subject: [PATCH 06/61] Updates toString and hashing methods for PrimitiveSymbol --- .../compiler/runtime/core/primitive_symbol.js | 19 ++++++++++++------- .../compiler/runtime/core/raw_hashing.js | 2 +- tests/racket-core/hash.rkt | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js b/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js index 7165be6e..35d44322 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js @@ -1,4 +1,5 @@ import { PrintablePrimitive } from './printable_primitive.js'; +import { hashString } from './raw_hashing.js'; let counter = 0; @@ -31,11 +32,15 @@ class PrimitiveSymbol extends PrintablePrimitive { return s === this.value; } - le(s) { + lt(s) { if (s === this) { return false; } - return this.value < s.value; + return this.toString() < s.toString(); + } + + hashForEqual() { + return hashString(this.toString()); } /* String printing */ @@ -47,16 +52,16 @@ class PrimitiveSymbol extends PrintablePrimitive { return this.toString(); } - toString() { - return Symbol.keyFor(this.sym); - } - displayUString(out) { out.consume(Symbol.keyFor(this.sym)); } displayNativeString(out) { - out.consume(Symbol.keyFor(this.sym)); + if (this.isInterned) { + out.consume(Symbol.keyFor(this.sym)); + } else { + out.consume(this.sym.toString()); + } } // Adds the quote character before the value, ex: 'sym diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js b/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js index 5784d5bd..e3b5add7 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js @@ -14,7 +14,7 @@ */ export function hash(o) { if (o === null) return 0; - if (o.sym) return hashString(`sym_${o}`); + if (o.sym) return hashString(`sym_${o.toString()}`); switch (typeof o) { case 'number': return hashNumber(o); diff --git a/tests/racket-core/hash.rkt b/tests/racket-core/hash.rkt index 47fe585a..49bcd32f 100644 --- a/tests/racket-core/hash.rkt +++ b/tests/racket-core/hash.rkt @@ -82,8 +82,9 @@ #"apple" 'a #"banana" 'b #"coconut" 'c u/apple 'a u/banana 'b u/coconut 'c ;; TODO: properly implement unreadable symbols + 'apple 'banana 'coconut 'coconut+ ; apple 'a banana 'b coconut 'c - 'apple 'a 'banana 'b 'coconut 'c 'coconut+ '+ + ;'apple 'a 'banana 'b 'coconut 'c 'coconut+ '+ '#:apple 'a '#:banana 'b '#:coconut 'c null 'one (void) 'one From 1a4f747181bdc05682e0d9daab0f484a446922b2 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Mon, 2 Aug 2021 15:59:54 -0400 Subject: [PATCH 07/61] Fixes how makeOutOfRangeError calculates the range for messaging Was breaking integration tests for basic/bytes.rkt --- .../racketscript/compiler/runtime/core/errors.js | 2 +- .../compiler/runtime/core/primitive_symbol.js | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/errors.js b/racketscript-compiler/racketscript/compiler/runtime/core/errors.js index b4d0072c..a4e15e3d 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/errors.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/errors.js @@ -186,7 +186,7 @@ export function makeOutOfRangeError(name, type, v, len, i) { stringOut.consume(i.toString()); stringOut.consume('\n'); stringOut.consume(' valid range: [0, '); - stringOut.consume((len - 1).toString()); + stringOut.consume(len.toString()); stringOut.consume(']\n'); stringOut.consume(' '); stringOut.consume(type); diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js b/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js index 35d44322..266e36ef 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/primitive_symbol.js @@ -5,7 +5,7 @@ let counter = 0; class PrimitiveSymbol extends PrintablePrimitive { constructor(name) { - super(name); + super(); if (name) { // interned @@ -52,10 +52,6 @@ class PrimitiveSymbol extends PrintablePrimitive { return this.toString(); } - displayUString(out) { - out.consume(Symbol.keyFor(this.sym)); - } - displayNativeString(out) { if (this.isInterned) { out.consume(Symbol.keyFor(this.sym)); @@ -63,12 +59,6 @@ class PrimitiveSymbol extends PrintablePrimitive { out.consume(this.sym.toString()); } } - - // Adds the quote character before the value, ex: 'sym - printUString(out) { - out.consume("'"); - this.writeNativeString(out); - } } export function make(v) { From aabf1ad78f2b3bc1938631ea2fd81dbe9a0adb38 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Mon, 2 Aug 2021 16:47:12 -0400 Subject: [PATCH 08/61] Correct test in transform.rkt Test was still expecting Core.Symbol instead of Core.PrimitiveSymbol --- racketscript-compiler/racketscript/compiler/transform.rkt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/racketscript-compiler/racketscript/compiler/transform.rkt b/racketscript-compiler/racketscript/compiler/transform.rkt index baf589b6..4a91b27a 100644 --- a/racketscript-compiler/racketscript/compiler/transform.rkt +++ b/racketscript-compiler/racketscript/compiler/transform.rkt @@ -894,7 +894,7 @@ (: ~sym (-> Symbol ILExpr)) (define (~sym s) (ILApp - (name-in-module 'core 'Symbol.make) (list (ILValue (symbol->string s))))) + (name-in-module 'core 'PrimitiveSymbol.make) (list (ILValue (symbol->string s))))) (: ~cons (-> ILExpr ILExpr ILExpr)) (define (~cons a b) From 0ddfd5eb3edc5dc1001d15ce0a512aff7bf7ce24 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Mon, 2 Aug 2021 18:17:10 -0400 Subject: [PATCH 09/61] Undo the fix for bytes.rkt locally --- .../racketscript/compiler/runtime/core/errors.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/errors.js b/racketscript-compiler/racketscript/compiler/runtime/core/errors.js index a4e15e3d..c07d2b61 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/errors.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/errors.js @@ -186,14 +186,16 @@ export function makeOutOfRangeError(name, type, v, len, i) { stringOut.consume(i.toString()); stringOut.consume('\n'); stringOut.consume(' valid range: [0, '); - stringOut.consume(len.toString()); + stringOut.consume((len - 1).toString()); stringOut.consume(']\n'); stringOut.consume(' '); stringOut.consume(type); stringOut.consume(': '); printNativeString(stringOut, v, true, 0); } else { - stringOut.consume(`${name.toString()}: index is out of range for empty ${type}\n`); + stringOut.consume( + `${name.toString()}: index is out of range for empty ${type}\n` + ); } return racketContractError(stringOut.getOutputString()); From e26c2703edc7f3c65c17cbb983cdfb41b0fde48c Mon Sep 17 00:00:00 2001 From: DarrenN Date: Mon, 2 Aug 2021 18:37:49 -0400 Subject: [PATCH 10/61] Corrects eslint issues --- .../racketscript/compiler/runtime/kernel.js | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.js b/racketscript-compiler/racketscript/compiler/runtime/kernel.js index dbe49beb..a2e768dc 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.js +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.js @@ -7,14 +7,11 @@ import * as Paramz from './paramz.js'; export function isImmutable(v) { if (Core.Primitive.check(v)) { return v.isImmutable(); - } else if (Core.Bytes.check(v) || typeof v === 'string') { + } + if (Core.Bytes.check(v) || typeof v === 'string') { return true; - } else if ( - typeof v === 'number' || - typeof v === 'boolean' || - typeof v === 'undefined' || - v === null - ) { + } + if (typeof v === 'number' || typeof v === 'boolean' || typeof v === 'undefined' || v === null) { return false; } throw Core.racketCoreError('isImmutable not implemented for', v); @@ -38,12 +35,12 @@ export function fprintf(isPrintAsExpression, out, form, ...args) { const matches = formStr.match(regex); const numExpected = matches - ? matches.filter(m => !NO_ARG_FORM_RE.test(m)).length + ? matches.filter((m) => !NO_ARG_FORM_RE.test(m)).length : 0; if (numExpected !== args.length) { throw Core.racketContractError( - `fprintf: format string requires ${numExpected} arguments, ` + - `given ${args.length}; arguments were:`, + `fprintf: format string requires ${numExpected} arguments, ` + + `given ${args.length}; arguments were:`, out, form, ...args @@ -59,8 +56,9 @@ export function fprintf(isPrintAsExpression, out, form, ...args) { prevIndex = reExecResult.index; lastMatch = reExecResult[0]; // eslint-disable-line prefer-destructuring if (/^~\s/.test(lastMatch)) continue; // eslint-disable-line no-continue + // eslint-disable-next-line default-case switch ( - lastMatch.charAt(1) // eslint-disable-line default-case + lastMatch.charAt(1) ) { case '~': Core.display(out, '~'); @@ -179,9 +177,9 @@ export function doraise(e) { export function argerror(name, expected, ...rest) { let theerr; if ( - Core.PrimitiveSymbol.check(name) && - (Core.UString.check(expected) || typeof expected === 'string') && - rest.length >= 1 + Core.PrimitiveSymbol.check(name) + && (Core.UString.check(expected) || typeof expected === 'string') + && rest.length >= 1 ) { theerr = Core.makeArgumentError(name, expected, ...rest); } else { @@ -203,9 +201,9 @@ export function argerror(name, expected, ...rest) { export function resulterror(name, expected, ...rest) { let theerr; if ( - Core.PrimitiveSymbol.check(name) && - (Core.UString.check(expected) || typeof expected === 'string') && - rest.length >= 1 + Core.PrimitiveSymbol.check(name) + && (Core.UString.check(expected) || typeof expected === 'string') + && rest.length >= 1 ) { theerr = Core.makeResultError(name, expected, ...rest); } else { @@ -226,11 +224,10 @@ export function resulterror(name, expected, ...rest) { export function argserror(name, msg, field, ...rest) { let theerr; if ( - Core.PrimitiveSymbol.check(name) && - (Core.UString.check(msg) || typeof msg === 'string') && - (Core.UString.check(field) || typeof field === 'string') && - rest.length >= 1 && - rest.length % 2 === 1 + Core.PrimitiveSymbol.check(name) + && (Core.UString.check(msg) || typeof msg === 'string') + && (Core.UString.check(field) || typeof field === 'string') + && rest.length >= 1 && rest.length % 2 === 1 ) { theerr = Core.makeArgumentsError(name, msg, field, ...rest); } else { @@ -251,8 +248,8 @@ export function argserror(name, msg, field, ...rest) { export function mismatcherror(name, msg, ...rest) { let theerr; if ( - Core.PrimitiveSymbol.check(name) && - (Core.UString.check(msg) || typeof msg === 'string') + Core.PrimitiveSymbol.check(name) + && (Core.UString.check(msg) || typeof msg === 'string') ) { theerr = Core.makeMismatchError(name, msg, ...rest); } else { @@ -274,10 +271,10 @@ export function mismatcherror(name, msg, ...rest) { export function outofrangeerror(name, type, v, len, i) { let theerr; if ( - typeof name === 'string' && - typeof type === 'string' && - typeof len === 'number' && - typeof i === 'number' + typeof name === 'string' + && typeof type === 'string' + && typeof len === 'number' + && typeof i === 'number' ) { theerr = Core.makeOutOfRangeError(name, type, v, len, i); } else { From 8031fdff6164cfb669cf71e482711853872336e3 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Mon, 2 Aug 2021 18:40:03 -0400 Subject: [PATCH 11/61] Corrects more eslint errors (had to switch to VSCode) --- .../racketscript/compiler/runtime/core/errors.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/errors.js b/racketscript-compiler/racketscript/compiler/runtime/core/errors.js index c07d2b61..ae6d6524 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/errors.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/errors.js @@ -37,8 +37,7 @@ function makeError(name) { e.prototype = Object.create(Error.prototype); e.prototype.constructor = e; - return (...args) => - new (Function.prototype.bind.apply(e, [this].concat(args)))(); + return (...args) => new (Function.prototype.bind.apply(e, [this].concat(args)))(); } export const racketCoreError = makeError('RacketCoreError'); @@ -193,9 +192,7 @@ export function makeOutOfRangeError(name, type, v, len, i) { stringOut.consume(': '); printNativeString(stringOut, v, true, 0); } else { - stringOut.consume( - `${name.toString()}: index is out of range for empty ${type}\n` - ); + stringOut.consume(`${name.toString()}: index is out of range for empty ${type}\n`); } return racketContractError(stringOut.getOutputString()); From 75a9ca436a905464e8909aa40888d5c11331d974 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Mon, 2 Aug 2021 21:36:18 -0400 Subject: [PATCH 12/61] Adds bitwise-and, bitwise-ior, bitwise-xor, bitwise-not These bitwise operators were missing from kernel.rkt. Adds tests to `basic/arithmatic/rkt`. --- .../compiler/runtime/core/numbers.js | 18 ++++++++++++++++++ .../racketscript/compiler/runtime/kernel.rkt | 18 ++++++++++++++++++ tests/basic/arithmatic.rkt | 10 ++++++++++ 3 files changed, 46 insertions(+) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/numbers.js b/racketscript-compiler/racketscript/compiler/runtime/core/numbers.js index 4032ea5a..6b5d0c7c 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/numbers.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/numbers.js @@ -72,3 +72,21 @@ export function equals(...operands) { export function check(v) { return typeof v === 'number'; } + +/* Bitwise operators */ + +export function bitwiseOr(...operands) { + return [].reduce.call(operands, (a, b) => a | b, 0); +} + +export function bitwiseXor(...operands) { + return [].reduce.call(operands, (a, b) => a ^ b, 0); +} + +export function bitwiseAnd(...operands) { + return [].reduce.call(operands, (a, b) => a & b, -1); +} + +export function bitwiseNot(v) { + return ~v; +} diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 87478b32..92b888b5 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -172,6 +172,24 @@ (define-checked+provide (numerator [x number?]) x) (define-checked+provide (denominator [x number?]) 1) +;; bitwise operators +(define+provide bitwise-and + (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.bitwiseAnd 1) + "bitwise-and")) + +(define+provide bitwise-ior + (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.bitwiseOr 1) + "bitwise-ior")) + +(define+provide bitwise-xor + (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.bitwiseXor 1) + "bitwise-xor")) + +(define-checked+provide (bitwise-not [v number?]) + (#js.Core.Number.bitwiseNot v)) ;; ---------------------------------------------------------------------------- ;; Booleans diff --git a/tests/basic/arithmatic.rkt b/tests/basic/arithmatic.rkt index e9377a5e..53d88d15 100644 --- a/tests/basic/arithmatic.rkt +++ b/tests/basic/arithmatic.rkt @@ -53,3 +53,13 @@ (displayln (+)) (displayln (*)) + +;; test bitwise operations +(displayln (bitwise-and 5 3)) ;; 1 +(displayln (bitwise-and 5 3 -1983)) ;; 1 +(displayln (bitwise-ior 5 3)) ;; 7 +(displayln (bitwise-ior 5 3 10)) ;; 15 +(displayln (bitwise-xor 5 3)) ;; 6 +(displayln (bitwise-xor 5 3 10)) ;; 12 +(displayln (bitwise-not 5)) ;; -6 +(displayln (bitwise-not -3)) ;; 2 From 698da49d92171cce2641aabcc58851e56ef1c5a8 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Tue, 3 Aug 2021 06:37:05 -0400 Subject: [PATCH 13/61] lint: removes parens --- racketscript-compiler/racketscript/compiler/runtime/kernel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.js b/racketscript-compiler/racketscript/compiler/runtime/kernel.js index a2e768dc..f1f029d6 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.js +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.js @@ -35,7 +35,7 @@ export function fprintf(isPrintAsExpression, out, form, ...args) { const matches = formStr.match(regex); const numExpected = matches - ? matches.filter((m) => !NO_ARG_FORM_RE.test(m)).length + ? matches.filter(m => !NO_ARG_FORM_RE.test(m)).length : 0; if (numExpected !== args.length) { throw Core.racketContractError( From 55f6d62b790f05cf4c8377505de3a82c00ba5347 Mon Sep 17 00:00:00 2001 From: DarrenN Date: Wed, 4 Aug 2021 20:41:50 -0400 Subject: [PATCH 14/61] Racket 6.12: Checks that o is "truthy" before checking for property Racket 6.12 will pass undefined to hash so we need to check o before testing for a property. --- .../racketscript/compiler/runtime/core/raw_hashing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js b/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js index e3b5add7..eb5adb5f 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/raw_hashing.js @@ -14,7 +14,7 @@ */ export function hash(o) { if (o === null) return 0; - if (o.sym) return hashString(`sym_${o.toString()}`); + if (o && o.sym) return hashString(`sym_${o.toString()}`); switch (typeof o) { case 'number': return hashNumber(o); From 9ea3f06a298d74f5ff9f275012a5fa997eaa6dca Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Sat, 7 Aug 2021 22:12:21 -0400 Subject: [PATCH 15/61] fix atan to support 1 or 2 args; fixes #243 * add asin and acos --- .../racketscript/compiler/runtime/kernel.rkt | 10 ++++++++-- tests/basic/math.rkt | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/basic/math.rkt diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 1ae90cc4..7182d43e 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -112,8 +112,14 @@ (#js.Math.cos v)) (define-checked+provide (tan [v real?]) (#js.Math.tan v)) -(define-checked+provide (atan [v real?]) - (#js.Math.atan v)) +(define-checked+provide (asin [v real?]) + (#js.Math.asin v)) +(define-checked+provide (acos [v real?]) + (#js.Math.acos v)) +(define+provide atan + (case-lambda + [(v) (#js.Math.atan v)] + [(x y) (#js.Math.atan2 x y)])) (define-checked+provide (ceiling [v real?]) (#js.Math.ceil v)) diff --git a/tests/basic/math.rkt b/tests/basic/math.rkt new file mode 100644 index 00000000..78d01275 --- /dev/null +++ b/tests/basic/math.rkt @@ -0,0 +1,9 @@ +#lang racket/base +(require racket/math) + +(displayln (atan 0 -1)) ; pi +(displayln pi) +(displayln (sin pi)) +(displayln (acos 0)) +(displayln (asin 0)) +(displayln (atan 0)) From b68136602ede4e729305f977f7397eab63575260 Mon Sep 17 00:00:00 2001 From: gamburgm <33709622+gamburgm@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:31:27 -0400 Subject: [PATCH 16/61] make-vector: Allow `#f` default value (#254) * don't check falsiness, check if undefined * closes #252 --- .../racketscript/compiler/runtime/kernel.rkt | 6 +++++- tests/basic/vector.rkt | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 7182d43e..21b24d70 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -375,7 +375,10 @@ ;; v is optional (define-checked+provide (make-vector [size integer?] [v #t]) - (#js.Core.Vector.makeInit size (or v 0))) + (#js.Core.Vector.makeInit size + (if (eq? v *undefined*) + 0 + v))) (define+provide vector? #js.Core.Vector.check) @@ -397,6 +400,7 @@ (define-checked+provide (vector->immutable-vector [vec vector?]) (#js.Core.Vector.copy vec #f)) + ;; -------------------------------------------------------------------------- ;; Hashes diff --git a/tests/basic/vector.rkt b/tests/basic/vector.rkt index fdc96af4..8d807fd3 100644 --- a/tests/basic/vector.rkt +++ b/tests/basic/vector.rkt @@ -21,3 +21,10 @@ (displayln "equal") (displayln (equal? #(1 2 3) #(1 2 3))) (displayln (equal? #(1 2 3) #(2 2 3))) + +(displayln "make-vector") +(displayln (make-vector 5)) +(displayln (make-vector 5 3)) +(displayln (make-vector 5 #f)) +(displayln (make-vector 0)) + From 881b5622f92f6e3c109907bd321c71a658c576e4 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 19 Nov 2021 19:47:09 -0500 Subject: [PATCH 17/61] support regexp literals; closed #273 --- .../racketscript/compiler/assembler.rkt | 8 - .../racketscript/compiler/runtime/kernel.rkt | 5 + .../racketscript/compiler/transform.rkt | 6 +- tests/racket-core/rx.rkt | 227 +++++++++--------- 4 files changed, 125 insertions(+), 121 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/assembler.rkt b/racketscript-compiler/racketscript/compiler/assembler.rkt index 21e49b3f..952d497d 100644 --- a/racketscript-compiler/racketscript/compiler/assembler.rkt +++ b/racketscript-compiler/racketscript/compiler/assembler.rkt @@ -310,14 +310,6 @@ [_ #:when (single-flonum? v) (emit (~a (exact->inexact (inexact->exact v))))] [_ (emit (~a v))])] ;; TODO [(boolean? v) (emit (if v "true" "false"))] - [(regexp? v) - (define s (string-replace (cast (object-name v) String) "/" "\\/")) - (write (format "/~a/" s) out)] - [(byte-regexp? v) - (define s (string-replace (bytes->string/utf-8 - (cast (object-name v) Bytes)) - "/" "\\/")) - (write (format "/~a/" s) out)] [(void? v) (emit "null")] [else (error "Unexpected value: " v)])) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 1ae90cc4..a6c241b0 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -1218,6 +1218,11 @@ (define+provide (regexp-match pattern input) (#js.Core.Regexp.match pattern input)) +(define+provide (regexp-match? pattern input) + (if (#js.Core.Regexp.match pattern input) + #t + #f)) + ;; -------------------------------------------------------------------------- ;; Procedures diff --git a/racketscript-compiler/racketscript/compiler/transform.rkt b/racketscript-compiler/racketscript/compiler/transform.rkt index 4a91b27a..6d2e72d7 100644 --- a/racketscript-compiler/racketscript/compiler/transform.rkt +++ b/racketscript-compiler/racketscript/compiler/transform.rkt @@ -658,10 +658,12 @@ [(char? d) (ILApp (name-in-module 'core 'Char.charFromCodepoint) (list (absyn-value->il (char->integer d))))] + [(or (regexp? d) (byte-regexp? d)) + (define v (object-name d)) ; string or bytes + (ILApp (name-in-module 'core 'Regexp.fromString) + (list (ILValue (if (bytes? v) (bytes->string/utf-8 v) v))))] [(or (integer? d) (boolean? d) - (regexp? d) - (byte-regexp? d) (void? d) (real? d)) (ILValue d)] diff --git a/tests/racket-core/rx.rkt b/tests/racket-core/rx.rkt index 1bd44f6b..9a8fd4ee 100644 --- a/tests/racket-core/rx.rkt +++ b/tests/racket-core/rx.rkt @@ -147,10 +147,11 @@ (test-regexp '(#"d") #"q?[ad]" #"d") (test-regexp #f #"q?[ad]" #"c") -;; (test '(#"a") regexp-match #rx#"^[^\0]" #"aaa\0") -;; (test #f regexp-match #rx#"^[^\0]" #"\0aaa\0") -;; (test '(#"aaa") regexp-match #rx#"^[^\0]*" #"aaa\0") +(test '(#"a") regexp-match #rx#"^[^\0]" #"aaa\0") +(test #f regexp-match #rx#"^[^\0]" #"\0aaa\0") +(test '(#"aaa") regexp-match #rx#"^[^\0]*" #"aaa\0") +;; this is testing err msg, but they will be different since we use js Regexp ;; (map (lambda (t) ;; (err/rt-test (byte-pregexp t)) ;; (err/rt-test (pregexp t))) @@ -270,121 +271,124 @@ ;; sigmas lambdas)) ;; sigmas)) -;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; Most of the following tests are derived from "testinput" in -;; ;; CL-PPCRE, which probably is from Perl originally. -;; ;; The tests have been modified to avoid various incompatibilities. +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Most of the following tests are derived from "testinput" in +;; CL-PPCRE, which probably is from Perl originally. +;; The tests have been modified to avoid various incompatibilities. -;; (define (make-reluctant-port bstr) -;; ;; Handing out a single character at a time stresses -;; ;; the regexp matcher's lazy reading of a port: -;; (define pos 0) -;; (define len (bytes-length bstr)) -;; (make-input-port -;; 'reluctant-bytes -;; (lambda (s) -;; (if (pos . >= . len) -;; eof -;; (begin -;; (bytes-set! s 0 (bytes-ref bstr pos)) -;; (set! pos (add1 pos)) -;; 1))) -;; (lambda (s skip evt) -;; (if ((+ pos skip) . >= . len) -;; eof -;; (begin -;; (bytes-set! s 0 (bytes-ref bstr (+ pos skip))) -;; 1))) -;; void)) +(define (make-reluctant-port bstr) + ;; Handing out a single character at a time stresses + ;; the regexp matcher's lazy reading of a port: + (define pos 0) + (define len (bytes-length bstr)) + (make-input-port + 'reluctant-bytes + (lambda (s) + (if (pos . >= . len) + eof + (begin + (bytes-set! s 0 (bytes-ref bstr pos)) + (set! pos (add1 pos)) + 1))) + (lambda (s skip evt) + (if ((+ pos skip) . >= . len) + eof + (begin + (bytes-set! s 0 (bytes-ref bstr (+ pos skip))) + 1))) + void)) -;; (map (lambda (t) -;; (if (pair? t) -;; (begin -;; (test (caddr t) regexp-match (byte-pregexp (car t)) (cadr t)) -;; (test (caddr t) regexp-match (byte-pregexp (car t)) (bytes-append #"xxxxxxxxxx" (cadr t)) 10) -;; (test (caddr t) regexp-match (byte-pregexp (car t)) (bytes-append (cadr t) #"xxxxxxxxxx") 0 (bytes-length (cadr t))) -;; (test (caddr t) regexp-match (byte-pregexp (car t)) (open-input-bytes (cadr t))) -;; (test (caddr t) regexp-match (byte-pregexp (car t)) (make-reluctant-port (cadr t))) -;; (test (and (caddr t) -;; (map (lambda (v) -;; (and v (bytes->string/latin-1 v))) -;; (caddr t))) -;; regexp-match -;; (pregexp (bytes->string/latin-1 (car t))) -;; (bytes->string/latin-1 (cadr t))) -;; (test (and (caddr t) -;; (map (lambda (v) -;; (and v (string->bytes/utf-8 (bytes->string/latin-1 v)))) -;; (caddr t))) -;; regexp-match -;; (pregexp (bytes->string/latin-1 (car t))) -;; (open-input-string (bytes->string/latin-1 (cadr t))))) -;; (begin -;; (err/rt-test (byte-pregexp t)) -;; (err/rt-test (pregexp (bytes->string/latin-1 t)))))) -;; '(#"}" +(map (lambda (t) + (if (pair? t) + (begin + (test (caddr t) regexp-match (byte-pregexp (car t)) (cadr t)) + ;; (test (caddr t) regexp-match (byte-pregexp (car t)) (bytes-append #"xxxxxxxxxx" (cadr t)) 10) + ;; (test (caddr t) regexp-match (byte-pregexp (car t)) (bytes-append (cadr t) #"xxxxxxxxxx") 0 (bytes-length (cadr t))) + ;; (test (caddr t) regexp-match (byte-pregexp (car t)) (open-input-bytes (cadr t))) + ;; (test (caddr t) regexp-match (byte-pregexp (car t)) (make-reluctant-port (cadr t))) + ;; (test (and (caddr t) + ;; (map (lambda (v) + ;; (and v (bytes->string/latin-1 v))) + ;; (caddr t))) + ;; regexp-match + ;; (pregexp (bytes->string/latin-1 (car t))) + ;; (bytes->string/latin-1 (cadr t))) + ;; (test (and (caddr t) + ;; (map (lambda (v) + ;; (and v (string->bytes/utf-8 (bytes->string/latin-1 v)))) + ;; (caddr t))) + ;; regexp-match + ;; (pregexp (bytes->string/latin-1 (car t))) + ;; (open-input-string (bytes->string/latin-1 (cadr t)))) + ) + ;; err cases, dont test these + (begin + (err/rt-test (byte-pregexp t)) + (err/rt-test (pregexp (bytes->string/latin-1 t))) + ))) + '(;#"}" ;; #"]" ;; #"[a[:alph:]b]" -;; (#"the quick brown fox" #"the quick brown fox" (#"the quick brown fox")) -;; (#"the quick brown fox" #"The quick brown FOX" #f) -;; (#"the quick brown fox" #"What do you know about the quick brown fox?" (#"the quick brown fox")) -;; (#"the quick brown fox" #"What do you know about THE QUICK BROWN FOX?" #f) + (#"the quick brown fox" #"the quick brown fox" (#"the quick brown fox")) + (#"the quick brown fox" #"The quick brown FOX" #f) + (#"the quick brown fox" #"What do you know about the quick brown fox?" (#"the quick brown fox")) + (#"the quick brown fox" #"What do you know about THE QUICK BROWN FOX?" #f) ;; (#"(?i:The quick brown fox)" #"the quick brown fox" (#"the quick brown fox")) ;; (#"(?i:The quick brown fox)" #"The quick brown FOX" (#"The quick brown FOX")) ;; (#"(?i:The quick brown fox)" #"What do you know about the quick brown fox?" (#"the quick brown fox")) ;; (#"(?i:The quick brown fox)" #"What do you know about THE QUICK BROWN FOX?" (#"THE QUICK BROWN FOX")) -;; (#"abcd\t\n\r\f\a\e\071\x3b\\$\\\\\\?caxyz" #"abcd\t\n\r\f\a\e9;$\\?caxyz" (#"abcd\t\n\r\f\a\e9;$\\?caxyz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrrabbxyyyypqAzz" (#"abxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrrabbxyyyypqAzz" (#"abxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aabxyzpqrrrabbxyyyypqAzz" (#"aabxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabxyzpqrrrabbxyyyypqAzz" (#"aaabxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabxyzpqrrrabbxyyyypqAzz" (#"aaaabxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abcxyzpqrrrabbxyyyypqAzz" (#"abcxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aabcxyzpqrrrabbxyyyypqAzz" (#"aabcxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypAzz" (#"aaabcxyzpqrrrabbxyyyypAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqAzz" (#"aaabcxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqqqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqqqqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqqqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqqqqqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzpqrrrabbxyyyypqAzz" (#"aaaabcxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzzpqrrrabbxyyyypqAzz" (#"abxyzzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aabxyzzzpqrrrabbxyyyypqAzz" (#"aabxyzzzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabxyzzzzpqrrrabbxyyyypqAzz" (#"aaabxyzzzzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabxyzzzzpqrrrabbxyyyypqAzz" (#"aaaabxyzzzzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abcxyzzpqrrrabbxyyyypqAzz" (#"abcxyzzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aabcxyzzzpqrrrabbxyyyypqAzz" (#"aabcxyzzzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzzzzpqrrrabbxyyyypqAzz" (#"aaabcxyzzzzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbxyyyypqAzz" (#"aaaabcxyzzzzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbbxyyyypqAzz" (#"aaaabcxyzzzzpqrrrabbbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbbxyyyyypqAzz" (#"aaaabcxyzzzzpqrrrabbbxyyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypABzz" (#"aaabcxyzpqrrrabbxyyyypABzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypABBzz" (#"aaabcxyzpqrrrabbxyyyypABBzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #">>>aaabxyzpqrrrabbxyyyypqAzz" (#"aaabxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #">aaaabxyzpqrrrabbxyyyypqAzz" (#"aaaabxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #">>>>abcxyzpqrrrabbxyyyypqAzz" (#"abcxyzpqrrrabbxyyyypqAzz")) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrabbxyyyypqAzz" #f) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrrrabbxyyyypqAzz" #f) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrrabxyyyypqAzz" #f) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz" #f) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbbxyyypqAzz" #f) -;; (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqqqqqAzz" #f) -;; (#"^(abc){1,2}zz" #"abczz" (#"abczz" #"abc")) -;; (#"^(abc){1,2}zz" #"abcabczz" (#"abcabczz" #"abc")) -;; (#"^(abc){1,2}zz" #"zz" #f) -;; (#"^(abc){1,2}zz" #"abcabcabczz" #f) -;; (#"^(abc){1,2}zz" #">>abczz" #f) -;; (#"^(b+?|a){1,2}?c" #"bc" (#"bc" #"b")) -;; (#"^(b+?|a){1,2}?c" #"bbc" (#"bbc" #"b")) -;; (#"^(b+?|a){1,2}?c" #"bbbc" (#"bbbc" #"bb")) -;; (#"^(b+?|a){1,2}?c" #"bac" (#"bac" #"a")) -;; (#"^(b+?|a){1,2}?c" #"bbac" (#"bbac" #"a")) -;; (#"^(b+?|a){1,2}?c" #"aac" (#"aac" #"a")) -;; (#"^(b+?|a){1,2}?c" #"abbbbbbbbbbbc" (#"abbbbbbbbbbbc" #"bbbbbbbbbbb")) -;; (#"^(b+?|a){1,2}?c" #"bbbbbbbbbbbac" (#"bbbbbbbbbbbac" #"a")) -;; (#"^(b+?|a){1,2}?c" #"aaac" #f) -;; (#"^(b+?|a){1,2}?c" #"abbbbbbbbbbbac" #f) + (#"abcd\t\n\r\f\a\e\071\x3b\\$\\\\\\?caxyz" #"abcd\t\n\r\f\a\e9;$\\?caxyz" (#"abcd\t\n\r\f\a\e9;$\\?caxyz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrrabbxyyyypqAzz" (#"abxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrrabbxyyyypqAzz" (#"abxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aabxyzpqrrrabbxyyyypqAzz" (#"aabxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabxyzpqrrrabbxyyyypqAzz" (#"aaabxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabxyzpqrrrabbxyyyypqAzz" (#"aaaabxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abcxyzpqrrrabbxyyyypqAzz" (#"abcxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aabcxyzpqrrrabbxyyyypqAzz" (#"aabcxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypAzz" (#"aaabcxyzpqrrrabbxyyyypAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqAzz" (#"aaabcxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqqqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqqqqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqqqqAzz" (#"aaabcxyzpqrrrabbxyyyypqqqqqqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzpqrrrabbxyyyypqAzz" (#"aaaabcxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzzpqrrrabbxyyyypqAzz" (#"abxyzzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aabxyzzzpqrrrabbxyyyypqAzz" (#"aabxyzzzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabxyzzzzpqrrrabbxyyyypqAzz" (#"aaabxyzzzzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabxyzzzzpqrrrabbxyyyypqAzz" (#"aaaabxyzzzzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abcxyzzpqrrrabbxyyyypqAzz" (#"abcxyzzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aabcxyzzzpqrrrabbxyyyypqAzz" (#"aabcxyzzzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzzzzpqrrrabbxyyyypqAzz" (#"aaabcxyzzzzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbxyyyypqAzz" (#"aaaabcxyzzzzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbbxyyyypqAzz" (#"aaaabcxyzzzzpqrrrabbbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbbxyyyyypqAzz" (#"aaaabcxyzzzzpqrrrabbbxyyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypABzz" (#"aaabcxyzpqrrrabbxyyyypABzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypABBzz" (#"aaabcxyzpqrrrabbxyyyypABBzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #">>>aaabxyzpqrrrabbxyyyypqAzz" (#"aaabxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #">aaaabxyzpqrrrabbxyyyypqAzz" (#"aaaabxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #">>>>abcxyzpqrrrabbxyyyypqAzz" (#"abcxyzpqrrrabbxyyyypqAzz")) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrabbxyyyypqAzz" #f) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrrrabbxyyyypqAzz" #f) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"abxyzpqrrrabxyyyypqAzz" #f) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz" #f) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaaabcxyzzzzpqrrrabbbxyyypqAzz" #f) + (#"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz" #"aaabcxyzpqrrrabbxyyyypqqqqqqqAzz" #f) + (#"^(abc){1,2}zz" #"abczz" (#"abczz" #"abc")) + (#"^(abc){1,2}zz" #"abcabczz" (#"abcabczz" #"abc")) + (#"^(abc){1,2}zz" #"zz" #f) + (#"^(abc){1,2}zz" #"abcabcabczz" #f) + (#"^(abc){1,2}zz" #">>abczz" #f) + (#"^(b+?|a){1,2}?c" #"bc" (#"bc" #"b")) + (#"^(b+?|a){1,2}?c" #"bbc" (#"bbc" #"b")) + (#"^(b+?|a){1,2}?c" #"bbbc" (#"bbbc" #"bb")) + (#"^(b+?|a){1,2}?c" #"bac" (#"bac" #"a")) + (#"^(b+?|a){1,2}?c" #"bbac" (#"bbac" #"a")) + (#"^(b+?|a){1,2}?c" #"aac" (#"aac" #"a")) + (#"^(b+?|a){1,2}?c" #"abbbbbbbbbbbc" (#"abbbbbbbbbbbc" #"bbbbbbbbbbb")) + (#"^(b+?|a){1,2}?c" #"bbbbbbbbbbbac" (#"bbbbbbbbbbbac" #"a")) + (#"^(b+?|a){1,2}?c" #"aaac" #f) + (#"^(b+?|a){1,2}?c" #"abbbbbbbbbbbac" #f) ;; (#"^(b+|a){1,2}c" #"bc" (#"bc" #"b")) ;; (#"^(b+|a){1,2}c" #"bbc" (#"bbc" #"bb")) ;; (#"^(b+|a){1,2}c" #"bbbc" (#"bbbc" #"bbb")) @@ -1622,7 +1626,8 @@ ;; (#"^(E)?(?(1)aa|a)*$" #"Eaaa" #f) ;; (#"^(E)?(?(1)aa|a)*$" #"Eaaaa" (#"Eaaaa" #"E")) ;; (#"^(E)?(?(1)aa|a)*$" #"aaa" (#"aaa" #f)) -;; (#"^(E)?(?(1)aa|a)*$" #"aaaa" (#"aaaa" #f)))) + ;; (#"^(E)?(?(1)aa|a)*$" #"aaaa" (#"aaaa" #f)) + )) ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Test unicode-property patterns From c652865934ac53b94d32f80bb8dc4241a9e9a2d8 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Sat, 20 Nov 2021 13:32:38 -0500 Subject: [PATCH 18/61] add regexp-match optional args; byte-append; enable more racket-core tests --- .../compiler/runtime/core/bytes.js | 15 ++ .../compiler/runtime/core/regexp.js | 8 +- .../racketscript/compiler/runtime/kernel.rkt | 12 +- tests/racket-core/rx.rkt | 173 +++++++++--------- 4 files changed, 115 insertions(+), 93 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js b/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js index 53d580b9..606e5d0e 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js @@ -28,6 +28,21 @@ export function ref(bs, i) { return bs[i]; } + +/** + * + * @param Array of {!Uint8Array} + * @return {!Uint8Array} + */ +export function append(bss) { + let size = 0; + bss.forEach(function (bs) { size = size + bs.length;}) + let res = new Uint8Array(size); + let i = 0; + bss.forEach(function (bs) { res.set(bs,i); i = i + bs.length; }) + return res; +} + /** * * @param {!Uint8Array} bs diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/regexp.js b/racketscript-compiler/racketscript/compiler/runtime/core/regexp.js index cebcadc0..406dff23 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/regexp.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/regexp.js @@ -23,9 +23,11 @@ export function fromString(str) { /** * @param {!(RegExp|Uint8Array|UString.UString)} pattern * @param {!(Uint8Array|UString.UString)} input + * @param {!Int} start-pos + * @param {!Int|#f} end-pos * @return {!Pair.Pair|false} A list of bytes or strings, depending on the input. */ -export function match(pattern, input) { +export function match(pattern, input, start, _end) { // TODO: Contract-checking should happen in kernel.rkt. const isRegexpPattern = check(pattern); const isBytesPattern = !isRegexpPattern && Bytes.check(pattern); @@ -49,7 +51,9 @@ export function match(pattern, input) { ? UString.fromBytesUtf8(/** @type {!Uint8Array} */(pattern)) : pattern; - const result = stringInput.toString().match(stringOrRegExpPattern); + const end = ((typeof _end) == 'number') ? _end : stringInput.length; + + const result = stringInput.toString().slice(start,end).match(stringOrRegExpPattern); if (result === null) { return false; diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index a6c241b0..b77bf754 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -1049,6 +1049,9 @@ (#js.Core.makeOutOfRangeError "bytes-set!" "byte string" bs #js.bs.length i)) (#js.Core.Bytes.set bs i b))) +(define+provide bytes-append + (v-λ bss #:unchecked (#js.Core.Bytes.append bss))) + (define-checked+provide (bytes->string/utf-8 [bs bytes?]) (#js.Core.UString.fromBytesUtf8 bs)) @@ -1215,11 +1218,11 @@ (define+provide byte-pregexp byte-regexp) -(define+provide (regexp-match pattern input) - (#js.Core.Regexp.match pattern input)) +(define+provide (regexp-match pattern input [start-pos 0] [end-pos #f]) + (#js.Core.Regexp.match pattern input start-pos end-pos)) -(define+provide (regexp-match? pattern input) - (if (#js.Core.Regexp.match pattern input) +(define+provide (regexp-match? pattern input [start-pos 0] [end-pos #f]) + (if (#js.Core.Regexp.match pattern input start-pos end-pos) #t #f)) @@ -1308,6 +1311,7 @@ [(fs-change) (#js.Core.Vector.make (array #false #false #false #false) #false)] [else #false]) ) + ;; TODO: manually implement weak references? or ES6 WeakMap? see pr#106 (define+provide make-weak-hash make-hash) (define+provide make-weak-hasheqv make-hasheqv) diff --git a/tests/racket-core/rx.rkt b/tests/racket-core/rx.rkt index 9a8fd4ee..0595c095 100644 --- a/tests/racket-core/rx.rkt +++ b/tests/racket-core/rx.rkt @@ -21,27 +21,26 @@ ;; bytes-string inputs => byte results (test result regexp-match (bytes->string/utf-8 pattern) input)] [else ; pattern == rx literal - ;; TODO: result is always strings for now - ;; bc js cannot differentiate between literal regexps and byte-regexps (test result regexp-match pattern (bytes->string/utf-8 input))]) - ;; (test result regexp-match (bytes-append #"(?:" pattern #")") input) - ;; (test result regexp-match (bytes-append #"(?:(?:" pattern #"))") input) - ;; (test (and result (cons (car result) result)) - ;; regexp-match (bytes-append #"(?:(" pattern #"))") input) - ;; (test result regexp-match (bytes-append #"(?:)" pattern #"") input) - ;; (test result regexp-match (bytes-append #"(?<=)" pattern #"") input) - ;; (test result regexp-match (bytes-append #"(?:^|(?<=.))" pattern #"") input) - ;; (test result regexp-match (bytes-append #"" pattern #"(?=)") input) - ;; (test result regexp-match (bytes-append #"" pattern #"(?:$|(?=.))") input) - ;; (test (and result (cons (car result) result)) - ;; regexp-match (byte-pregexp (bytes-append #"(?=(" pattern #"))\\1")) input) + (test result regexp-match (bytes-append #"(?:" pattern #")") input) + (test result regexp-match (bytes-append #"(?:(?:" pattern #"))") input) + (test (and result (cons (car result) result)) + regexp-match (bytes-append #"(?:(" pattern #"))") input) + (test result regexp-match (bytes-append #"(?:)" pattern #"") input) + (test result regexp-match (bytes-append #"(?<=)" pattern #"") input) + (test result regexp-match (bytes-append #"(?:^|(?<=.))" pattern #"") input) + (test result regexp-match (bytes-append #"" pattern #"(?=)") input) + (test result regexp-match (bytes-append #"" pattern #"(?:$|(?=.))") input) + (test (and result (cons (car result) result)) + regexp-match (byte-pregexp (bytes-append #"(?=(" pattern #"))\\1")) input) + ;; not valid JS Regexp? ;; (test result regexp-match (bytes-append #"(?>" pattern #")") input) ) ;; For when adding "x"s to the beginning and end shouldn't change the result: (define (test-regexp-x result pattern input) (test-regexp result pattern input) -; (test-regexp result pattern (bytes-append #"xxx" input #"xxx")) + (test-regexp result pattern (bytes-append #"xxx" input #"xxx")) ) (test-regexp-x '(#"a") #"a" #"abc") @@ -302,8 +301,8 @@ (if (pair? t) (begin (test (caddr t) regexp-match (byte-pregexp (car t)) (cadr t)) - ;; (test (caddr t) regexp-match (byte-pregexp (car t)) (bytes-append #"xxxxxxxxxx" (cadr t)) 10) - ;; (test (caddr t) regexp-match (byte-pregexp (car t)) (bytes-append (cadr t) #"xxxxxxxxxx") 0 (bytes-length (cadr t))) + (test (caddr t) regexp-match (byte-pregexp (car t)) (bytes-append #"xxxxxxxxxx" (cadr t)) 10) + (test (caddr t) regexp-match (byte-pregexp (car t)) (bytes-append (cadr t) #"xxxxxxxxxx") 0 (bytes-length (cadr t))) ;; (test (caddr t) regexp-match (byte-pregexp (car t)) (open-input-bytes (cadr t))) ;; (test (caddr t) regexp-match (byte-pregexp (car t)) (make-reluctant-port (cadr t))) ;; (test (and (caddr t) @@ -389,46 +388,46 @@ (#"^(b+?|a){1,2}?c" #"bbbbbbbbbbbac" (#"bbbbbbbbbbbac" #"a")) (#"^(b+?|a){1,2}?c" #"aaac" #f) (#"^(b+?|a){1,2}?c" #"abbbbbbbbbbbac" #f) -;; (#"^(b+|a){1,2}c" #"bc" (#"bc" #"b")) -;; (#"^(b+|a){1,2}c" #"bbc" (#"bbc" #"bb")) -;; (#"^(b+|a){1,2}c" #"bbbc" (#"bbbc" #"bbb")) -;; (#"^(b+|a){1,2}c" #"bac" (#"bac" #"a")) -;; (#"^(b+|a){1,2}c" #"bbac" (#"bbac" #"a")) -;; (#"^(b+|a){1,2}c" #"aac" (#"aac" #"a")) -;; (#"^(b+|a){1,2}c" #"abbbbbbbbbbbc" (#"abbbbbbbbbbbc" #"bbbbbbbbbbb")) -;; (#"^(b+|a){1,2}c" #"bbbbbbbbbbbac" (#"bbbbbbbbbbbac" #"a")) -;; (#"^(b+|a){1,2}c" #"aaac" #f) -;; (#"^(b+|a){1,2}c" #"abbbbbbbbbbbac" #f) -;; (#"^(b+|a){1,2}?bc" #"bbc" (#"bbc" #"b")) + (#"^(b+|a){1,2}c" #"bc" (#"bc" #"b")) + (#"^(b+|a){1,2}c" #"bbc" (#"bbc" #"bb")) + (#"^(b+|a){1,2}c" #"bbbc" (#"bbbc" #"bbb")) + (#"^(b+|a){1,2}c" #"bac" (#"bac" #"a")) + (#"^(b+|a){1,2}c" #"bbac" (#"bbac" #"a")) + (#"^(b+|a){1,2}c" #"aac" (#"aac" #"a")) + (#"^(b+|a){1,2}c" #"abbbbbbbbbbbc" (#"abbbbbbbbbbbc" #"bbbbbbbbbbb")) + (#"^(b+|a){1,2}c" #"bbbbbbbbbbbac" (#"bbbbbbbbbbbac" #"a")) + (#"^(b+|a){1,2}c" #"aaac" #f) + (#"^(b+|a){1,2}c" #"abbbbbbbbbbbac" #f) + (#"^(b+|a){1,2}?bc" #"bbc" (#"bbc" #"b")) ;; #"^(b*|ba){1,2}?bc" -;; (#"(.)c|ad" #"ad" (#"ad" #f)) -;; (#"(a)c|ad" #"ad" (#"ad" #f)) -;; (#"(?<=(a))c|d" #"ad" (#"d" #f)) -;; (#"(?=(a))ac|ad" #"ad" (#"ad" #f)) -;; (#"^[ab\\]cde]" #"athing" (#"a")) -;; (#"^[ab\\]cde]" #"bthing" (#"b")) -;; (#"^[ab\\]cde]" #"]thing" (#"]")) -;; (#"^[ab\\]cde]" #"cthing" (#"c")) -;; (#"^[ab\\]cde]" #"dthing" (#"d")) -;; (#"^[ab\\]cde]" #"ething" (#"e")) -;; (#"^[ab\\]cde]" #"fthing" #f) -;; (#"^[ab\\]cde]" #"[thing" #f) -;; (#"^[ab\\]cde]" #"\\\\thing" #f) + (#"(.)c|ad" #"ad" (#"ad" #f)) + (#"(a)c|ad" #"ad" (#"ad" #f)) + (#"(?<=(a))c|d" #"ad" (#"d" #f)) + (#"(?=(a))ac|ad" #"ad" (#"ad" #f)) + (#"^[ab\\]cde]" #"athing" (#"a")) + (#"^[ab\\]cde]" #"bthing" (#"b")) + (#"^[ab\\]cde]" #"]thing" (#"]")) + (#"^[ab\\]cde]" #"cthing" (#"c")) + (#"^[ab\\]cde]" #"dthing" (#"d")) + (#"^[ab\\]cde]" #"ething" (#"e")) + (#"^[ab\\]cde]" #"fthing" #f) + (#"^[ab\\]cde]" #"[thing" #f) + (#"^[ab\\]cde]" #"\\\\thing" #f) ;; (#"^[]cde]" #"]thing" (#"]")) ;; (#"^[]cde]" #"cthing" (#"c")) ;; (#"^[]cde]" #"dthing" (#"d")) ;; (#"^[]cde]" #"ething" (#"e")) -;; (#"^[]cde]" #"athing" #f) -;; (#"^[]cde]" #"fthing" #f) -;; (#"^[^ab\\]cde]" #"fthing" (#"f")) -;; (#"^[^ab\\]cde]" #"[thing" (#"[")) -;; (#"^[^ab\\]cde]" #"\\\\thing" (#"\\")) -;; (#"^[^ab\\]cde]" #"athing" #f) -;; (#"^[^ab\\]cde]" #"bthing" #f) -;; (#"^[^ab\\]cde]" #"]thing" #f) -;; (#"^[^ab\\]cde]" #"cthing" #f) -;; (#"^[^ab\\]cde]" #"dthing" #f) -;; (#"^[^ab\\]cde]" #"ething" #f) + (#"^[]cde]" #"athing" #f) + (#"^[]cde]" #"fthing" #f) + (#"^[^ab\\]cde]" #"fthing" (#"f")) + (#"^[^ab\\]cde]" #"[thing" (#"[")) + (#"^[^ab\\]cde]" #"\\\\thing" (#"\\")) + (#"^[^ab\\]cde]" #"athing" #f) + (#"^[^ab\\]cde]" #"bthing" #f) + (#"^[^ab\\]cde]" #"]thing" #f) + (#"^[^ab\\]cde]" #"cthing" #f) + (#"^[^ab\\]cde]" #"dthing" #f) + (#"^[^ab\\]cde]" #"ething" #f) ;; (#"^[^]cde]" #"athing" (#"a")) ;; (#"^[^]cde]" #"fthing" (#"f")) ;; (#"^[^]cde]" #"]thing" #f) @@ -437,42 +436,42 @@ ;; (#"^[^]cde]" #"ething" #f) ;; (#"^\\\201" #"\201" (#"\201")) ;; (#"^\377" #"\377" (#"\377")) -;; (#"^[0-9]+$" #"0" (#"0")) -;; (#"^[0-9]+$" #"1" (#"1")) -;; (#"^[0-9]+$" #"2" (#"2")) -;; (#"^[0-9]+$" #"3" (#"3")) -;; (#"^[0-9]+$" #"4" (#"4")) -;; (#"^[0-9]+$" #"5" (#"5")) -;; (#"^[0-9]+$" #"6" (#"6")) -;; (#"^[0-9]+$" #"7" (#"7")) -;; (#"^[0-9]+$" #"8" (#"8")) -;; (#"^[0-9]+$" #"9" (#"9")) -;; (#"^[0-9]+$" #"10" (#"10")) -;; (#"^[0-9]+$" #"100" (#"100")) -;; (#"^[0-9]+$" #"abc" #f) -;; (#"^.*nter" #"enter" (#"enter")) -;; (#"^.*nter" #"inter" (#"inter")) -;; (#"^.*nter" #"uponter" (#"uponter")) -;; (#"^xxx[0-9]+$" #"xxx0" (#"xxx0")) -;; (#"^xxx[0-9]+$" #"xxx1234" (#"xxx1234")) -;; (#"^xxx[0-9]+$" #"xxx" #f) -;; (#"^.+[0-9][0-9][0-9]$" #"x123" (#"x123")) -;; (#"^.+[0-9][0-9][0-9]$" #"xx123" (#"xx123")) -;; (#"^.+[0-9][0-9][0-9]$" #"123456" (#"123456")) -;; (#"^.+[0-9][0-9][0-9]$" #"123" #f) -;; (#"^.+[0-9][0-9][0-9]$" #"x1234" (#"x1234")) -;; (#"^.+?[0-9][0-9][0-9]$" #"x123" (#"x123")) -;; (#"^.+?[0-9][0-9][0-9]$" #"xx123" (#"xx123")) -;; (#"^.+?[0-9][0-9][0-9]$" #"123456" (#"123456")) -;; (#"^.+?[0-9][0-9][0-9]$" #"123" #f) -;; (#"^.+?[0-9][0-9][0-9]$" #"x1234" (#"x1234")) -;; (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!pqr=apquxz.ixr.zzz.ac.uk" (#"abc!pqr=apquxz.ixr.zzz.ac.uk" #"abc" #"pqr")) -;; (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"!pqr=apquxz.ixr.zzz.ac.uk" #f) -;; (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!=apquxz.ixr.zzz.ac.uk" #f) -;; (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!pqr=apquxz:ixr.zzz.ac.uk" #f) -;; (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!pqr=apquxz.ixr.zzz.ac.ukk" #f) -;; (#":" #"Well, we need a colon: somewhere" (#":")) -;; (#":" #"Fail if we don't" #f) + (#"^[0-9]+$" #"0" (#"0")) + (#"^[0-9]+$" #"1" (#"1")) + (#"^[0-9]+$" #"2" (#"2")) + (#"^[0-9]+$" #"3" (#"3")) + (#"^[0-9]+$" #"4" (#"4")) + (#"^[0-9]+$" #"5" (#"5")) + (#"^[0-9]+$" #"6" (#"6")) + (#"^[0-9]+$" #"7" (#"7")) + (#"^[0-9]+$" #"8" (#"8")) + (#"^[0-9]+$" #"9" (#"9")) + (#"^[0-9]+$" #"10" (#"10")) + (#"^[0-9]+$" #"100" (#"100")) + (#"^[0-9]+$" #"abc" #f) + (#"^.*nter" #"enter" (#"enter")) + (#"^.*nter" #"inter" (#"inter")) + (#"^.*nter" #"uponter" (#"uponter")) + (#"^xxx[0-9]+$" #"xxx0" (#"xxx0")) + (#"^xxx[0-9]+$" #"xxx1234" (#"xxx1234")) + (#"^xxx[0-9]+$" #"xxx" #f) + (#"^.+[0-9][0-9][0-9]$" #"x123" (#"x123")) + (#"^.+[0-9][0-9][0-9]$" #"xx123" (#"xx123")) + (#"^.+[0-9][0-9][0-9]$" #"123456" (#"123456")) + (#"^.+[0-9][0-9][0-9]$" #"123" #f) + (#"^.+[0-9][0-9][0-9]$" #"x1234" (#"x1234")) + (#"^.+?[0-9][0-9][0-9]$" #"x123" (#"x123")) + (#"^.+?[0-9][0-9][0-9]$" #"xx123" (#"xx123")) + (#"^.+?[0-9][0-9][0-9]$" #"123456" (#"123456")) + (#"^.+?[0-9][0-9][0-9]$" #"123" #f) + (#"^.+?[0-9][0-9][0-9]$" #"x1234" (#"x1234")) + (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!pqr=apquxz.ixr.zzz.ac.uk" (#"abc!pqr=apquxz.ixr.zzz.ac.uk" #"abc" #"pqr")) + (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"!pqr=apquxz.ixr.zzz.ac.uk" #f) + (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!=apquxz.ixr.zzz.ac.uk" #f) + (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!pqr=apquxz:ixr.zzz.ac.uk" #f) + (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!pqr=apquxz.ixr.zzz.ac.ukk" #f) + (#":" #"Well, we need a colon: somewhere" (#":")) + (#":" #"Fail if we don't" #f) ;; (#"(?i:([\\da-f:]+)$)" #"0abc" (#"0abc" #"0abc")) ;; (#"(?i:([\\da-f:]+)$)" #"abc" (#"abc" #"abc")) ;; (#"(?i:([\\da-f:]+)$)" #"fed" (#"fed" #"fed")) From e6610b62fd0d16abb63916d46cbfc7060b382a58 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Sat, 20 Nov 2021 13:45:29 -0500 Subject: [PATCH 19/61] fix lint errs --- .../racketscript/compiler/runtime/core/bytes.js | 6 +++--- .../racketscript/compiler/runtime/core/regexp.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js b/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js index 606e5d0e..2ec77e98 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js @@ -36,10 +36,10 @@ export function ref(bs, i) { */ export function append(bss) { let size = 0; - bss.forEach(function (bs) { size = size + bs.length;}) - let res = new Uint8Array(size); + bss.forEach((bs) => { size += bs.length; }) + const res = new Uint8Array(size); let i = 0; - bss.forEach(function (bs) { res.set(bs,i); i = i + bs.length; }) + bss.forEach((bs) => { res.set(bs,i); i += bs.length; }) return res; } diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/regexp.js b/racketscript-compiler/racketscript/compiler/runtime/core/regexp.js index 406dff23..d1f04e96 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/regexp.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/regexp.js @@ -51,9 +51,9 @@ export function match(pattern, input, start, _end) { ? UString.fromBytesUtf8(/** @type {!Uint8Array} */(pattern)) : pattern; - const end = ((typeof _end) == 'number') ? _end : stringInput.length; + const end = ((typeof _end) === 'number') ? _end : stringInput.length; - const result = stringInput.toString().slice(start,end).match(stringOrRegExpPattern); + const result = stringInput.toString().slice(start, end).match(stringOrRegExpPattern); if (result === null) { return false; From 914729d69da45afd9835f3efc275f51f03c7f454 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Sat, 20 Nov 2021 17:12:54 -0500 Subject: [PATCH 20/61] fix more lint errs --- .../racketscript/compiler/runtime/core/bytes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js b/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js index 2ec77e98..a1bbcc5e 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js @@ -36,10 +36,10 @@ export function ref(bs, i) { */ export function append(bss) { let size = 0; - bss.forEach((bs) => { size += bs.length; }) + bss.forEach((bs) => { size += bs.length; }); const res = new Uint8Array(size); let i = 0; - bss.forEach((bs) => { res.set(bs,i); i += bs.length; }) + bss.forEach((bs) => { res.set(bs, i); i += bs.length; }); return res; } From cb8af742e0f1568f3bc8c51a189c3c48fbb39511 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Sat, 20 Nov 2021 18:30:46 -0500 Subject: [PATCH 21/61] add latin1 conversion; enable more tests --- .../compiler/runtime/core/bytes.js | 9 + .../compiler/runtime/core/unicode_string.js | 8 + .../racketscript/compiler/runtime/kernel.rkt | 6 + tests/racket-core/rx.rkt | 318 +++++++++--------- 4 files changed, 184 insertions(+), 157 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js b/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js index a1bbcc5e..6d2499e9 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/bytes.js @@ -127,6 +127,7 @@ export function fromIntArray(ints) { } const utf8Decoder = new TextDecoder('utf-8'); +const latin1Decoder = new TextDecoder('latin1'); /** * @param {!Uint8Array} bytes @@ -136,6 +137,14 @@ export function toString(bytes) { return utf8Decoder.decode(bytes); } +/** + * @param {!Uint8Array} bytes + * @return {!String} + */ +export function toLatin1String(bytes) { + return latin1Decoder.decode(bytes); +} + /** * Writes a string representation similar to Racket's `display` to the given port. * diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/unicode_string.js b/racketscript-compiler/racketscript/compiler/runtime/core/unicode_string.js index d454f9e0..0ece6d5e 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/unicode_string.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/unicode_string.js @@ -488,6 +488,14 @@ export function fromBytesUtf8(bytes) { return makeMutable(Bytes.toString(bytes)); } +/** + * @param {!Uint8Array} bytes + * @return {!MutableUString} + */ +export function fromBytesLatin1(bytes) { + return makeMutable(Bytes.toString(bytes)); +} + /** * @param {!UString[]} strs * @return {!MutableUString} diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index b77bf754..2c3a8a8e 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -1055,9 +1055,15 @@ (define-checked+provide (bytes->string/utf-8 [bs bytes?]) (#js.Core.UString.fromBytesUtf8 bs)) +(define-checked+provide (bytes->string/latin-1 [bs bytes?]) + (#js.Core.UString.fromBytesLatin1 bs)) + (define-checked+provide (string->bytes/utf-8 [str string?]) (#js.Core.UString.toBytesUtf8 str)) +(define+provide (string->bytes/locale str [err-byte #t] [start 0] [end 0]) + (#js.Core.UString.toBytesUtf8 str)) + (define-checked+provide (bytes=? [bstr1 bytes?] [bstr2 bytes?]) (#js.Core.Bytes.eq bstr1 bstr2)) diff --git a/tests/racket-core/rx.rkt b/tests/racket-core/rx.rkt index 0595c095..f830face 100644 --- a/tests/racket-core/rx.rkt +++ b/tests/racket-core/rx.rkt @@ -33,7 +33,7 @@ (test result regexp-match (bytes-append #"" pattern #"(?:$|(?=.))") input) (test (and result (cons (car result) result)) regexp-match (byte-pregexp (bytes-append #"(?=(" pattern #"))\\1")) input) - ;; not valid JS Regexp? + ;; invalid JS Regexp: "Invalid group" ;; (test result regexp-match (bytes-append #"(?>" pattern #")") input) ) @@ -332,6 +332,7 @@ (#"the quick brown fox" #"The quick brown FOX" #f) (#"the quick brown fox" #"What do you know about the quick brown fox?" (#"the quick brown fox")) (#"the quick brown fox" #"What do you know about THE QUICK BROWN FOX?" #f) +;; SyntaxError: Invalid regular expression: /(?i:The quick brown fox)/: Invalid group ;; (#"(?i:The quick brown fox)" #"the quick brown fox" (#"the quick brown fox")) ;; (#"(?i:The quick brown fox)" #"The quick brown FOX" (#"The quick brown FOX")) ;; (#"(?i:The quick brown fox)" #"What do you know about the quick brown fox?" (#"the quick brown fox")) @@ -472,6 +473,7 @@ (#"^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" #"abc!pqr=apquxz.ixr.zzz.ac.ukk" #f) (#":" #"Well, we need a colon: somewhere" (#":")) (#":" #"Fail if we don't" #f) +;; SyntaxError: Invalid regular expression: /(?i:([\da-f:]+)$)/: Invalid group ;; (#"(?i:([\\da-f:]+)$)" #"0abc" (#"0abc" #"0abc")) ;; (#"(?i:([\\da-f:]+)$)" #"abc" (#"abc" #"abc")) ;; (#"(?i:([\\da-f:]+)$)" #"fed" (#"fed" #"fed")) @@ -484,130 +486,131 @@ ;; (#"(?i:([\\da-f:]+)$)" #"gzzz" #f) ;; (#"(?i:([\\da-f:]+)$)" #"fed\\x20" (#"20" #"20")) ;; (#"(?i:([\\da-f:]+)$)" #"Any old rubbish" #f) -;; (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #".1.2.3" (#".1.2.3" #"1" #"2" #"3")) -;; (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #"A.12.123.0" (#"A.12.123.0" #"12" #"123" #"0")) -;; (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #".1.2.3333" #f) -;; (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #"1.2.3" #f) -;; (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #"1234.2.3" #f) -;; (#"^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" #"1 IN SOA non-sp1 non-sp2(" (#"1 IN SOA non-sp1 non-sp2(" #"1" #"non-sp1" #"non-sp2")) -;; (#"^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" #"1 IN SOA non-sp1 non-sp2 (" (#"1 IN SOA non-sp1 non-sp2 (" #"1" #"non-sp1" #"non-sp2")) -;; (#"^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" #"1IN SOA non-sp1 non-sp2(" #f) -;; (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"a." (#"a." #f)) -;; (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"Z." (#"Z." #f)) -;; (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"2." (#"2." #f)) -;; (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"ab-c.pq-r." (#"ab-c.pq-r." #".pq-r")) -;; (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"sxk.zzz.ac.uk." (#"sxk.zzz.ac.uk." #".uk")) -;; (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"x-.y-." (#"x-.y-." #".y-")) -;; (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"-abc.peq." #f) -;; (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.a" (#"*.a" #f #f #f)) -;; (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.b0-a" (#"*.b0-a" #"0-a" #f #f)) -;; (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.c3-b.c" (#"*.c3-b.c" #"3-b" #".c" #f)) -;; (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.c-a.b-c" (#"*.c-a.b-c" #"-a" #".b-c" #"-c")) -;; (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.0" #f) -;; (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.a-" #f) -;; (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.a-b.c-" #f) -;; (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.c-a.0-c" #f) -;; (#"^(?=ab(de))(abd)(e)" #"abde" (#"abde" #"de" #"abd" #"e")) -;; (#"^(?!(ab)de|x)(abd)(f)" #"abdf" (#"abdf" #f #"abd" #"f")) -;; (#"^(?=(ab(cd)))(ab)" #"abcd" (#"ab" #"abcd" #"cd" #"ab")) + (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #".1.2.3" (#".1.2.3" #"1" #"2" #"3")) + (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #"A.12.123.0" (#"A.12.123.0" #"12" #"123" #"0")) + (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #".1.2.3333" #f) + (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #"1.2.3" #f) + (#"^.*\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$" #"1234.2.3" #f) + (#"^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" #"1 IN SOA non-sp1 non-sp2(" (#"1 IN SOA non-sp1 non-sp2(" #"1" #"non-sp1" #"non-sp2")) + (#"^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" #"1 IN SOA non-sp1 non-sp2 (" (#"1 IN SOA non-sp1 non-sp2 (" #"1" #"non-sp1" #"non-sp2")) + (#"^(\\d+)\\s+IN\\s+SOA\\s+(\\S+)\\s+(\\S+)\\s*\\(\\s*$" #"1IN SOA non-sp1 non-sp2(" #f) + (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"a." (#"a." #f)) + (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"Z." (#"Z." #f)) + (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"2." (#"2." #f)) + (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"ab-c.pq-r." (#"ab-c.pq-r." #".pq-r")) + (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"sxk.zzz.ac.uk." (#"sxk.zzz.ac.uk." #".uk")) + (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"x-.y-." (#"x-.y-." #".y-")) + (#"^[a-zA-Z\\d][a-zA-Z\\d\\-]*(\\.[a-zA-Z\\d][a-zA-Z\\d\\-]*)*\\.$" #"-abc.peq." #f) + (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.a" (#"*.a" #f #f #f)) + (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.b0-a" (#"*.b0-a" #"0-a" #f #f)) + (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.c3-b.c" (#"*.c3-b.c" #"3-b" #".c" #f)) + (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.c-a.b-c" (#"*.c-a.b-c" #"-a" #".b-c" #"-c")) + (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.0" #f) + (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.a-" #f) + (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.a-b.c-" #f) + (#"^\\*\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?(\\.[a-z]([a-z\\-\\d]*[a-z\\d]+)?)*$" #"*.c-a.0-c" #f) + (#"^(?=ab(de))(abd)(e)" #"abde" (#"abde" #"de" #"abd" #"e")) + (#"^(?!(ab)de|x)(abd)(f)" #"abdf" (#"abdf" #f #"abd" #"f")) + (#"^(?=(ab(cd)))(ab)" #"abcd" (#"ab" #"abcd" #"cd" #"ab")) +;; SyntaxError: Invalid regular expression: /(?i:^[\da-f](\.[\da-f])*$)/: Invalid group ;; (#"(?i:^[\\da-f](\\.[\\da-f])*$)" #"a.b.c.d" (#"a.b.c.d" #".d")) ;; (#"(?i:^[\\da-f](\\.[\\da-f])*$)" #"A.B.C.D" (#"A.B.C.D" #".D")) ;; (#"(?i:^[\\da-f](\\.[\\da-f])*$)" #"a.b.c.1.2.3.C" (#"a.b.c.1.2.3.C" #".C")) -;; (#"^\\\".*\\\"\\s*(;.*)?$" #"\"1234\"" (#"\"1234\"" #f)) -;; (#"^\\\".*\\\"\\s*(;.*)?$" #"\"abcd\" ;" (#"\"abcd\" ;" #";")) -;; (#"^\\\".*\\\"\\s*(;.*)?$" #"\"\" ; rhubarb" (#"\"\" ; rhubarb" #"; rhubarb")) -;; (#"^\\\".*\\\"\\s*(;.*)?$" #"\"1234\" : things" #f) -;; (#"^$" #"\\" #f) -;; (#"^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$" #"abcdefhijklm" (#"abcdefhijklm" #"abc" #"bc" #"c" #"def" #"ef" #"f" #"hij" #"ij" #"j" #"klm" #"lm" #"m")) -;; (#"^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$" #"abcdefhijklm" (#"abcdefhijklm" #"bc" #"c" #"ef" #"f" #"ij" #"j" #"lm" #"m")) -;; ; (#"^[\\w][\\W][\\s][\\S][\\d][\\D][\\b][\\n][\\c]][\\022]" #"a+ Z0+\\x08\\n\\x1d\\x12" #f) -;; (#"^[.^$|()*+?{,}]+" #".^\\$(*+)|{?,?}" (#".^")) -;; (#"^a*\\w" #"z" (#"z")) -;; (#"^a*\\w" #"az" (#"az")) -;; (#"^a*\\w" #"aaaz" (#"aaaz")) -;; (#"^a*\\w" #"a" (#"a")) -;; (#"^a*\\w" #"aa" (#"aa")) -;; (#"^a*\\w" #"aaaa" (#"aaaa")) -;; (#"^a*\\w" #"a+" (#"a")) -;; (#"^a*\\w" #"aa+" (#"aa")) -;; (#"^a*?\\w" #"z" (#"z")) -;; (#"^a*?\\w" #"az" (#"a")) -;; (#"^a*?\\w" #"aaaz" (#"a")) -;; (#"^a*?\\w" #"a" (#"a")) -;; (#"^a*?\\w" #"aa" (#"a")) -;; (#"^a*?\\w" #"aaaa" (#"a")) -;; (#"^a*?\\w" #"a+" (#"a")) -;; (#"^a*?\\w" #"aa+" (#"a")) -;; (#"^a+\\w" #"az" (#"az")) -;; (#"^a+\\w" #"aaaz" (#"aaaz")) -;; (#"^a+\\w" #"aa" (#"aa")) -;; (#"^a+\\w" #"aaaa" (#"aaaa")) -;; (#"^a+\\w" #"aa+" (#"aa")) -;; (#"^a+?\\w" #"az" (#"az")) -;; (#"^a+?\\w" #"aaaz" (#"aa")) -;; (#"^a+?\\w" #"aa" (#"aa")) -;; (#"^a+?\\w" #"aaaa" (#"aa")) -;; (#"^a+?\\w" #"aa+" (#"aa")) -;; (#"^\\d{8}\\w{2,}" #"1234567890" (#"1234567890")) -;; (#"^\\d{8}\\w{2,}" #"12345678ab" (#"12345678ab")) -;; (#"^\\d{8}\\w{2,}" #"12345678__" (#"12345678__")) -;; (#"^\\d{8}\\w{2,}" #"1234567" #f) -;; (#"^[aeiou\\d]{4,5}$" #"uoie" (#"uoie")) -;; (#"^[aeiou\\d]{4,5}$" #"1234" (#"1234")) -;; (#"^[aeiou\\d]{4,5}$" #"12345" (#"12345")) -;; (#"^[aeiou\\d]{4,5}$" #"aaaaa" (#"aaaaa")) -;; (#"^[aeiou\\d]{4,5}$" #"123456" #f) -;; (#"^[aeiou\\d]{4,5}?" #"uoie" (#"uoie")) -;; (#"^[aeiou\\d]{4,5}?" #"1234" (#"1234")) -;; (#"^[aeiou\\d]{4,5}?" #"12345" (#"1234")) -;; (#"^[aeiou\\d]{4,5}?" #"aaaaa" (#"aaaa")) -;; (#"^[aeiou\\d]{4,5}?" #"123456" (#"1234")) -;; (#"^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\\11*(\\3\\4)\\12$" #"abcdefghijkcda2" #f) -;; (#"^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\\11*(\\3\\4)\\12$" #"abcdefghijkkkkcda2" #f) -;; (#"(cat(a(ract|tonic)|erpillar)) \\1()2(3)" #"cataract cataract23" (#"cataract cataract23" #"cataract" #"aract" #"ract" #"" #"3")) -;; (#"(cat(a(ract|tonic)|erpillar)) \\1()2(3)" #"catatonic catatonic23" (#"catatonic catatonic23" #"catatonic" #"atonic" #"tonic" #"" #"3")) -;; (#"(cat(a(ract|tonic)|erpillar)) \\1()2(3)" #"caterpillar caterpillar23" (#"caterpillar caterpillar23" #"caterpillar" #"erpillar" #f #"" #"3")) -;; (#"^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]" #"From abcd Mon Sep 01 12:33:02 1997" (#"From abcd Mon Sep 01 12:33" #"abcd")) -;; (#"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" #"From abcd Mon Sep 01 12:33:02 1997" (#"From abcd Mon Sep 01 12:33" #"Sep ")) -;; (#"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" #"From abcd Mon Sep 1 12:33:02 1997" (#"From abcd Mon Sep 1 12:33" #"Sep ")) -;; (#"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" #"From abcd Sep 01 12:33:02 1997" #f) -;; (#"\\w+(?=\t)" #"the quick brown\\t fox" #f) -;; (#"foo(?!bar)(.*)" #"foobar is foolish see?" (#"foolish see?" #"lish see?")) -;; (#"(?:(?!foo)...|^.{0,2})bar(.*)" #"foobar crowbar etc" (#"rowbar etc" #" etc")) -;; (#"(?:(?!foo)...|^.{0,2})bar(.*)" #"barrel" (#"barrel" #"rel")) -;; (#"(?:(?!foo)...|^.{0,2})bar(.*)" #"2barrel" (#"2barrel" #"rel")) -;; (#"(?:(?!foo)...|^.{0,2})bar(.*)" #"A barrel" (#"A barrel" #"rel")) -;; (#"^(\\D*)(?=\\d)(?!123)" #"abc456" (#"abc" #"abc")) -;; (#"^(\\D*)(?=\\d)(?!123)" #"abc123" #f) -;; (#"^(a)\\1{2,3}(.)" #"aaab" (#"aaab" #"a" #"b")) -;; (#"^(a)\\1{2,3}(.)" #"aaaab" (#"aaaab" #"a" #"b")) -;; (#"^(a)\\1{2,3}(.)" #"aaaaab" (#"aaaaa" #"a" #"a")) -;; (#"^(a)\\1{2,3}(.)" #"aaaaaab" (#"aaaaa" #"a" #"a")) -;; (#"(?!^)abc" #"the abc" (#"abc")) -;; (#"(?!^)abc" #"abc" #f) -;; (#"(?=^)abc" #"abc" (#"abc")) -;; (#"(?=^)abc" #"the abc" #f) -;; (#"^[ab]{1,3}(ab*|b)" #"aabbbbb" (#"aabb" #"b")) -;; (#"^[ab]{1,3}?(ab*|b)" #"aabbbbb" (#"aabbbbb" #"abbbbb")) -;; (#"^[ab]{1,3}?(ab*?|b)" #"aabbbbb" (#"aa" #"a")) -;; (#"^[ab]{1,3}(ab*?|b)" #"aabbbbb" (#"aabb" #"b")) -;; #| -;; (#"abc\\0def\\00pqr\\000xyz\\0000AB" #"abc\\0def\\00pqr\\000xyz\\0000AB" #f) -;; (#"abc\\0def\\00pqr\\000xyz\\0000AB" #"abc456 abc\\0def\\00pqr\\000xyz\\0000ABCDE" #f) -;; (#"abc\\x0def\\x00pqr\\x000xyz\\x0000AB" #"abc\\x0def\\x00pqr\\x000xyz\\x0000AB" #f) -;; (#"abc\\x0def\\x00pqr\\x000xyz\\x0000AB" #"abc456 abc\\x0def\\x00pqr\\x000xyz\\x0000ABCDE" #f) -;; (#"^[\\000-\\037]" #"\\0A" #f) -;; (#"^[\\000-\\037]" #"\\01B" #f) -;; (#"^[\\000-\\037]" #"\\037C" #f) -;; (#"\\0*" #"\\0\\0\\0\\0" #f) -;; (#"A\\x0{2,3}Z" #"The A\\x0\\x0Z" #f) -;; (#"A\\x0{2,3}Z" #"An A\\0\\x0\\0Z" #f) -;; (#"A\\x0{2,3}Z" #"A\\0Z" #f) -;; (#"A\\x0{2,3}Z" #"A\\0\\x0\\0\\x0Z" #f) -;; |# -;; (#"^(cow|)\\1(bell)" #"cowcowbell" (#"cowcowbell" #"cow" #"bell")) -;; (#"^(cow|)\\1(bell)" #"bell" (#"bell" #"" #"bell")) -;; (#"^(cow|)\\1(bell)" #"cowbell" #f) + (#"^\\\".*\\\"\\s*(;.*)?$" #"\"1234\"" (#"\"1234\"" #f)) + (#"^\\\".*\\\"\\s*(;.*)?$" #"\"abcd\" ;" (#"\"abcd\" ;" #";")) + (#"^\\\".*\\\"\\s*(;.*)?$" #"\"\" ; rhubarb" (#"\"\" ; rhubarb" #"; rhubarb")) + (#"^\\\".*\\\"\\s*(;.*)?$" #"\"1234\" : things" #f) + (#"^$" #"\\" #f) + (#"^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$" #"abcdefhijklm" (#"abcdefhijklm" #"abc" #"bc" #"c" #"def" #"ef" #"f" #"hij" #"ij" #"j" #"klm" #"lm" #"m")) + (#"^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$" #"abcdefhijklm" (#"abcdefhijklm" #"bc" #"c" #"ef" #"f" #"ij" #"j" #"lm" #"m")) +; (#"^[\\w][\\W][\\s][\\S][\\d][\\D][\\b][\\n][\\c]][\\022]" #"a+ Z0+\\x08\\n\\x1d\\x12" #f) + (#"^[.^$|()*+?{,}]+" #".^\\$(*+)|{?,?}" (#".^")) + (#"^a*\\w" #"z" (#"z")) + (#"^a*\\w" #"az" (#"az")) + (#"^a*\\w" #"aaaz" (#"aaaz")) + (#"^a*\\w" #"a" (#"a")) + (#"^a*\\w" #"aa" (#"aa")) + (#"^a*\\w" #"aaaa" (#"aaaa")) + (#"^a*\\w" #"a+" (#"a")) + (#"^a*\\w" #"aa+" (#"aa")) + (#"^a*?\\w" #"z" (#"z")) + (#"^a*?\\w" #"az" (#"a")) + (#"^a*?\\w" #"aaaz" (#"a")) + (#"^a*?\\w" #"a" (#"a")) + (#"^a*?\\w" #"aa" (#"a")) + (#"^a*?\\w" #"aaaa" (#"a")) + (#"^a*?\\w" #"a+" (#"a")) + (#"^a*?\\w" #"aa+" (#"a")) + (#"^a+\\w" #"az" (#"az")) + (#"^a+\\w" #"aaaz" (#"aaaz")) + (#"^a+\\w" #"aa" (#"aa")) + (#"^a+\\w" #"aaaa" (#"aaaa")) + (#"^a+\\w" #"aa+" (#"aa")) + (#"^a+?\\w" #"az" (#"az")) + (#"^a+?\\w" #"aaaz" (#"aa")) + (#"^a+?\\w" #"aa" (#"aa")) + (#"^a+?\\w" #"aaaa" (#"aa")) + (#"^a+?\\w" #"aa+" (#"aa")) + (#"^\\d{8}\\w{2,}" #"1234567890" (#"1234567890")) + (#"^\\d{8}\\w{2,}" #"12345678ab" (#"12345678ab")) + (#"^\\d{8}\\w{2,}" #"12345678__" (#"12345678__")) + (#"^\\d{8}\\w{2,}" #"1234567" #f) + (#"^[aeiou\\d]{4,5}$" #"uoie" (#"uoie")) + (#"^[aeiou\\d]{4,5}$" #"1234" (#"1234")) + (#"^[aeiou\\d]{4,5}$" #"12345" (#"12345")) + (#"^[aeiou\\d]{4,5}$" #"aaaaa" (#"aaaaa")) + (#"^[aeiou\\d]{4,5}$" #"123456" #f) + (#"^[aeiou\\d]{4,5}?" #"uoie" (#"uoie")) + (#"^[aeiou\\d]{4,5}?" #"1234" (#"1234")) + (#"^[aeiou\\d]{4,5}?" #"12345" (#"1234")) + (#"^[aeiou\\d]{4,5}?" #"aaaaa" (#"aaaa")) + (#"^[aeiou\\d]{4,5}?" #"123456" (#"1234")) + (#"^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\\11*(\\3\\4)\\12$" #"abcdefghijkcda2" #f) + (#"^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\\11*(\\3\\4)\\12$" #"abcdefghijkkkkcda2" #f) + (#"(cat(a(ract|tonic)|erpillar)) \\1()2(3)" #"cataract cataract23" (#"cataract cataract23" #"cataract" #"aract" #"ract" #"" #"3")) + (#"(cat(a(ract|tonic)|erpillar)) \\1()2(3)" #"catatonic catatonic23" (#"catatonic catatonic23" #"catatonic" #"atonic" #"tonic" #"" #"3")) + (#"(cat(a(ract|tonic)|erpillar)) \\1()2(3)" #"caterpillar caterpillar23" (#"caterpillar caterpillar23" #"caterpillar" #"erpillar" #f #"" #"3")) + (#"^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]" #"From abcd Mon Sep 01 12:33:02 1997" (#"From abcd Mon Sep 01 12:33" #"abcd")) + (#"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" #"From abcd Mon Sep 01 12:33:02 1997" (#"From abcd Mon Sep 01 12:33" #"Sep ")) + (#"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" #"From abcd Mon Sep 1 12:33:02 1997" (#"From abcd Mon Sep 1 12:33" #"Sep ")) + (#"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" #"From abcd Sep 01 12:33:02 1997" #f) + (#"\\w+(?=\t)" #"the quick brown\\t fox" #f) + (#"foo(?!bar)(.*)" #"foobar is foolish see?" (#"foolish see?" #"lish see?")) + (#"(?:(?!foo)...|^.{0,2})bar(.*)" #"foobar crowbar etc" (#"rowbar etc" #" etc")) + (#"(?:(?!foo)...|^.{0,2})bar(.*)" #"barrel" (#"barrel" #"rel")) + (#"(?:(?!foo)...|^.{0,2})bar(.*)" #"2barrel" (#"2barrel" #"rel")) + (#"(?:(?!foo)...|^.{0,2})bar(.*)" #"A barrel" (#"A barrel" #"rel")) + (#"^(\\D*)(?=\\d)(?!123)" #"abc456" (#"abc" #"abc")) + (#"^(\\D*)(?=\\d)(?!123)" #"abc123" #f) + (#"^(a)\\1{2,3}(.)" #"aaab" (#"aaab" #"a" #"b")) + (#"^(a)\\1{2,3}(.)" #"aaaab" (#"aaaab" #"a" #"b")) + (#"^(a)\\1{2,3}(.)" #"aaaaab" (#"aaaaa" #"a" #"a")) + (#"^(a)\\1{2,3}(.)" #"aaaaaab" (#"aaaaa" #"a" #"a")) + (#"(?!^)abc" #"the abc" (#"abc")) + (#"(?!^)abc" #"abc" #f) + (#"(?=^)abc" #"abc" (#"abc")) + (#"(?=^)abc" #"the abc" #f) + (#"^[ab]{1,3}(ab*|b)" #"aabbbbb" (#"aabb" #"b")) + (#"^[ab]{1,3}?(ab*|b)" #"aabbbbb" (#"aabbbbb" #"abbbbb")) + (#"^[ab]{1,3}?(ab*?|b)" #"aabbbbb" (#"aa" #"a")) + (#"^[ab]{1,3}(ab*?|b)" #"aabbbbb" (#"aabb" #"b")) +#| + (#"abc\\0def\\00pqr\\000xyz\\0000AB" #"abc\\0def\\00pqr\\000xyz\\0000AB" #f) + (#"abc\\0def\\00pqr\\000xyz\\0000AB" #"abc456 abc\\0def\\00pqr\\000xyz\\0000ABCDE" #f) + (#"abc\\x0def\\x00pqr\\x000xyz\\x0000AB" #"abc\\x0def\\x00pqr\\x000xyz\\x0000AB" #f) + (#"abc\\x0def\\x00pqr\\x000xyz\\x0000AB" #"abc456 abc\\x0def\\x00pqr\\x000xyz\\x0000ABCDE" #f) + (#"^[\\000-\\037]" #"\\0A" #f) + (#"^[\\000-\\037]" #"\\01B" #f) + (#"^[\\000-\\037]" #"\\037C" #f) + (#"\\0*" #"\\0\\0\\0\\0" #f) + (#"A\\x0{2,3}Z" #"The A\\x0\\x0Z" #f) + (#"A\\x0{2,3}Z" #"An A\\0\\x0\\0Z" #f) + (#"A\\x0{2,3}Z" #"A\\0Z" #f) + (#"A\\x0{2,3}Z" #"A\\0\\x0\\0\\x0Z" #f) +|# + (#"^(cow|)\\1(bell)" #"cowcowbell" (#"cowcowbell" #"cow" #"bell")) + (#"^(cow|)\\1(bell)" #"bell" (#"bell" #"" #"bell")) + (#"^(cow|)\\1(bell)" #"cowbell" #f) ;; #| ;; (#"^\\s" #"\\040abc" #f) ;; (#"^\\s" #"\\x0cabc" #f) @@ -616,46 +619,47 @@ ;; (#"^\\s" #"\\tabc" #f) ;; (#"^\\s" #"abc" #f) ;; |# -;; (#"^(a|x)\\1*b" #"ab" (#"ab" #"a")) -;; (#"^(a|x)\\1*b" #"aaaab" (#"aaaab" #"a")) -;; (#"^(a|x)\\1*b" #"acb" #f) -;; (#"^(a|x)\\1+b" #"aab" (#"aab" #"a")) -;; (#"^(a|x)\\1+b" #"aaaab" (#"aaaab" #"a")) -;; (#"^(a|x)\\1+b" #"ab" #f) -;; (#"^(a|)\\1?b" #"ab" (#"ab" #"a")) -;; (#"^(a|)\\1?b" #"aab" (#"aab" #"a")) -;; (#"^(a|)\\1?b" #"b" (#"b" #"")) -;; (#"^(a|)\\1?b" #"acb" #f) + (#"^(a|x)\\1*b" #"ab" (#"ab" #"a")) + (#"^(a|x)\\1*b" #"aaaab" (#"aaaab" #"a")) + (#"^(a|x)\\1*b" #"acb" #f) + (#"^(a|x)\\1+b" #"aab" (#"aab" #"a")) + (#"^(a|x)\\1+b" #"aaaab" (#"aaaab" #"a")) + (#"^(a|x)\\1+b" #"ab" #f) + (#"^(a|)\\1?b" #"ab" (#"ab" #"a")) + (#"^(a|)\\1?b" #"aab" (#"aab" #"a")) + (#"^(a|)\\1?b" #"b" (#"b" #"")) + (#"^(a|)\\1?b" #"acb" #f) ;; #"^(a|)\\1{2}b" ;; #"^(a|)\\1{2,3}b" -;; (#"ab{1,3}bc" #"abbbbc" (#"abbbbc")) -;; (#"ab{1,3}bc" #"abbbc" (#"abbbc")) -;; (#"ab{1,3}bc" #"abbc" (#"abbc")) -;; (#"ab{1,3}bc" #"abc" #f) -;; (#"ab{1,3}bc" #"abbbbbc" #f) -;; (#"([^.]*)\\.([^:]*):[T ]+(.*)" #"track1.title:TBlah blah blah" (#"track1.title:TBlah blah blah" #"track1" #"title" #"Blah blah blah")) + (#"ab{1,3}bc" #"abbbbc" (#"abbbbc")) + (#"ab{1,3}bc" #"abbbc" (#"abbbc")) + (#"ab{1,3}bc" #"abbc" (#"abbc")) + (#"ab{1,3}bc" #"abc" #f) + (#"ab{1,3}bc" #"abbbbbc" #f) + (#"([^.]*)\\.([^:]*):[T ]+(.*)" #"track1.title:TBlah blah blah" (#"track1.title:TBlah blah blah" #"track1" #"title" #"Blah blah blah")) +;; SyntaxError: Invalid regular expression: /(?i:([^.]*)\.([^:]*):[T ]+(.*))/: Invalid group ;; (#"(?i:([^.]*)\\.([^:]*):[T ]+(.*))" #"track1.title:TBlah blah blah" (#"track1.title:TBlah blah blah" #"track1" #"title" #"Blah blah blah")) ;; (#"(?i:([^.]*)\\.([^:]*):[t ]+(.*))" #"track1.title:TBlah blah blah" (#"track1.title:TBlah blah blah" #"track1" #"title" #"Blah blah blah")) -;; (#"^[W-c]+$" #"WXY_^abc" (#"WXY_^abc")) -;; (#"^[W-c]+$" #"wxy" #f) -;; (#"(?i:^[W-c]+$)" #"WXY_^abc" (#"WXY_^abc")) -;; (#"(?i:^[W-c]+$)" #"wxy_^ABC" (#"wxy_^ABC")) -;; (#"(?i:^[\x3f-\x5F]+$)" #"WXY_^abc" (#"WXY_^abc")) -;; (#"(?i:^[\x3f-\x5F]+$)" #"wxy_^ABC" (#"wxy_^ABC")) -;; (#"(?:b)|(?::+)" #"b::c" (#"b")) -;; (#"(?:b)|(?::+)" #"c::b" (#"::")) -;; (#"[-az]+" #"az-" (#"az-")) -;; (#"[-az]+" #"b" #f) -;; (#"[az-]+" #"za-" (#"za-")) -;; (#"[az-]+" #"b" #f) -;; (#"[a\\-z]+" #"a-z" (#"a-z")) -;; (#"[a\\-z]+" #"b" #f) -;; (#"[a-z]+" #"abcdxyz" (#"abcdxyz")) -;; (#"[\\d-]+" #"12-34" (#"12-34")) -;; (#"[\\d-]+" #"aaa" #f) + (#"^[W-c]+$" #"WXY_^abc" (#"WXY_^abc")) + (#"^[W-c]+$" #"wxy" #f) + ;; (#"(?i:^[W-c]+$)" #"WXY_^abc" (#"WXY_^abc")) + ;; (#"(?i:^[W-c]+$)" #"wxy_^ABC" (#"wxy_^ABC")) + ;; (#"(?i:^[\x3f-\x5F]+$)" #"WXY_^abc" (#"WXY_^abc")) + ;; (#"(?i:^[\x3f-\x5F]+$)" #"wxy_^ABC" (#"wxy_^ABC")) + (#"(?:b)|(?::+)" #"b::c" (#"b")) + (#"(?:b)|(?::+)" #"c::b" (#"::")) + (#"[-az]+" #"az-" (#"az-")) + (#"[-az]+" #"b" #f) + (#"[az-]+" #"za-" (#"za-")) + (#"[az-]+" #"b" #f) + (#"[a\\-z]+" #"a-z" (#"a-z")) + (#"[a\\-z]+" #"b" #f) + (#"[a-z]+" #"abcdxyz" (#"abcdxyz")) + (#"[\\d-]+" #"12-34" (#"12-34")) + (#"[\\d-]+" #"aaa" #f) ;; #"[\\d-z]" -;; (#"[\\dz-]+" #"12-34z" (#"12-34z")) -;; (#"[\\dz-]+" #"aaa" #f) + (#"[\\dz-]+" #"12-34z" (#"12-34z")) + (#"[\\dz-]+" #"aaa" #f) ;; (#"\\\x5c" #"\\\\" (#"\\")) ;; (#"\x20Z" #"the Zoo" (#" Z")) ;; (#"\x20Z" #"Zulu" #f) From 1b4b4d0e26d19ca4daf5c0831d7509b5272df8e8 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Mon, 22 Nov 2021 10:03:21 -0500 Subject: [PATCH 22/61] enable more rx tests --- tests/racket-core/rx.rkt | 310 +++++++++++++++++++-------------------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/tests/racket-core/rx.rkt b/tests/racket-core/rx.rkt index f830face..db563a3d 100644 --- a/tests/racket-core/rx.rkt +++ b/tests/racket-core/rx.rkt @@ -660,201 +660,201 @@ ;; #"[\\d-z]" (#"[\\dz-]+" #"12-34z" (#"12-34z")) (#"[\\dz-]+" #"aaa" #f) -;; (#"\\\x5c" #"\\\\" (#"\\")) -;; (#"\x20Z" #"the Zoo" (#" Z")) -;; (#"\x20Z" #"Zulu" #f) + (#"\\\x5c" #"\\\\" (#"\\")) + (#"\x20Z" #"the Zoo" (#" Z")) + (#"\x20Z" #"Zulu" #f) ;; (#"(?i:(abc)\\1)" #"abcabc" (#"abcabc" #"abc")) ;; (#"(?i:(abc)\\1)" #"ABCabc" (#"ABCabc" #"ABC")) ;; (#"(?i:(abc)\\1)" #"abcABC" (#"abcABC" #"abc")) -;; (#"ab\\{3cd" #"ab{3cd" (#"ab{3cd")) + (#"ab\\{3cd" #"ab{3cd" (#"ab{3cd")) ;; #"ab{3cd" -;; (#"ab\\{3,cd" #"ab{3,cd" (#"ab{3,cd")) + (#"ab\\{3,cd" #"ab{3,cd" (#"ab{3,cd")) ;; #"ab{3,cd" -;; (#"ab\\{3,4a\\}cd" #"ab{3,4a}cd" (#"ab{3,4a}cd")) + (#"ab\\{3,4a\\}cd" #"ab{3,4a}cd" (#"ab{3,4a}cd")) ;; #"ab{3,4a}cd" -;; (#"\\{4,5a\\}bc" #"{4,5a}bc" (#"{4,5a}bc")) + (#"\\{4,5a\\}bc" #"{4,5a}bc" (#"{4,5a}bc")) ;; #"{4,5a}bc" -;; (#"(abc)\123" #"abc\x53" (#"abcS" #"abc")) + (#"(abc)\123" #"abc\x53" (#"abcS" #"abc")) ;; (#"(abc)\223" #"abc\x93" (#"abc\x93" #"abc")) ;; (#"(abc)\323" #"abc\xd3" (#"abc\xd3" #"abc")) -;; (#"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\12\123" #"abcdefghijkllS" (#"abcdefghijkllS" #"a" #"b" #"c" #"d" #"e" #"f" #"g" #"h" #"i" #"j" #"k" #"l")) + (#"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\12\123" #"abcdefghijkllS" (#"abcdefghijkllS" #"a" #"b" #"c" #"d" #"e" #"f" #"g" #"h" #"i" #"j" #"k" #"l")) ;; #"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\\12\123" -;; (#"a{0}bc" #"bc" (#"bc")) -;; (#"(a|(bc)){0,0}?xyz" #"xyz" (#"xyz" #f #f)) + (#"a{0}bc" #"bc" (#"bc")) + (#"(a|(bc)){0,0}?xyz" #"xyz" (#"xyz" #f #f)) ;; (#"abc[\\10]de" #"abc\010de" #f) ;; (#"abc[\\1]de" #"abc\1de" #f) ;; (#"(abc)[\\1]de" #"abc\1de" #f) ;; "^([^a])([^\\b])([^c]*)([^d]{3,4})" -;; (#"[^a]" #"Abc" (#"A")) + (#"[^a]" #"Abc" (#"A")) ;; (#"(?i:[^a])" #"Abc " (#"b")) -;; (#"[^a]+" #"AAAaAbc" (#"AAA")) + (#"[^a]+" #"AAAaAbc" (#"AAA")) ;; (#"(?i:[^a]+)" #"AAAaAbc " (#"bc ")) -;; (#"[^k]$" #"abc" (#"c")) -;; (#"[^k]$" #"abk " (#" ")) -;; (#"[^k]{2,3}$" #"abc" (#"abc")) -;; (#"[^k]{2,3}$" #"kbc" (#"bc")) -;; (#"[^k]{2,3}$" #"kabc " (#"bc ")) -;; (#"[^k]{2,3}$" #"abk" #f) -;; (#"[^k]{2,3}$" #"akb" #f) -;; (#"[^k]{2,3}$" #"akk " #f) -;; (#"^\\d{8,}\\@.+[^k]$" #"12345678\\@a.b.c.d" #f) -;; (#"^\\d{8,}\\@.+[^k]$" #"123456789\\@x.y.z" #f) -;; (#"^\\d{8,}\\@.+[^k]$" #"12345678\\@x.y.uk" #f) -;; (#"^\\d{8,}\\@.+[^k]$" #"1234567\\@a.b.c.d " #f) -;; (#"(a)\\1{8,}" #"aaaaaaaaa" (#"aaaaaaaaa" #"a")) -;; (#"(a)\\1{8,}" #"aaaaaaaaaa" (#"aaaaaaaaaa" #"a")) -;; (#"(a)\\1{8,}" #"aaaaaaa " #f) -;; (#"[^a]" #"aaaabcd" (#"b")) -;; (#"[^a]" #"aaAabcd " (#"A")) + (#"[^k]$" #"abc" (#"c")) + (#"[^k]$" #"abk " (#" ")) + (#"[^k]{2,3}$" #"abc" (#"abc")) + (#"[^k]{2,3}$" #"kbc" (#"bc")) + (#"[^k]{2,3}$" #"kabc " (#"bc ")) + (#"[^k]{2,3}$" #"abk" #f) + (#"[^k]{2,3}$" #"akb" #f) + (#"[^k]{2,3}$" #"akk " #f) + (#"^\\d{8,}\\@.+[^k]$" #"12345678\\@a.b.c.d" #f) + (#"^\\d{8,}\\@.+[^k]$" #"123456789\\@x.y.z" #f) + (#"^\\d{8,}\\@.+[^k]$" #"12345678\\@x.y.uk" #f) + (#"^\\d{8,}\\@.+[^k]$" #"1234567\\@a.b.c.d " #f) + (#"(a)\\1{8,}" #"aaaaaaaaa" (#"aaaaaaaaa" #"a")) + (#"(a)\\1{8,}" #"aaaaaaaaaa" (#"aaaaaaaaaa" #"a")) + (#"(a)\\1{8,}" #"aaaaaaa " #f) + (#"[^a]" #"aaaabcd" (#"b")) + (#"[^a]" #"aaAabcd " (#"A")) ;; (#"(?i:[^a])" #"aaaabcd" (#"b")) ;; (#"(?i:[^a])" #"aaAabcd " (#"b")) -;; (#"[^az]" #"aaaabcd" (#"b")) -;; (#"[^az]" #"aaAabcd " (#"A")) + (#"[^az]" #"aaaabcd" (#"b")) + (#"[^az]" #"aaAabcd " (#"A")) ;; (#"(?i:[^az])" #"aaaabcd" (#"b")) ;; (#"(?i:[^az])" #"aaAabcd " (#"b")) -;; (#"P[^*]TAIRE[^*]{1,6}?LL" #"xxxxxxxxxxxPSTAIREISLLxxxxxxxxx" (#"PSTAIREISLL")) -;; (#"P[^*]TAIRE[^*]{1,}?LL" #"xxxxxxxxxxxPSTAIREISLLxxxxxxxxx" (#"PSTAIREISLL")) -;; (#"(\\.\\d\\d[1-9]?)\\d+" #"1.230003938" (#".230003938" #".23")) -;; (#"(\\.\\d\\d[1-9]?)\\d+" #"1.875000282 " (#".875000282" #".875")) -;; (#"(\\.\\d\\d[1-9]?)\\d+" #"1.235 " (#".235" #".23")) -;; (#"(\\.\\d\\d((?=0)|\\d(?=\\d)))" #"1.230003938 " (#".23" #".23" #"")) -;; (#"(\\.\\d\\d((?=0)|\\d(?=\\d)))" #"1.875000282" (#".875" #".875" #"5")) -;; (#"(\\.\\d\\d((?=0)|\\d(?=\\d)))" #"1.235 " #f) -;; (#"a(?:)b" #"ab " (#"ab")) + (#"P[^*]TAIRE[^*]{1,6}?LL" #"xxxxxxxxxxxPSTAIREISLLxxxxxxxxx" (#"PSTAIREISLL")) + (#"P[^*]TAIRE[^*]{1,}?LL" #"xxxxxxxxxxxPSTAIREISLLxxxxxxxxx" (#"PSTAIREISLL")) + (#"(\\.\\d\\d[1-9]?)\\d+" #"1.230003938" (#".230003938" #".23")) + (#"(\\.\\d\\d[1-9]?)\\d+" #"1.875000282 " (#".875000282" #".875")) + (#"(\\.\\d\\d[1-9]?)\\d+" #"1.235 " (#".235" #".23")) + (#"(\\.\\d\\d((?=0)|\\d(?=\\d)))" #"1.230003938 " (#".23" #".23" #"")) + (#"(\\.\\d\\d((?=0)|\\d(?=\\d)))" #"1.875000282" (#".875" #".875" #"5")) + (#"(\\.\\d\\d((?=0)|\\d(?=\\d)))" #"1.235 " #f) + (#"a(?:)b" #"ab " (#"ab")) ;; (#"(?i:\\b(foo)\\s+(\\w+))" #"Food is on the foo table" (#"foo table" #"foo" #"table")) -;; (#"foo(.*)bar" #"The food is under the bar in the barn." (#"food is under the bar in the bar" #"d is under the bar in the ")) -;; (#"foo(.*?)bar" #"The food is under the bar in the barn." (#"food is under the bar" #"d is under the ")) -;; (#"(.*)(\\d*)" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: 53147" #"")) -;; (#"(.*)(\\d+)" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: 5314" #"7")) -;; (#"(.*?)(\\d*)" #"I have 2 numbers: 53147" (#"" #"" #"")) -;; (#"(.*?)(\\d+)" #"I have 2 numbers: 53147" (#"I have 2" #"I have " #"2")) -;; (#"(.*)(\\d+)$" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: 5314" #"7")) -;; (#"(.*?)(\\d+)$" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: " #"53147")) -;; (#"(.*)\\b(\\d+)$" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: " #"53147")) -;; (#"(.*\\D)(\\d+)$" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: " #"53147")) -;; (#"^\\D*(?!123)" #"ABC123" (#"AB")) -;; (#"^(\\D*)(?=\\d)(?!123)" #"ABC445" (#"ABC" #"ABC")) -;; (#"^(\\D*)(?=\\d)(?!123)" #"ABC123" #f) + (#"foo(.*)bar" #"The food is under the bar in the barn." (#"food is under the bar in the bar" #"d is under the bar in the ")) + (#"foo(.*?)bar" #"The food is under the bar in the barn." (#"food is under the bar" #"d is under the ")) + (#"(.*)(\\d*)" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: 53147" #"")) + (#"(.*)(\\d+)" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: 5314" #"7")) + (#"(.*?)(\\d*)" #"I have 2 numbers: 53147" (#"" #"" #"")) + (#"(.*?)(\\d+)" #"I have 2 numbers: 53147" (#"I have 2" #"I have " #"2")) + (#"(.*)(\\d+)$" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: 5314" #"7")) + (#"(.*?)(\\d+)$" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: " #"53147")) + (#"(.*)\\b(\\d+)$" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: " #"53147")) + (#"(.*\\D)(\\d+)$" #"I have 2 numbers: 53147" (#"I have 2 numbers: 53147" #"I have 2 numbers: " #"53147")) + (#"^\\D*(?!123)" #"ABC123" (#"AB")) + (#"^(\\D*)(?=\\d)(?!123)" #"ABC445" (#"ABC" #"ABC")) + (#"^(\\D*)(?=\\d)(?!123)" #"ABC123" #f) ;; #"^[W-]46]" -;; (#"^[W-]46\\]" #"W46]789 " (#"W46]")) -;; (#"^[W-]46\\]" #"-46]789" (#"-46]")) -;; (#"^[W-]46\\]" #"Wall" #f) -;; (#"^[W-]46\\]" #"Zebra" #f) -;; (#"^[W-]46\\]" #"42" #f) -;; (#"^[W-]46\\]" #"[abcd] " #f) -;; (#"^[W-]46\\]" #"]abcd[" #f) -;; (#"^[W-\\]46]" #"W46]789 " (#"W")) -;; (#"^[W-\\]46]" #"Wall" (#"W")) -;; (#"^[W-\\]46]" #"Zebra" (#"Z")) -;; (#"^[W-\\]46]" #"Xylophone " (#"X")) -;; (#"^[W-\\]46]" #"42" (#"4")) -;; (#"^[W-\\]46]" #"[abcd] " (#"[")) -;; (#"^[W-\\]46]" #"]abcd[" (#"]")) -;; (#"^[W-\\]46]" #"\\\\backslash " (#"\\")) -;; (#"^[W-\\]46]" #"-46]789" #f) -;; (#"^[W-\\]46]" #"well" #f) -;; (#"\\d\\d\\/\\d\\d\\/\\d\\d\\d\\d" #"01/01/2000" (#"01/01/2000")) -;; (#"word (?:[a-zA-Z0-9]+ ){0,10}otherword" #"rd cat dog elephant mussel cow horse canary baboon snake shark otherword" #f) -;; (#"word (?:[a-zA-Z0-9]+ ){0,10}otherword" #"rd cat dog elephant mussel cow horse canary baboon snake shark" #f) -;; (#"word (?:[a-zA-Z0-9]+ ){0,300}otherword" #"rd cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope" #f) -;; (#"^(a){0,0}" #"bcd" (#"" #f)) -;; (#"^(a){0,0}" #"abc" (#"" #f)) -;; (#"^(a){0,0}" #"aab " (#"" #f)) -;; (#"^(a){0,1}" #"bcd" (#"" #f)) -;; (#"^(a){0,1}" #"abc" (#"a" #"a")) -;; (#"^(a){0,1}" #"aab " (#"a" #"a")) -;; (#"^(a){0,2}" #"bcd" (#"" #f)) -;; (#"^(a){0,2}" #"abc" (#"a" #"a")) -;; (#"^(a){0,2}" #"aab " (#"aa" #"a")) -;; (#"^(a){0,3}" #"bcd" (#"" #f)) -;; (#"^(a){0,3}" #"abc" (#"a" #"a")) -;; (#"^(a){0,3}" #"aab" (#"aa" #"a")) -;; (#"^(a){0,3}" #"aaa " (#"aaa" #"a")) -;; (#"^(a){0,}" #"bcd" (#"" #f)) -;; (#"^(a){0,}" #"abc" (#"a" #"a")) -;; (#"^(a){0,}" #"aab" (#"aa" #"a")) -;; (#"^(a){0,}" #"aaa" (#"aaa" #"a")) -;; (#"^(a){0,}" #"aaaaaaaa " (#"aaaaaaaa" #"a")) -;; (#"^(a){1,1}" #"bcd" #f) -;; (#"^(a){1,1}" #"abc" (#"a" #"a")) -;; (#"^(a){1,1}" #"aab " (#"a" #"a")) -;; (#"^(a){1,2}" #"bcd" #f) -;; (#"^(a){1,2}" #"abc" (#"a" #"a")) -;; (#"^(a){1,2}" #"aab " (#"aa" #"a")) -;; (#"^(a){1,3}" #"bcd" #f) -;; (#"^(a){1,3}" #"abc" (#"a" #"a")) -;; (#"^(a){1,3}" #"aab" (#"aa" #"a")) -;; (#"^(a){1,3}" #"aaa " (#"aaa" #"a")) -;; (#"^(a){1,}" #"bcd" #f) -;; (#"^(a){1,}" #"abc" (#"a" #"a")) -;; (#"^(a){1,}" #"aab" (#"aa" #"a")) -;; (#"^(a){1,}" #"aaa" (#"aaa" #"a")) -;; (#"^(a){1,}" #"aaaaaaaa " (#"aaaaaaaa" #"a")) -;; (#"^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" #"123456654321" (#"123456654321")) -;; (#"^\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d" #"123456654321 " (#"123456654321")) -;; (#"^[\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d]" #"123456654321" (#"123456654321")) -;; (#"^[abc]{12}" #"abcabcabcabc" (#"abcabcabcabc")) -;; (#"^[a-c]{12}" #"abcabcabcabc" (#"abcabcabcabc")) -;; (#"^(a|b|c){12}" #"abcabcabcabc " (#"abcabcabcabc" #"c")) -;; (#"^[abcdefghijklmnopqrstuvwxy0123456789]" #"n" (#"n")) -;; (#"^[abcdefghijklmnopqrstuvwxy0123456789]" #"z " #f) -;; (#"abcde{0,0}" #"abcd" (#"abcd")) -;; (#"abcde{0,0}" #"abce " #f) -;; (#"ab[cd]{0,0}e" #"abe" (#"abe")) -;; (#"ab[cd]{0,0}e" #"abcde " #f) -;; (#"ab(c){0,0}d" #"abd" (#"abd" #f)) -;; (#"ab(c){0,0}d" #"abcd " #f) -;; (#"a(b*)" #"a" (#"a" #"")) -;; (#"a(b*)" #"ab" (#"ab" #"b")) -;; (#"a(b*)" #"abbbb" (#"abbbb" #"bbbb")) -;; (#"a(b*)" #"bbbbb " #f) -;; (#"ab\\d{0}e" #"abe" (#"abe")) -;; (#"ab\\d{0}e" #"ab1e " #f) -;; (#"\"([^\\\\\"]+|\\\\.)*\"" #"the \\\"quick\\\" brown fox" #f) -;; (#"\"([^\\\\\"]+|\\\\.)*\"" #"\\\"the \\\\\\\"quick\\\\\\\" brown fox\\\" " #f) + (#"^[W-]46\\]" #"W46]789 " (#"W46]")) + (#"^[W-]46\\]" #"-46]789" (#"-46]")) + (#"^[W-]46\\]" #"Wall" #f) + (#"^[W-]46\\]" #"Zebra" #f) + (#"^[W-]46\\]" #"42" #f) + (#"^[W-]46\\]" #"[abcd] " #f) + (#"^[W-]46\\]" #"]abcd[" #f) + (#"^[W-\\]46]" #"W46]789 " (#"W")) + (#"^[W-\\]46]" #"Wall" (#"W")) + (#"^[W-\\]46]" #"Zebra" (#"Z")) + (#"^[W-\\]46]" #"Xylophone " (#"X")) + (#"^[W-\\]46]" #"42" (#"4")) + (#"^[W-\\]46]" #"[abcd] " (#"[")) + (#"^[W-\\]46]" #"]abcd[" (#"]")) + (#"^[W-\\]46]" #"\\\\backslash " (#"\\")) + (#"^[W-\\]46]" #"-46]789" #f) + (#"^[W-\\]46]" #"well" #f) + (#"\\d\\d\\/\\d\\d\\/\\d\\d\\d\\d" #"01/01/2000" (#"01/01/2000")) + (#"word (?:[a-zA-Z0-9]+ ){0,10}otherword" #"rd cat dog elephant mussel cow horse canary baboon snake shark otherword" #f) + (#"word (?:[a-zA-Z0-9]+ ){0,10}otherword" #"rd cat dog elephant mussel cow horse canary baboon snake shark" #f) + (#"word (?:[a-zA-Z0-9]+ ){0,300}otherword" #"rd cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope" #f) + (#"^(a){0,0}" #"bcd" (#"" #f)) + (#"^(a){0,0}" #"abc" (#"" #f)) + (#"^(a){0,0}" #"aab " (#"" #f)) + (#"^(a){0,1}" #"bcd" (#"" #f)) + (#"^(a){0,1}" #"abc" (#"a" #"a")) + (#"^(a){0,1}" #"aab " (#"a" #"a")) + (#"^(a){0,2}" #"bcd" (#"" #f)) + (#"^(a){0,2}" #"abc" (#"a" #"a")) + (#"^(a){0,2}" #"aab " (#"aa" #"a")) + (#"^(a){0,3}" #"bcd" (#"" #f)) + (#"^(a){0,3}" #"abc" (#"a" #"a")) + (#"^(a){0,3}" #"aab" (#"aa" #"a")) + (#"^(a){0,3}" #"aaa " (#"aaa" #"a")) + (#"^(a){0,}" #"bcd" (#"" #f)) + (#"^(a){0,}" #"abc" (#"a" #"a")) + (#"^(a){0,}" #"aab" (#"aa" #"a")) + (#"^(a){0,}" #"aaa" (#"aaa" #"a")) + (#"^(a){0,}" #"aaaaaaaa " (#"aaaaaaaa" #"a")) + (#"^(a){1,1}" #"bcd" #f) + (#"^(a){1,1}" #"abc" (#"a" #"a")) + (#"^(a){1,1}" #"aab " (#"a" #"a")) + (#"^(a){1,2}" #"bcd" #f) + (#"^(a){1,2}" #"abc" (#"a" #"a")) + (#"^(a){1,2}" #"aab " (#"aa" #"a")) + (#"^(a){1,3}" #"bcd" #f) + (#"^(a){1,3}" #"abc" (#"a" #"a")) + (#"^(a){1,3}" #"aab" (#"aa" #"a")) + (#"^(a){1,3}" #"aaa " (#"aaa" #"a")) + (#"^(a){1,}" #"bcd" #f) + (#"^(a){1,}" #"abc" (#"a" #"a")) + (#"^(a){1,}" #"aab" (#"aa" #"a")) + (#"^(a){1,}" #"aaa" (#"aaa" #"a")) + (#"^(a){1,}" #"aaaaaaaa " (#"aaaaaaaa" #"a")) + (#"^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" #"123456654321" (#"123456654321")) + (#"^\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d" #"123456654321 " (#"123456654321")) + (#"^[\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d]" #"123456654321" (#"123456654321")) + (#"^[abc]{12}" #"abcabcabcabc" (#"abcabcabcabc")) + (#"^[a-c]{12}" #"abcabcabcabc" (#"abcabcabcabc")) + (#"^(a|b|c){12}" #"abcabcabcabc " (#"abcabcabcabc" #"c")) + (#"^[abcdefghijklmnopqrstuvwxy0123456789]" #"n" (#"n")) + (#"^[abcdefghijklmnopqrstuvwxy0123456789]" #"z " #f) + (#"abcde{0,0}" #"abcd" (#"abcd")) + (#"abcde{0,0}" #"abce " #f) + (#"ab[cd]{0,0}e" #"abe" (#"abe")) + (#"ab[cd]{0,0}e" #"abcde " #f) + (#"ab(c){0,0}d" #"abd" (#"abd" #f)) + (#"ab(c){0,0}d" #"abcd " #f) + (#"a(b*)" #"a" (#"a" #"")) + (#"a(b*)" #"ab" (#"ab" #"b")) + (#"a(b*)" #"abbbb" (#"abbbb" #"bbbb")) + (#"a(b*)" #"bbbbb " #f) + (#"ab\\d{0}e" #"abe" (#"abe")) + (#"ab\\d{0}e" #"ab1e " #f) + (#"\"([^\\\\\"]+|\\\\.)*\"" #"the \\\"quick\\\" brown fox" #f) + (#"\"([^\\\\\"]+|\\\\.)*\"" #"\\\"the \\\\\\\"quick\\\\\\\" brown fox\\\" " #f) ;; (#"(?i:]{0,})>]{0,})>([\\d]{0,}\\.)(.*)((
([\\w\\W\\s\\d][^<>]{0,})|[\\s]{0,}))<\\/a><\\/TD>]{0,})>([\\w\\W\\s\\d][^<>]{0,})<\\/TD>]{0,})>([\\w\\W\\s\\d][^<>]{0,})<\\/TD><\\/TR>)" #"R BGCOLOR='#DBE9E9'>43.Word Processor
(N-1286)
Lega lstaff.comCA - Statewide" #f) -;; (#"^(b+?|a){1,2}?c" #"bac" (#"bac" #"a")) -;; (#"^(b+?|a){1,2}?c" #"bbac" (#"bbac" #"a")) -;; (#"^(b+?|a){1,2}?c" #"bbbac" (#"bbbac" #"a")) -;; (#"^(b+?|a){1,2}?c" #"bbbbac" (#"bbbbac" #"a")) -;; (#"^(b+?|a){1,2}?c" #"bbbbbac " (#"bbbbbac" #"a")) -;; (#"^(b+|a){1,2}?c" #"bac" (#"bac" #"a")) -;; (#"^(b+|a){1,2}?c" #"bbac" (#"bbac" #"a")) -;; (#"^(b+|a){1,2}?c" #"bbbac" (#"bbbac" #"a")) -;; (#"^(b+|a){1,2}?c" #"bbbbac" (#"bbbbac" #"a")) -;; (#"^(b+|a){1,2}?c" #"bbbbbac " (#"bbbbbac" #"a")) -;; (#"\x0\\{ab\\}" #"\0{ab}" (#"\0{ab}")) -;; (#"(A|B)*?CD" #"CD " (#"CD" #f)) -;; (#"(A|B)*CD" #"CD " (#"CD" #f)) + (#"^(b+?|a){1,2}?c" #"bac" (#"bac" #"a")) + (#"^(b+?|a){1,2}?c" #"bbac" (#"bbac" #"a")) + (#"^(b+?|a){1,2}?c" #"bbbac" (#"bbbac" #"a")) + (#"^(b+?|a){1,2}?c" #"bbbbac" (#"bbbbac" #"a")) + (#"^(b+?|a){1,2}?c" #"bbbbbac " (#"bbbbbac" #"a")) + (#"^(b+|a){1,2}?c" #"bac" (#"bac" #"a")) + (#"^(b+|a){1,2}?c" #"bbac" (#"bbac" #"a")) + (#"^(b+|a){1,2}?c" #"bbbac" (#"bbbac" #"a")) + (#"^(b+|a){1,2}?c" #"bbbbac" (#"bbbbac" #"a")) + (#"^(b+|a){1,2}?c" #"bbbbbac " (#"bbbbbac" #"a")) + (#"\x0\\{ab\\}" #"\0{ab}" (#"\0{ab}")) + (#"(A|B)*?CD" #"CD " (#"CD" #f)) + (#"(A|B)*CD" #"CD " (#"CD" #f)) ;; (#"(AB)*?\\1" #"ABABAB" (#"ABAB" #"AB")) ;; (#"(AB)*\\1" #"ABABAB" (#"ABABAB" #"AB")) ;; #"((a{0,5}){0,5}){0,5}[c]" ;; #"((a{0,5}){0,5})*[c]" ;; #"((a{0,5}){0,5})*[c]" ;; #"(\\b)*a" -;; (#"(a)*b" #"ab" (#"ab" #"a")) + (#"(a)*b" #"ab" (#"ab" #"a")) ;; #"(a|)*b" ;; #"(a|)*b" ;; #"(a|)*b" ;; (#"^(?:(a)|(b))*\\1\\2$" #"abab" (#"abab" #"a" #"b")) -;; (#"abc[^x]def" #"abcxabcydef" (#"abcydef")) + (#"abc[^x]def" #"abcxabcydef" (#"abcydef")) ;; (#"^(a|\\1x)*$" #"aax" (#"aax" #"ax")) ;; (#"^(a|\\1x)*$" #"aaxa" (#"aaxa" #"a")) -;; (#"" #"@{['']}" (#"")) + (#"" #"@{['']}" (#"")) ;; (#"^(?:(a)|(b))*$" #"ab" (#"ab" #"a" #"b")) -;; (#"[\0]" #"a" #f) -;; (#"[\0]" #"\0" (#"\0")) -;; (#"[\1]" #"a" #f) -;; (#"[\1]" #"\1" (#"\1")) + (#"[\0]" #"a" #f) + (#"[\0]" #"\0" (#"\0")) + (#"[\1]" #"a" #f) + (#"[\1]" #"\1" (#"\1")) ;; (#"\\10()()()()()()()()()()" #"a" #f) -;; (#"a(?<=)b" #"ab" (#"ab")) ;; << added "=" to pattern -;; (#"(?<=qq)b*" #"aqbbbqqbb" (#"bb")) ;; << added -;; (#"(?<=q?q)b*" #"aqbbbqqbb" (#"bbb")) ;; << added -;; (#"()" #"a" (#"" #"")) + (#"a(?<=)b" #"ab" (#"ab")) ;; << added "=" to pattern + (#"(?<=qq)b*" #"aqbbbqqbb" (#"bb")) ;; << added + (#"(?<=q?q)b*" #"aqbbbqqbb" (#"bbb")) ;; << added + (#"()" #"a" (#"" #"")) ;; #"[\\x]" ;; #"[\\x]" ;; #"((a)*)*" -;; (#"()a\\1" #"a" (#"a" #"")) + (#"()a\\1" #"a" (#"a" #"")) ;; (#"a\\1()" #"a" #f) ;; (#"a(?i:a)a" #"aaa" (#"aaa")) ;; (#"a(?i:a)a" #"aAa" (#"aAa")) From aae4bff92f04c8c9ff3ba0bd9afb531f11aecdaa Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Tue, 23 Nov 2021 13:17:39 -0500 Subject: [PATCH 23/61] enable more rx tests --- tests/racket-core/rx.rkt | 274 ++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 134 deletions(-) diff --git a/tests/racket-core/rx.rkt b/tests/racket-core/rx.rkt index db563a3d..27c3fb9d 100644 --- a/tests/racket-core/rx.rkt +++ b/tests/racket-core/rx.rkt @@ -856,6 +856,7 @@ ;; #"((a)*)*" (#"()a\\1" #"a" (#"a" #"")) ;; (#"a\\1()" #"a" #f) +;; SyntaxError: Invalid regular expression: /a(?i:a)a/: Invalid group ;; (#"a(?i:a)a" #"aaa" (#"aaa")) ;; (#"a(?i:a)a" #"aAa" (#"aAa")) ;; (#"a(?i:a)a" #"aAA" #f) @@ -877,33 +878,33 @@ ;; #"[\\d-f]" ;; #"[\\d-f]" ;; #"[\\d-f]" -;; (#"[-b\\d]" #"b" (#"b")) -;; (#"[-b\\d]" #"c" #f) -;; (#"[-b\\d]" #"d" #f) -;; (#"[-b\\d]" #"-" (#"-")) -;; (#"[-b\\d]" #"1" (#"1")) -;; (#"[\\df-]" #"d" #f) -;; (#"[\\df-]" #"e" #f) -;; (#"[\\df-]" #"f" (#"f")) -;; (#"[\\df-]" #"-" (#"-")) -;; (#"[\\df-]" #"1" (#"1")) -;; (#"[-a-c]" #"-" (#"-")) -;; (#"[-a-c]" #"a" (#"a")) -;; (#"[-a-c]" #"b" (#"b")) -;; (#"[-a-c]" #"d" #f) -;; (#"[a-c-]" #"-" (#"-")) -;; (#"[a-c-]" #"a" (#"a")) -;; (#"[a-c-]" #"b" (#"b")) -;; (#"[a-c-]" #"d" #f) -;; (#"[-]" #"a" #f) -;; (#"[-]" #"-" (#"-")) -;; (#"[--]" #"a" #f) -;; (#"[--]" #"-" (#"-")) + (#"[-b\\d]" #"b" (#"b")) + (#"[-b\\d]" #"c" #f) + (#"[-b\\d]" #"d" #f) + (#"[-b\\d]" #"-" (#"-")) + (#"[-b\\d]" #"1" (#"1")) + (#"[\\df-]" #"d" #f) + (#"[\\df-]" #"e" #f) + (#"[\\df-]" #"f" (#"f")) + (#"[\\df-]" #"-" (#"-")) + (#"[\\df-]" #"1" (#"1")) + (#"[-a-c]" #"-" (#"-")) + (#"[-a-c]" #"a" (#"a")) + (#"[-a-c]" #"b" (#"b")) + (#"[-a-c]" #"d" #f) + (#"[a-c-]" #"-" (#"-")) + (#"[a-c-]" #"a" (#"a")) + (#"[a-c-]" #"b" (#"b")) + (#"[a-c-]" #"d" #f) + (#"[-]" #"a" #f) + (#"[-]" #"-" (#"-")) + (#"[--]" #"a" #f) + (#"[--]" #"-" (#"-")) ;; #"[---]" ;; #"[--b]" -;; (#"[-b-]" #"-" (#"-")) -;; (#"[-b-]" #"a" #f) -;; (#"[-b-]" #"c" #f) + (#"[-b-]" #"-" (#"-")) + (#"[-b-]" #"a" #f) + (#"[-b-]" #"c" #f) ;; #"a{" ;; (#"a{}" #"aaa" (#"")) ;; #"a{3" @@ -925,11 +926,11 @@ ;; #"^a{ 1}$" ;; #"{}" ;; #"{}" -;; (#"|" #"x" (#"")) -;; (#"|x" #"x" (#"")) -;; (#"x|" #"x" (#"x")) -;; (#"\0000" #"\0000" (#"\0\x30")) -;; (#"a(?<=)b" #"ab" (#"ab")) + (#"|" #"x" (#"")) + (#"|x" #"x" (#"")) + (#"x|" #"x" (#"x")) + (#"\0000" #"\0000" (#"\0\x30")) + (#"a(?<=)b" #"ab" (#"ab")) ;; (#"a(?i:b)" #"ab" (#"ab")) ;; (#"a(?i:b)" #"aB" (#"aB")) ;; (#"a(?i:b)" #"Ab" #f) @@ -944,35 +945,37 @@ ;; #"a(?<=(a))*\\1" ;; #"a(?<=(a))*?\\1" ;; #"(?=(a)\\1)*aa" -;; (#"^((a|b){2,5}){2}$" #"aaabbbbb" (#"aaabbbbb" #"bbb" #"b")) + (#"^((a|b){2,5}){2}$" #"aaabbbbb" (#"aaabbbbb" #"bbb" #"b")) ;; #"^(b*|ba){1,2}bc" -;; (#"^a{4,5}(?:c|a)c$" #"aaac" #f) -;; (#"^a{4,5}(?:c|a)c$" #"aaaac" #f) + (#"^a{4,5}(?:c|a)c$" #"aaac" #f) + (#"^a{4,5}(?:c|a)c$" #"aaaac" #f) ;; #"^(a|){4,5}(?:c|a)c$" +;; SyntaxError: Invalid regular expression: /(?m:^).abc$/: Invalid group ;; (#"(?m:^).abc$" #"exabc" #f) ;; (#"(?m:^)abc" #"c" #f) -;; (#"^abc" #"c" #f) -;; (#"(?(\.\d\d[1-9]?))\d+/: Invalid group ;; (#"(?>(\\.\\d\\d[1-9]?))\\d+" #"1.230003938" (#".230003938" #".23")) ;; (#"(?>(\\.\\d\\d[1-9]?))\\d+" #"1.875000282" (#".875000282" #".875")) ;; (#"(?>(\\.\\d\\d[1-9]?))\\d+" #"1.235 " #f) ;; (#"^((?>\\w+)|(?>\\s+))*$" #"now is the time for all good men to come to the aid of the party" (#"now is the time for all good men to come to the aid of the party" #"party")) ;; (#"^((?>\\w+)|(?>\\s+))*$" #"this is not a line with only words and spaces!" #f) -;; (#"(\\d+)(\\w)" #"12345a" (#"12345a" #"12345" #"a")) -;; (#"(\\d+)(\\w)" #"12345+ " (#"12345" #"1234" #"5")) + (#"(\\d+)(\\w)" #"12345a" (#"12345a" #"12345" #"a")) + (#"(\\d+)(\\w)" #"12345+ " (#"12345" #"1234" #"5")) ;; (#"((?>\\d+))(\\w)" #"12345a" (#"12345a" #"12345" #"a")) ;; (#"((?>\\d+))(\\w)" #"12345+ " #f) ;; (#"(?>a+)b" #"aaab" (#"aaab")) @@ -1048,10 +1051,10 @@ ;; #"(?>a*)*" ;; #"((?>a*))*" ;; #"((?>a*?))*" -;; (#"(?<=(foo))bar\\1" #"foobarfoo" (#"barfoo" #"foo")) -;; (#"(?<=(foo))bar\\1" #"foobarfootling " (#"barfoo" #"foo")) -;; (#"(?<=(foo))bar\\1" #"foobar" #f) -;; (#"(?<=(foo))bar\\1" #"barfoo " #f) + (#"(?<=(foo))bar\\1" #"foobarfoo" (#"barfoo" #"foo")) + (#"(?<=(foo))bar\\1" #"foobarfootling " (#"barfoo" #"foo")) + (#"(?<=(foo))bar\\1" #"foobar" #f) + (#"(?<=(foo))bar\\1" #"barfoo " #f) ;; (#"(?i:saturday|sunday)" #"saturday" (#"saturday")) ;; (#"(?i:saturday|sunday)" #"sunday" (#"sunday")) ;; (#"(?i:saturday|sunday)" #"Saturday" (#"Saturday")) @@ -1083,93 +1086,96 @@ ;; (#"^(ab|a(?i:[b-c](?m-i:d))|(?m-i:x(?i:y))|(?i:z))" #"Zambesi" (#"Z" #"Z")) ;; (#"^(ab|a(?i:[b-c](?m-i:d))|(?m-i:x(?i:y))|(?i:z))" #"aCD " #f) ;; (#"^(ab|a(?i:[b-c](?m-i:d))|(?m-i:x(?i:y))|(?i:z))" #"XY " #f) -;; (#"(?<=(? Date: Wed, 15 Dec 2021 20:05:31 -0500 Subject: [PATCH 24/61] enable more tests --- tests/racket-core/rx.rkt | 210 +++++++++++++++++++-------------------- 1 file changed, 105 insertions(+), 105 deletions(-) diff --git a/tests/racket-core/rx.rkt b/tests/racket-core/rx.rkt index 27c3fb9d..24db82f2 100644 --- a/tests/racket-core/rx.rkt +++ b/tests/racket-core/rx.rkt @@ -1175,115 +1175,115 @@ ;; #"a]" ;; (#"a[]]" #"a]" (#"a]")) ;; (#"a[]]b" #"a]b" (#"a]b")) - (#"a[^bc]d" #"aed" (#"aed")) -;; (#"a[^bc]d" #"abd" #f) -;; (#"a[^bc]d" #"abd" #f) -;; (#"a[^-b]c" #"adc" (#"adc")) + (#"a[^bc]d" #"aed" (#"aed")) + (#"a[^bc]d" #"abd" #f) + (#"a[^bc]d" #"abd" #f) + (#"a[^-b]c" #"adc" (#"adc")) ;; (#"a[^]b]c" #"adc" (#"adc")) ;; (#"a[^]b]c" #"a-c" (#"a-c")) ;; (#"a[^]b]c" #"a]c" #f) -;; (#"\\ba\\b" #"a-" (#"a")) -;; (#"\\ba\\b" #"-a" (#"a")) -;; (#"\\ba\\b" #"-a-" (#"a")) -;; (#"\\by\\b" #"xy" #f) -;; (#"\\by\\b" #"yz" #f) -;; (#"\\by\\b" #"xyz" #f) -;; (#"\\Ba\\B" #"a-" #f) -;; (#"\\Ba\\B" #"-a" #f) -;; (#"\\Ba\\B" #"-a-" #f) -;; (#"\\By\\b" #"xy" (#"y")) -;; (#"\\by\\B" #"yz" (#"y")) -;; (#"\\By\\B" #"xyz" (#"y")) -;; (#"\\w" #"a" (#"a")) -;; (#"\\W" #"-" (#"-")) -;; (#"\\W" #"-" (#"-")) -;; (#"\\W" #"a" #f) -;; (#"a\\sb" #"a b" (#"a b")) -;; (#"a\\Sb" #"a-b" (#"a-b")) -;; (#"a\\Sb" #"a-b" (#"a-b")) -;; (#"a\\Sb" #"a b" #f) -;; (#"\\d" #"1" (#"1")) -;; (#"\\D" #"-" (#"-")) -;; (#"\\D" #"-" (#"-")) -;; (#"\\D" #"1" #f) -;; (#"[\\w]" #"a" (#"a")) -;; (#"[\\W]" #"-" (#"-")) -;; (#"[\\W]" #"-" (#"-")) -;; (#"[\\W]" #"a" #f) -;; (#"a[\\s]b" #"a b" (#"a b")) -;; (#"a[\\S]b" #"a-b" (#"a-b")) -;; (#"a[\\S]b" #"a-b" (#"a-b")) -;; (#"a[\\S]b" #"a b" #f) -;; (#"[\\d]" #"1" (#"1")) -;; (#"[\\D]" #"-" (#"-")) -;; (#"[\\D]" #"-" (#"-")) -;; (#"[\\D]" #"1" #f) -;; (#"ab|cd" #"abc" (#"ab")) -;; (#"ab|cd" #"abcd" (#"ab")) -;; (#"()ef" #"def" (#"ef" #"")) -;; (#"a\\(b" #"a(b" (#"a(b")) -;; (#"a\\(*b" #"ab" (#"ab")) -;; (#"a\\(*b" #"a((b" (#"a((b")) -;; (#"a\\\\b" #"a\\b" (#"a\\b")) -;; (#"((a))" #"abc" (#"a" #"a" #"a")) -;; (#"(a)b(c)" #"abc" (#"abc" #"a" #"c")) -;; (#"a+b+c" #"aabbabc" (#"abc")) -;; (#"a{1,}b{1,}c" #"aabbabc" (#"abc")) -;; (#"a.+?c" #"abcabc" (#"abc")) -;; (#"(a+|b)*" #"ab" (#"ab" #"b")) -;; (#"(a+|b){0,}" #"ab" (#"ab" #"b")) -;; (#"(a+|b)+" #"ab" (#"ab" #"b")) -;; (#"(a+|b){1,}" #"ab" (#"ab" #"b")) -;; (#"(a+|b)?" #"ab" (#"a" #"a")) -;; (#"(a+|b){0,1}" #"ab" (#"a" #"a")) -;; (#"[^ab]*" #"cde" (#"cde")) -;; (#"abc" #"b" #f) -;; (#"([abc])*d" #"abbbcd" (#"abbbcd" #"c")) -;; (#"([abc])*bcd" #"abcd" (#"abcd" #"a")) -;; (#"a|b|c|d|e" #"e" (#"e")) -;; (#"(a|b|c|d|e)f" #"ef" (#"ef" #"e")) -;; (#"abcd*efg" #"abcdefg" (#"abcdefg")) -;; (#"ab*" #"xabyabbbz" (#"ab")) -;; (#"ab*" #"xayabbbz" (#"a")) -;; (#"(ab|cd)e" #"abcde" (#"cde" #"cd")) -;; (#"[abhgefdc]ij" #"hij" (#"hij")) -;; (#"(abc|)ef" #"abcdef" (#"ef" #"")) -;; (#"(a|b)c*d" #"abcd" (#"bcd" #"b")) -;; (#"(ab|ab*)bc" #"abc" (#"abc" #"a")) -;; (#"a([bc]*)c*" #"abc" (#"abc" #"bc")) -;; (#"a([bc]*)(c*d)" #"abcd" (#"abcd" #"bc" #"d")) -;; (#"a([bc]+)(c*d)" #"abcd" (#"abcd" #"bc" #"d")) -;; (#"a([bc]*)(c+d)" #"abcd" (#"abcd" #"b" #"cd")) -;; (#"a[bcd]*dcdcde" #"adcdcde" (#"adcdcde")) -;; (#"a[bcd]+dcdcde" #"abcde" #f) -;; (#"a[bcd]+dcdcde" #"adcdcde" #f) -;; (#"(ab|a)b*c" #"abc" (#"abc" #"ab")) -;; (#"((a)(b)c)(d)" #"abcd" (#"abcd" #"abc" #"a" #"b" #"d")) -;; (#"[a-zA-Z_][a-zA-Z0-9_]*" #"alpha" (#"alpha")) -;; (#"^a(bc+|b[eh])g|.h$" #"abh" (#"bh" #f)) -;; (#"(bc+d$|ef*g.|h?i(j|k))" #"effgz" (#"effgz" #"effgz" #f)) -;; (#"(bc+d$|ef*g.|h?i(j|k))" #"ij" (#"ij" #"ij" #"j")) -;; (#"(bc+d$|ef*g.|h?i(j|k))" #"reffgz" (#"effgz" #"effgz" #f)) -;; (#"(bc+d$|ef*g.|h?i(j|k))" #"effg" #f) -;; (#"(bc+d$|ef*g.|h?i(j|k))" #"bcdd" #f) -;; (#"((((((((((a))))))))))" #"a" (#"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a")) -;; (#"((((((((((a))))))))))\\10" #"aa" (#"aa" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a")) -;; (#"(((((((((a)))))))))" #"a" (#"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a")) -;; (#"multiple words of text" #"aa" #f) -;; (#"multiple words of text" #"uh-uh" #f) -;; (#"multiple words" #"multiple words, yeah" (#"multiple words")) -;; (#"(.*)c(.*)" #"abcde" (#"abcde" #"ab" #"de")) -;; (#"\\((.*), (.*)\\)" #"(a, b)" (#"(a, b)" #"a" #"b")) -;; (#"abcd" #"abcd" (#"abcd")) -;; (#"a(bc)d" #"abcd" (#"abcd" #"bc")) -;; (#"a[-]?c" #"ac" (#"ac")) -;; (#"(abc)\\1" #"abcabc" (#"abcabc" #"abc")) -;; (#"([a-c]*)\\1" #"abcabc" (#"abcabc" #"abc")) -;; (#"(a)|\\1" #"a" (#"a" #"a")) -;; (#"(a)|\\1" #"ab" (#"a" #"a")) + (#"\\ba\\b" #"a-" (#"a")) + (#"\\ba\\b" #"-a" (#"a")) + (#"\\ba\\b" #"-a-" (#"a")) + (#"\\by\\b" #"xy" #f) + (#"\\by\\b" #"yz" #f) + (#"\\by\\b" #"xyz" #f) + (#"\\Ba\\B" #"a-" #f) + (#"\\Ba\\B" #"-a" #f) + (#"\\Ba\\B" #"-a-" #f) + (#"\\By\\b" #"xy" (#"y")) + (#"\\by\\B" #"yz" (#"y")) + (#"\\By\\B" #"xyz" (#"y")) + (#"\\w" #"a" (#"a")) + (#"\\W" #"-" (#"-")) + (#"\\W" #"-" (#"-")) + (#"\\W" #"a" #f) + (#"a\\sb" #"a b" (#"a b")) + (#"a\\Sb" #"a-b" (#"a-b")) + (#"a\\Sb" #"a-b" (#"a-b")) + (#"a\\Sb" #"a b" #f) + (#"\\d" #"1" (#"1")) + (#"\\D" #"-" (#"-")) + (#"\\D" #"-" (#"-")) + (#"\\D" #"1" #f) + (#"[\\w]" #"a" (#"a")) + (#"[\\W]" #"-" (#"-")) + (#"[\\W]" #"-" (#"-")) + (#"[\\W]" #"a" #f) + (#"a[\\s]b" #"a b" (#"a b")) + (#"a[\\S]b" #"a-b" (#"a-b")) + (#"a[\\S]b" #"a-b" (#"a-b")) + (#"a[\\S]b" #"a b" #f) + (#"[\\d]" #"1" (#"1")) + (#"[\\D]" #"-" (#"-")) + (#"[\\D]" #"-" (#"-")) + (#"[\\D]" #"1" #f) + (#"ab|cd" #"abc" (#"ab")) + (#"ab|cd" #"abcd" (#"ab")) + (#"()ef" #"def" (#"ef" #"")) + (#"a\\(b" #"a(b" (#"a(b")) + (#"a\\(*b" #"ab" (#"ab")) + (#"a\\(*b" #"a((b" (#"a((b")) + (#"a\\\\b" #"a\\b" (#"a\\b")) + (#"((a))" #"abc" (#"a" #"a" #"a")) + (#"(a)b(c)" #"abc" (#"abc" #"a" #"c")) + (#"a+b+c" #"aabbabc" (#"abc")) + (#"a{1,}b{1,}c" #"aabbabc" (#"abc")) + (#"a.+?c" #"abcabc" (#"abc")) + (#"(a+|b)*" #"ab" (#"ab" #"b")) + (#"(a+|b){0,}" #"ab" (#"ab" #"b")) + (#"(a+|b)+" #"ab" (#"ab" #"b")) + (#"(a+|b){1,}" #"ab" (#"ab" #"b")) + (#"(a+|b)?" #"ab" (#"a" #"a")) + (#"(a+|b){0,1}" #"ab" (#"a" #"a")) + (#"[^ab]*" #"cde" (#"cde")) + (#"abc" #"b" #f) + (#"([abc])*d" #"abbbcd" (#"abbbcd" #"c")) + (#"([abc])*bcd" #"abcd" (#"abcd" #"a")) + (#"a|b|c|d|e" #"e" (#"e")) + (#"(a|b|c|d|e)f" #"ef" (#"ef" #"e")) + (#"abcd*efg" #"abcdefg" (#"abcdefg")) + (#"ab*" #"xabyabbbz" (#"ab")) + (#"ab*" #"xayabbbz" (#"a")) + (#"(ab|cd)e" #"abcde" (#"cde" #"cd")) + (#"[abhgefdc]ij" #"hij" (#"hij")) + (#"(abc|)ef" #"abcdef" (#"ef" #"")) + (#"(a|b)c*d" #"abcd" (#"bcd" #"b")) + (#"(ab|ab*)bc" #"abc" (#"abc" #"a")) + (#"a([bc]*)c*" #"abc" (#"abc" #"bc")) + (#"a([bc]*)(c*d)" #"abcd" (#"abcd" #"bc" #"d")) + (#"a([bc]+)(c*d)" #"abcd" (#"abcd" #"bc" #"d")) + (#"a([bc]*)(c+d)" #"abcd" (#"abcd" #"b" #"cd")) + (#"a[bcd]*dcdcde" #"adcdcde" (#"adcdcde")) + (#"a[bcd]+dcdcde" #"abcde" #f) + (#"a[bcd]+dcdcde" #"adcdcde" #f) + (#"(ab|a)b*c" #"abc" (#"abc" #"ab")) + (#"((a)(b)c)(d)" #"abcd" (#"abcd" #"abc" #"a" #"b" #"d")) + (#"[a-zA-Z_][a-zA-Z0-9_]*" #"alpha" (#"alpha")) + (#"^a(bc+|b[eh])g|.h$" #"abh" (#"bh" #f)) + (#"(bc+d$|ef*g.|h?i(j|k))" #"effgz" (#"effgz" #"effgz" #f)) + (#"(bc+d$|ef*g.|h?i(j|k))" #"ij" (#"ij" #"ij" #"j")) + (#"(bc+d$|ef*g.|h?i(j|k))" #"reffgz" (#"effgz" #"effgz" #f)) + (#"(bc+d$|ef*g.|h?i(j|k))" #"effg" #f) + (#"(bc+d$|ef*g.|h?i(j|k))" #"bcdd" #f) + (#"((((((((((a))))))))))" #"a" (#"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a")) + (#"((((((((((a))))))))))\\10" #"aa" (#"aa" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a")) + (#"(((((((((a)))))))))" #"a" (#"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a" #"a")) + (#"multiple words of text" #"aa" #f) + (#"multiple words of text" #"uh-uh" #f) + (#"multiple words" #"multiple words, yeah" (#"multiple words")) + (#"(.*)c(.*)" #"abcde" (#"abcde" #"ab" #"de")) + (#"\\((.*), (.*)\\)" #"(a, b)" (#"(a, b)" #"a" #"b")) + (#"abcd" #"abcd" (#"abcd")) + (#"a(bc)d" #"abcd" (#"abcd" #"bc")) + (#"a[-]?c" #"ac" (#"ac")) + (#"(abc)\\1" #"abcabc" (#"abcabc" #"abc")) + (#"([a-c]*)\\1" #"abcabc" (#"abcabc" #"abc")) + (#"(a)|\\1" #"a" (#"a" #"a")) + (#"(a)|\\1" #"ab" (#"a" #"a")) ;; (#"(a)|\\1" #"x" #f) -;; (#"(([a-c])b*?\\2)*" #"ababbbcbc" (#"ababb" #"bb" #"b")) -;; (#"(([a-c])b*?\\2){3}" #"ababbbcbc" (#"ababbbcbc" #"cbc" #"c")) + (#"(([a-c])b*?\\2)*" #"ababbbcbc" (#"ababb" #"bb" #"b")) + (#"(([a-c])b*?\\2){3}" #"ababbbcbc" (#"ababbbcbc" #"cbc" #"c")) ;; (#"((\\3|b)\\2(a)x)+" #"aaaxabaxbaaxbbax" (#"bbax" #"bbax" #"b" #"a")) ;; (#"((\\3|b)\\2(a)){2,}" #"bbaababbabaaaaabbaaaabba" (#"bbaaaabba" #"bba" #"b" #"a")) ;; (#"(?i:abc)" #"ABC" (#"ABC")) From cb481456ec6ac2c3be57a3bc78bd7db4deacefcf Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Thu, 16 Dec 2021 09:37:31 -0500 Subject: [PATCH 25/61] fix imported super struct uncounted fields; closes #272 --- .../racketscript/compiler/runtime/core/struct.js | 16 +++++++++------- tests/struct/p.rkt | 4 ++++ tests/struct/super-required.rkt | 10 ++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 tests/struct/p.rkt create mode 100644 tests/struct/super-required.rkt diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js index 1a435e41..3c132852 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js @@ -39,12 +39,14 @@ class Struct extends PrintablePrimitive { super(); this._desc = desc; /* struct-type-descriptor */ - C.eq( - fields.length, - this._desc._totalInitFields, - racketCoreError, - 'arity mismatch' - ); + if (this._desc.getSuperType() !== undefined) { + C.eq( + fields.length, + this._desc._totalInitFields, + racketCoreError, + 'arity mismatch' + ); + } // Guard's are applied starting from subtype to supertype // Later when we instantiate the subtype, its guard will be @@ -67,7 +69,7 @@ class Struct extends PrintablePrimitive { // Initialize current and super instance this._superStructInstance = false; /* Struct instance of super-type */ const superType = this._desc.getSuperType(); - if (superType !== false) { + if ((superType !== false) && (superType !== undefined)){ const superInitFields = fields.slice(0, superType._totalInitFields); this._fields = fields.slice(superType._totalInitFields); this._superStructInstance = superType diff --git a/tests/struct/p.rkt b/tests/struct/p.rkt new file mode 100644 index 00000000..019333e9 --- /dev/null +++ b/tests/struct/p.rkt @@ -0,0 +1,4 @@ +#lang racket/base +;; this is imported by super-required.rkt, see pr #272 +(#%provide (struct p ())) +(define-struct p (val)) diff --git a/tests/struct/super-required.rkt b/tests/struct/super-required.rkt new file mode 100644 index 00000000..a37fbc41 --- /dev/null +++ b/tests/struct/super-required.rkt @@ -0,0 +1,10 @@ +#lang racket/base + +(require "p.rkt") + +;; fixes pr #272 +;; was getting arity mismatch err bc imported super struct's fields are counted +;; (there are subsequent errors as well if arity check is disabled) +;; (real-world example where this shows up is promises) +(define-struct (p2 p) ()) +(p2 1) From a3732e02357a9108dca9d102a64c18171cf9bd96 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Thu, 16 Dec 2021 10:39:15 -0500 Subject: [PATCH 26/61] fix lint errs --- .../racketscript/compiler/runtime/core/struct.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js index 3c132852..4b6f89f0 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js @@ -39,14 +39,14 @@ class Struct extends PrintablePrimitive { super(); this._desc = desc; /* struct-type-descriptor */ - if (this._desc.getSuperType() !== undefined) { + if (this._desc.getSuperType() !== undefined) { C.eq( - fields.length, - this._desc._totalInitFields, - racketCoreError, - 'arity mismatch' + fields.length, + this._desc._totalInitFields, + racketCoreError, + 'arity mismatch' ); - } + } // Guard's are applied starting from subtype to supertype // Later when we instantiate the subtype, its guard will be @@ -69,7 +69,7 @@ class Struct extends PrintablePrimitive { // Initialize current and super instance this._superStructInstance = false; /* Struct instance of super-type */ const superType = this._desc.getSuperType(); - if ((superType !== false) && (superType !== undefined)){ + if ((superType !== false) && (superType !== undefined)) { const superInitFields = fields.slice(0, superType._totalInitFields); this._fields = fields.slice(superType._totalInitFields); this._superStructInstance = superType From 90a7884f0cae9df00505e43427626c6a007147f6 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 17 Dec 2021 10:26:35 -0500 Subject: [PATCH 27/61] fix protect-out; closes # 284 --- .../racketscript/compiler/expand.rkt | 3 ++- .../racketscript/compiler/runtime/kernel.rkt | 17 ++++++++++++++++- tests/basic/protect-out.rkt | 3 +++ tests/basic/require-provide.rkt | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/basic/protect-out.rkt diff --git a/racketscript-compiler/racketscript/compiler/expand.rkt b/racketscript-compiler/racketscript/compiler/expand.rkt index cbe1d51c..a4ab9fb6 100644 --- a/racketscript-compiler/racketscript/compiler/expand.rkt +++ b/racketscript-compiler/racketscript/compiler/expand.rkt @@ -134,7 +134,8 @@ [((~datum all-from-except) p ...) '()] [((~datum for-meta) 1 p ...) '()] [((~datum for-syntax) p ...) '()] - [((~datum protect) p ...) '()] + [((~datum protect) p ...) + (stx-map (λ (pv) (SimpleProvide (syntax-e pv))) #'(p ...))] [_ #;(error "unsupported provide form " (syntax->datum r)) '()])) (define (formals->absyn formals) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 21b24d70..982b14e1 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -1297,6 +1297,9 @@ (define+provide (variable-reference-constant? x) #f) (define+provide (variable-reference-from-unsafe? x) #f) +(define+provide (variable-reference->module-source x) #f) +(define+provide (variable-reference->resolved-module-path x) #f) +(define+provide (module-name-fixup x) #f) (define+provide (inspector? p) #t) @@ -1305,7 +1308,7 @@ (define __count 1000) -(define+provide (system-type mode) +(define+provide (system-type [mode 'os]) (case mode [(os) 'unix] [(vm) 'javascript] @@ -1313,6 +1316,12 @@ [(fs-change) (#js.Core.Vector.make (array #false #false #false #false) #false)] [else #false]) ) + +;; path stubs +(define+provide (find-system-path kind) "") +(define+provide build-path ; multi-arity + (v-λ (base) #:unchecked base)) + ;; TODO: manually implement weak references? or ES6 WeakMap? see pr#106 (define+provide make-weak-hash make-hash) (define+provide make-weak-hasheqv make-hasheqv) @@ -1338,6 +1347,12 @@ (define+provide (datum-intern-literal v) v) +;; semaphore stubs +(define+provide (make-semaphore x) x) +(define+provide (semaphore-peek-evt x) x) +(define+provide call-with-semaphore + (v-λ (s f) #:unchecked #f)) + ;; ---------------------------------------------------------------------------- ;; Syntax diff --git a/tests/basic/protect-out.rkt b/tests/basic/protect-out.rkt new file mode 100644 index 00000000..8a6d7da2 --- /dev/null +++ b/tests/basic/protect-out.rkt @@ -0,0 +1,3 @@ +#lang racket/base +(define (f x) x) +(provide (protect-out f)) diff --git a/tests/basic/require-provide.rkt b/tests/basic/require-provide.rkt index baff121c..0e73cfe3 100644 --- a/tests/basic/require-provide.rkt +++ b/tests/basic/require-provide.rkt @@ -11,3 +11,6 @@ (define (sub a b) (- a b)) +;; require protected id, see pr#284 +(require "protect-out.rkt") +(displayln (f 10)) From 47432e31bffb172dab22fae4057e206d8860ffdd Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 17 Dec 2021 16:52:49 -0500 Subject: [PATCH 28/61] allow protect-out to work with non-ids; fixes #284 for real --- racketscript-compiler/racketscript/compiler/expand.rkt | 2 +- tests/basic/protect-out.rkt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/expand.rkt b/racketscript-compiler/racketscript/compiler/expand.rkt index a4ab9fb6..18d00d76 100644 --- a/racketscript-compiler/racketscript/compiler/expand.rkt +++ b/racketscript-compiler/racketscript/compiler/expand.rkt @@ -135,7 +135,7 @@ [((~datum for-meta) 1 p ...) '()] [((~datum for-syntax) p ...) '()] [((~datum protect) p ...) - (stx-map (λ (pv) (SimpleProvide (syntax-e pv))) #'(p ...))] + (apply append (stx-map parse-provide #'(p ...)))] [_ #;(error "unsupported provide form " (syntax->datum r)) '()])) (define (formals->absyn formals) diff --git a/tests/basic/protect-out.rkt b/tests/basic/protect-out.rkt index 8a6d7da2..2f9ae07e 100644 --- a/tests/basic/protect-out.rkt +++ b/tests/basic/protect-out.rkt @@ -1,3 +1,4 @@ #lang racket/base (define (f x) x) -(provide (protect-out f)) +(define-for-syntax (f1 x) x) +(provide (protect-out f (for-meta 1 f1))) From 8f6394e6e5207f1606a158794b352907ab0caa2b Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Mon, 20 Dec 2021 11:00:47 -0500 Subject: [PATCH 29/61] fix #%provide struct form; actually fixes #272 (reverts cb48145) --- .../racketscript/compiler/expand.rkt | 12 ++++++++++++ .../racketscript/compiler/runtime/core/struct.js | 16 +++++++--------- tests/struct/p.rkt | 6 ++++++ tests/struct/super-required.rkt | 6 +++++- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/expand.rkt b/racketscript-compiler/racketscript/compiler/expand.rkt index 18d00d76..9644fb70 100644 --- a/racketscript-compiler/racketscript/compiler/expand.rkt +++ b/racketscript-compiler/racketscript/compiler/expand.rkt @@ -136,6 +136,18 @@ [((~datum for-syntax) p ...) '()] [((~datum protect) p ...) (apply append (stx-map parse-provide #'(p ...)))] + [((~datum struct) p (f ...)) + (append + (list (SimpleProvide (syntax-e #'p)) + (SimpleProvide (syntax-e (format-id #'p "make-~a" #'p))) + (SimpleProvide (syntax-e (format-id #'p "struct:~a" #'p))) + (SimpleProvide (syntax-e (format-id #'p "~a?" #'p)))) + (stx-map ; accessors + (lambda (f) (syntax-e (format-id #'p "~a-~a" #'p f))) + #'(f ...)) + (stx-map ; mutators + (lambda (f) (syntax-e (format-id #'p "set-~a-~a!" #'p f))) + #'(f ...)))] [_ #;(error "unsupported provide form " (syntax->datum r)) '()])) (define (formals->absyn formals) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js index 4b6f89f0..1a435e41 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js @@ -39,14 +39,12 @@ class Struct extends PrintablePrimitive { super(); this._desc = desc; /* struct-type-descriptor */ - if (this._desc.getSuperType() !== undefined) { - C.eq( - fields.length, - this._desc._totalInitFields, - racketCoreError, - 'arity mismatch' - ); - } + C.eq( + fields.length, + this._desc._totalInitFields, + racketCoreError, + 'arity mismatch' + ); // Guard's are applied starting from subtype to supertype // Later when we instantiate the subtype, its guard will be @@ -69,7 +67,7 @@ class Struct extends PrintablePrimitive { // Initialize current and super instance this._superStructInstance = false; /* Struct instance of super-type */ const superType = this._desc.getSuperType(); - if ((superType !== false) && (superType !== undefined)) { + if (superType !== false) { const superInitFields = fields.slice(0, superType._totalInitFields); this._fields = fields.slice(superType._totalInitFields); this._superStructInstance = superType diff --git a/tests/struct/p.rkt b/tests/struct/p.rkt index 019333e9..c21c35ff 100644 --- a/tests/struct/p.rkt +++ b/tests/struct/p.rkt @@ -1,4 +1,10 @@ #lang racket/base + ;; this is imported by super-required.rkt, see pr #272 + +;; get "set-p-val! not defined err" if field name is included in this provide (#%provide (struct p ())) + (define-struct p (val)) +(displayln (p 3)) +(displayln (p-val (p 3))) diff --git a/tests/struct/super-required.rkt b/tests/struct/super-required.rkt index a37fbc41..d2facf6a 100644 --- a/tests/struct/super-required.rkt +++ b/tests/struct/super-required.rkt @@ -7,4 +7,8 @@ ;; (there are subsequent errors as well if arity check is disabled) ;; (real-world example where this shows up is promises) (define-struct (p2 p) ()) -(p2 1) +(displayln (p2 1)) +(displayln (p 2)) +(displayln (p? (p 2))) +(displayln (p? (make-p 2))) +(displayln (p? (p2 2))) From 099da28ab006943da03f994992042313c07c555e Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 31 Dec 2021 00:38:14 +0000 Subject: [PATCH 30/61] interop: add shorthand for testing undefined or null --- racketscript-compiler/racketscript/interop.rkt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/racketscript-compiler/racketscript/interop.rkt b/racketscript-compiler/racketscript/interop.rkt index ef492c27..8796e7c8 100644 --- a/racketscript-compiler/racketscript/interop.rkt +++ b/racketscript-compiler/racketscript/interop.rkt @@ -12,7 +12,9 @@ $/:= $/throw $/undefined + $/defined? $/null + $/null? $/typeof $/instanceof $/arguments @@ -101,10 +103,20 @@ (syntax-parse stx [_ #`(#%js-ffi 'undefined)])) +;; shorthand for testing if something is undefined +(define-syntax ($/defined? stx) + (syntax-parse stx + [(_ x) #'($/binop !== x $/undefined)])) + (define-syntax ($/null stx) (syntax-parse stx [_ #`(#%js-ffi 'null)])) +;; shorthand for testing null +(define-syntax ($/null? stx) + (syntax-parse stx + [(_ x) #'($/binop === x $/null)])) + (define-syntax ($/this stx) (syntax-parse stx [_ #`(#%js-ffi 'this)])) From e93613bde4d4d343222e6e5190161de5b849a3f9 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 31 Dec 2021 00:44:07 +0000 Subject: [PATCH 31/61] add vector-copy --- racketscript-compiler/racketscript/compiler/runtime/kernel.rkt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index c4b003f8..00d3d113 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -400,6 +400,8 @@ (define-checked+provide (vector->immutable-vector [vec vector?]) (#js.Core.Vector.copy vec #f)) +(define-checked+provide (vector-copy [vec vector?]) + (#js.Core.Vector.copy vec #t)) ; a vector copy is always mutable ;; -------------------------------------------------------------------------- ;; Hashes From 9ce4e5ad8cb83537acbb73e15ab1a1e2dc0c1fa6 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Wed, 5 Jan 2022 23:29:47 +0000 Subject: [PATCH 32/61] racks: set current-source-file with --il option; closes #291 --- racketscript-compiler/racketscript/compiler/main.rkt | 1 + 1 file changed, 1 insertion(+) diff --git a/racketscript-compiler/racketscript/compiler/main.rkt b/racketscript-compiler/racketscript/compiler/main.rkt index c28a6b58..abbe9f4e 100644 --- a/racketscript-compiler/racketscript/compiler/main.rkt +++ b/racketscript-compiler/racketscript/compiler/main.rkt @@ -336,6 +336,7 @@ [`(,_ ,#t) (error 'racketscript "Don't expect filename with `--stdin` mode")] [`(,filename ,#f) (let ([complete-filename (path->complete-path filename)]) + (current-source-file complete-filename) (main-source-file complete-filename) complete-filename)]))) From c1f802a9f2aec65b7f20bcaa9cf34abf62685b15 Mon Sep 17 00:00:00 2001 From: gamburgm <33709622+gamburgm@users.noreply.github.com> Date: Tue, 11 Jan 2022 12:22:22 -0500 Subject: [PATCH 33/61] `prop:sealed` support (#294) --- .../compiler/runtime/core/struct.js | 21 +++++++++++++++++++ .../racketscript/compiler/runtime/kernel.rkt | 1 + 2 files changed, 22 insertions(+) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js index 1a435e41..1defa2aa 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js @@ -232,6 +232,11 @@ class StructTypeDescriptor extends PrintablePrimitive { // those of super types this._totalInitFields = options.initFieldCount; if (options.superType) { + C.falsy( + options.superType._isSealed(), + racketCoreError, + 'make-struct-type: cannot make a subtype of a sealed type', + ); this._totalInitFields += options.superType._totalInitFields; } @@ -401,6 +406,18 @@ class StructTypeDescriptor extends PrintablePrimitive { isFieldImmutable(n) { return this._options.immutables.has(n); } + + _isSealed() { + for (let desc = this; desc; desc = desc.getSuperType()) { + for (const [prop, val] of desc._options.props) { + if (prop._isSealedProperty()) { + return val; + } + } + } + + return false; // should be undefined, testing for now + } } /** ************************************************************************** */ @@ -484,6 +501,10 @@ class StructTypeProperty extends PrintablePrimitive { prop.attachToStructTypeDescriptor(desc, proc(newV)); }); } + + _isSealedProperty() { + return this._name === 'prop:sealed'; + } } /** ************************************************************************** */ diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 00d3d113..8fbce96b 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -1023,6 +1023,7 @@ (define-property+provide prop:authentic) (define-property+provide prop:serialize) (define-property+provide prop:custom-write) +(define-property+provide prop:sealed) (define+provide prop:procedure #js.Core.Struct.propProcedure) (define+provide prop:equal+hash #js.Core.Struct.propEqualHash) From 06606ec427804c47d600f43cefdd51c833241a72 Mon Sep 17 00:00:00 2001 From: Stephen De Gabrielle Date: Wed, 19 Jan 2022 21:26:23 +0000 Subject: [PATCH 34/61] badges badges badges! just some pretty badges. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4fc6d697..4b1e2b20 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ [![Coverage Status](https://codecov.io/gh/racketscript/racketscript/coverage.svg?branch=master)](https://codecov.io/gh/racketscript/racketscript?branch=master) [![Try Online](https://img.shields.io/badge/try_it-online!-ff9900.svg)](http://play.racketscript.org) +[![Racket](https://img.shields.io/badge/-Racket-darkred?logo=racket)](https://racket-lang.org) +[![Discourse users](https://img.shields.io/discourse/users?label=Discuss%20on%20Racket%20Discourse&logo=racket&server=https%3A%2F%2Fracket.discourse.group)](https://racket.discourse.group/) +[![Racket Discord](https://img.shields.io/discord/571040468092321801?label=Chat%20on%20Racket%20Discord&logo=racket)](https://discord.gg/6Zq8sH5) + RacketScript is an **experimental** lightweight Racket to JavaScript (ECMAScript 6) compiler. RacketScript aims to leverage both JavaScript and Racket's ecosystem, and make interoperability between them clean and smooth. From 7ada7a6f5237bcf904f8e30109d448103ad1cb13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Apr 2022 01:18:32 +0000 Subject: [PATCH 35/61] Bump minimist from 1.2.5 to 1.2.6 Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 71a13da0..1b960042 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1041,9 +1041,9 @@ } }, "node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "node_modules/mkdirp": { @@ -2593,9 +2593,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "mkdirp": { From a856be04608bafa11aa7c5636b93a077a071c4e0 Mon Sep 17 00:00:00 2001 From: Stephen De Gabrielle Date: Fri, 15 Apr 2022 13:19:25 +0100 Subject: [PATCH 36/61] add Rackt --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4b1e2b20..7e6bd3ab 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ currently supports only a subset of Racket. You can try RacketScript in your browser at [RacketScript Playground](http://play.racketscript.org). +You may alo be interested in [Rackt](https://rackt-org.github.io) - An ultrasmall (~70 loc) React wrapper written in RacketScript. + ## Disclaimer RacketScript is **work-in-progress** and is not mature and stable. Several From b5d5d4e1218774c24967b88fa9eb28ad8e322c40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Apr 2022 16:48:45 +0000 Subject: [PATCH 37/61] Bump path-parse from 1.0.5 to 1.0.7 Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.5 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1b960042..88da3f44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1205,9 +1205,9 @@ "dev": true }, "node_modules/path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "node_modules/path-type": { @@ -2727,9 +2727,9 @@ "dev": true }, "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-type": { From 7a86b1ab326f6e2fcddec06b1c115c9cd501fe99 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 22 Apr 2022 04:14:42 +0000 Subject: [PATCH 38/61] fixes #303, fixes #304 --- racketscript-extras/racketscript/htdp/private/color.rkt | 1 + racketscript-extras/racketscript/htdp/universe.rkt | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/racketscript-extras/racketscript/htdp/private/color.rkt b/racketscript-extras/racketscript/htdp/private/color.rkt index 04aa28d0..dfca1300 100644 --- a/racketscript-extras/racketscript/htdp/private/color.rkt +++ b/racketscript-extras/racketscript/htdp/private/color.rkt @@ -66,6 +66,7 @@ ["darksalmon" (-color 233 150 122)] ["gold" (-color 255 215 0)] ["yellow" (-color 255 255 0)] + ["medium yellow" (-color 255 255 0)] ["olive" (-color 128 128 0)] ["burlywood" (-color 222 184 135)] ["tan" (-color 210 180 140)] diff --git a/racketscript-extras/racketscript/htdp/universe.rkt b/racketscript-extras/racketscript/htdp/universe.rkt index 7785578b..e41d8be4 100644 --- a/racketscript-extras/racketscript/htdp/universe.rkt +++ b/racketscript-extras/racketscript/htdp/universe.rkt @@ -64,7 +64,7 @@ (:= #js.canvas.width #js.img.width) (:= #js.canvas.height #js.img.height) - ;; We are reassiging using change-world so that change world + ;; We are reassigning using change-world so that change world ;; callbacks gets invoked at start of big-bang (#js.this.change-world #js.this.world) @@ -93,6 +93,8 @@ (λ () #:with-this this (:= #js.this.-stopped #f) + ; always draw first, in case no on-tick handler provided + (#js.this.queue-event ($/obj [type #js"to-draw"])) (#js.this.process-events))] [stop (λ () @@ -149,9 +151,10 @@ (define changed? (cond - [handler (#js.handler.invoke #js.this.world evt)] + ; raw evt must be checked 1st; bc handler will be undefined [(equal? #js.evt.type #js"raw") (#js.evt.invoke #js.this.world evt)] + [handler (#js.handler.invoke #js.this.world evt)] [else (#js.console.warn "ignoring unknown/unregistered event type: " evt)])) (loop (or world-changed? changed?))] From 780c152090895ac3aa3c6706c7ce01a62c72ba54 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 22 Apr 2022 17:46:27 +0000 Subject: [PATCH 39/61] add some unsafe and fl prims --- .../compiler/runtime/core/unicode_string.js | 8 ++++++++ .../racketscript/compiler/runtime/core/vector.js | 9 ++++++++- .../racketscript/compiler/runtime/flfxnum.rkt | 4 ++++ .../racketscript/compiler/runtime/kernel.rkt | 9 +++++++++ .../racketscript/compiler/runtime/unsafe.rkt | 14 ++++++++++++++ tests/basic/for.rkt | 8 ++++++++ tests/basic/string.rkt | 2 ++ tests/basic/vector.rkt | 3 +++ 8 files changed, 56 insertions(+), 1 deletion(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/unicode_string.js b/racketscript-compiler/racketscript/compiler/runtime/core/unicode_string.js index 0ece6d5e..b49cc9b0 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/unicode_string.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/unicode_string.js @@ -480,6 +480,14 @@ export function toBytesUtf8(str) { return utf8Encoder.encode(str.toString()); } +/** + * @param {!(UString|String)} str + * @return {!Char.Char[]} chars + */ +export function toArray(str) { + return str.chars; +} + /** * @param {!Uint8Array} bytes * @return {!MutableUString} diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/vector.js b/racketscript-compiler/racketscript/compiler/runtime/core/vector.js index edf71532..be941306 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/vector.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/vector.js @@ -61,6 +61,14 @@ class Vector extends PrintablePrimitive { this.items[n] = v; } + copy(dest_start, src, src_start, src_end) { + for (let i = src_start, j = dest_start; + i < src_end && i < src.items.length && j < this.items.length; + i++, j++) { + this.items[j] = src.items[i]; + } + } + length() { return this.items.length; } @@ -106,7 +114,6 @@ export function copy(vec, mutable) { return new Vector(vec.items, mutable); } - export function makeInit(size, init) { const r = new Array(size); r.fill(init); diff --git a/racketscript-compiler/racketscript/compiler/runtime/flfxnum.rkt b/racketscript-compiler/racketscript/compiler/runtime/flfxnum.rkt index 2ce41ff7..32ddbc9e 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/flfxnum.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/flfxnum.rkt @@ -79,3 +79,7 @@ (define-fx-binop+provide fxxor ^) (define+provide fxnot #js.Core.bitwiseNot) +(define+provide flvector #js.Array.from) ; just create regular array +(define+provide flvector? #js.Array.isArray) +(define+provide fxvector #js.Array.from) ; just create regular array +(define+provide fxvector? #js.Array.isArray) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 8fbce96b..5621e563 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -403,6 +403,13 @@ (define-checked+provide (vector-copy [vec vector?]) (#js.Core.Vector.copy vec #t)) ; a vector copy is always mutable +(define-checked+provide (vector-copy! [dest vector?] + [dest-start integer?] + [src vector?] + [src-start integer?] + [src-end integer?]) + (#js.dest.copy dest-start src src-start src-end)) + ;; -------------------------------------------------------------------------- ;; Hashes @@ -818,6 +825,8 @@ (define+provide (list->string lst) (#js.Kernel.listToString lst)) +(define+provide (string->list [str string?]) + (#js.Core.Pair.listFromArray (#js.Core.UString.toArray str))) (define+provide (string->immutable-string [s string?]) (#js.Core.UString.stringToImmutableString s)) diff --git a/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt b/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt index 0ae90929..ce83df7c 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt @@ -107,6 +107,15 @@ (define+provide (unsafe-vector-length v) (#js.v.length)) +(define+provide (unsafe-vector*-ref v k) + (#js.v.ref k)) + +(define+provide (unsafe-vector*-set! v k val) + (#js.v.set k val)) + +(define+provide (unsafe-vector*-length v) + (#js.v.length)) + ;;----------------------------------------------------------------------------- ;; Hash (define+provide (unsafe-immutable-hash-iterate-first h) @@ -156,3 +165,8 @@ (define+provide (unsafe-root-continuation-prompt-tag) (#js.Core.Marks.defaultContinuationPromptTag)) + +;; strings +(define+provide (unsafe-string-length s) + #js.s.length) + diff --git a/tests/basic/for.rkt b/tests/basic/for.rkt index 976b8541..60cdd486 100644 --- a/tests/basic/for.rkt +++ b/tests/basic/for.rkt @@ -5,3 +5,11 @@ (displayln v))) (fn (list 1 2 3 4)) + +;; string sequences +;; needs unsafe-string-length +(for ([c "string"]) + (displayln c)) + +(for ([c (string->list "string")]) + (displayln c)) diff --git a/tests/basic/string.rkt b/tests/basic/string.rkt index 816f6eee..01c19d60 100644 --- a/tests/basic/string.rkt +++ b/tests/basic/string.rkt @@ -25,6 +25,8 @@ (displayln (immutable? (string->immutable-string (string #\i #\🎂 #\c)))) (displayln (list->string '(#\a #\🎂 #\c))) +(displayln (string->list "abc")) +(displayln (string->list "")) (displayln (immutable? (list->string '(#\a #\🎂 #\c)))) (displayln (string-length (list->string '(#\a #\🎂 #\c)))) diff --git a/tests/basic/vector.rkt b/tests/basic/vector.rkt index 8d807fd3..b145e398 100644 --- a/tests/basic/vector.rkt +++ b/tests/basic/vector.rkt @@ -28,3 +28,6 @@ (displayln (make-vector 5 #f)) (displayln (make-vector 0)) +(define vec2 (vector 4 5 6)) +(vector-copy! vec 1 vec2 0 3) +(displayln vec) From 201bbfa9b8a22b2b4bb901413b64fe2f7c266114 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Sun, 24 Apr 2022 17:26:59 +0000 Subject: [PATCH 40/61] fix eslint errs --- .../racketscript/compiler/runtime/core/vector.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/vector.js b/racketscript-compiler/racketscript/compiler/runtime/core/vector.js index be941306..2834539d 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/vector.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/vector.js @@ -61,10 +61,10 @@ class Vector extends PrintablePrimitive { this.items[n] = v; } - copy(dest_start, src, src_start, src_end) { - for (let i = src_start, j = dest_start; - i < src_end && i < src.items.length && j < this.items.length; - i++, j++) { + copy(destStart, src, srcStart, srcEnd) { + for (let i = srcStart, j = destStart; + i < srcEnd && i < src.items.length && j < this.items.length; + i++, j++) { this.items[j] = src.items[i]; } } From d23314b3f148952a14239cc4923224d850e4db26 Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Tue, 20 Sep 2022 09:42:54 -0400 Subject: [PATCH 41/61] Add #lang racketscript (#311) Adds the ability to use #lang racketscript. It's the same as doing #lang racketscript/base for now but can be extended later. The #lang in tests/ffi/for-array.rkt was changed from racketscript/base to racketscript as a simple test that it works. --- racketscript-compiler/racketscript/lang/reader.rkt | 6 ++++++ tests/ffi/for-array.rkt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 racketscript-compiler/racketscript/lang/reader.rkt diff --git a/racketscript-compiler/racketscript/lang/reader.rkt b/racketscript-compiler/racketscript/lang/reader.rkt new file mode 100644 index 00000000..bfa2e428 --- /dev/null +++ b/racketscript-compiler/racketscript/lang/reader.rkt @@ -0,0 +1,6 @@ +#lang s-exp syntax/module-reader +racketscript + +#:read x-read +#:read-syntax x-read-syntax +(require "../boot/lang/reader.rkt") diff --git a/tests/ffi/for-array.rkt b/tests/ffi/for-array.rkt index 6d03360b..5322bc77 100644 --- a/tests/ffi/for-array.rkt +++ b/tests/ffi/for-array.rkt @@ -1,4 +1,4 @@ -#lang racketscript/base +#lang racketscript (require racketscript/interop) From 2748b7caedcd47a4f72c02e67121c959ec11e426 Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Tue, 18 Oct 2022 15:21:02 -0400 Subject: [PATCH 42/61] Fix stale dependency compilation issue. Fixes the issue where a stale dependency is not recompiled if the dependent file hasn't changed. It does this by checking all cached timestamps for stale files before the main compilation loop, instead of doing it in flight. --- racketscript-compiler/racketscript/compiler/main.rkt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/racketscript-compiler/racketscript/compiler/main.rkt b/racketscript-compiler/racketscript/compiler/main.rkt index abbe9f4e..03e75cb9 100644 --- a/racketscript-compiler/racketscript/compiler/main.rkt +++ b/racketscript-compiler/racketscript/compiler/main.rkt @@ -245,6 +245,11 @@ (for ([pm primitive-modules]) (put-to-pending! pm)) + ;; Add stale modules to the compile queue. + (for ([(mod timestamp) timestamps]) + (when (not (skip-module-compile? timestamps mod)) + (put-to-pending! mod))) + (let loop () (define next (and (non-empty-queue? pending) (dequeue! pending))) (cond From 023f36fffc8c2c5cdc2c6fbcfbe7718f3e87e262 Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Mon, 7 Nov 2022 14:01:26 -0500 Subject: [PATCH 43/61] Added stale dependency test Added a test to ensure stale dependencies are recompiled. --- .../racketscript/compiler/main.rkt | 39 +++++++++++++++++-- tests/dep-cache/has-dependency.rkt | 10 +++++ tests/dep-cache/private/dependency.rkt | 6 +++ 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 tests/dep-cache/has-dependency.rkt create mode 100644 tests/dep-cache/private/dependency.rkt diff --git a/racketscript-compiler/racketscript/compiler/main.rkt b/racketscript-compiler/racketscript/compiler/main.rkt index 03e75cb9..51aaa29d 100644 --- a/racketscript-compiler/racketscript/compiler/main.rkt +++ b/racketscript-compiler/racketscript/compiler/main.rkt @@ -250,12 +250,12 @@ (when (not (skip-module-compile? timestamps mod)) (put-to-pending! mod))) - (let loop () + (let loop ([compiled-modules empty]) (define next (and (non-empty-queue? pending) (dequeue! pending))) (cond [(and next (skip-module-compile? timestamps next)) (log-rjs-info (~a "Skipping " next)) - (loop)] + (loop compiled-modules)] [next (current-source-file next) (make-directory* (path-only (module-output-file next))) @@ -277,13 +277,14 @@ [(? symbol? _) (void)] [_ #:when (collects-module? mod) (void) (put-to-pending! mod)] [_ (put-to-pending! mod)])) - (loop)] + (loop (cons next compiled-modules))] [(false? next) (dump-module-timestamps! timestamps) (unless (equal? (js-target) "plain") (log-rjs-info "Running NPM [Install/Build].") (npm-install-build)) - (log-rjs-info "Finished.")]))) + (log-rjs-info "Finished.") + compiled-modules]))) ;; String -> String (define (js-string-beautify js-str) @@ -423,3 +424,33 @@ ['complete (racket->js)]) (void)) + +(module+ test + (require rackunit) + + (define tests-dir (normalize-path (build-path racketscript-dir + 'up 'up + "tests"))) + + (test-case "check stale dependency compilation" + (define dep-cache-dir (build-path tests-dir "dep-cache")) + (define has-dependency (build-path dep-cache-dir + "has-dependency.rkt")) + (define dependency (normalize-path (build-path tests-dir + "dep-cache" + "private" + "dependency.rkt"))) + (parameterize ([main-source-file has-dependency] + [global-export-graph (get-export-tree (list has-dependency))] + [current-source-file has-dependency] + [recompile-all-modules? #f] + [current-output-port (open-output-nowhere)]) + (file-or-directory-modify-seconds dependency 100) + (racket->js) + ;; Change dependency's modification time to simulate + ;; an edit to the source file. + (file-or-directory-modify-seconds dependency 200) + (check-true (ormap (lambda (mod) (equal? mod dependency)) + (racket->js)) + "stale dependency not recompiled.")) + (delete-directory/files (output-directory)))) diff --git a/tests/dep-cache/has-dependency.rkt b/tests/dep-cache/has-dependency.rkt new file mode 100644 index 00000000..52b46b6d --- /dev/null +++ b/tests/dep-cache/has-dependency.rkt @@ -0,0 +1,10 @@ +#lang racket + +;; Tests dependecy caching by compiling once, then swapping +;; the names of ./private/dependency.rkt and ./private/depndency-changed.rkt, +;; then compiling again. If dependency caching isn't working properly, there +;; will be an error on the second compilation. + +(require "./private/dependency.rkt") + +(println (format "~a" (add 5))) diff --git a/tests/dep-cache/private/dependency.rkt b/tests/dep-cache/private/dependency.rkt new file mode 100644 index 00000000..ca92c738 --- /dev/null +++ b/tests/dep-cache/private/dependency.rkt @@ -0,0 +1,6 @@ +#lang racket + +(provide add) + +(define (add n) + (+ n 2)) From b74ecce2e24071b7656d3f2475a4096393e62026 Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Sun, 13 Nov 2022 22:26:54 -0500 Subject: [PATCH 44/61] Fix unintended printing of module paths to stdout The compiler would print a list of compiled modules to standard out after finishing a compilation. This was unintended behavior and is fixed by this commit. This commit also refactors the (racket->js) function. --- .../racketscript/compiler/main.rkt | 94 +++++++++---------- 1 file changed, 43 insertions(+), 51 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/main.rkt b/racketscript-compiler/racketscript/compiler/main.rkt index 51aaa29d..cde9cb4c 100644 --- a/racketscript-compiler/racketscript/compiler/main.rkt +++ b/racketscript-compiler/racketscript/compiler/main.rkt @@ -221,70 +221,64 @@ (= (get-module-timestamp ts mod) (file-or-directory-modify-seconds (actual-module-path mod))))) -;; -> Void +;; -> (Setof Path) ;; For given global parameters starts build process starting -;; with entry point module and all its dependencies +;; with entry point module and all its dependencies. Returns +;; a set module paths that were compiled (typically ignored). (define (racket->js) (define added (mutable-set)) (define pending (make-queue)) - - ;; build directories to output build folder. - (define default-module-name (string-slice (~a (last-path-element - (main-source-file))) - 0 -4)) - (prepare-build-directory default-module-name) - (define (put-to-pending! mod) (unless (set-member? added mod) (set-add! added mod) (enqueue! pending mod))) - (define timestamps (load-cached-module-timestamps)) + (define default-module-name (string-slice (~a (last-path-element + (main-source-file))) + 0 -4)) + (prepare-build-directory default-module-name) (put-to-pending! (path->complete-path (main-source-file))) (for ([pm primitive-modules]) (put-to-pending! pm)) - ;; Add stale modules to the compile queue. + (define timestamps (load-cached-module-timestamps)) (for ([(mod timestamp) timestamps]) (when (not (skip-module-compile? timestamps mod)) (put-to-pending! mod))) - (let loop ([compiled-modules empty]) - (define next (and (non-empty-queue? pending) (dequeue! pending))) - (cond - [(and next (skip-module-compile? timestamps next)) - (log-rjs-info (~a "Skipping " next)) - (loop compiled-modules)] - [next - (current-source-file next) - (make-directory* (path-only (module-output-file next))) - (save-module-timestamp! timestamps next) - - (define expanded (quick-expand next)) - (define ast (convert expanded (override-module-path next))) - - (assemble-module (insert-arity-checks - (absyn-module->il* ast)) - #f) - - ;; Run JS beautifier - (when (js-output-beautify?) - (system (format "js-beautify -r ~a" (module-output-file next)))) - - (for ([mod (in-set (Module-imports ast))]) - (match mod - [(? symbol? _) (void)] - [_ #:when (collects-module? mod) (void) (put-to-pending! mod)] - [_ (put-to-pending! mod)])) - (loop (cons next compiled-modules))] - [(false? next) - (dump-module-timestamps! timestamps) - (unless (equal? (js-target) "plain") - (log-rjs-info "Running NPM [Install/Build].") - (npm-install-build)) - (log-rjs-info "Finished.") - compiled-modules]))) + (define compiled-modules + (for/set ([next (in-queue pending)] + #:unless (and (skip-module-compile? timestamps next) + (log-rjs-info (~a "Skipping " next)))) + + (current-source-file next) + (make-directory* (path-only (module-output-file next))) + (save-module-timestamp! timestamps next) + + (define expanded (quick-expand next)) + (define ast (convert expanded (override-module-path next))) + (assemble-module (insert-arity-checks + (absyn-module->il* ast)) + #f) + + (when (js-output-beautify?) + (system (format "js-beautify -r ~a" (module-output-file next)))) + + (for ([mod (in-set (Module-imports ast))]) + (match mod + [(? symbol? _) (void)] + [_ #:when (collects-module? mod) (put-to-pending! mod)] + [_ (put-to-pending! mod)])) + + next)) + + (dump-module-timestamps! timestamps) + (unless (equal? (js-target) "plain") + (log-rjs-info "Running NPM [Install/Build].") + (npm-install-build)) + (log-rjs-info "Finished.") + compiled-modules) ;; String -> String (define (js-string-beautify js-str) @@ -421,9 +415,7 @@ (if (js-output-beautify?) (js-string-beautify (get-output-string output-string)) (get-output-string output-string)))] - ['complete (racket->js)]) - - (void)) + ['complete (racket->js) (void)])) (module+ test (require rackunit) @@ -450,7 +442,7 @@ ;; Change dependency's modification time to simulate ;; an edit to the source file. (file-or-directory-modify-seconds dependency 200) - (check-true (ormap (lambda (mod) (equal? mod dependency)) - (racket->js)) + (check-true (set-member? (racket->js) + dependency) "stale dependency not recompiled.")) (delete-directory/files (output-directory)))) From 07c88d3b5cdafd322f694defbcf07728abfb646a Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 18 Nov 2022 12:42:59 -0500 Subject: [PATCH 45/61] trim dependency: threading -> threading-lib --- racketscript-compiler/info.rkt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/racketscript-compiler/info.rkt b/racketscript-compiler/info.rkt index 4420b113..4a7c3ef9 100644 --- a/racketscript-compiler/info.rkt +++ b/racketscript-compiler/info.rkt @@ -8,7 +8,7 @@ ["racket" "6.4"] "typed-racket-lib" "typed-racket-more" - "threading" + "threading-lib" "graph-lib" "anaphoric")) From 8afb7d7ed4ec60c38d29389655b0d195d8f523a1 Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Mon, 19 Dec 2022 12:31:39 -0500 Subject: [PATCH 46/61] Add support for Racket 8.7 Makes changes such that all RacketScript tests pass on Racket 8.7. Implements bitwise-bit-set?, procedure-arity-mask, and prop:object-name. Put's empty? before list? in the absyn-val->il cond expression in transform.rkt. --- .../racketscript/compiler/runtime/kernel.rkt | 13 +++++++++++-- .../racketscript/compiler/transform.rkt | 7 ++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 5621e563..875156f9 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -197,6 +197,8 @@ (define-checked+provide (bitwise-not [v number?]) (#js.Core.Number.bitwiseNot v)) +(define+provide (bitwise-bit-set? n m) + (not (zero? (bitwise-and n (arithmetic-shift 1 m))))) ;; ---------------------------------------------------------------------------- ;; Booleans @@ -1033,6 +1035,7 @@ (define-property+provide prop:serialize) (define-property+provide prop:custom-write) (define-property+provide prop:sealed) +(define-property+provide prop:object-name) (define+provide prop:procedure #js.Core.Struct.propProcedure) (define+provide prop:equal+hash #js.Core.Struct.propEqualHash) @@ -1219,8 +1222,6 @@ (v-λ (x n) "str" #;(#js.x.toString))) -(define+provide (procedure-arity-mask fn) (procedure-arity fn)) -(define+provide (bitwise-bit-set? mask n) #t) (define+provide (procedure-extract-target f) #f) ;; -------------------------------------------------------------------------- @@ -1300,6 +1301,14 @@ (kernel:arity-at-least? v))) v))) +(define+provide (procedure-arity-mask fn) + (let ([ar (procedure-arity fn)]) + (cond + [(integer? ar) + (arithmetic-shift 1 ar)] + [(kernel:arity-at-least? ar) + (arithmetic-shift -1 (kernel:arity-at-least-value ar))]))) + (define+provide (checked-procedure-check-and-extract type v proc v1 v2) (cond [(and (#js.Core.Struct.check v type) diff --git a/racketscript-compiler/racketscript/compiler/transform.rkt b/racketscript-compiler/racketscript/compiler/transform.rkt index 6d2e72d7..e300e529 100644 --- a/racketscript-compiler/racketscript/compiler/transform.rkt +++ b/racketscript-compiler/racketscript/compiler/transform.rkt @@ -606,9 +606,10 @@ (cons (ILVarDec result-id v) binding-stms))])) - (: absyn-value->il (-> Any ILExpr)) (define (absyn-value->il d) + ;; Order here matters. For example, a list is always a cons + ;; but a cons is not always a list. (cond [(Quote? d) (absyn-value->il (Quote-datum d))] [(string? d) @@ -620,11 +621,11 @@ [(keyword? d) (ILApp (name-in-module 'core 'Keyword.make) (list (ILValue (keyword->string d))))] + [(empty? d) + (name-in-module 'core 'Pair.EMPTY)] [(list? d) (ILApp (name-in-module 'core 'Pair.makeList) (map absyn-value->il d))] - [(empty? d) - (name-in-module 'core 'Pair.EMPTY)] [(cons? d) (ILApp (name-in-module 'core 'Pair.make) (list (absyn-value->il (car d)) From 03d8580c399b1b1c5c39f3234b61aff8c3a9a984 Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Mon, 19 Dec 2022 12:56:06 -0500 Subject: [PATCH 47/61] Add Racket 8.2 - 8.7 to CI workflow. --- .github/workflows/racket.yml | 37 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/.github/workflows/racket.yml b/.github/workflows/racket.yml index 4ac8ba5e..8637b985 100644 --- a/.github/workflows/racket.yml +++ b/.github/workflows/racket.yml @@ -14,19 +14,32 @@ jobs: strategy: fail-fast: false matrix: - racket-version: [ '6.12', '7.0', '7.4', '7.5', '7.6', '7.7', '7.8' ] - racket-variant: [ 'BC' ] - experimental: [false] + racket-version: [ '8.0', '8.1', '8.2', '8.3', '8.4', + '8.5', '8.6', '8.7', 'current'] + racket-variant: [ 'CS' ] + experimental: [true] include: - - racket-version: '8.0' - racket-variant: 'CS' - experimental: true - - racket-version: '8.1' - racket-variant: 'CS' - experimental: true - - racket-version: 'current' - racket-variant: 'CS' - experimental: true + - racket-version: '6.12' + racket-variant: 'BC' + experimental: false + - racket-version: '7.0' + racket-variant: 'BC' + experimental: false + - racket-version: '7.4' + racket-variant: 'BC' + experimental: false + - racket-version: '7.5' + racket-variant: 'BC' + experimental: false + - racket-version: '7.6' + racket-variant: 'BC' + experimental: false + - racket-version: '7.7' + racket-variant: 'BC' + experimental: false + - racket-version: '7.8' + racket-variant: 'BC' + experimental: false name: Racket ${{ matrix.racket-version }} ${{ matrix.racket-variant }} steps: - uses: actions/checkout@master From 51fb8bd4f9594bc034047508e265e12d27e8204c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Dec 2022 15:26:48 +0000 Subject: [PATCH 48/61] Bump minimatch from 3.0.4 to 3.1.2 Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 88da3f44..96303c7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1029,9 +1029,9 @@ } }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -2584,9 +2584,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" From 50fb2ed23e48eb1f8cd2c508179aa7969c3cc995 Mon Sep 17 00:00:00 2001 From: Stephen De Gabrielle Date: Sat, 25 Mar 2023 17:54:51 +0000 Subject: [PATCH 49/61] implement empty-scene with rectangle like https://github.com/racket/htdp/blob/aa78794fa1788358d6abd11dad54b3c9f4f5a80b/htdp-lib/htdp/image.rkt#L107 --- racketscript-extras/racketscript/htdp/image.rkt | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/racketscript-extras/racketscript/htdp/image.rkt b/racketscript-extras/racketscript/htdp/image.rkt index 8d30aba6..6de5d82b 100644 --- a/racketscript-extras/racketscript/htdp/image.rkt +++ b/racketscript-extras/racketscript/htdp/image.rkt @@ -124,18 +124,6 @@ (define (image-height i) #js.i.height) (define (image-width i) #js.i.width) -(define-proto EmptyScene - (λ (width height borders?) - #:with-this this - (set-object! this - [type "empty-scene"] - [width width] - [height height] - [borders? borders?])) - [render (λ (ctx x y) - ;; TODO: borders? - (void))]) - (define-proto Text (λ (text size color face family style weight underline?) #:with-this this @@ -281,7 +269,8 @@ (loop (cdr points)))))))]) (define (empty-scene width height) - (new (EmptyScene width height #f))) + (overlay (rectangle width height 'solid 'white) + (rectangle width height 'outline 'black))) (define (text txt size color) (new (Text txt From 3c64af8feb8e18200dc7b511af4b9740d3a988dc Mon Sep 17 00:00:00 2001 From: Ayden Diel Date: Sun, 2 Apr 2023 16:34:55 -0400 Subject: [PATCH 50/61] Tweaked implementation of empty-scene --- racketscript-extras/racketscript/htdp/image.rkt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/racketscript-extras/racketscript/htdp/image.rkt b/racketscript-extras/racketscript/htdp/image.rkt index 6de5d82b..0229354b 100644 --- a/racketscript-extras/racketscript/htdp/image.rkt +++ b/racketscript-extras/racketscript/htdp/image.rkt @@ -268,9 +268,8 @@ (#js.ctx.lineTo (posn-x pt) (posn-y pt)) (loop (cdr points)))))))]) -(define (empty-scene width height) - (overlay (rectangle width height 'solid 'white) - (rectangle width height 'outline 'black))) +(define (empty-scene width height color) + (rectangle width height "solid" color)) (define (text txt size color) (new (Text txt From 7bb5cda4c3486922bf2238420e0e9af942f4534f Mon Sep 17 00:00:00 2001 From: Stephen De Gabrielle Date: Mon, 10 Apr 2023 16:42:44 +0100 Subject: [PATCH 51/61] update syb --- racketscript-extras/racketscript/htdp/image.rkt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/racketscript-extras/racketscript/htdp/image.rkt b/racketscript-extras/racketscript/htdp/image.rkt index 0229354b..1a7083d2 100644 --- a/racketscript-extras/racketscript/htdp/image.rkt +++ b/racketscript-extras/racketscript/htdp/image.rkt @@ -268,8 +268,9 @@ (#js.ctx.lineTo (posn-x pt) (posn-y pt)) (loop (cdr points)))))))]) -(define (empty-scene width height color) - (rectangle width height "solid" color)) +(define (empty-scene width height) + (rectangle width height "solid" "white") + (rectangle width height "outline" "black")) (define (text txt size color) (new (Text txt From fbe1b961f7152decc8ddbfd544752066aa50f8be Mon Sep 17 00:00:00 2001 From: Stephen De Gabrielle Date: Mon, 10 Apr 2023 16:49:18 +0100 Subject: [PATCH 52/61] Update image.rkt default color to white not fixed to white --- racketscript-extras/racketscript/htdp/image.rkt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/racketscript-extras/racketscript/htdp/image.rkt b/racketscript-extras/racketscript/htdp/image.rkt index 1a7083d2..58d1e194 100644 --- a/racketscript-extras/racketscript/htdp/image.rkt +++ b/racketscript-extras/racketscript/htdp/image.rkt @@ -268,9 +268,9 @@ (#js.ctx.lineTo (posn-x pt) (posn-y pt)) (loop (cdr points)))))))]) -(define (empty-scene width height) - (rectangle width height "solid" "white") - (rectangle width height "outline" "black")) +(define (empty-scene width height [color "white"]) + (rectangle width height "solid" color) + (rectangle width height "outline" "black")) (define (text txt size color) (new (Text txt From 90ab7390dd3cdf95efd2be1582ac7237803661d5 Mon Sep 17 00:00:00 2001 From: Stephen De Gabrielle Date: Wed, 12 Apr 2023 09:02:32 +0100 Subject: [PATCH 53/61] Update image.rkt (define (empty-scene width height [color "white"]) (overlay (rectangle width height "solid" color) (rectangle width height "outline" "black"))) --- racketscript-extras/racketscript/htdp/image.rkt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/racketscript-extras/racketscript/htdp/image.rkt b/racketscript-extras/racketscript/htdp/image.rkt index 58d1e194..e5db9547 100644 --- a/racketscript-extras/racketscript/htdp/image.rkt +++ b/racketscript-extras/racketscript/htdp/image.rkt @@ -269,8 +269,9 @@ (loop (cdr points)))))))]) (define (empty-scene width height [color "white"]) - (rectangle width height "solid" color) - (rectangle width height "outline" "black")) + (overlay + (rectangle width height "solid" color) + (rectangle width height "outline" "black"))) (define (text txt size color) (new (Text txt From 6eb8062381696217d24fe314ab402083793bb0b1 Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Sat, 25 Mar 2023 18:48:04 -0400 Subject: [PATCH 54/61] Added support for Scheme number semantics. Adds support for the numeric tower and Scheme number semantics. This includes complex numbers, which is newly supported as of this commit. Support comes from a scheme numbers library by Danny Yoo. It differs from the eslint style pretty drastically, so the config file was updated to ignore it for now. The eslint version had to be bumped up to make this easier. Minor refactoring and bug fixes are included. Scheme numbers are off by default. --- .eslintrc | 1 + package-lock.json | 2623 +++++----- package.json | 2 +- .../racketscript/compiler/config.rkt | 10 +- .../racketscript/compiler/directive.rkt | 24 + .../racketscript/compiler/expand.rkt | 4 - .../racketscript/compiler/main.rkt | 5 +- .../racketscript/compiler/runtime/core.js | 2 +- .../compiler/runtime/core/equality.js | 24 + .../{numbers.js => numbers/js-numbers.js} | 2 +- .../compiler/runtime/core/numbers/numbers.js | 7 + .../runtime/core/numbers/scheme-numbers.js | 4470 +++++++++++++++++ .../compiler/runtime/core/struct.js | 2 +- .../racketscript/compiler/runtime/flfxnum.rkt | 86 +- .../racketscript/compiler/runtime/kernel.rkt | 363 +- .../racketscript/compiler/runtime/runtime.rkt | 1 + .../racketscript/compiler/runtime/unsafe.rkt | 5 +- .../racketscript/compiler/transform.rkt | 67 +- .../racketscript/compiler/util-untyped.rkt | 3 +- tests/basic/__complex.rkt | 52 + tests/fixture.rkt | 193 +- tests/test-utils.rkt | 6 +- 22 files changed, 6230 insertions(+), 1722 deletions(-) create mode 100644 racketscript-compiler/racketscript/compiler/directive.rkt rename racketscript-compiler/racketscript/compiler/runtime/core/{numbers.js => numbers/js-numbers.js} (97%) create mode 100644 racketscript-compiler/racketscript/compiler/runtime/core/numbers/numbers.js create mode 100644 racketscript-compiler/racketscript/compiler/runtime/core/numbers/scheme-numbers.js create mode 100644 tests/basic/__complex.rkt diff --git a/.eslintrc b/.eslintrc index 535a1ebf..cd47acb0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,6 +4,7 @@ "ecmaVersion": 2017, "sourceType": "module" }, + "ignorePatterns": ["**/scheme-numbers.js"], "rules": { "indent": ["error", 4], "import/extensions": ["error", "always"], diff --git a/package-lock.json b/package-lock.json index 88da3f44..96b04128 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,137 +5,202 @@ "packages": { "": { "devDependencies": { - "eslint": "^4.19.1", + "eslint": "^8.36.0", "eslint-config-airbnb-base": "^12.0.0", "eslint-plugin-import": "^2.7.0" } }, - "node_modules/acorn": { - "version": "5.7.4", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", - "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", "dev": true, - "bin": { - "acorn": "bin/acorn" + "dependencies": { + "eslint-visitor-keys": "^3.3.0" }, "engines": { - "node": ">=0.4.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, - "node_modules/acorn-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", - "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "node_modules/@eslint-community/regexpp": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.4.1.tgz", + "integrity": "sha512-BISJ6ZE4xQsuL/FmsyRaiffpq977bMlsKfGHTQrOGFErfByxIe6iZTxPf/00Zon9b9a7iUykfQwejN3s2ZW/Bw==", "dev": true, - "dependencies": { - "acorn": "^3.0.4" + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, - "node_modules/acorn-jsx/node_modules/acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "node_modules/@eslint/eslintrc": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.1.tgz", + "integrity": "sha512-eFRmABvW2E5Ho6f5fHLqgena46rOj7r7OKHYfLElqcBfGFHHpjBhivyi5+jOEQuSpdc/1phIZJlbC2te+tZNIw==", "dev": true, - "bin": { - "acorn": "bin/acorn" + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.5.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" }, "engines": { - "node": ">=0.4.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "node_modules/@eslint/js": { + "version": "8.36.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.36.0.tgz", + "integrity": "sha512-lxJ9R5ygVm8ZWgYdUweoq5ownDlJ4upvoWmO4eLxBYHdMo+vZ/Rx0EN6MbKWDJOSUGrqJy2Gt+Dyv/VKml0fjg==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", "dev": true, "dependencies": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" } }, - "node_modules/ajv-keywords": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", - "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, - "node_modules/ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, "engines": { - "node": ">=4" + "node": ">= 8" } }, - "node_modules/ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">= 8" } }, - "node_modules/ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, "engines": { - "node": ">=0.10.0" + "node": ">= 8" } }, - "node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "node_modules/acorn": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" } }, - "node_modules/babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, - "dependencies": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/babel-code-frame/node_modules/chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "dependencies": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, - "node_modules/babel-code-frame/node_modules/strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "dependencies": { - "ansi-regex": "^2.0.0" + "color-convert": "^2.0.1" }, "engines": { - "node": ">=0.10.0" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -152,12 +217,6 @@ "concat-map": "0.0.1" } }, - "node_modules/buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true - }, "node_modules/builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", @@ -167,118 +226,47 @@ "node": ">=0.10.0" } }, - "node_modules/caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "dependencies": { - "callsites": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=6" } }, "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/chalk/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "dependencies": { - "color-convert": "^1.9.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "engines": { - "node": ">=4" - } - }, - "node_modules/chalk/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" + "node": ">=10" }, - "engines": { - "node": ">=4" + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", - "dev": true - }, - "node_modules/circular-json": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", - "dev": true - }, - "node_modules/cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "dependencies": { - "restore-cursor": "^2.0.0" + "color-name": "~1.1.4" }, "engines": { - "node": ">=4" - } - }, - "node_modules/cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", - "dev": true - }, - "node_modules/co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true, - "engines": { - "iojs": ">= 1.0.0", - "node": ">= 0.12.0" - } - }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" + "node": ">=7.0.0" } }, "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, "node_modules/concat-map": { @@ -287,21 +275,6 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "node_modules/concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "engines": [ - "node >= 0.8" - ], - "dependencies": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, "node_modules/contains-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", @@ -311,30 +284,35 @@ "node": ">=0.10.0" } }, - "node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, "node_modules/cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "dependencies": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" } }, "node_modules/debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "dependencies": { - "ms": "^2.1.1" + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/debug/node_modules/ms": { @@ -344,21 +322,21 @@ "dev": true }, "node_modules/deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, "node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "dependencies": { "esutils": "^2.0.2" }, "engines": { - "node": ">=0.10.0" + "node": ">=6.0.0" } }, "node_modules/error-ex": { @@ -371,64 +349,72 @@ } }, "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, "engines": { - "node": ">=0.8.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/eslint": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", - "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", - "dev": true, - "dependencies": { - "ajv": "^5.3.0", - "babel-code-frame": "^6.22.0", - "chalk": "^2.1.0", - "concat-stream": "^1.6.0", - "cross-spawn": "^5.1.0", - "debug": "^3.1.0", - "doctrine": "^2.1.0", - "eslint-scope": "^3.7.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^3.5.4", - "esquery": "^1.0.0", + "version": "8.36.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.36.0.tgz", + "integrity": "sha512-Y956lmS7vDqomxlaaQAHVmeb4tNMp2FWIvU/RnU5BD3IKMD/MJPr76xdyr68P8tV1iNMvN2mRK0yy3c+UjL+bw==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.1", + "@eslint/js": "8.36.0", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.1.1", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.5.0", + "esquery": "^1.4.2", "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", - "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.0.1", - "ignore": "^3.3.3", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", + "ignore": "^5.2.0", + "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^3.0.6", - "is-resolvable": "^1.0.0", - "js-yaml": "^3.9.1", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", + "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.4", - "minimatch": "^3.0.2", - "mkdirp": "^0.5.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "pluralize": "^7.0.0", - "progress": "^2.0.0", - "regexpp": "^1.0.1", - "require-uncached": "^1.0.3", - "semver": "^5.3.0", - "strip-ansi": "^4.0.0", - "strip-json-comments": "~2.0.1", - "table": "4.0.2", - "text-table": "~0.2.0" + "optionator": "^0.9.1", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" }, "engines": { - "node": ">=4" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-config-airbnb-base": { @@ -534,81 +520,142 @@ "dev": true }, "node_modules/eslint-scope": { - "version": "3.7.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", - "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", + "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", "dev": true, "dependencies": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" }, "engines": { - "node": ">=4.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/eslint-visitor-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", - "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true, "engines": { - "node": ">=4" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/espree": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "node_modules/eslint/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "dependencies": { - "acorn": "^5.5.0", - "acorn-jsx": "^3.0.0" + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "node_modules/eslint/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" + "dependencies": { + "p-locate": "^5.0.0" }, "engines": { - "node": ">=4" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/espree": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.0.tgz", + "integrity": "sha512-JPbJGhKc47++oo4JkEoTe2wjy4fmMwvFpgJT9cQzmfXKp22Dr6Hf1tdCteLz1h0P3t+mGvWZ+4Uankvh8+c6zw==", + "dev": true, + "dependencies": { + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "dependencies": { - "estraverse": "^4.0.0" + "estraverse": "^5.1.0" }, "engines": { - "node": ">=0.6" + "node": ">=0.10" } }, "node_modules/esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "dependencies": { - "estraverse": "^4.1.0" + "estraverse": "^5.2.0" }, "engines": { "node": ">=4.0" } }, "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, "engines": { "node": ">=4.0" @@ -623,61 +670,43 @@ "node": ">=0.10.0" } }, - "node_modules/external-editor": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", - "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", - "dev": true, - "dependencies": { - "chardet": "^0.4.0", - "iconv-lite": "^0.4.17", - "tmp": "^0.0.33" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, "node_modules/fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, - "node_modules/figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", "dev": true, "dependencies": { - "escape-string-regexp": "^1.0.5" - }, - "engines": { - "node": ">=4" + "reusify": "^1.0.4" } }, "node_modules/file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "dependencies": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" + "flat-cache": "^3.0.4" }, "engines": { - "node": ">=0.10.0" + "node": "^10.12.0 || >=12.0.0" } }, "node_modules/find-up": { @@ -694,24 +723,28 @@ } }, "node_modules/flat-cache": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", - "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", "dev": true, "dependencies": { - "circular-json": "^0.3.1", - "graceful-fs": "^4.1.2", - "rimraf": "~2.6.2", - "write": "^0.2.1" + "flatted": "^3.1.0", + "rimraf": "^3.0.2" }, "engines": { - "node": ">=0.10.0" + "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", + "dev": true + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "node_modules/function-bind": { @@ -720,36 +753,51 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "node_modules/functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, "node_modules/glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, "engines": { "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" } }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, "engines": { - "node": ">=4" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/graceful-fs": { @@ -761,6 +809,12 @@ "node": ">=0.4.0" } }, + "node_modules/grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, "node_modules/has": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", @@ -773,25 +827,13 @@ "node": ">= 0.8.0" } }, - "node_modules/has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/hosted-git-info": { @@ -800,24 +842,31 @@ "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, - "node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "node_modules/ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/ignore": { - "version": "3.3.10", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", - "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", - "dev": true - }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -830,7 +879,7 @@ "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "dependencies": { "once": "^1.3.0", @@ -843,28 +892,6 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "node_modules/inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", - "dev": true, - "dependencies": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^2.0.4", - "figures": "^2.0.0", - "lodash": "^4.3.0", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rx-lite": "^4.0.8", - "rx-lite-aggregates": "^4.0.8", - "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", - "through": "^2.3.6" - } - }, "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -883,26 +910,35 @@ "node": ">=0.10.0" } }, - "node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { - "node": ">=4" + "node": ">=0.10.0" } }, - "node_modules/is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } }, - "node_modules/is-resolvable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", - "dev": true + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } }, "node_modules/isarray": { "version": "1.0.0", @@ -913,32 +949,35 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "node_modules/js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true + "node_modules/js-sdsl": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", + "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } }, "node_modules/js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "node_modules/json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, "node_modules/json-stable-stringify-without-jsonify": { @@ -948,13 +987,13 @@ "dev": true }, "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -997,41 +1036,22 @@ "node": ">=4" } }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, "node_modules/lodash.cond": { "version": "4.5.2", "resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz", "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=", "dev": true }, - "node_modules/lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", - "dev": true, - "dependencies": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, - "node_modules/mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true, - "engines": { - "node": ">=4" - } + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -1040,36 +1060,12 @@ "node": "*" } }, - "node_modules/minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true - }, - "node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "node_modules/mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -1088,62 +1084,32 @@ "validate-npm-package-license": "^3.0.1" } }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "dependencies": { "wrappy": "1" } }, - "node_modules/onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "dependencies": { - "mimic-fn": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "dev": true, "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" }, "engines": { "node": ">= 0.8.0" } }, - "node_modules/os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/p-limit": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.1.0.tgz", @@ -1165,6 +1131,18 @@ "node": ">=4" } }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -1192,17 +1170,20 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } }, "node_modules/path-parse": { "version": "1.0.7", @@ -1264,44 +1245,43 @@ "node": ">=0.10.0" } }, - "node_modules/pluralize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", - "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "engines": { "node": ">= 0.8.0" } }, - "node_modules/process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "node_modules/punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", "dev": true, "engines": { - "node": ">=0.4.0" + "node": ">=6" } }, - "node_modules/pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/read-pkg": { "version": "2.0.0", @@ -1342,43 +1322,6 @@ "node": ">=4" } }, - "node_modules/readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/regexpp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", - "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==", - "dev": true, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, - "dependencies": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/resolve": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", @@ -1389,78 +1332,62 @@ } }, "node_modules/resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=4" } }, - "node_modules/restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", "dev": true, - "dependencies": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - }, "engines": { - "node": ">=4" + "iojs": ">=1.0.0", + "node": ">=0.10.0" } }, "node_modules/rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "dependencies": { "glob": "^7.1.3" }, "bin": { "rimraf": "bin.js" - } - }, - "node_modules/run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, - "dependencies": { - "is-promise": "^2.1.0" }, - "engines": { - "node": ">=0.12.0" + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/rx-lite": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", - "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", - "dev": true - }, - "node_modules/rx-lite-aggregates": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", - "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "dependencies": { - "rx-lite": "*" + "queue-microtask": "^1.2.2" } }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, "node_modules/semver": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", @@ -1471,42 +1398,24 @@ } }, "node_modules/shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "dependencies": { - "shebang-regex": "^1.0.0" + "shebang-regex": "^3.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, "node_modules/shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, - "node_modules/slice-ansi": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", - "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, - "dependencies": { - "is-fullwidth-code-point": "^2.0.0" - }, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/spdx-correct": { @@ -1530,53 +1439,16 @@ "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", "dev": true }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "dependencies": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "dependencies": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^5.0.1" }, "engines": { - "node": ">=4" - } - }, - "node_modules/strip-ansi/node_modules/ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true, - "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/strip-bom": { @@ -1589,35 +1461,27 @@ } }, "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/table": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", - "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "dependencies": { - "ajv": "^5.2.3", - "ajv-keywords": "^2.1.0", - "chalk": "^2.1.0", - "lodash": "^4.17.4", - "slice-ansi": "1.0.0", - "string-width": "^2.1.1" + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, "node_modules/text-table": { @@ -1626,47 +1490,38 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "node_modules/through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "node_modules/tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "dependencies": { - "os-tmpdir": "~1.0.2" + "prelude-ls": "^1.2.1" }, "engines": { - "node": ">=0.6.0" + "node": ">= 0.8.0" } }, - "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2" - }, "engines": { - "node": ">= 0.8.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } }, "node_modules/validate-npm-package-license": { "version": "3.0.1", @@ -1679,272 +1534,233 @@ } }, "node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "dependencies": { "isexe": "^2.0.0" }, "bin": { - "which": "bin/which" + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true + "node_modules/word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, - "node_modules/write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, - "dependencies": { - "mkdirp": "^0.5.1" - }, "engines": { - "node": ">=0.10.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } - }, - "node_modules/yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true } }, "dependencies": { - "acorn": { - "version": "5.7.4", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", - "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", - "dev": true - }, - "acorn-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", - "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", "dev": true, "requires": { - "acorn": "^3.0.4" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - } + "eslint-visitor-keys": "^3.3.0" } }, - "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "@eslint-community/regexpp": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.4.1.tgz", + "integrity": "sha512-BISJ6ZE4xQsuL/FmsyRaiffpq977bMlsKfGHTQrOGFErfByxIe6iZTxPf/00Zon9b9a7iUykfQwejN3s2ZW/Bw==", + "dev": true + }, + "@eslint/eslintrc": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.1.tgz", + "integrity": "sha512-eFRmABvW2E5Ho6f5fHLqgena46rOj7r7OKHYfLElqcBfGFHHpjBhivyi5+jOEQuSpdc/1phIZJlbC2te+tZNIw==", "dev": true, "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.5.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" } }, - "ajv-keywords": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", - "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", + "@eslint/js": { + "version": "8.36.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.36.0.tgz", + "integrity": "sha512-lxJ9R5ygVm8ZWgYdUweoq5ownDlJ4upvoWmO4eLxBYHdMo+vZ/Rx0EN6MbKWDJOSUGrqJy2Gt+Dyv/VKml0fjg==", "dev": true }, - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true + "@humanwhocodes/config-array": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "dev": true, + "requires": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + } }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", "dev": true }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" - }, - "dependencies": { - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" } }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" } }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "acorn": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", "dev": true }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true + "acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "requires": {} }, - "caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "requires": { - "callsites": "^0.2.0" + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, - "callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" } }, - "chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "circular-json": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", "dev": true, "requires": { - "restore-cursor": "^2.0.0" + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" } }, - "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "requires": { - "color-name": "1.1.3" + "color-name": "~1.1.4" } }, "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, "concat-map": { @@ -1953,48 +1769,30 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, "contains-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", "dev": true }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" } }, "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" }, "dependencies": { "ms": { @@ -2006,15 +1804,15 @@ } }, "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "requires": { "esutils": "^2.0.2" @@ -2030,55 +1828,102 @@ } }, "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, "eslint": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", - "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", - "dev": true, - "requires": { - "ajv": "^5.3.0", - "babel-code-frame": "^6.22.0", - "chalk": "^2.1.0", - "concat-stream": "^1.6.0", - "cross-spawn": "^5.1.0", - "debug": "^3.1.0", - "doctrine": "^2.1.0", - "eslint-scope": "^3.7.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^3.5.4", - "esquery": "^1.0.0", + "version": "8.36.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.36.0.tgz", + "integrity": "sha512-Y956lmS7vDqomxlaaQAHVmeb4tNMp2FWIvU/RnU5BD3IKMD/MJPr76xdyr68P8tV1iNMvN2mRK0yy3c+UjL+bw==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.1", + "@eslint/js": "8.36.0", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.1.1", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.5.0", + "esquery": "^1.4.2", "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", - "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.0.1", - "ignore": "^3.3.3", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", + "ignore": "^5.2.0", + "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^3.0.6", - "is-resolvable": "^1.0.0", - "js-yaml": "^3.9.1", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", + "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.4", - "minimatch": "^3.0.2", - "mkdirp": "^0.5.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "pluralize": "^7.0.0", - "progress": "^2.0.0", - "regexpp": "^1.0.1", - "require-uncached": "^1.0.3", - "semver": "^5.3.0", - "strip-ansi": "^4.0.0", - "strip-json-comments": "~2.0.1", - "table": "4.0.2", - "text-table": "~0.2.0" + "optionator": "^0.9.1", + "strip-ansi": "^6.0.1", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0" + }, + "dependencies": { + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + } } }, "eslint-config-airbnb-base": { @@ -2178,59 +2023,54 @@ "dev": true }, "eslint-scope": { - "version": "3.7.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", - "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", + "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", "dev": true, "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" } }, "eslint-visitor-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", - "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true }, "espree": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.0.tgz", + "integrity": "sha512-JPbJGhKc47++oo4JkEoTe2wjy4fmMwvFpgJT9cQzmfXKp22Dr6Hf1tdCteLz1h0P3t+mGvWZ+4Uankvh8+c6zw==", "dev": true, "requires": { - "acorn": "^5.5.0", - "acorn-jsx": "^3.0.0" + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.3.0" } }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "requires": { - "estraverse": "^4.0.0" + "estraverse": "^5.1.0" } }, "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "requires": { - "estraverse": "^4.1.0" + "estraverse": "^5.2.0" } }, "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true }, "esutils": { @@ -2239,52 +2079,40 @@ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, - "external-editor": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", - "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", - "dev": true, - "requires": { - "chardet": "^0.4.0", - "iconv-lite": "^0.4.17", - "tmp": "^0.0.33" - } - }, "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", "dev": true, "requires": { - "escape-string-regexp": "^1.0.5" + "reusify": "^1.0.4" } }, "file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "requires": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" + "flat-cache": "^3.0.4" } }, "find-up": { @@ -2298,21 +2126,25 @@ } }, "flat-cache": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", - "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", "dev": true, "requires": { - "circular-json": "^0.3.1", - "graceful-fs": "^4.1.2", - "rimraf": "~2.6.2", - "write": "^0.2.1" + "flatted": "^3.1.0", + "rimraf": "^3.0.2" } }, + "flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", + "dev": true + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "function-bind": { @@ -2321,31 +2153,37 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "requires": { + "is-glob": "^4.0.3" + } + }, "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } }, "graceful-fs": { "version": "4.1.11", @@ -2353,6 +2191,12 @@ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", "dev": true }, + "grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, "has": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", @@ -2362,19 +2206,10 @@ "function-bind": "^1.0.2" } }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, "hosted-git-info": { @@ -2383,21 +2218,22 @@ "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "dev": true + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "requires": { - "safer-buffer": ">= 2.1.2 < 3" + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" } }, - "ignore": { - "version": "3.3.10", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", - "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", - "dev": true - }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -2407,7 +2243,7 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "requires": { "once": "^1.3.0", @@ -2420,28 +2256,6 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", - "dev": true, - "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^2.0.4", - "figures": "^2.0.0", - "lodash": "^4.3.0", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rx-lite": "^4.0.8", - "rx-lite-aggregates": "^4.0.8", - "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", - "through": "^2.3.6" - } - }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -2457,22 +2271,25 @@ "builtin-modules": "^1.0.0" } }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } }, - "is-resolvable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true }, "isarray": { @@ -2484,29 +2301,28 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "js-sdsl": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", + "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", "dev": true }, "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "^2.0.1" } }, "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, "json-stable-stringify-without-jsonify": { @@ -2516,13 +2332,13 @@ "dev": true }, "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" } }, "load-json-file": { @@ -2555,70 +2371,33 @@ } } }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, "lodash.cond": { "version": "4.5.2", "resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz", "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=", "dev": true }, - "lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", - "dev": true, - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" } }, - "minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true - }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -2637,50 +2416,29 @@ "validate-npm-package-license": "^3.0.1" } }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "requires": { "wrappy": "1" } }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "^1.0.0" - } - }, "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "dev": true, "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" } }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, "p-limit": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.1.0.tgz", @@ -2696,6 +2454,15 @@ "p-limit": "^1.1.0" } }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -2717,13 +2484,13 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true }, "path-parse": { @@ -2771,34 +2538,22 @@ "find-up": "^1.0.0" } }, - "pluralize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", - "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", - "dev": true - }, "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", "dev": true }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true }, "read-pkg": { @@ -2833,37 +2588,6 @@ } } }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "regexpp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", - "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==", - "dev": true - }, - "require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, - "requires": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" - } - }, "resolve": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", @@ -2874,66 +2598,35 @@ } }, "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - } + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true }, "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "requires": { "glob": "^7.1.3" } }, - "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, - "requires": { - "is-promise": "^2.1.0" - } - }, - "rx-lite": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", - "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", - "dev": true - }, - "rx-lite-aggregates": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", - "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "requires": { - "rx-lite": "*" + "queue-microtask": "^1.2.2" } }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, "semver": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", @@ -2941,35 +2634,20 @@ "dev": true }, "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "requires": { - "shebang-regex": "^1.0.0" + "shebang-regex": "^3.0.0" } }, "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, - "slice-ansi": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", - "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0" - } - }, "spdx-correct": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", @@ -2991,46 +2669,13 @@ "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", "dev": true }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - } + "ansi-regex": "^5.0.1" } }, "strip-bom": { @@ -3040,29 +2685,18 @@ "dev": true }, "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "table": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", - "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { - "ajv": "^5.2.3", - "ajv-keywords": "^2.1.0", - "chalk": "^2.1.0", - "lodash": "^4.17.4", - "slice-ansi": "1.0.0", - "string-width": "^2.1.1" + "has-flag": "^4.0.0" } }, "text-table": { @@ -3071,41 +2705,29 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "~1.0.2" - } - }, "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "requires": { - "prelude-ls": "~1.1.2" + "prelude-ls": "^1.2.1" } }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } }, "validate-npm-package-license": { "version": "3.0.1", @@ -3118,39 +2740,30 @@ } }, "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "requires": { "isexe": "^2.0.0" } }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", "dev": true }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, - "write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } - }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true } } diff --git a/package.json b/package.json index 21c49307..1f8fc693 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "eslint": "^4.19.1", + "eslint": "^8.36.0", "eslint-config-airbnb-base": "^12.0.0", "eslint-plugin-import": "^2.7.0" } diff --git a/racketscript-compiler/racketscript/compiler/config.rkt b/racketscript-compiler/racketscript/compiler/config.rkt index 7350dca5..ddf23215 100644 --- a/racketscript-compiler/racketscript/compiler/config.rkt +++ b/racketscript-compiler/racketscript/compiler/config.rkt @@ -27,7 +27,9 @@ ignored-module-imports-in-boot ignored-undefined-identifier? - skip-arity-checks?) + skip-arity-checks? + + use-scheme-numbers?) ;;; --------------------------------------------------------------------------- (define FFI-CALL-ID '#%js-ffi) @@ -134,3 +136,9 @@ (: skip-arity-checks? (Parameter Boolean)) (define skip-arity-checks? (make-parameter #f)) + +;;; --------------------------------------------------------------------------- + +;; Compiler flag for switching between JS and Scheme number semantics. +(: use-scheme-numbers? (Parameter Boolean)) +(define use-scheme-numbers? (make-parameter #f)) diff --git a/racketscript-compiler/racketscript/compiler/directive.rkt b/racketscript-compiler/racketscript/compiler/directive.rkt new file mode 100644 index 00000000..2afe65b5 --- /dev/null +++ b/racketscript-compiler/racketscript/compiler/directive.rkt @@ -0,0 +1,24 @@ + +#lang racket/base + +(require (for-syntax racket + syntax/parse)) + +(provide #%rs-compiler + if-scheme-numbers) + +;; #%rs-compiler is treated specially by the compiler to implement +;; compiler directives. +(define #%rs-compiler + (lambda _ + (#%app error 'racketscript "cannot use Racketscript compiler directive in Racket"))) + +(define-syntax (if-scheme-numbers stx) + (syntax-parse stx + [(_ consequent:expr alternate:expr) + #'(#%rs-compiler 'if-scheme-numbers + consequent + alternate)] + [(_ consequent:expr) + #'(#%rs-compiler 'if-scheme-numbers + consequent)])) diff --git a/racketscript-compiler/racketscript/compiler/expand.rkt b/racketscript-compiler/racketscript/compiler/expand.rkt index 9644fb70..d501351f 100644 --- a/racketscript-compiler/racketscript/compiler/expand.rkt +++ b/racketscript-compiler/racketscript/compiler/expand.rkt @@ -369,14 +369,10 @@ [_ #:when (prefab-struct-key (syntax-e v)) #f] ;; TODO: No error to compile FFI [_ #:when (box? (syntax-e v)) (box (parameterize ([quoted? #t]) (to-absyn (unbox (syntax-e v)))))] - [_ #:when (exact-integer? (syntax-e v)) - (Quote (syntax-e v))] [_ #:when (boolean? (syntax-e v)) (Quote (syntax-e v))] [_ #:when (keyword? (syntax-e v)) (Quote (syntax-e v))] [(~or (~datum +inf.0) (~datum -inf.0) (~datum nan.0)) (Quote (syntax-e v))] - [_ #:when (real? (syntax-e v)) (Quote (syntax-e v))] - [_ #:when (complex? (syntax-e v)) #f] [_ #:when (char? (syntax-e v)) (Quote (syntax-e v))] [_ #:when (regexp? (syntax-e v)) diff --git a/racketscript-compiler/racketscript/compiler/main.rkt b/racketscript-compiler/racketscript/compiler/main.rkt index cde9cb4c..734aed99 100644 --- a/racketscript-compiler/racketscript/compiler/main.rkt +++ b/racketscript-compiler/racketscript/compiler/main.rkt @@ -35,7 +35,8 @@ racketscript-dir skip-npm-install enabled-optimizations - recompile-all-modules?) + recompile-all-modules? + use-scheme-numbers?) (define build-mode (make-parameter 'complete)) (define skip-npm-install (make-parameter #f)) @@ -314,6 +315,8 @@ (enabled-optimizations (set-add (enabled-optimizations) flatten-if-else))] ["--lift-returns" "Translate self tail calls to loops" (enabled-optimizations (set-add (enabled-optimizations) lift-returns))] + ["--scheme-numbers" "Use Scheme number semantics" + (use-scheme-numbers? #t)] #:multi [("-t" "--target") target "Build target environment [plain|webpack|closure-compiler|babel]" (if (member target *targets*) diff --git a/racketscript-compiler/racketscript/compiler/runtime/core.js b/racketscript-compiler/racketscript/compiler/runtime/core.js index 5d2fe6ef..abbaeb75 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core.js @@ -8,7 +8,7 @@ import * as UString from './core/unicode_string.js'; import * as Regexp from './core/regexp.js'; import * as Hash from './core/hash.js'; import * as Keyword from './core/keyword.js'; -import * as Number from './core/numbers.js'; +import * as Number from './core/numbers/numbers.js'; import * as Pair from './core/pair.js'; import * as Ports from './core/ports.js'; import * as Primitive from './core/primitive.js'; diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/equality.js b/racketscript-compiler/racketscript/compiler/runtime/core/equality.js index 3af8dfec..81be9dd6 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/equality.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/equality.js @@ -2,6 +2,11 @@ import * as Primitive from './primitive.js'; import * as PrimitiveSymbol from './primitive_symbol.js'; import * as Char from './char.js'; import * as Bytes from './bytes.js'; +import { + isSchemeNumber, + equals as schemeEquals, + eqv as schemeEqv +} from './numbers/scheme-numbers.js'; /** * @param {*} v1 @@ -22,6 +27,10 @@ export function isEq(v1, v2) { * @return {!boolean} */ export function isEqv(v1, v2) { + if (useSchemeEquality(v1, v2)) { + return schemeEqv(v1, v2); + } + // Handle Symbols if (PrimitiveSymbol.check(v1)) { return v1.equals(v2); @@ -38,6 +47,11 @@ export function isEqv(v1, v2) { */ export function isEqual(v1, v2) { if (v1 === v2) return true; + + if (useSchemeEquality(v1, v2)) { + return schemeEquals(v1, v2); + } + if (Primitive.check(v1)) return v1.equals(v2); // Bytes are not a Primitive. @@ -45,3 +59,13 @@ export function isEqual(v1, v2) { return false; } + +function useSchemeEquality(v1, v2) { + if (typeof v1 === 'number' && !Number.isInteger(v1)) { + return false; + } + if (typeof v2 === 'number' && !Number.isInteger(v2)) { + return false; + } + return isSchemeNumber(v1) && isSchemeNumber(v2); +} diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/numbers.js b/racketscript-compiler/racketscript/compiler/runtime/core/numbers/js-numbers.js similarity index 97% rename from racketscript-compiler/racketscript/compiler/runtime/core/numbers.js rename to racketscript-compiler/racketscript/compiler/runtime/core/numbers/js-numbers.js index 6b5d0c7c..15aa54e7 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/numbers.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/numbers/js-numbers.js @@ -1,4 +1,4 @@ -import { racketCoreError } from './errors.js'; +import { racketCoreError } from '../errors.js'; /* Arithmetic */ diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/numbers/numbers.js b/racketscript-compiler/racketscript/compiler/runtime/core/numbers/numbers.js new file mode 100644 index 00000000..d3764dbb --- /dev/null +++ b/racketscript-compiler/racketscript/compiler/runtime/core/numbers/numbers.js @@ -0,0 +1,7 @@ +import * as Scheme from './scheme-numbers.js'; +import * as JS from './js-numbers.js'; + +export { + Scheme, + JS +}; diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/numbers/scheme-numbers.js b/racketscript-compiler/racketscript/compiler/runtime/core/numbers/scheme-numbers.js new file mode 100644 index 00000000..80b2db0b --- /dev/null +++ b/racketscript-compiler/racketscript/compiler/runtime/core/numbers/scheme-numbers.js @@ -0,0 +1,4470 @@ +// Taken from https://github.com/dyoo/js-numbers/blob/master/src/js-numbers.js +// and originally written by Danny Yoo (dyoo@cs.wpi.edu) +// The original license is provided below. Modifications to the original +// source are made under the Racketscript license. +// +// +// // Licensing +// --------- +// +// This software is covered under the following copyright: +// +// /* +// * Copyright (c) 2010 Danny Yoo +// * All Rights Reserved. +// * +// * Permission is hereby granted, free of charge, to any person obtaining +// * a copy of this software and associated documentation files (the +// * "Software"), to deal in the Software without restriction, including +// * without limitation the rights to use, copy, modify, merge, publish, +// * distribute, sublicense, and/or sell copies of the Software, and to +// * permit persons to whom the Software is furnished to do so, subject to +// * the following conditions: +// * +// * The above copyright notice and this permission notice shall be +// * included in all copies or substantial portions of the Software. +// * +// * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +// * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +// * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +// * +// * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, +// * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER +// * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF +// * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT +// * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// * +// * In addition, the following condition applies: +// * +// * All redistributions must retain an intact copy of this copyright notice +// * and disclaimer. +// */ +// +// +// +// +// +// ====================================================================== +// +// js-numbers uses code from the jsbn library. The LICENSE to it is: +// +// Licensing +// --------- +// +// This software is covered under the following copyright: +// +// /* +// * Copyright (c) 2003-2005 Tom Wu +// * All Rights Reserved. +// * +// * Permission is hereby granted, free of charge, to any person obtaining +// * a copy of this software and associated documentation files (the +// * "Software"), to deal in the Software without restriction, including +// * without limitation the rights to use, copy, modify, merge, publish, +// * distribute, sublicense, and/or sell copies of the Software, and to +// * permit persons to whom the Software is furnished to do so, subject to +// * the following conditions: +// * +// * The above copyright notice and this permission notice shall be +// * included in all copies or substantial portions of the Software. +// * +// * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +// * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +// * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +// * +// * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, +// * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER +// * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF +// * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT +// * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// * +// * In addition, the following condition applies: +// * +// * All redistributions must retain an intact copy of this copyright notice +// * and disclaimer. +// */ +// +// Address all questions regarding this license to: +// +// Tom Wu +// tjw@cs.Stanford.EDU + + +// Scheme numbers. + +// The numeric tower has the following levels: +// integers +// rationals +// floats +// complex numbers +// +// with the representations: +// integers: fixnum or BigInteger [level=0] +// rationals: Rational [level=1] +// floats: FloatPoint [level=2] +// complex numbers: Complex [level=3] + +// We try to stick with the unboxed fixnum representation for +// integers, since that's what scheme programs commonly deal with, and +// we want that common type to be lightweight. + + +// A boxed-scheme-number is either BigInteger, Rational, FloatPoint, or Complex. +// An integer-scheme-number is either fixnum or BigInteger. + +// Abbreviation +var Numbers = {}; + +// makeNumericBinop: (fixnum fixnum -> any) (scheme-number scheme-number -> any) -> (scheme-number scheme-number) X +// Creates a binary function that works either on fixnums or boxnums. +// Applies the appropriate binary function, ensuring that both scheme numbers are +// lifted to the same level. +var makeNumericBinop = function(onFixnums, onBoxednums, options) { + options = options || {}; + return function(x, y) { + if (options.isXSpecialCase && options.isXSpecialCase(x)) + return options.onXSpecialCase(x, y); + if (options.isYSpecialCase && options.isYSpecialCase(y)) + return options.onYSpecialCase(x, y); + if (typeof(x) === 'number' && + typeof(y) === 'number') { + return onFixnums(x, y); + } + if (typeof(x) === 'number') { + x = liftFixnumInteger(x, y); + } + if (typeof(y) === 'number') { + y = liftFixnumInteger(y, x); + } + if (x.level < y.level) x = x.liftTo(y); + if (y.level < x.level) y = y.liftTo(x); + return onBoxednums(x, y); + }; +} + +// fromFixnum: fixnum -> scheme-number +var fromFixnum = function(x) { + if (isNaN(x) || (!isFinite(x))) { + return FloatPoint.makeInstance(x); + } + var nf = Math.floor(x); + if (nf === x) { + if (isOverflow(nf)) { + return makeBignum(expandExponent(x + '')); + } else { + return nf; + } + } else { + return FloatPoint.makeInstance(x); + } +}; +var expandExponent = function(s) { + var match = s.match(scientificPattern), + mantissaChunks, exponent; + if (match) { + mantissaChunks = match[1].match(/^([^.]*)(.*)$/); + exponent = Number(match[2]); + if (mantissaChunks[2].length === 0) { + return mantissaChunks[1] + zfill(exponent); + } + if (exponent >= mantissaChunks[2].length - 1) { + return (mantissaChunks[1] + + mantissaChunks[2].substring(1) + + zfill(exponent - (mantissaChunks[2].length - 1))); + } else { + return (mantissaChunks[1] + + mantissaChunks[2].substring(1, 1 + exponent)); + } + } else { + return s; + } +}; +// zfill: integer -> string +// builds a string of "0"'s of length n. +var zfill = function(n) { + var buffer = []; + buffer.length = n; + for (var i = 0; i < n; i++) { + buffer[i] = '0'; + } + return buffer.join(''); +}; + +// liftFixnumInteger: fixnum-integer boxed-scheme-number -> boxed-scheme-number +// Lifts up fixnum integers to a boxed type. +var liftFixnumInteger = function(x, other) { + switch (other.level) { + case 0: // BigInteger + return makeBignum(x); + case 1: // Rational + return new Rational(x, 1); + case 2: // FloatPoint + return new FloatPoint(x); + case 3: // Complex + return new Complex(x, 0); + default: + throwRuntimeError("IMPOSSIBLE: cannot lift fixnum integer to " + other.toString(), x, other); + } +}; + +// throwRuntimeError: string (scheme-number | undefined) (scheme-number | undefined) -> void +// Throws a runtime error with the given message string. +var throwRuntimeError = function(msg, x, y) { + Numbers['onThrowRuntimeError'](msg, x, y); +}; + +// onThrowRuntimeError: string (scheme-number | undefined) (scheme-number | undefined) -> void +// By default, will throw a new Error with the given message. +// Override Numbers['onThrowRuntimeError'] if you need to do something special. +var onThrowRuntimeError = function(msg, x, y) { + throw new Error(msg); +}; + +// isSchemeNumber: any -> boolean +// Returns true if the thing is a scheme number. +var isSchemeNumber = function(thing) { + return (typeof(thing) === 'number' || + (thing instanceof Rational || + thing instanceof FloatPoint || + thing instanceof Complex || + thing instanceof BigInteger)); +}; + +// isRational: scheme-number -> boolean +var isRational = function(n) { + return (typeof(n) === 'number' || + (isSchemeNumber(n) && n.isRational())); +}; +// isReal: scheme-number -> boolean +var isReal = function(n) { + return (typeof(n) === 'number' || + (isSchemeNumber(n) && n.isReal())); +}; +// isExact: scheme-number -> boolean +var isExact = function(n) { + return (typeof(n) === 'number' || + (isSchemeNumber(n) && n.isExact())); +}; +// isExact: scheme-number -> boolean +var isInexact = function(n) { + if (typeof(n) === 'number') { + return false; + } else { + return (isSchemeNumber(n) && n.isInexact()); + } +}; +// isInteger: scheme-number -> boolean +var isInteger = function(n) { + return (typeof(n) === 'number' || + (isSchemeNumber(n) && n.isInteger())); +}; +// isExactInteger: scheme-number -> boolean +var isExactInteger = function(n) { + return (typeof(n) === 'number' || + (isSchemeNumber(n) && + n.isInteger() && + n.isExact())); +} + +// toFixnum: scheme-number -> javascript-number +var toFixnum = function(n) { + if (typeof(n) === 'number') + return n; + return n.toFixnum(); +}; +// toExact: scheme-number -> scheme-number +var toExact = function(n) { + if (typeof(n) === 'number') + return n; + return n.toExact(); +}; + +// toExact: scheme-number -> scheme-number +var toInexact = function(n) { + if (typeof(n) === 'number') + return FloatPoint.makeInstance(n); + return n.toInexact(); +}; + +////////////////////////////////////////////////////////////////////// + +// Takes a two argument function and makes it multi-arity. +// Can provide an alternative function for when called with +// a single argument or no arguments. +function makeMultiArityArithmetic(multiArg, singleArg=false, noArg=false) { + function quickReduce(array) { + let result = array[0]; + for (let i = 1; i < array.length; i++) { + result = multiArg(result, array[i]); + } + return result; + } + + if (noArg && singleArg) { + return function(...operands) { + if (operands.length === 0) { + return noArg(); + } else if (operands.length === 1) { + return singleArg(operands[0]); + } + return quickReduce(operands); + } + } + + if (singleArg) { + return function(...operands) { + if (operands.length === 1) { + return singleArg(operands[0]); + } + quickReduce(operands); + } + } + + if (!singleArge && !noArg) { + return function(...operands) { + quickReduce(operands); + } + } + + throwRuntimeError("singleArg must be provided if noArg is provided."); +} + +// multiAdd: multi-arity version of add. +var multiAdd = makeMultiArityArithmetic(add, (value) => value, () => 0); + +// add: scheme-number scheme-number -> scheme-number +var add = function(x, y) { + var sum; + if (typeof(x) === 'number' && typeof(y) === 'number') { + sum = x + y; + if (isOverflow(sum)) { + return (makeBignum(x)).add(makeBignum(y)); + } + } + if (x instanceof FloatPoint && y instanceof FloatPoint) { + return x.add(y); + } + return addSlow(x, y); +}; +var addSlow = makeNumericBinop( + function(x, y) { + var sum = x + y; + if (isOverflow(sum)) { + return (makeBignum(x)).add(makeBignum(y)); + } else { + return sum; + } + }, + function(x, y) { + return x.add(y); + }, { + isXSpecialCase: function(x) { + return isExactInteger(x) && _integerIsZero(x) + }, + onXSpecialCase: function(x, y) { + return y; + }, + isYSpecialCase: function(y) { + return isExactInteger(y) && _integerIsZero(y) + }, + onYSpecialCase: function(x, y) { + return x; + } + }); + +// multiSub: multi-arity version of subtract. +var multiSub = makeMultiArityArithmetic(subtract, (value) => subtract(0, value)); + +// subtract: scheme-number scheme-number -> scheme-number +var subtract = makeNumericBinop( + function(x, y) { + var diff = x - y; + if (isOverflow(diff)) { + return (makeBignum(x)).subtract(makeBignum(y)); + } else { + return diff; + } + }, + function(x, y) { + return x.subtract(y); + }, { + isXSpecialCase: function(x) { + return isExactInteger(x) && _integerIsZero(x) + }, + onXSpecialCase: function(x, y) { + return negate(y); + }, + isYSpecialCase: function(y) { + return isExactInteger(y) && _integerIsZero(y) + }, + onYSpecialCase: function(x, y) { + return x; + } + }); + +// mul: multi-arity version of multiply. +var multiMultiply = makeMultiArityArithmetic(multiply, (value) => value, () => 1); + +// mulitply: scheme-number scheme-number -> scheme-number +var multiply = function(x, y) { + var prod; + if (typeof(x) === 'number' && typeof(y) === 'number') { + prod = x * y; + if (isOverflow(prod)) { + return (makeBignum(x)).multiply(makeBignum(y)); + } else { + return prod; + } + } + if (x instanceof FloatPoint && y instanceof FloatPoint) { + return x.multiply(y); + } + return multiplySlow(x, y); +}; +var multiplySlow = makeNumericBinop( + function(x, y) { + var prod = x * y; + if (isOverflow(prod)) { + return (makeBignum(x)).multiply(makeBignum(y)); + } else { + return prod; + } + }, + function(x, y) { + return x.multiply(y); + }, { + isXSpecialCase: function(x) { + return (isExactInteger(x) && + (_integerIsZero(x) || _integerIsOne(x) || _integerIsNegativeOne(x))) + }, + onXSpecialCase: function(x, y) { + if (_integerIsZero(x)) + return 0; + if (_integerIsOne(x)) + return y; + if (_integerIsNegativeOne(x)) + return negate(y); + }, + isYSpecialCase: function(y) { + return (isExactInteger(y) && + (_integerIsZero(y) || _integerIsOne(y) || _integerIsNegativeOne(y))) + }, + onYSpecialCase: function(x, y) { + if (_integerIsZero(y)) + return 0; + if (_integerIsOne(y)) + return x; + if (_integerIsNegativeOne(y)) + return negate(x); + } + }); + +// div: multi-arity version of divide. +var multiDivide = makeMultiArityArithmetic(divide, (value) => divide(1, value)); + +// divide: scheme-number scheme-number -> scheme-number +var divide = makeNumericBinop( + function(x, y) { + if (_integerIsZero(y)) + throwRuntimeError("/: division by zero", x, y); + var div = x / y; + if (isOverflow(div)) { + return (makeBignum(x)).divide(makeBignum(y)); + } else if (Math.floor(div) !== div) { + return Rational.makeInstance(x, y); + } else { + return div; + } + }, + function(x, y) { + return x.divide(y); + }, { + isXSpecialCase: function(x) { + return (eqv(x, 0)); + }, + onXSpecialCase: function(x, y) { + if (eqv(y, 0)) { + throwRuntimeError("/: division by zero", x, y); + } + return 0; + }, + isYSpecialCase: function(y) { + return (eqv(y, 0)); + }, + onYSpecialCase: function(x, y) { + throwRuntimeError("/: division by zero", x, y); + } + }); + +// Makes a multi-arity comparison function. +function makeMultiArityComparison(compare) { + return function(...operands) { + if (operands.length === 1) { + return true; + } + for (let i = 1; i < operands.length; i++) { + if (!compare(operands[i - 1], operands[i])) { + return false; + } + } + return true; + } +} + + + +// equals: scheme-number scheme-number -> boolean +var equals = makeNumericBinop( + function(x, y) { + return x === y; + }, + function(x, y) { + return x.equals(y); + }); + +// eqv: scheme-number scheme-number -> boolean +var eqv = function(x, y) { + if (x === y) + return true; + if (typeof(x) === 'number' && typeof(y) === 'number') + return x === y; + if (x === NEGATIVE_ZERO || y === NEGATIVE_ZERO) + return x === y; + if (x instanceof Complex || y instanceof Complex) { + return (eqv(realPart(x), realPart(y)) && + eqv(imaginaryPart(x), imaginaryPart(y))); + } + var ex = isExact(x), + ey = isExact(y); + return (((ex && ey) || (!ex && !ey)) && equals(x, y)); +}; +// approxEqual: scheme-number scheme-number scheme-number -> boolean +var approxEquals = function(x, y, delta) { + return lessThan(abs(subtract(x, y)), + delta); +}; +// greaterThanOrEqual: scheme-number scheme-number -> boolean +var greaterThanOrEqual = makeNumericBinop( + function(x, y) { + return x >= y; + }, + function(x, y) { + if (!(isReal(x) && isReal(y))) + throwRuntimeError( + ">=: couldn't be applied to complex number", x, y); + return x.greaterThanOrEqual(y); + }); + +// lessThanOrEqual: scheme-number scheme-number -> boolean +var lessThanOrEqual = makeNumericBinop( + function(x, y) { + return x <= y; + }, + function(x, y) { + if (!(isReal(x) && isReal(y))) + throwRuntimeError("<=: couldn't be applied to complex number", x, y); + return x.lessThanOrEqual(y); + }); + +// greaterThan: scheme-number scheme-number -> boolean +var greaterThan = makeNumericBinop( + function(x, y) { + return x > y; + }, + function(x, y) { + if (!(isReal(x) && isReal(y))) + throwRuntimeError(">: couldn't be applied to complex number", x, y); + return x.greaterThan(y); + }); + +// lessThan: scheme-number scheme-number -> boolean +var lessThan = makeNumericBinop( + function(x, y) { + return x < y; + }, + function(x, y) { + if (!(isReal(x) && isReal(y))) + throwRuntimeError("<: couldn't be applied to complex number", x, y); + return x.lessThan(y); + }); + +// expt: scheme-number scheme-number -> scheme-number +var expt = (function() { + var _expt = makeNumericBinop( + function(x, y) { + var pow = Math.pow(x, y); + if (isOverflow(pow)) { + return (makeBignum(x)).expt(makeBignum(y)); + } else { + return pow; + } + }, + function(x, y) { + if (equals(y, 0)) { + return add(y, 1); + } else { + return x.expt(y); + } + }); + return function(x, y) { + if (equals(y, 0)) + return add(y, 1); + if (isReal(y) && lessThan(y, 0)) { + return _expt(divide(1, x), negate(y)); + } + return _expt(x, y); + }; +})(); + +// exp: scheme-number -> scheme-number +var exp = function(n) { + if (eqv(n, 0)) { + return 1; + } + if (typeof(n) === 'number') { + return FloatPoint.makeInstance(Math.exp(n)); + } + return n.exp(); +}; + +// modulo: scheme-number scheme-number -> scheme-number +var modulo = function(m, n) { + if (!isInteger(m)) { + throwRuntimeError('modulo: the first argument ' + + m + " is not an integer.", m, n); + } + if (!isInteger(n)) { + throwRuntimeError('modulo: the second argument ' + + n + " is not an integer.", m, n); + } + var result; + if (typeof(m) === 'number') { + result = m % n; + if (n < 0) { + if (result <= 0) + return result; + else + return result + n; + } else { + if (result < 0) + return result + n; + else + return result; + } + } + result = _integerModulo(floor(m), floor(n)); + // The sign of the result should match the sign of n. + if (lessThan(n, 0)) { + if (lessThanOrEqual(result, 0)) { + return result; + } + return add(result, n); + } else { + if (lessThan(result, 0)) { + return add(result, n); + } + return result; + } +}; + +// numerator: scheme-number -> scheme-number +var numerator = function(n) { + if (typeof(n) === 'number') + return n; + return n.numerator(); +}; + +// denominator: scheme-number -> scheme-number +var denominator = function(n) { + if (typeof(n) === 'number') + return 1; + return n.denominator(); +}; +// sqrt: scheme-number -> scheme-number +var sqrt = function(n) { + if (typeof(n) === 'number') { + if (n >= 0) { + var result = Math.sqrt(n); + if (Math.floor(result) === result) { + return result; + } else { + return FloatPoint.makeInstance(result); + } + } else { + return (Complex.makeInstance(0, sqrt(-n))); + } + } + return n.sqrt(); +}; +// abs: scheme-number -> scheme-number +var abs = function(n) { + if (typeof(n) === 'number') { + return Math.abs(n); + } + return n.abs(); +}; +// floor: scheme-number -> scheme-number +var floor = function(n) { + if (typeof(n) === 'number') + return n; + return n.floor(); +}; +// ceiling: scheme-number -> scheme-number +var ceiling = function(n) { + if (typeof(n) === 'number') { + return Math.ceil(n); + } + return n.ceiling(); +}; +// conjugate: scheme-number -> scheme-number +var conjugate = function(n) { + if (typeof(n) === 'number') + return n; + return n.conjugate(); +}; +// magnitude: scheme-number -> scheme-number +var magnitude = function(n) { + if (typeof(n) === 'number') + return Math.abs(n); + return n.magnitude(); +}; + +// log: scheme-number -> scheme-number +var log = function(n) { + if (eqv(n, 1)) { + return 0; + } + if (typeof(n) === 'number') { + return FloatPoint.makeInstance(Math.log(n)); + } + return n.log(); +}; +// angle: scheme-number -> scheme-number +var angle = function(n) { + if (typeof(n) === 'number') { + if (n > 0) + return 0; + else + return FloatPoint.pi; + } + return n.angle(); +}; +// tan: scheme-number -> scheme-number +var tan = function(n) { + if (eqv(n, 0)) { + return 0; + } + if (typeof(n) === 'number') { + return FloatPoint.makeInstance(Math.tan(n)); + } + return n.tan(); +}; +// atan: scheme-number -> scheme-number +var atan = function(n) { + if (eqv(n, 0)) { + return 0; + } + if (typeof(n) === 'number') { + return FloatPoint.makeInstance(Math.atan(n)); + } + return n.atan(); +}; + +var atan2 = function(y, x) { + if (typeof(y) == 'number' && typeof(x) == 'number') { + return FloatPoint.makeInstance(Math.atan2(y, x)) + } + y = toInexact(y); + x = toInexact(x); + return FloatPoint.makeInstance(Math.atan2(y.n, x.n)) +} +// cos: scheme-number -> scheme-number +var cos = function(n) { + if (eqv(n, 0)) { + return 1; + } + if (typeof(n) === 'number') { + return FloatPoint.makeInstance(Math.cos(n)); + } + return n.cos(); +}; +// sin: scheme-number -> scheme-number +var sin = function(n) { + if (eqv(n, 0)) { + return 0; + } + if (typeof(n) === 'number') { + return FloatPoint.makeInstance(Math.sin(n)); + } + return n.sin(); +}; +// acos: scheme-number -> scheme-number +var acos = function(n) { + if (eqv(n, 1)) { + return 0; + } + if (typeof(n) === 'number') { + return FloatPoint.makeInstance(Math.acos(n)); + } + return n.acos(); +}; +// asin: scheme-number -> scheme-number +var asin = function(n) { + if (eqv(n, 0)) { + return 0; + } + if (typeof(n) === 'number') { + return FloatPoint.makeInstance(Math.asin(n)); + } + return n.asin(); +}; +// imaginaryPart: scheme-number -> scheme-number +var imaginaryPart = function(n) { + if (typeof(n) === 'number') { + return 0; + } + return n.imaginaryPart(); +}; +// realPart: scheme-number -> scheme-number +var realPart = function(n) { + if (typeof(n) === 'number') { + return n; + } + return n.realPart(); +}; +// round: scheme-number -> scheme-number +var round = function(n) { + if (typeof(n) === 'number') { + return n; + } + return n.round(); +}; + +// sqr: scheme-number -> scheme-number +var sqr = function(x) { + return multiply(x, x); +}; + +// integerSqrt: scheme-number -> scheme-number +var integerSqrt = function(x) { + if (!isInteger(x)) { + throwRuntimeError('integer-sqrt: the argument ' + x.toString() + + " is not an integer.", x); + } + if (typeof(x) === 'number') { + if (x < 0) { + return Complex.makeInstance(0, + Math.floor(Math.sqrt(-x))) + } else { + return Math.floor(Math.sqrt(x)); + } + } + return x.integerSqrt(); +}; + +// gcd: scheme-number [scheme-number ...] -> scheme-number +var gcd = function(first, rest) { + if (!isInteger(first)) { + throwRuntimeError('gcd: the argument ' + first.toString() + + " is not an integer.", first); + } + var a = abs(first), + t, b; + for (var i = 0; i < rest.length; i++) { + b = abs(rest[i]); + if (!isInteger(b)) { + throwRuntimeError('gcd: the argument ' + b.toString() + + " is not an integer.", b); + } + while (!_integerIsZero(b)) { + t = a; + a = b; + b = _integerModulo(t, b); + } + } + return a; +}; +// lcm: scheme-number [scheme-number ...] -> scheme-number +var lcm = function(first, rest) { + if (!isInteger(first)) { + throwRuntimeError('lcm: the argument ' + first.toString() + + " is not an integer.", first); + } + var result = abs(first); + if (_integerIsZero(result)) { + return 0; + } + for (var i = 0; i < rest.length; i++) { + if (!isInteger(rest[i])) { + throwRuntimeError('lcm: the argument ' + rest[i].toString() + + " is not an integer.", rest[i]); + } + var divisor = _integerGcd(result, rest[i]); + if (_integerIsZero(divisor)) { + return 0; + } + result = divide(multiply(result, rest[i]), divisor); + } + return result; +}; + +var quotient = function(x, y) { + if (!isInteger(x)) { + throwRuntimeError('quotient: the first argument ' + x.toString() + + " is not an integer.", x); + } + if (!isInteger(y)) { + throwRuntimeError('quotient: the second argument ' + y.toString() + + " is not an integer.", y); + } + return _integerQuotient(x, y); +}; + +var remainder = function(x, y) { + if (!isInteger(x)) { + throwRuntimeError('remainder: the first argument ' + x.toString() + + " is not an integer.", x); + } + if (!isInteger(y)) { + throwRuntimeError('remainder: the second argument ' + y.toString() + + " is not an integer.", y); + } + return _integerRemainder(x, y); +}; + +// Implementation of the hyperbolic functions +// http://en.wikipedia.org/wiki/Hyperbolic_cosine +var cosh = function(x) { + if (eqv(x, 0)) { + return FloatPoint.makeInstance(1.0); + } + return divide(add(exp(x), exp(negate(x))), + 2); +}; +var sinh = function(x) { + return divide(subtract(exp(x), exp(negate(x))), + 2); +}; + +var makeComplexPolar = function(r, theta) { + // special case: if theta is zero, just return + // the scalar. + if (eqv(theta, 0)) { + return r; + } + return Complex.makeInstance(multiply(r, cos(theta)), + multiply(r, sin(theta))); +}; + +var bitwiseAnd = function(...nums) { + var jsNums = getJSExactIntegers(...nums); + return jsNums.reduce((x, y) => (x & y)); +} + +var bitwiseOr = function(...nums) { + var jsNums = getJSExactIntegers(...nums); + return jsNums.reduce((x, y) => (x | y)); +} + +var bitwiseXor = function(...nums) { + var jsNums = getJSExactIntegers(...nums); + return jsNums.reduce((x, y) => (x ^ y)); +} + +var bitwiseNot = function(n) { + var jsNum = getJSExactIntegers(n)[0]; + return ~jsNum; +} + +var arithmeticShift = function(n, m) { + [n, m] = getJSExactIntegers(n, m); + if (m < 0) { + return n >> -m; + } else { + return n << m; + } +} + +////////////////////////////////////////////////////////////////////// +// Helpers + +// IsFinite: scheme-number -> boolean +// Returns true if the scheme number is finite or not. +var isSchemeNumberFinite = function(n) { + if (typeof(n) === 'number') { + return isFinite(n); + } else { + return n.isFinite(); + } +}; +// isOverflow: javascript-number -> boolean +// Returns true if we consider the number an overflow. +var MIN_FIXNUM = -(9e15); +var MAX_FIXNUM = (9e15); +var isOverflow = function(n) { + return (n < MIN_FIXNUM || MAX_FIXNUM < n); +}; + +// negate: scheme-number -> scheme-number +// multiplies a number times -1. +var negate = function(n) { + if (typeof(n) === 'number') { + return -n; + } + return n.negate(); +}; + +// halve: scheme-number -> scheme-number +// Divide a number by 2. +var halve = function(n) { + return divide(n, 2); +}; + +// timesI: scheme-number scheme-number +// multiplies a number times i. +var timesI = function(x) { + return multiply(x, plusI); +}; + +// fastExpt: computes n^k by squaring. +// n^k = (n^2)^(k/2) +// Assumes k is non-negative integer. +var fastExpt = function(n, k) { + var acc = 1; + while (true) { + if (_integerIsZero(k)) { + return acc; + } + if (equals(modulo(k, 2), 0)) { + n = multiply(n, n); + k = divide(k, 2); + } else { + acc = multiply(acc, n); + k = subtract(k, 1); + } + } +}; + +// getJSExactIntegers: scheme-number [scheme-number ...] -> [js-number] +// Get's the underlying JS numbers from one or more scheme exact integers +// and returns them in an array. +var getJSExactIntegers = function(...nums) { + // Only defined for exact integers. + nums.map((x) => { + if (!isExactInteger(x)) { + throwRuntimeError("Expected exact integer(s).") + } + }) + + // Get the JS value. + return nums.map((x) => { + if (typeof(x) === 'number') { + return x; + } else { + return x.n; + } + }) +} + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// + +// Integer operations +// Integers are either represented as fixnums or as BigIntegers. +// makeIntegerBinop: (fixnum fixnum -> X) (BigInteger BigInteger -> X) -> X +// Helper to collect the common logic for coersing integer fixnums or bignums to a +// common type before doing an operation. +var makeIntegerBinop = function(onFixnums, onBignums, options) { + options = options || {}; + return (function(m, n) { + if (m instanceof Rational) { + m = numerator(m); + } else if (m instanceof Complex) { + m = realPart(m); + } + if (n instanceof Rational) { + n = numerator(n); + } else if (n instanceof Complex) { + n = realPart(n); + } + if (typeof(m) === 'number' && typeof(n) === 'number') { + var result = onFixnums(m, n); + if (!isOverflow(result) || + (options.ignoreOverflow)) { + return result; + } + } + if (m instanceof FloatPoint || n instanceof FloatPoint) { + if (options.doNotCoerseToFloating) { + return onFixnums(toFixnum(m), toFixnum(n)); + } else { + return FloatPoint.makeInstance( + onFixnums(toFixnum(m), toFixnum(n))); + } + } + if (typeof(m) === 'number') { + m = makeBignum(m); + } + if (typeof(n) === 'number') { + n = makeBignum(n); + } + return onBignums(m, n); + }); +}; + +var makeIntegerUnOp = function(onFixnums, onBignums, options) { + options = options || {}; + return (function(m) { + if (m instanceof Rational) { + m = numerator(m); + } else if (m instanceof Complex) { + m = realPart(m); + } + if (typeof(m) === 'number') { + var result = onFixnums(m); + if (!isOverflow(result) || + (options.ignoreOverflow)) { + return result; + } + } + if (m instanceof FloatPoint) { + return onFixnums(toFixnum(m)); + } + if (typeof(m) === 'number') { + m = makeBignum(m); + } + return onBignums(m); + }); +}; + +// _integerModulo: integer-scheme-number integer-scheme-number -> integer-scheme-number +var _integerModulo = makeIntegerBinop( + function(m, n) { + return m % n; + }, + function(m, n) { + return bnMod.call(m, n); + }); + +// _integerGcd: integer-scheme-number integer-scheme-number -> integer-scheme-number +var _integerGcd = makeIntegerBinop( + function(a, b) { + var t; + while (b !== 0) { + t = a; + a = b; + b = t % b; + } + return a; + }, + function(m, n) { + return bnGCD.call(m, n); + }); + +// _integerIsZero: integer-scheme-number -> boolean +// Returns true if the number is zero. +var _integerIsZero = makeIntegerUnOp( + function(n) { + return n === 0; + }, + function(n) { + return bnEquals.call(n, BigInteger.ZERO); + } +); + +// _integerIsOne: integer-scheme-number -> boolean +var _integerIsOne = makeIntegerUnOp( + function(n) { + return n === 1; + }, + function(n) { + return bnEquals.call(n, BigInteger.ONE); + }); + +// _integerIsNegativeOne: integer-scheme-number -> boolean +var _integerIsNegativeOne = makeIntegerUnOp( + function(n) { + return n === -1; + }, + function(n) { + return bnEquals.call(n, BigInteger.NEGATIVE_ONE); + }); + +// _integerAdd: integer-scheme-number integer-scheme-number -> integer-scheme-number +var _integerAdd = makeIntegerBinop( + function(m, n) { + return m + n; + }, + function(m, n) { + return bnAdd.call(m, n); + }); +// _integerSubtract: integer-scheme-number integer-scheme-number -> integer-scheme-number +var _integerSubtract = makeIntegerBinop( + function(m, n) { + return m - n; + }, + function(m, n) { + return bnSubtract.call(m, n); + }); +// _integerMultiply: integer-scheme-number integer-scheme-number -> integer-scheme-number +var _integerMultiply = makeIntegerBinop( + function(m, n) { + return m * n; + }, + function(m, n) { + return bnMultiply.call(m, n); + }); +//_integerQuotient: integer-scheme-number integer-scheme-number -> integer-scheme-number +var _integerQuotient = makeIntegerBinop( + function(m, n) { + return ((m - (m % n)) / n); + }, + function(m, n) { + return bnDivide.call(m, n); + }); +var _integerRemainder = makeIntegerBinop( + function(m, n) { + return m % n; + }, + function(m, n) { + return bnRemainder.call(m, n); + }); + +// _integerDivideToFixnum: integer-scheme-number integer-scheme-number -> fixnum +var _integerDivideToFixnum = makeIntegerBinop( + function(m, n) { + return m / n; + }, + function(m, n) { + return toFixnum(m) / toFixnum(n); + }, { + ignoreOverflow: true, + doNotCoerseToFloating: true + }); + +// _integerEquals: integer-scheme-number integer-scheme-number -> boolean +var _integerEquals = makeIntegerBinop( + function(m, n) { + return m === n; + }, + function(m, n) { + return bnEquals.call(m, n); + }, { + doNotCoerseToFloating: true + }); +// _integerGreaterThan: integer-scheme-number integer-scheme-number -> boolean +var _integerGreaterThan = makeIntegerBinop( + function(m, n) { + return m > n; + }, + function(m, n) { + return bnCompareTo.call(m, n) > 0; + }, { + doNotCoerseToFloating: true + }); +// _integerLessThan: integer-scheme-number integer-scheme-number -> boolean +var _integerLessThan = makeIntegerBinop( + function(m, n) { + return m < n; + }, + function(m, n) { + return bnCompareTo.call(m, n) < 0; + }, { + doNotCoerseToFloating: true + }); +// _integerGreaterThanOrEqual: integer-scheme-number integer-scheme-number -> boolean +var _integerGreaterThanOrEqual = makeIntegerBinop( + function(m, n) { + return m >= n; + }, + function(m, n) { + return bnCompareTo.call(m, n) >= 0; + }, { + doNotCoerseToFloating: true + }); +// _integerLessThanOrEqual: integer-scheme-number integer-scheme-number -> boolean +var _integerLessThanOrEqual = makeIntegerBinop( + function(m, n) { + return m <= n; + }, + function(m, n) { + return bnCompareTo.call(m, n) <= 0; + }, { + doNotCoerseToFloating: true + }); + +////////////////////////////////////////////////////////////////////// +// The boxed number types are expected to implement the following +// interface. +// +// toString: -> string +// level: number +// liftTo: scheme-number -> scheme-number +// isFinite: -> boolean +// isInteger: -> boolean +// Produce true if this number can be coersed into an integer. +// isRational: -> boolean +// Produce true if the number is rational. +// isReal: -> boolean +// Produce true if the number is real. +// isExact: -> boolean +// Produce true if the number is exact +// toExact: -> scheme-number +// Produce an exact number. +// toFixnum: -> javascript-number +// Produce a javascript number. +// greaterThan: scheme-number -> boolean +// Compare against instance of the same type. +// greaterThanOrEqual: scheme-number -> boolean +// Compare against instance of the same type. +// lessThan: scheme-number -> boolean +// Compare against instance of the same type. +// lessThanOrEqual: scheme-number -> boolean +// Compare against instance of the same type. +// add: scheme-number -> scheme-number +// Add with an instance of the same type. +// subtract: scheme-number -> scheme-number +// Subtract with an instance of the same type. +// multiply: scheme-number -> scheme-number +// Multiply with an instance of the same type. +// divide: scheme-number -> scheme-number +// Divide with an instance of the same type. +// numerator: -> scheme-number +// Return the numerator. +// denominator: -> scheme-number +// Return the denominator. +// integerSqrt: -> scheme-number +// Produce the integer square root. +// sqrt: -> scheme-number +// Produce the square root. +// abs: -> scheme-number +// Produce the absolute value. +// floor: -> scheme-number +// Produce the floor. +// ceiling: -> scheme-number +// Produce the ceiling. +// conjugate: -> scheme-number +// Produce the conjugate. +// magnitude: -> scheme-number +// Produce the magnitude. +// log: -> scheme-number +// Produce the log. +// angle: -> scheme-number +// Produce the angle. +// atan: -> scheme-number +// Produce the arc tangent. +// cos: -> scheme-number +// Produce the cosine. +// sin: -> scheme-number +// Produce the sine. +// expt: scheme-number -> scheme-number +// Produce the power to the input. +// exp: -> scheme-number +// Produce e raised to the given power. +// acos: -> scheme-number +// Produce the arc cosine. +// asin: -> scheme-number +// Produce the arc sine. +// imaginaryPart: -> scheme-number +// Produce the imaginary part +// realPart: -> scheme-number +// Produce the real part. +// round: -> scheme-number +// Round to the nearest integer. +// equals: scheme-number -> boolean +// Produce true if the given number of the same type is equal. + +////////////////////////////////////////////////////////////////////// +// Rationals + +var Rational = function(n, d) { + this.n = n; + this.d = d; +}; + +Rational.prototype.toString = function() { + if (_integerIsOne(this.d)) { + return this.n.toString() + ""; + } else { + return this.n.toString() + "/" + this.d.toString(); + } +}; + +Rational.prototype.level = 1; + +Rational.prototype.liftTo = function(target) { + if (target.level === 2) + return new FloatPoint( + _integerDivideToFixnum(this.n, this.d)); + if (target.level === 3) + return new Complex(this, 0); + return throwRuntimeError("invalid level of Number", this, target); +}; +Rational.prototype.isFinite = function() { + return true; +}; +Rational.prototype.equals = function(other) { + return (other instanceof Rational && + _integerEquals(this.n, other.n) && + _integerEquals(this.d, other.d)); +}; + +Rational.prototype.isInteger = function() { + return _integerIsOne(this.d); +}; +Rational.prototype.isRational = function() { + return true; +}; +Rational.prototype.isReal = function() { + return true; +}; + +Rational.prototype.add = function(other) { + return Rational.makeInstance(_integerAdd(_integerMultiply(this.n, other.d), + _integerMultiply(this.d, other.n)), + _integerMultiply(this.d, other.d)); +}; +Rational.prototype.subtract = function(other) { + return Rational.makeInstance(_integerSubtract(_integerMultiply(this.n, other.d), + _integerMultiply(this.d, other.n)), + _integerMultiply(this.d, other.d)); +}; +Rational.prototype.negate = function() { + return Rational.makeInstance(-this.n, this.d) +}; +Rational.prototype.multiply = function(other) { + return Rational.makeInstance(_integerMultiply(this.n, other.n), + _integerMultiply(this.d, other.d)); +}; +Rational.prototype.divide = function(other) { + if (_integerIsZero(this.d) || _integerIsZero(other.n)) { + throwRuntimeError("/: division by zero", this, other); + } + return Rational.makeInstance(_integerMultiply(this.n, other.d), + _integerMultiply(this.d, other.n)); +}; + +Rational.prototype.toExact = function() { + return this; +}; +Rational.prototype.toInexact = function() { + return FloatPoint.makeInstance(this.toFixnum()); +}; + +Rational.prototype.isExact = function() { + return true; +}; +Rational.prototype.isInexact = function() { + return false; +}; + +Rational.prototype.toFixnum = function() { + return _integerDivideToFixnum(this.n, this.d); +}; +Rational.prototype.numerator = function() { + return this.n; +}; +Rational.prototype.denominator = function() { + return this.d; +}; +Rational.prototype.greaterThan = function(other) { + return _integerGreaterThan(_integerMultiply(this.n, other.d), + _integerMultiply(this.d, other.n)); +}; +Rational.prototype.greaterThanOrEqual = function(other) { + return _integerGreaterThanOrEqual(_integerMultiply(this.n, other.d), + _integerMultiply(this.d, other.n)); +}; +Rational.prototype.lessThan = function(other) { + return _integerLessThan(_integerMultiply(this.n, other.d), + _integerMultiply(this.d, other.n)); +}; +Rational.prototype.lessThanOrEqual = function(other) { + return _integerLessThanOrEqual(_integerMultiply(this.n, other.d), + _integerMultiply(this.d, other.n)); +}; + +Rational.prototype.integerSqrt = function() { + var result = sqrt(this); + if (isRational(result)) { + return toExact(floor(result)); + } else if (isReal(result)) { + return toExact(floor(result)); + } else { + return Complex.makeInstance(toExact(floor(realPart(result))), + toExact(floor(imaginaryPart(result)))); + } +}; + + +Rational.prototype.sqrt = function() { + if (_integerGreaterThanOrEqual(this.n, 0)) { + var newN = sqrt(this.n); + var newD = sqrt(this.d); + if (equals(floor(newN), newN) && + equals(floor(newD), newD)) { + return Rational.makeInstance(newN, newD); + } else { + return FloatPoint.makeInstance(_integerDivideToFixnum(newN, newD)); + } + } else { + var newN = sqrt(negate(this.n)); + var newD = sqrt(this.d); + if (equals(floor(newN), newN) && + equals(floor(newD), newD)) { + return Complex.makeInstance( + 0, + Rational.makeInstance(newN, newD)); + } else { + return Complex.makeInstance( + 0, + FloatPoint.makeInstance(_integerDivideToFixnum(newN, newD))); + } + } +}; + +Rational.prototype.abs = function() { + return Rational.makeInstance(abs(this.n), + this.d); +}; + + +Rational.prototype.floor = function() { + var quotient = _integerQuotient(this.n, this.d); + if (_integerLessThan(this.n, 0)) { + return subtract(quotient, 1); + } else { + return quotient; + } +}; + + +Rational.prototype.ceiling = function() { + var quotient = _integerQuotient(this.n, this.d); + if (_integerLessThan(this.n, 0)) { + return quotient; + } else { + return add(quotient, 1); + } +}; + +Rational.prototype.conjugate = function() { + return this; +}; + +Rational.prototype.magnitude = Rational.prototype.abs; + +Rational.prototype.log = function() { + return FloatPoint.makeInstance(Math.log(this.n / this.d)); +}; + +Rational.prototype.angle = function() { + if (_integerIsZero(this.n)) + return 0; + if (_integerGreaterThan(this.n, 0)) + return 0; + else + return FloatPoint.pi; +}; + +Rational.prototype.tan = function() { + return FloatPoint.makeInstance(Math.tan(_integerDivideToFixnum(this.n, this.d))); +}; + +Rational.prototype.atan = function() { + return FloatPoint.makeInstance(Math.atan(_integerDivideToFixnum(this.n, this.d))); +}; + +Rational.prototype.cos = function() { + return FloatPoint.makeInstance(Math.cos(_integerDivideToFixnum(this.n, this.d))); +}; + +Rational.prototype.sin = function() { + return FloatPoint.makeInstance(Math.sin(_integerDivideToFixnum(this.n, this.d))); +}; + +Rational.prototype.expt = function(a) { + if (isExactInteger(a) && greaterThanOrEqual(a, 0)) { + return fastExpt(this, a); + } + return FloatPoint.makeInstance(Math.pow(_integerDivideToFixnum(this.n, this.d), + _integerDivideToFixnum(a.n, a.d))); +}; + +Rational.prototype.exp = function() { + return FloatPoint.makeInstance(Math.exp(_integerDivideToFixnum(this.n, this.d))); +}; + +Rational.prototype.acos = function() { + return FloatPoint.makeInstance(Math.acos(_integerDivideToFixnum(this.n, this.d))); +}; + +Rational.prototype.asin = function() { + return FloatPoint.makeInstance(Math.asin(_integerDivideToFixnum(this.n, this.d))); +}; + +Rational.prototype.imaginaryPart = function() { + return 0; +}; + +Rational.prototype.realPart = function() { + return this; +}; + + +Rational.prototype.round = function() { + // FIXME: not correct when values are bignums + if (equals(this.d, 2)) { + // Round to even if it's a n/2 + var v = _integerDivideToFixnum(this.n, this.d); + var fl = Math.floor(v); + var ce = Math.ceil(v); + if (_integerIsZero(fl % 2)) { + return fl; + } else { + return ce; + } + } else { + return Math.round(this.n / this.d); + } +}; + + +Rational.makeInstance = function(n, d) { + if (n === undefined) + throwRuntimeError("n undefined", n, d); + + if (d === undefined) { + d = 1; + } + + if (_integerLessThan(d, 0)) { + n = negate(n); + d = negate(d); + } + + var divisor = _integerGcd(abs(n), abs(d)); + n = _integerQuotient(n, divisor); + d = _integerQuotient(d, divisor); + + // Optimization: if we can get around construction the rational + // in favor of just returning n, do it: + if (_integerIsOne(d) || _integerIsZero(n)) { + return n; + } + + return new Rational(n, d); +}; + + + +// Floating Point numbers +var FloatPoint = function(n) { + this.n = n; +}; +FloatPoint = FloatPoint; + + +var NaN = new FloatPoint(Number.NaN); +var inf = new FloatPoint(Number.POSITIVE_INFINITY); +var neginf = new FloatPoint(Number.NEGATIVE_INFINITY); + +// We use these two constants to represent the floating-point coersion +// of bignums that can't be represented with fidelity. +var TOO_POSITIVE_TO_REPRESENT = new FloatPoint(Number.POSITIVE_INFINITY); +var TOO_NEGATIVE_TO_REPRESENT = new FloatPoint(Number.NEGATIVE_INFINITY); + +// Negative zero is a distinguished value representing -0.0. +// There should only be one instance for -0.0. +var NEGATIVE_ZERO = new FloatPoint(-0.0); +var INEXACT_ZERO = new FloatPoint(0.0); + +FloatPoint.pi = new FloatPoint(Math.PI); +FloatPoint.e = new FloatPoint(Math.E); +FloatPoint.nan = NaN; +FloatPoint.inf = inf; +FloatPoint.neginf = neginf; + +FloatPoint.makeInstance = function(n) { + if (isNaN(n)) { + return FloatPoint.nan; + } else if (n === Number.POSITIVE_INFINITY) { + return FloatPoint.inf; + } else if (n === Number.NEGATIVE_INFINITY) { + return FloatPoint.neginf; + } else if (n === 0) { + if ((1 / n) === -Infinity) { + return NEGATIVE_ZERO; + } else { + return INEXACT_ZERO; + } + } + return new FloatPoint(n); +}; + + +FloatPoint.prototype.isExact = function() { + return false; +}; + +FloatPoint.prototype.isInexact = function() { + return true; +}; + + +FloatPoint.prototype.isFinite = function() { + return (isFinite(this.n) || + this === TOO_POSITIVE_TO_REPRESENT || + this === TOO_NEGATIVE_TO_REPRESENT); +}; + + +FloatPoint.prototype.toExact = function() { + // The precision of ieee is about 16 decimal digits, which we use here. + if (!isFinite(this.n) || isNaN(this.n)) { + throwRuntimeError("toExact: no exact representation for " + this, this); + } + + var stringRep = this.n.toString(); + var match = stringRep.match(/^(.*)\.(.*)$/); + if (match) { + var intPart = parseInt(match[1]); + var fracPart = parseInt(match[2]); + var tenToDecimalPlaces = Math.pow(10, match[2].length); + return Rational.makeInstance(Math.round(this.n * tenToDecimalPlaces), + tenToDecimalPlaces); + } else { + return this.n; + } +}; + +FloatPoint.prototype.toInexact = function() { + return this; +}; + +FloatPoint.prototype.isInexact = function() { + return true; +}; + + +FloatPoint.prototype.level = 2; + + +FloatPoint.prototype.liftTo = function(target) { + if (target.level === 3) + return new Complex(this, 0); + return throwRuntimeError("invalid level of Number", this, target); +}; + +FloatPoint.prototype.toString = function() { + if (isNaN(this.n)) + return "+nan.0"; + if (this.n === Number.POSITIVE_INFINITY) + return "+inf.0"; + if (this.n === Number.NEGATIVE_INFINITY) + return "-inf.0"; + if (this === NEGATIVE_ZERO) + return "-0.0"; + var partialResult = this.n.toString(); + if (!partialResult.match('\\.')) { + return partialResult + ".0"; + } else { + return partialResult; + } +}; + + +FloatPoint.prototype.equals = function(other, aUnionFind) { + return ((other instanceof FloatPoint) && + ((this.n === other.n))); +}; + + + +FloatPoint.prototype.isRational = function() { + return this.isFinite(); +}; + +FloatPoint.prototype.isInteger = function() { + return this.isFinite() && this.n === Math.floor(this.n); +}; + +FloatPoint.prototype.isReal = function() { + return true; +}; + + +// sign: Number -> {-1, 0, 1} +var sign = function(n) { + if (lessThan(n, 0)) { + return -1; + } else if (greaterThan(n, 0)) { + return 1; + } else if (n === NEGATIVE_ZERO) { + return -1; + } else { + return 0; + } +}; + + +FloatPoint.prototype.add = function(other) { + if (this.isFinite() && other.isFinite()) { + return FloatPoint.makeInstance(this.n + other.n); + } else { + if (isNaN(this.n) || isNaN(other.n)) { + return NaN; + } else if (this.isFinite() && !other.isFinite()) { + return other; + } else if (!this.isFinite() && other.isFinite()) { + return this; + } else { + return ((sign(this) * sign(other) === 1) ? + this : NaN); + }; + } +}; + +FloatPoint.prototype.subtract = function(other) { + if (this.isFinite() && other.isFinite()) { + return FloatPoint.makeInstance(this.n - other.n); + } else if (isNaN(this.n) || isNaN(other.n)) { + return NaN; + } else if (!this.isFinite() && !other.isFinite()) { + if (sign(this) === sign(other)) { + return NaN; + } else { + return this; + } + } else if (this.isFinite()) { + return multiply(other, -1); + } else { // other.isFinite() + return this; + } +}; + + +FloatPoint.prototype.negate = function() { + return FloatPoint.makeInstance(-this.n); +}; + +FloatPoint.prototype.multiply = function(other) { + return FloatPoint.makeInstance(this.n * other.n); +}; + +FloatPoint.prototype.divide = function(other) { + return FloatPoint.makeInstance(this.n / other.n); +}; + + +FloatPoint.prototype.toFixnum = function() { + return this.n; +}; + +FloatPoint.prototype.numerator = function() { + var stringRep = this.n.toString(); + var match = stringRep.match(/^(.*)\.(.*)$/); + if (match) { + var afterDecimal = parseInt(match[2]); + var factorToInt = Math.pow(10, match[2].length); + var extraFactor = _integerGcd(factorToInt, afterDecimal); + var multFactor = factorToInt / extraFactor; + return FloatPoint.makeInstance(Math.round(this.n * multFactor)); + } else { + return this; + } +}; + +FloatPoint.prototype.denominator = function() { + var stringRep = this.n.toString(); + var match = stringRep.match(/^(.*)\.(.*)$/); + if (match) { + var afterDecimal = parseInt(match[2]); + var factorToInt = Math.pow(10, match[2].length); + var extraFactor = _integerGcd(factorToInt, afterDecimal); + return FloatPoint.makeInstance(Math.round(factorToInt / extraFactor)); + } else { + return FloatPoint.makeInstance(1); + } +}; + + +FloatPoint.prototype.floor = function() { + return FloatPoint.makeInstance(Math.floor(this.n)); +}; + +FloatPoint.prototype.ceiling = function() { + return FloatPoint.makeInstance(Math.ceil(this.n)); +}; + + +FloatPoint.prototype.greaterThan = function(other) { + return this.n > other.n; +}; + +FloatPoint.prototype.greaterThanOrEqual = function(other) { + return this.n >= other.n; +}; + +FloatPoint.prototype.lessThan = function(other) { + return this.n < other.n; +}; + +FloatPoint.prototype.lessThanOrEqual = function(other) { + return this.n <= other.n; +}; + + +FloatPoint.prototype.integerSqrt = function() { + if (this === NEGATIVE_ZERO) { + return this; + } + if (isInteger(this)) { + if (this.n >= 0) { + return FloatPoint.makeInstance(Math.floor(Math.sqrt(this.n))); + } else { + return Complex.makeInstance( + INEXACT_ZERO, + FloatPoint.makeInstance(Math.floor(Math.sqrt(-this.n)))); + } + } else { + throwRuntimeError("integerSqrt: can only be applied to an integer", this); + } +}; + +FloatPoint.prototype.sqrt = function() { + if (this.n < 0) { + var result = Complex.makeInstance( + 0, + FloatPoint.makeInstance(Math.sqrt(-this.n))); + return result; + } else { + return FloatPoint.makeInstance(Math.sqrt(this.n)); + } +}; + +FloatPoint.prototype.abs = function() { + return FloatPoint.makeInstance(Math.abs(this.n)); +}; + + + +FloatPoint.prototype.log = function() { + if (this.n < 0) + return (new Complex(this, 0)).log(); + else + return FloatPoint.makeInstance(Math.log(this.n)); +}; + +FloatPoint.prototype.angle = function() { + if (0 === this.n) + return 0; + if (this.n > 0) + return 0; + else + return FloatPoint.pi; +}; + +FloatPoint.prototype.tan = function() { + return FloatPoint.makeInstance(Math.tan(this.n)); +}; + +FloatPoint.prototype.atan = function() { + return FloatPoint.makeInstance(Math.atan(this.n)); +}; + +FloatPoint.prototype.cos = function() { + return FloatPoint.makeInstance(Math.cos(this.n)); +}; + +FloatPoint.prototype.sin = function() { + return FloatPoint.makeInstance(Math.sin(this.n)); +}; + +FloatPoint.prototype.expt = function(a) { + if (this.n === 1) { + if (a.isFinite()) { + return this; + } else if (isNaN(a.n)) { + return this; + } else { + return this; + } + } else { + return FloatPoint.makeInstance(Math.pow(this.n, a.n)); + } +}; + +FloatPoint.prototype.exp = function() { + return FloatPoint.makeInstance(Math.exp(this.n)); +}; + +FloatPoint.prototype.acos = function() { + return FloatPoint.makeInstance(Math.acos(this.n)); +}; + +FloatPoint.prototype.asin = function() { + return FloatPoint.makeInstance(Math.asin(this.n)); +}; + +FloatPoint.prototype.imaginaryPart = function() { + return 0; +}; + +FloatPoint.prototype.realPart = function() { + return this; +}; + + +FloatPoint.prototype.round = function() { + if (isFinite(this.n)) { + if (this === NEGATIVE_ZERO) { + return this; + } + if (Math.abs(Math.floor(this.n) - this.n) === 0.5) { + if (Math.floor(this.n) % 2 === 0) + return FloatPoint.makeInstance(Math.floor(this.n)); + return FloatPoint.makeInstance(Math.ceil(this.n)); + } else { + return FloatPoint.makeInstance(Math.round(this.n)); + } + } else { + return this; + } +}; + + +FloatPoint.prototype.conjugate = function() { + return this; +}; + +FloatPoint.prototype.magnitude = FloatPoint.prototype.abs; + + + +////////////////////////////////////////////////////////////////////// +// Complex numbers +////////////////////////////////////////////////////////////////////// + +var Complex = function(r, i) { + this.r = r; + this.i = i; +}; + +// Constructs a complex number from two basic number r and i. r and i can +// either be plt.type.Rational or plt.type.FloatPoint. +Complex.makeInstance = function(r, i) { + if (i === undefined) { + i = 0; + } + if (isExact(i) && isInteger(i) && _integerIsZero(i)) { + return r; + } + if (isInexact(r) || isInexact(i)) { + r = toInexact(r); + i = toInexact(i); + } + return new Complex(r, i); +}; + +Complex.prototype.toString = function() { + var realPart = this.r.toString(), + imagPart = this.i.toString(); + if (imagPart[0] === '-' || imagPart[0] === '+') { + return realPart + imagPart + 'i'; + } else { + return realPart + "+" + imagPart + 'i'; + } +}; + + +Complex.prototype.isFinite = function() { + return isSchemeNumberFinite(this.r) && isSchemeNumberFinite(this.i); +}; + + +Complex.prototype.isRational = function() { + return isRational(this.r) && eqv(this.i, 0); +}; + +Complex.prototype.isInteger = function() { + return (isInteger(this.r) && + eqv(this.i, 0)); +}; + +Complex.prototype.toExact = function() { + return Complex.makeInstance(toExact(this.r), toExact(this.i)); +}; + +Complex.prototype.toInexact = function() { + return Complex.makeInstance(toInexact(this.r), + toInexact(this.i)); +}; + + +Complex.prototype.isExact = function() { + return isExact(this.r) && isExact(this.i); +}; + + +Complex.prototype.isInexact = function() { + return isInexact(this.r) || isInexact(this.i); +}; + + +Complex.prototype.level = 3; + + +Complex.prototype.liftTo = function(target) { + throwRuntimeError("Don't know how to lift Complex number", this, target); +}; + +Complex.prototype.equals = function(other) { + var result = ((other instanceof Complex) && + (equals(this.r, other.r)) && + (equals(this.i, other.i))); + return result; +}; + + + +Complex.prototype.greaterThan = function(other) { + if (!this.isReal() || !other.isReal()) { + throwRuntimeError(">: expects argument of type real number", this, other); + } + return greaterThan(this.r, other.r); +}; + +Complex.prototype.greaterThanOrEqual = function(other) { + if (!this.isReal() || !other.isReal()) { + throwRuntimeError(">=: expects argument of type real number", this, other); + } + return greaterThanOrEqual(this.r, other.r); +}; + +Complex.prototype.lessThan = function(other) { + if (!this.isReal() || !other.isReal()) { + throwRuntimeError("<: expects argument of type real number", this, other); + } + return lessThan(this.r, other.r); +}; + +Complex.prototype.lessThanOrEqual = function(other) { + if (!this.isReal() || !other.isReal()) { + throwRuntimeError("<=: expects argument of type real number", this, other); + } + return lessThanOrEqual(this.r, other.r); +}; + + +Complex.prototype.abs = function() { + if (!equals(this.i, 0).valueOf()) + throwRuntimeError("abs: expects argument of type real number", this); + return abs(this.r); +}; + +Complex.prototype.toFixnum = function() { + if (!equals(this.i, 0).valueOf()) + throwRuntimeError("toFixnum: expects argument of type real number", this); + return toFixnum(this.r); +}; + +Complex.prototype.numerator = function() { + if (!this.isReal()) + throwRuntimeError("numerator: can only be applied to real number", this); + return numerator(this.n); +}; + + +Complex.prototype.denominator = function() { + if (!this.isReal()) + throwRuntimeError("floor: can only be applied to real number", this); + return denominator(this.n); +}; + +Complex.prototype.add = function(other) { + return Complex.makeInstance( + add(this.r, other.r), + add(this.i, other.i)); +}; + +Complex.prototype.subtract = function(other) { + return Complex.makeInstance( + subtract(this.r, other.r), + subtract(this.i, other.i)); +}; + +Complex.prototype.negate = function() { + return Complex.makeInstance(negate(this.r), + negate(this.i)); +}; + + +Complex.prototype.multiply = function(other) { + // If the other value is real, just do primitive division + if (other.isReal()) { + return Complex.makeInstance( + multiply(this.r, other.r), + multiply(this.i, other.r)); + } + var r = subtract( + multiply(this.r, other.r), + multiply(this.i, other.i)); + var i = add( + multiply(this.r, other.i), + multiply(this.i, other.r)); + return Complex.makeInstance(r, i); +}; + + + + + +Complex.prototype.divide = function(other) { + var a, b, c, d, r, x, y; + // If the other value is real, just do primitive division + if (other.isReal()) { + return Complex.makeInstance( + divide(this.r, other.r), + divide(this.i, other.r)); + } + + if (this.isInexact() || other.isInexact()) { + // http://portal.acm.org/citation.cfm?id=1039814 + // We currently use Smith's method, though we should + // probably switch over to Priest's method. + a = this.r; + b = this.i; + c = other.r; + d = other.i; + if (lessThanOrEqual(abs(d), abs(c))) { + r = divide(d, c); + x = divide(add(a, multiply(b, r)), + add(c, multiply(d, r))); + y = divide(subtract(b, multiply(a, r)), + add(c, multiply(d, r))); + } else { + r = divide(c, d); + x = divide(add(multiply(a, r), b), + add(multiply(c, r), d)); + y = divide(subtract(multiply(b, r), a), + add(multiply(c, r), d)); + } + return Complex.makeInstance(x, y); + } else { + var con = conjugate(other); + var up = multiply(this, con); + + // Down is guaranteed to be real by this point. + var down = realPart(multiply(other, con)); + + var result = Complex.makeInstance( + divide(realPart(up), down), + divide(imaginaryPart(up), down)); + return result; + } +}; + +Complex.prototype.conjugate = function() { + var result = Complex.makeInstance( + this.r, + subtract(0, this.i)); + + return result; +}; + +Complex.prototype.magnitude = function() { + var sum = add( + multiply(this.r, this.r), + multiply(this.i, this.i)); + return sqrt(sum); +}; + +Complex.prototype.isReal = function() { + return eqv(this.i, 0); +}; + +Complex.prototype.integerSqrt = function() { + if (isInteger(this)) { + return integerSqrt(this.r); + } else { + throwRuntimeError("integerSqrt: can only be applied to an integer", this); + } +}; + +Complex.prototype.sqrt = function() { + if (this.isReal()) + return sqrt(this.r); + // http://en.wikipedia.org/wiki/Square_root#Square_roots_of_negative_and_complex_numbers + var r_plus_x = add(this.magnitude(), this.r); + + var r = sqrt(halve(r_plus_x)); + + var i = divide(this.i, sqrt(multiply(r_plus_x, 2))); + + + return Complex.makeInstance(r, i); +}; + +Complex.prototype.log = function() { + var m = this.magnitude(); + var theta = this.angle(); + var result = add( + log(m), + timesI(theta)); + return result; +}; + +Complex.prototype.angle = function() { + if (this.isReal()) { + return angle(this.r); + } + if (equals(0, this.r)) { + var tmp = halve(FloatPoint.pi); + return greaterThan(this.i, 0) ? + tmp : negate(tmp); + } else { + var tmp = atan(divide(abs(this.i), abs(this.r))); + if (greaterThan(this.r, 0)) { + return greaterThan(this.i, 0) ? + tmp : negate(tmp); + } else { + return greaterThan(this.i, 0) ? + subtract(FloatPoint.pi, tmp) : subtract(tmp, FloatPoint.pi); + } + } +}; + +var plusI = Complex.makeInstance(0, 1); +var minusI = Complex.makeInstance(0, -1); + + +Complex.prototype.tan = function() { + return divide(this.sin(), this.cos()); +}; + +Complex.prototype.atan = function() { + if (equals(this, plusI) || + equals(this, minusI)) { + return neginf; + } + return multiply( + plusI, + multiply( + FloatPoint.makeInstance(0.5), + log(divide( + add(plusI, this), + add( + plusI, + subtract(0, this)))))); +}; + +Complex.prototype.cos = function() { + if (this.isReal()) + return cos(this.r); + var iz = timesI(this); + var iz_negate = negate(iz); + + return halve(add(exp(iz), exp(iz_negate))); +}; + +Complex.prototype.sin = function() { + if (this.isReal()) + return sin(this.r); + var iz = timesI(this); + var iz_negate = negate(iz); + var z2 = Complex.makeInstance(0, 2); + var exp_negate = subtract(exp(iz), exp(iz_negate)); + var result = divide(exp_negate, z2); + return result; +}; + + +Complex.prototype.expt = function(y) { + if (isExactInteger(y) && greaterThanOrEqual(y, 0)) { + return fastExpt(this, y); + } + var expo = multiply(y, this.log()); + return exp(expo); +}; + +Complex.prototype.exp = function() { + var r = exp(this.r); + var cos_a = cos(this.i); + var sin_a = sin(this.i); + + return multiply( + r, + add(cos_a, timesI(sin_a))); +}; + +Complex.prototype.acos = function() { + if (this.isReal()) + return acos(this.r); + var pi_half = halve(FloatPoint.pi); + var iz = timesI(this); + var root = sqrt(subtract(1, sqr(this))); + var l = timesI(log(add(iz, root))); + return add(pi_half, l); +}; + +Complex.prototype.asin = function() { + if (this.isReal()) + return asin(this.r); + + var oneNegateThisSq = + subtract(1, sqr(this)); + var sqrtOneNegateThisSq = sqrt(oneNegateThisSq); + return multiply(2, atan(divide(this, + add(1, sqrtOneNegateThisSq)))); +}; + +Complex.prototype.ceiling = function() { + if (!this.isReal()) + throwRuntimeError("ceiling: can only be applied to real number", this); + return ceiling(this.r); +}; + +Complex.prototype.floor = function() { + if (!this.isReal()) + throwRuntimeError("floor: can only be applied to real number", this); + return floor(this.r); +}; + +Complex.prototype.imaginaryPart = function() { + return this.i; +}; + +Complex.prototype.realPart = function() { + return this.r; +}; + +Complex.prototype.round = function() { + if (!this.isReal()) + throwRuntimeError("round: can only be applied to real number", this); + return round(this.r); +}; + + + +var rationalRegexp = new RegExp("^([+-]?\\d+)/(\\d+)$"); +var complexRegexp = new RegExp("^([+-]?[\\d\\w/\\.]*)([+-])([\\d\\w/\\.]*)i$"); +var digitRegexp = new RegExp("^[+-]?\\d+$"); +var flonumRegexp = new RegExp("^([+-]?\\d*)\\.(\\d*)$"); +var scientificPattern = new RegExp("^([+-]?\\d*\\.?\\d*)[Ee](\\+?\\d+)$"); + +// fromString: string -> (scheme-number | false) +var fromString = function(x) { + x = x.toString(); // TODO: This can be done better. + + var aMatch = x.match(rationalRegexp); + if (aMatch) { + return Rational.makeInstance(fromString(aMatch[1]), + fromString(aMatch[2])); + } + + var cMatch = x.match(complexRegexp); + if (cMatch) { + return Complex.makeInstance(fromString(cMatch[1] || "0"), + fromString(cMatch[2] + (cMatch[3] || "1"))); + } + + // Floating point tests + if (x === '+nan.0' || x === '-nan.0') + return FloatPoint.nan; + if (x === '+inf.0') + return FloatPoint.inf; + if (x === '-inf.0') + return FloatPoint.neginf; + if (x === "-0.0") { + return NEGATIVE_ZERO; + } + if (x.match(flonumRegexp) || x.match(scientificPattern)) { + return FloatPoint.makeInstance(Number(x)); + } + + // Finally, integer tests. + if (x.match(digitRegexp)) { + var n = Number(x); + if (isOverflow(n)) { + return makeBignum(x); + } else { + return n; + } + } else { + return false; + } +}; + + + + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// + +// The code below comes from Tom Wu's BigInteger implementation: + +// Copyright (c) 2005 Tom Wu +// All Rights Reserved. +// See "LICENSE" for details. + +// Basic JavaScript BN library - subset useful for RSA encryption. + +// Bits per digit +var dbits; + +// JavaScript engine analysis +var canary = 0xdeadbeefcafe; +var j_lm = ((canary & 0xffffff) == 0xefcafe); + +// (public) Constructor +function BigInteger(a, b, c) { + if (a != null) + if ("number" == typeof a) this.fromNumber(a, b, c); + else if (b == null && "string" != typeof a) this.fromString(a, 256); + else this.fromString(a, b); +} + +// return new, unset BigInteger +function nbi() { + return new BigInteger(null); +} + +// am: Compute w_j += (x*this_i), propagate carries, +// c is initial carry, returns final carry. +// c < 3*dvalue, x < 2*dvalue, this_i < dvalue +// We need to select the fastest one that works in this environment. + +// am1: use a single mult and divide to get the high bits, +// max digit bits should be 26 because +// max internal value = 2*dvalue^2-2*dvalue (< 2^53) +function am1(i, x, w, j, c, n) { + while (--n >= 0) { + var v = x * this[i++] + w[j] + c; + c = Math.floor(v / 0x4000000); + w[j++] = v & 0x3ffffff; + } + return c; +} +// am2 avoids a big mult-and-extract completely. +// Max digit bits should be <= 30 because we do bitwise ops +// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) +function am2(i, x, w, j, c, n) { + var xl = x & 0x7fff, + xh = x >> 15; + while (--n >= 0) { + var l = this[i] & 0x7fff; + var h = this[i++] >> 15; + var m = xh * l + h * xl; + l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff); + c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30); + w[j++] = l & 0x3fffffff; + } + return c; +} +// Alternately, set max digit bits to 28 since some +// browsers slow down when dealing with 32-bit numbers. +function am3(i, x, w, j, c, n) { + var xl = x & 0x3fff, + xh = x >> 14; + while (--n >= 0) { + var l = this[i] & 0x3fff; + var h = this[i++] >> 14; + var m = xh * l + h * xl; + l = xl * l + ((m & 0x3fff) << 14) + w[j] + c; + c = (l >> 28) + (m >> 14) + xh * h; + w[j++] = l & 0xfffffff; + } + return c; +} +if (j_lm && (typeof(navigator) !== 'undefined' && navigator.appName == "Microsoft Internet Explorer")) { + BigInteger.prototype.am = am2; + dbits = 30; +} else if (j_lm && (typeof(navigator) !== 'undefined' && navigator.appName != "Netscape")) { + BigInteger.prototype.am = am1; + dbits = 26; +} else { // Mozilla/Netscape seems to prefer am3 + BigInteger.prototype.am = am3; + dbits = 28; +} + +BigInteger.prototype.DB = dbits; +BigInteger.prototype.DM = ((1 << dbits) - 1); +BigInteger.prototype.DV = (1 << dbits); + +var BI_FP = 52; +BigInteger.prototype.FV = Math.pow(2, BI_FP); +BigInteger.prototype.F1 = BI_FP - dbits; +BigInteger.prototype.F2 = 2 * dbits - BI_FP; + +// Digit conversions +var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz"; +var BI_RC = []; +var rr, vv; +rr = "0".charCodeAt(0); +for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv; +rr = "a".charCodeAt(0); +for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; +rr = "A".charCodeAt(0); +for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; + +function int2char(n) { + return BI_RM.charAt(n); +} + +function intAt(s, i) { + var c = BI_RC[s.charCodeAt(i)]; + return (c == null) ? -1 : c; +} + +// (protected) copy this to r +function bnpCopyTo(r) { + for (var i = this.t - 1; i >= 0; --i) r[i] = this[i]; + r.t = this.t; + r.s = this.s; +} + +// (protected) set from integer value x, -DV <= x < DV +function bnpFromInt(x) { + this.t = 1; + this.s = (x < 0) ? -1 : 0; + if (x > 0) this[0] = x; + else if (x < -1) this[0] = x + DV; + else this.t = 0; +} + +// return bigint initialized to value +function nbv(i) { + var r = nbi(); + r.fromInt(i); + return r; +} + +// (protected) set from string and radix +function bnpFromString(s, b) { + var k; + if (b == 16) k = 4; + else if (b == 8) k = 3; + else if (b == 256) k = 8; // byte array + else if (b == 2) k = 1; + else if (b == 32) k = 5; + else if (b == 4) k = 2; + else { + this.fromRadix(s, b); + return; + } + this.t = 0; + this.s = 0; + var i = s.length, + mi = false, + sh = 0; + while (--i >= 0) { + var x = (k == 8) ? s[i] & 0xff : intAt(s, i); + if (x < 0) { + if (s.charAt(i) == "-") mi = true; + continue; + } + mi = false; + if (sh == 0) + this[this.t++] = x; + else if (sh + k > this.DB) { + this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh; + this[this.t++] = (x >> (this.DB - sh)); + } else + this[this.t - 1] |= x << sh; + sh += k; + if (sh >= this.DB) sh -= this.DB; + } + if (k == 8 && (s[0] & 0x80) != 0) { + this.s = -1; + if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh; + } + this.clamp(); + if (mi) BigInteger.ZERO.subTo(this, this); +} + +// (protected) clamp off excess high words +function bnpClamp() { + var c = this.s & this.DM; + while (this.t > 0 && this[this.t - 1] == c) --this.t; +} + +// (public) return string representation in given radix +function bnToString(b) { + if (this.s < 0) return "-" + this.negate().toString(b); + var k; + if (b == 16) k = 4; + else if (b == 8) k = 3; + else if (b == 2) k = 1; + else if (b == 32) k = 5; + else if (b == 4) k = 2; + else return this.toRadix(b); + var km = (1 << k) - 1, + d, m = false, + r = [], + i = this.t; + var p = this.DB - (i * this.DB) % k; + if (i-- > 0) { + if (p < this.DB && (d = this[i] >> p) > 0) { + m = true; + r.push(int2char(d)); + } + while (i >= 0) { + if (p < k) { + d = (this[i] & ((1 << p) - 1)) << (k - p); + d |= this[--i] >> (p += this.DB - k); + } else { + d = (this[i] >> (p -= k)) & km; + if (p <= 0) { + p += this.DB; + --i; + } + } + if (d > 0) m = true; + if (m) r.push(int2char(d)); + } + } + return m ? r.join("") : "0"; +} + +// (public) -this +function bnNegate() { + var r = nbi(); + BigInteger.ZERO.subTo(this, r); + return r; +} + +// (public) |this| +function bnAbs() { + return (this.s < 0) ? this.negate() : this; +} + +// (public) return + if this > a, - if this < a, 0 if equal +function bnCompareTo(a) { + var r = this.s - a.s; + if (r != 0) return r; + var i = this.t; + if (this.s < 0) { + r = a.t - i; + } else { + r = i - a.t; + } + if (r != 0) return r; + while (--i >= 0) + if ((r = this[i] - a[i]) != 0) return r; + return 0; +} + +// returns bit length of the integer x +function nbits(x) { + var r = 1, + t; + if ((t = x >>> 16) != 0) { + x = t; + r += 16; + } + if ((t = x >> 8) != 0) { + x = t; + r += 8; + } + if ((t = x >> 4) != 0) { + x = t; + r += 4; + } + if ((t = x >> 2) != 0) { + x = t; + r += 2; + } + if ((t = x >> 1) != 0) { + x = t; + r += 1; + } + return r; +} + +// (public) return the number of bits in "this" +function bnBitLength() { + if (this.t <= 0) return 0; + return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM)); +} + +// (protected) r = this << n*DB +function bnpDLShiftTo(n, r) { + var i; + for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i]; + for (i = n - 1; i >= 0; --i) r[i] = 0; + r.t = this.t + n; + r.s = this.s; +} + +// (protected) r = this >> n*DB +function bnpDRShiftTo(n, r) { + for (var i = n; i < this.t; ++i) r[i - n] = this[i]; + r.t = Math.max(this.t - n, 0); + r.s = this.s; +} + +// (protected) r = this << n +function bnpLShiftTo(n, r) { + var bs = n % this.DB; + var cbs = this.DB - bs; + var bm = (1 << cbs) - 1; + var ds = Math.floor(n / this.DB), + c = (this.s << bs) & this.DM, + i; + for (i = this.t - 1; i >= 0; --i) { + r[i + ds + 1] = (this[i] >> cbs) | c; + c = (this[i] & bm) << bs; + } + for (i = ds - 1; i >= 0; --i) r[i] = 0; + r[ds] = c; + r.t = this.t + ds + 1; + r.s = this.s; + r.clamp(); +} + +// (protected) r = this >> n +function bnpRShiftTo(n, r) { + r.s = this.s; + var ds = Math.floor(n / this.DB); + if (ds >= this.t) { + r.t = 0; + return; + } + var bs = n % this.DB; + var cbs = this.DB - bs; + var bm = (1 << bs) - 1; + r[0] = this[ds] >> bs; + for (var i = ds + 1; i < this.t; ++i) { + r[i - ds - 1] |= (this[i] & bm) << cbs; + r[i - ds] = this[i] >> bs; + } + if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs; + r.t = this.t - ds; + r.clamp(); +} + +// (protected) r = this - a +function bnpSubTo(a, r) { + var i = 0, + c = 0, + m = Math.min(a.t, this.t); + while (i < m) { + c += this[i] - a[i]; + r[i++] = c & this.DM; + c >>= this.DB; + } + if (a.t < this.t) { + c -= a.s; + while (i < this.t) { + c += this[i]; + r[i++] = c & this.DM; + c >>= this.DB; + } + c += this.s; + } else { + c += this.s; + while (i < a.t) { + c -= a[i]; + r[i++] = c & this.DM; + c >>= this.DB; + } + c -= a.s; + } + r.s = (c < 0) ? -1 : 0; + if (c < -1) r[i++] = this.DV + c; + else if (c > 0) r[i++] = c; + r.t = i; + r.clamp(); +} + +// (protected) r = this * a, r != this,a (HAC 14.12) +// "this" should be the larger one if appropriate. +function bnpMultiplyTo(a, r) { + var x = this.abs(), + y = a.abs(); + var i = x.t; + r.t = i + y.t; + while (--i >= 0) r[i] = 0; + for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t); + r.s = 0; + r.clamp(); + if (this.s != a.s) BigInteger.ZERO.subTo(r, r); +} + +// (protected) r = this^2, r != this (HAC 14.16) +function bnpSquareTo(r) { + var x = this.abs(); + var i = r.t = 2 * x.t; + while (--i >= 0) r[i] = 0; + for (i = 0; i < x.t - 1; ++i) { + var c = x.am(i, x[i], r, 2 * i, 0, 1); + if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) { + r[i + x.t] -= x.DV; + r[i + x.t + 1] = 1; + } + } + if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1); + r.s = 0; + r.clamp(); +} + + +// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) +// r != q, this != m. q or r may be null. +function bnpDivRemTo(m, q, r) { + var pm = m.abs(); + if (pm.t <= 0) return; + var pt = this.abs(); + if (pt.t < pm.t) { + if (q != null) q.fromInt(0); + if (r != null) this.copyTo(r); + return; + } + if (r == null) r = nbi(); + var y = nbi(), + ts = this.s, + ms = m.s; + var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus + if (nsh > 0) { + pm.lShiftTo(nsh, y); + pt.lShiftTo(nsh, r); + } else { + pm.copyTo(y); + pt.copyTo(r); + } + var ys = y.t; + var y0 = y[ys - 1]; + if (y0 == 0) return; + var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0); + var d1 = this.FV / yt, + d2 = (1 << this.F1) / yt, + e = 1 << this.F2; + var i = r.t, + j = i - ys, + t = (q == null) ? nbi() : q; + y.dlShiftTo(j, t); + if (r.compareTo(t) >= 0) { + r[r.t++] = 1; + r.subTo(t, r); + } + BigInteger.ONE.dlShiftTo(ys, t); + t.subTo(y, y); // "negative" y so we can replace sub with am later + while (y.t < ys) y[y.t++] = 0; + while (--j >= 0) { + // Estimate quotient digit + var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2); + if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out + y.dlShiftTo(j, t); + r.subTo(t, r); + while (r[i] < --qd) r.subTo(t, r); + } + } + if (q != null) { + r.drShiftTo(ys, q); + if (ts != ms) BigInteger.ZERO.subTo(q, q); + } + r.t = ys; + r.clamp(); + if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder + if (ts < 0) BigInteger.ZERO.subTo(r, r); +} + +// (public) this mod a +function bnMod(a) { + var r = nbi(); + this.abs().divRemTo(a, null, r); + if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r); + return r; +} + +// Modular reduction using "classic" algorithm +function Classic(m) { + this.m = m; +} + +function cConvert(x) { + if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); + else return x; +} + +function cRevert(x) { + return x; +} + +function cReduce(x) { + x.divRemTo(this.m, null, x); +} + +function cMulTo(x, y, r) { + x.multiplyTo(y, r); + this.reduce(r); +} + +function cSqrTo(x, r) { + x.squareTo(r); + this.reduce(r); +} + +Classic.prototype.convert = cConvert; +Classic.prototype.revert = cRevert; +Classic.prototype.reduce = cReduce; +Classic.prototype.mulTo = cMulTo; +Classic.prototype.sqrTo = cSqrTo; + +// (protected) return "-1/this % 2^DB"; useful for Mont. reduction +// justification: +// xy == 1 (mod m) +// xy = 1+km +// xy(2-xy) = (1+km)(1-km) +// x[y(2-xy)] = 1-k^2m^2 +// x[y(2-xy)] == 1 (mod m^2) +// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 +// should reduce x and y(2-xy) by m^2 at each step to keep size bounded. +// JS multiply "overflows" differently from C/C++, so care is needed here. +function bnpInvDigit() { + if (this.t < 1) return 0; + var x = this[0]; + if ((x & 1) == 0) return 0; + var y = x & 3; // y == 1/x mod 2^2 + y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4 + y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8 + y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16 + // last step - calculate inverse mod DV directly; + // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints + y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits + // we really want the negative inverse, and -DV < y < DV + return (y > 0) ? this.DV - y : -y; +} + +// Montgomery reduction +function Montgomery(m) { + this.m = m; + this.mp = m.invDigit(); + this.mpl = this.mp & 0x7fff; + this.mph = this.mp >> 15; + this.um = (1 << (m.DB - 15)) - 1; + this.mt2 = 2 * m.t; +} + +// xR mod m +function montConvert(x) { + var r = nbi(); + x.abs().dlShiftTo(this.m.t, r); + r.divRemTo(this.m, null, r); + if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r); + return r; +} + +// x/R mod m +function montRevert(x) { + var r = nbi(); + x.copyTo(r); + this.reduce(r); + return r; +} + +// x = x/R mod m (HAC 14.32) +function montReduce(x) { + while (x.t <= this.mt2) // pad x so am has enough room later + x[x.t++] = 0; + for (var i = 0; i < this.m.t; ++i) { + // faster way of calculating u0 = x[i]*mp mod DV + var j = x[i] & 0x7fff; + var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM; + // use am to combine the multiply-shift-add into one call + j = i + this.m.t; + x[j] += this.m.am(0, u0, x, i, 0, this.m.t); + // propagate carry + while (x[j] >= x.DV) { + x[j] -= x.DV; + x[++j]++; + } + } + x.clamp(); + x.drShiftTo(this.m.t, x); + if (x.compareTo(this.m) >= 0) x.subTo(this.m, x); +} + +// r = "x^2/R mod m"; x != r +function montSqrTo(x, r) { + x.squareTo(r); + this.reduce(r); +} + +// r = "xy/R mod m"; x,y != r +function montMulTo(x, y, r) { + x.multiplyTo(y, r); + this.reduce(r); +} + +Montgomery.prototype.convert = montConvert; +Montgomery.prototype.revert = montRevert; +Montgomery.prototype.reduce = montReduce; +Montgomery.prototype.mulTo = montMulTo; +Montgomery.prototype.sqrTo = montSqrTo; + +// (protected) true iff this is even +function bnpIsEven() { + return ((this.t > 0) ? (this[0] & 1) : this.s) == 0; +} + +// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) +function bnpExp(e, z) { + if (e > 0xffffffff || e < 1) return BigInteger.ONE; + var r = nbi(), + r2 = nbi(), + g = z.convert(this), + i = nbits(e) - 1; + g.copyTo(r); + while (--i >= 0) { + z.sqrTo(r, r2); + if ((e & (1 << i)) > 0) z.mulTo(r2, g, r); + else { + var t = r; + r = r2; + r2 = t; + } + } + return z.revert(r); +} + +// (public) this^e % m, 0 <= e < 2^32 +function bnModPowInt(e, m) { + var z; + if (e < 256 || m.isEven()) z = new Classic(m); + else z = new Montgomery(m); + return this.exp(e, z); +} + +// protected +BigInteger.prototype.copyTo = bnpCopyTo; +BigInteger.prototype.fromInt = bnpFromInt; +BigInteger.prototype.fromString = bnpFromString; +BigInteger.prototype.clamp = bnpClamp; +BigInteger.prototype.dlShiftTo = bnpDLShiftTo; +BigInteger.prototype.drShiftTo = bnpDRShiftTo; +BigInteger.prototype.lShiftTo = bnpLShiftTo; +BigInteger.prototype.rShiftTo = bnpRShiftTo; +BigInteger.prototype.subTo = bnpSubTo; +BigInteger.prototype.multiplyTo = bnpMultiplyTo; +BigInteger.prototype.squareTo = bnpSquareTo; +BigInteger.prototype.divRemTo = bnpDivRemTo; +BigInteger.prototype.invDigit = bnpInvDigit; +BigInteger.prototype.isEven = bnpIsEven; +BigInteger.prototype.exp = bnpExp; + +// public +BigInteger.prototype.toString = bnToString; +BigInteger.prototype.negate = bnNegate; +BigInteger.prototype.abs = bnAbs; +BigInteger.prototype.compareTo = bnCompareTo; +BigInteger.prototype.bitLength = bnBitLength; +BigInteger.prototype.mod = bnMod; +BigInteger.prototype.modPowInt = bnModPowInt; + +// "constants" +BigInteger.ZERO = nbv(0); +BigInteger.ONE = nbv(1); + +// Copyright (c) 2005-2009 Tom Wu +// All Rights Reserved. +// See "LICENSE" for details. + +// Extended JavaScript BN functions, required for RSA private ops. + +// Version 1.1: new BigInteger("0", 10) returns "proper" zero + +// (public) +function bnClone() { + var r = nbi(); + this.copyTo(r); + return r; +} + +// (public) return value as integer +function bnIntValue() { + if (this.s < 0) { + if (this.t == 1) return this[0] - this.DV; + else if (this.t == 0) return -1; + } else if (this.t == 1) return this[0]; + else if (this.t == 0) return 0; + // assumes 16 < DB < 32 + return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0]; +} + +// (public) return value as byte +function bnByteValue() { + return (this.t == 0) ? this.s : (this[0] << 24) >> 24; +} + +// (public) return value as short (assumes DB>=16) +function bnShortValue() { + return (this.t == 0) ? this.s : (this[0] << 16) >> 16; +} + +// (protected) return x s.t. r^x < DV +function bnpChunkSize(r) { + return Math.floor(Math.LN2 * this.DB / Math.log(r)); +} + +// (public) 0 if this == 0, 1 if this > 0 +function bnSigNum() { + if (this.s < 0) return -1; + else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0; + else return 1; +} + +// (protected) convert to radix string +function bnpToRadix(b) { + if (b == null) b = 10; + if (this.signum() == 0 || b < 2 || b > 36) return "0"; + var cs = this.chunkSize(b); + var a = Math.pow(b, cs); + var d = nbv(a), + y = nbi(), + z = nbi(), + r = ""; + this.divRemTo(d, y, z); + while (y.signum() > 0) { + r = (a + z.intValue()).toString(b).substr(1) + r; + y.divRemTo(d, y, z); + } + return z.intValue().toString(b) + r; +} + +// (protected) convert from radix string +function bnpFromRadix(s, b) { + this.fromInt(0); + if (b == null) b = 10; + var cs = this.chunkSize(b); + var d = Math.pow(b, cs), + mi = false, + j = 0, + w = 0; + for (var i = 0; i < s.length; ++i) { + var x = intAt(s, i); + if (x < 0) { + if (s.charAt(i) == "-" && this.signum() == 0) mi = true; + continue; + } + w = b * w + x; + if (++j >= cs) { + this.dMultiply(d); + this.dAddOffset(w, 0); + j = 0; + w = 0; + } + } + if (j > 0) { + this.dMultiply(Math.pow(b, j)); + this.dAddOffset(w, 0); + } + if (mi) BigInteger.ZERO.subTo(this, this); +} + +// (protected) alternate constructor +function bnpFromNumber(a, b, c) { + if ("number" == typeof b) { + // new BigInteger(int,int,RNG) + if (a < 2) this.fromInt(1); + else { + this.fromNumber(a, c); + if (!this.testBit(a - 1)) // force MSB set + this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this); + if (this.isEven()) this.dAddOffset(1, 0); // force odd + while (!this.isProbablePrime(b)) { + this.dAddOffset(2, 0); + if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this); + } + } + } else { + // new BigInteger(int,RNG) + var x = [], + t = a & 7; + x.length = (a >> 3) + 1; + b.nextBytes(x); + if (t > 0) x[0] &= ((1 << t) - 1); + else x[0] = 0; + this.fromString(x, 256); + } +} + +// (public) convert to bigendian byte array +function bnToByteArray() { + var i = this.t, + r = []; + r[0] = this.s; + var p = this.DB - (i * this.DB) % 8, + d, k = 0; + if (i-- > 0) { + if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) + r[k++] = d | (this.s << (this.DB - p)); + while (i >= 0) { + if (p < 8) { + d = (this[i] & ((1 << p) - 1)) << (8 - p); + d |= this[--i] >> (p += this.DB - 8); + } else { + d = (this[i] >> (p -= 8)) & 0xff; + if (p <= 0) { + p += this.DB; + --i; + } + } + if ((d & 0x80) != 0) d |= -256; + if (k == 0 && (this.s & 0x80) != (d & 0x80)) ++k; + if (k > 0 || d != this.s) r[k++] = d; + } + } + return r; +} + +function bnEquals(a) { + return (this.compareTo(a) == 0); +} + +function bnMin(a) { + return (this.compareTo(a) < 0) ? this : a; +} + +function bnMax(a) { + return (this.compareTo(a) > 0) ? this : a; +} + +// (protected) r = this op a (bitwise) +function bnpBitwiseTo(a, op, r) { + var i, f, m = Math.min(a.t, this.t); + for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]); + if (a.t < this.t) { + f = a.s & this.DM; + for (i = m; i < this.t; ++i) r[i] = op(this[i], f); + r.t = this.t; + } else { + f = this.s & this.DM; + for (i = m; i < a.t; ++i) r[i] = op(f, a[i]); + r.t = a.t; + } + r.s = op(this.s, a.s); + r.clamp(); +} + +// (public) this & a +function op_and(x, y) { + return x & y; +} + +function bnAnd(a) { + var r = nbi(); + this.bitwiseTo(a, op_and, r); + return r; +} + +// (public) this | a +function op_or(x, y) { + return x | y; +} + +function bnOr(a) { + var r = nbi(); + this.bitwiseTo(a, op_or, r); + return r; +} + +// (public) this ^ a +function op_xor(x, y) { + return x ^ y; +} + +function bnXor(a) { + var r = nbi(); + this.bitwiseTo(a, op_xor, r); + return r; +} + +// (public) this & ~a +function op_andnot(x, y) { + return x & ~y; +} + +function bnAndNot(a) { + var r = nbi(); + this.bitwiseTo(a, op_andnot, r); + return r; +} + +// (public) ~this +function bnNot() { + var r = nbi(); + for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i]; + r.t = this.t; + r.s = ~this.s; + return r; +} + +// (public) this << n +function bnShiftLeft(n) { + var r = nbi(); + if (n < 0) this.rShiftTo(-n, r); + else this.lShiftTo(n, r); + return r; +} + +// (public) this >> n +function bnShiftRight(n) { + var r = nbi(); + if (n < 0) this.lShiftTo(-n, r); + else this.rShiftTo(n, r); + return r; +} + +// return index of lowest 1-bit in x, x < 2^31 +function lbit(x) { + if (x == 0) return -1; + var r = 0; + if ((x & 0xffff) == 0) { + x >>= 16; + r += 16; + } + if ((x & 0xff) == 0) { + x >>= 8; + r += 8; + } + if ((x & 0xf) == 0) { + x >>= 4; + r += 4; + } + if ((x & 3) == 0) { + x >>= 2; + r += 2; + } + if ((x & 1) == 0) ++r; + return r; +} + +// (public) returns index of lowest 1-bit (or -1 if none) +function bnGetLowestSetBit() { + for (var i = 0; i < this.t; ++i) + if (this[i] != 0) return i * this.DB + lbit(this[i]); + if (this.s < 0) return this.t * this.DB; + return -1; +} + +// return number of 1 bits in x +function cbit(x) { + var r = 0; + while (x != 0) { + x &= x - 1; + ++r; + } + return r; +} + +// (public) return number of set bits +function bnBitCount() { + var r = 0, + x = this.s & this.DM; + for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x); + return r; +} + +// (public) true iff nth bit is set +function bnTestBit(n) { + var j = Math.floor(n / this.DB); + if (j >= this.t) return (this.s != 0); + return ((this[j] & (1 << (n % this.DB))) != 0); +} + +// (protected) this op (1<>= this.DB; + } + if (a.t < this.t) { + c += a.s; + while (i < this.t) { + c += this[i]; + r[i++] = c & this.DM; + c >>= this.DB; + } + c += this.s; + } else { + c += this.s; + while (i < a.t) { + c += a[i]; + r[i++] = c & this.DM; + c >>= this.DB; + } + c += a.s; + } + r.s = (c < 0) ? -1 : 0; + if (c > 0) r[i++] = c; + else if (c < -1) r[i++] = this.DV + c; + r.t = i; + r.clamp(); +} + +// (public) this + a +function bnAdd(a) { + var r = nbi(); + this.addTo(a, r); + return r; +} + +// (public) this - a +function bnSubtract(a) { + var r = nbi(); + this.subTo(a, r); + return r; +} + +// (public) this * a +function bnMultiply(a) { + var r = nbi(); + this.multiplyTo(a, r); + return r; +} + +// (public) this / a +function bnDivide(a) { + var r = nbi(); + this.divRemTo(a, r, null); + return r; +} + +// (public) this % a +function bnRemainder(a) { + var r = nbi(); + this.divRemTo(a, null, r); + return r; +} + +// (public) [this/a,this%a] +function bnDivideAndRemainder(a) { + var q = nbi(), + r = nbi(); + this.divRemTo(a, q, r); + return [q, r]; +} + +// (protected) this *= n, this >= 0, 1 < n < DV +function bnpDMultiply(n) { + this[this.t] = this.am(0, n - 1, this, 0, 0, this.t); + ++this.t; + this.clamp(); +} + +// (protected) this += n << w words, this >= 0 +function bnpDAddOffset(n, w) { + if (n == 0) return; + while (this.t <= w) this[this.t++] = 0; + this[w] += n; + while (this[w] >= this.DV) { + this[w] -= this.DV; + if (++w >= this.t) this[this.t++] = 0; + ++this[w]; + } +} + +// A "null" reducer +function NullExp() {} + +function nNop(x) { + return x; +} + +function nMulTo(x, y, r) { + x.multiplyTo(y, r); +} + +function nSqrTo(x, r) { + x.squareTo(r); +} + +NullExp.prototype.convert = nNop; +NullExp.prototype.revert = nNop; +NullExp.prototype.mulTo = nMulTo; +NullExp.prototype.sqrTo = nSqrTo; + +// (public) this^e +function bnPow(e) { + return this.exp(e, new NullExp()); +} + +// (protected) r = lower n words of "this * a", a.t <= n +// "this" should be the larger one if appropriate. +function bnpMultiplyLowerTo(a, n, r) { + var i = Math.min(this.t + a.t, n); + r.s = 0; // assumes a,this >= 0 + r.t = i; + while (i > 0) r[--i] = 0; + var j; + for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t); + for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i); + r.clamp(); +} + +// (protected) r = "this * a" without lower n words, n > 0 +// "this" should be the larger one if appropriate. +function bnpMultiplyUpperTo(a, n, r) { + --n; + var i = r.t = this.t + a.t - n; + r.s = 0; // assumes a,this >= 0 + while (--i >= 0) r[i] = 0; + for (i = Math.max(n - this.t, 0); i < a.t; ++i) + r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n); + r.clamp(); + r.drShiftTo(1, r); +} + +// Barrett modular reduction +function Barrett(m) { + // setup Barrett + this.r2 = nbi(); + this.q3 = nbi(); + BigInteger.ONE.dlShiftTo(2 * m.t, this.r2); + this.mu = this.r2.divide(m); + this.m = m; +} + +function barrettConvert(x) { + if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m); + else if (x.compareTo(this.m) < 0) return x; + else { + var r = nbi(); + x.copyTo(r); + this.reduce(r); + return r; + } +} + +function barrettRevert(x) { + return x; +} + +// x = x mod m (HAC 14.42) +function barrettReduce(x) { + x.drShiftTo(this.m.t - 1, this.r2); + if (x.t > this.m.t + 1) { + x.t = this.m.t + 1; + x.clamp(); + } + this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3); + this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); + while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1); + x.subTo(this.r2, x); + while (x.compareTo(this.m) >= 0) x.subTo(this.m, x); +} + +// r = x^2 mod m; x != r +function barrettSqrTo(x, r) { + x.squareTo(r); + this.reduce(r); +} + +// r = x*y mod m; x,y != r +function barrettMulTo(x, y, r) { + x.multiplyTo(y, r); + this.reduce(r); +} + +Barrett.prototype.convert = barrettConvert; +Barrett.prototype.revert = barrettRevert; +Barrett.prototype.reduce = barrettReduce; +Barrett.prototype.mulTo = barrettMulTo; +Barrett.prototype.sqrTo = barrettSqrTo; + +// (public) this^e % m (HAC 14.85) +function bnModPow(e, m) { + var i = e.bitLength(), + k, r = nbv(1), + z; + if (i <= 0) return r; + else if (i < 18) k = 1; + else if (i < 48) k = 3; + else if (i < 144) k = 4; + else if (i < 768) k = 5; + else k = 6; + if (i < 8) + z = new Classic(m); + else if (m.isEven()) + z = new Barrett(m); + else + z = new Montgomery(m); + + // precomputation + var g = [], + n = 3, + k1 = k - 1, + km = (1 << k) - 1; + g[1] = z.convert(this); + if (k > 1) { + var g2 = nbi(); + z.sqrTo(g[1], g2); + while (n <= km) { + g[n] = nbi(); + z.mulTo(g2, g[n - 2], g[n]); + n += 2; + } + } + + var j = e.t - 1, + w, is1 = true, + r2 = nbi(), + t; + i = nbits(e[j]) - 1; + while (j >= 0) { + if (i >= k1) w = (e[j] >> (i - k1)) & km; + else { + w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i); + if (j > 0) w |= e[j - 1] >> (this.DB + i - k1); + } + + n = k; + while ((w & 1) == 0) { + w >>= 1; + --n; + } + if ((i -= n) < 0) { + i += this.DB; + --j; + } + if (is1) { // ret == 1, don't bother squaring or multiplying it + g[w].copyTo(r); + is1 = false; + } else { + while (n > 1) { + z.sqrTo(r, r2); + z.sqrTo(r2, r); + n -= 2; + } + if (n > 0) z.sqrTo(r, r2); + else { + t = r; + r = r2; + r2 = t; + } + z.mulTo(r2, g[w], r); + } + + while (j >= 0 && (e[j] & (1 << i)) == 0) { + z.sqrTo(r, r2); + t = r; + r = r2; + r2 = t; + if (--i < 0) { + i = this.DB - 1; + --j; + } + } + } + return z.revert(r); +} + +// (public) gcd(this,a) (HAC 14.54) +function bnGCD(a) { + var x = (this.s < 0) ? this.negate() : this.clone(); + var y = (a.s < 0) ? a.negate() : a.clone(); + if (x.compareTo(y) < 0) { + var t = x; + x = y; + y = t; + } + var i = x.getLowestSetBit(), + g = y.getLowestSetBit(); + if (g < 0) return x; + if (i < g) g = i; + if (g > 0) { + x.rShiftTo(g, x); + y.rShiftTo(g, y); + } + while (x.signum() > 0) { + if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x); + if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y); + if (x.compareTo(y) >= 0) { + x.subTo(y, x); + x.rShiftTo(1, x); + } else { + y.subTo(x, y); + y.rShiftTo(1, y); + } + } + if (g > 0) y.lShiftTo(g, y); + return y; +} + +// (protected) this % n, n < 2^26 +function bnpModInt(n) { + if (n <= 0) return 0; + var d = this.DV % n, + r = (this.s < 0) ? n - 1 : 0; + if (this.t > 0) + if (d == 0) r = this[0] % n; + else + for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n; + return r; +} + +// (public) 1/this % m (HAC 14.61) +function bnModInverse(m) { + var ac = m.isEven(); + if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO; + var u = m.clone(), + v = this.clone(); + var a = nbv(1), + b = nbv(0), + c = nbv(0), + d = nbv(1); + while (u.signum() != 0) { + while (u.isEven()) { + u.rShiftTo(1, u); + if (ac) { + if (!a.isEven() || !b.isEven()) { + a.addTo(this, a); + b.subTo(m, b); + } + a.rShiftTo(1, a); + } else if (!b.isEven()) b.subTo(m, b); + b.rShiftTo(1, b); + } + while (v.isEven()) { + v.rShiftTo(1, v); + if (ac) { + if (!c.isEven() || !d.isEven()) { + c.addTo(this, c); + d.subTo(m, d); + } + c.rShiftTo(1, c); + } else if (!d.isEven()) d.subTo(m, d); + d.rShiftTo(1, d); + } + if (u.compareTo(v) >= 0) { + u.subTo(v, u); + if (ac) a.subTo(c, a); + b.subTo(d, b); + } else { + v.subTo(u, v); + if (ac) c.subTo(a, c); + d.subTo(b, d); + } + } + if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO; + if (d.compareTo(m) >= 0) return d.subtract(m); + if (d.signum() < 0) d.addTo(m, d); + else return d; + if (d.signum() < 0) return d.add(m); + else return d; +} + +var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509]; +var lplim = (1 << 26) / lowprimes[lowprimes.length - 1]; + +// (public) test primality with certainty >= 1-.5^t +function bnIsProbablePrime(t) { + var i, x = this.abs(); + if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) { + for (i = 0; i < lowprimes.length; ++i) + if (x[0] == lowprimes[i]) return true; + return false; + } + if (x.isEven()) return false; + i = 1; + while (i < lowprimes.length) { + var m = lowprimes[i], + j = i + 1; + while (j < lowprimes.length && m < lplim) m *= lowprimes[j++]; + m = x.modInt(m); + while (i < j) + if (m % lowprimes[i++] == 0) return false; + } + return x.millerRabin(t); +} + +// (protected) true if probably prime (HAC 4.24, Miller-Rabin) +function bnpMillerRabin(t) { + var n1 = this.subtract(BigInteger.ONE); + var k = n1.getLowestSetBit(); + if (k <= 0) return false; + var r = n1.shiftRight(k); + t = (t + 1) >> 1; + if (t > lowprimes.length) t = lowprimes.length; + var a = nbi(); + for (var i = 0; i < t; ++i) { + a.fromInt(lowprimes[i]); + var y = a.modPow(r, this); + if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) { + var j = 1; + while (j++ < k && y.compareTo(n1) != 0) { + y = y.modPowInt(2, this); + if (y.compareTo(BigInteger.ONE) == 0) return false; + } + if (y.compareTo(n1) != 0) return false; + } + } + return true; +} + + + +// protected +BigInteger.prototype.chunkSize = bnpChunkSize; +BigInteger.prototype.toRadix = bnpToRadix; +BigInteger.prototype.fromRadix = bnpFromRadix; +BigInteger.prototype.fromNumber = bnpFromNumber; +BigInteger.prototype.bitwiseTo = bnpBitwiseTo; +BigInteger.prototype.changeBit = bnpChangeBit; +BigInteger.prototype.addTo = bnpAddTo; +BigInteger.prototype.dMultiply = bnpDMultiply; +BigInteger.prototype.dAddOffset = bnpDAddOffset; +BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo; +BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo; +BigInteger.prototype.modInt = bnpModInt; +BigInteger.prototype.millerRabin = bnpMillerRabin; + +// public +BigInteger.prototype.clone = bnClone; +BigInteger.prototype.intValue = bnIntValue; +BigInteger.prototype.byteValue = bnByteValue; +BigInteger.prototype.shortValue = bnShortValue; +BigInteger.prototype.signum = bnSigNum; +BigInteger.prototype.toByteArray = bnToByteArray; +BigInteger.prototype.equals = bnEquals; +BigInteger.prototype.min = bnMin; +BigInteger.prototype.max = bnMax; +BigInteger.prototype.and = bnAnd; +BigInteger.prototype.or = bnOr; +BigInteger.prototype.xor = bnXor; +BigInteger.prototype.andNot = bnAndNot; +BigInteger.prototype.not = bnNot; +BigInteger.prototype.shiftLeft = bnShiftLeft; +BigInteger.prototype.shiftRight = bnShiftRight; +BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit; +BigInteger.prototype.bitCount = bnBitCount; +BigInteger.prototype.testBit = bnTestBit; +BigInteger.prototype.setBit = bnSetBit; +BigInteger.prototype.clearBit = bnClearBit; +BigInteger.prototype.flipBit = bnFlipBit; +BigInteger.prototype.add = bnAdd; +BigInteger.prototype.subtract = bnSubtract; +BigInteger.prototype.multiply = bnMultiply; +BigInteger.prototype.divide = bnDivide; +BigInteger.prototype.remainder = bnRemainder; +BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder; +BigInteger.prototype.modPow = bnModPow; +BigInteger.prototype.modInverse = bnModInverse; +BigInteger.prototype.pow = bnPow; +BigInteger.prototype.gcd = bnGCD; +BigInteger.prototype.isProbablePrime = bnIsProbablePrime; + +// BigInteger interfaces not implemented in jsbn: + +// BigInteger(int signum, byte[] magnitude) +// double doubleValue() +// float floatValue() +// int hashCode() +// long longValue() +// static BigInteger valueOf(long val) + + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +// END OF copy-and-paste of jsbn. + + + +BigInteger.NEGATIVE_ONE = BigInteger.ONE.negate(); + + +// Other methods we need to add for compatibilty with js-numbers numeric tower. + +// add is implemented above. +// subtract is implemented above. +// multiply is implemented above. +// equals is implemented above. +// abs is implemented above. +// negate is defined above. + +// makeBignum: string -> BigInteger +var makeBignum = function(s) { + if (typeof(s) === 'number') { + s = s + ''; + } + s = expandExponent(s); + return new BigInteger(s, 10); +}; + +var zerostring = function(n) { + var buf = []; + for (var i = 0; i < n; i++) { + buf.push('0'); + } + return buf.join(''); +}; + + +BigInteger.prototype.level = 0; +BigInteger.prototype.liftTo = function(target) { + if (target.level === 1) { + return new Rational(this, 1); + } + if (target.level === 2) { + var fixrep = this.toFixnum(); + if (fixrep === Number.POSITIVE_INFINITY) + return TOO_POSITIVE_TO_REPRESENT; + if (fixrep === Number.NEGATIVE_INFINITY) + return TOO_NEGATIVE_TO_REPRESENT; + return new FloatPoint(fixrep); + } + if (target.level === 3) { + return new Complex(this, 0); + } + return throwRuntimeError("invalid level for BigInteger lift", this, target); +}; + +BigInteger.prototype.isFinite = function() { + return true; +}; + +BigInteger.prototype.isInteger = function() { + return true; +}; + +BigInteger.prototype.isRational = function() { + return true; +}; + +BigInteger.prototype.isReal = function() { + return true; +}; + +BigInteger.prototype.isExact = function() { + return true; +}; + +BigInteger.prototype.isInexact = function() { + return false; +}; + +BigInteger.prototype.toExact = function() { + return this; +}; + +BigInteger.prototype.toInexact = function() { + return FloatPoint.makeInstance(this.toFixnum()); +}; + +BigInteger.prototype.toFixnum = function() { + var result = 0, + str = this.toString(), + i; + if (str[0] === '-') { + for (i = 1; i < str.length; i++) { + result = result * 10 + Number(str[i]); + } + return -result; + } else { + for (i = 0; i < str.length; i++) { + result = result * 10 + Number(str[i]); + } + return result; + } +}; + + +BigInteger.prototype.greaterThan = function(other) { + return this.compareTo(other) > 0; +}; + +BigInteger.prototype.greaterThanOrEqual = function(other) { + return this.compareTo(other) >= 0; +}; + +BigInteger.prototype.lessThan = function(other) { + return this.compareTo(other) < 0; +}; + +BigInteger.prototype.lessThanOrEqual = function(other) { + return this.compareTo(other) <= 0; +}; + +// divide: scheme-number -> scheme-number +// WARNING NOTE: we override the old version of divide. +BigInteger.prototype.divide = function(other) { + var quotientAndRemainder = bnDivideAndRemainder.call(this, other); + if (quotientAndRemainder[1].compareTo(BigInteger.ZERO) === 0) { + return quotientAndRemainder[0]; + } else { + var result = add(quotientAndRemainder[0], + Rational.makeInstance(quotientAndRemainder[1], other)); + return result; + } +}; + +BigInteger.prototype.numerator = function() { + return this; +}; + +BigInteger.prototype.denominator = function() { + return 1; +}; + + +(function() { + // Classic implementation of Newton-Ralphson square-root search, + // adapted for integer-sqrt. + // http://en.wikipedia.org/wiki/Newton's_method#Square_root_of_a_number + var searchIter = function(n, guess) { + while (!(lessThanOrEqual(sqr(guess), n) && + lessThan(n, sqr(add(guess, 1))))) { + guess = floor(divide(add(guess, + floor(divide(n, guess))), + 2)); + } + return guess; + }; + + // integerSqrt: -> scheme-number + BigInteger.prototype.integerSqrt = function() { + var n; + if (sign(this) >= 0) { + return searchIter(this, this); + } else { + n = this.negate(); + return Complex.makeInstance(0, searchIter(n, n)); + } + }; +})(); + + +(function() { + // Get an approximation using integerSqrt, and then start another + // Newton-Ralphson search if necessary. + BigInteger.prototype.sqrt = function() { + var approx = this.integerSqrt(), + fix; + if (eqv(sqr(approx), this)) { + return approx; + } + fix = toFixnum(this); + if (isFinite(fix)) { + if (fix >= 0) { + return FloatPoint.makeInstance(Math.sqrt(fix)); + } else { + return Complex.makeInstance( + 0, + FloatPoint.makeInstance(Math.sqrt(-fix))); + } + } else { + return approx; + } + }; +})(); + + + + + +// sqrt: -> scheme-number +// http://en.wikipedia.org/wiki/Newton's_method#Square_root_of_a_number +// Produce the square root. + +// floor: -> scheme-number +// Produce the floor. +BigInteger.prototype.floor = function() { + return this; +} + +// ceiling: -> scheme-number +// Produce the ceiling. +BigInteger.prototype.ceiling = function() { + return this; +} + +// conjugate: -> scheme-number +// Produce the conjugate. + +// magnitude: -> scheme-number +// Produce the magnitude. + +// log: -> scheme-number +// Produce the log. + +// angle: -> scheme-number +// Produce the angle. + +// atan: -> scheme-number +// Produce the arc tangent. + +// cos: -> scheme-number +// Produce the cosine. + +// sin: -> scheme-number +// Produce the sine. + + +// expt: scheme-number -> scheme-number +// Produce the power to the input. +BigInteger.prototype.expt = function(n) { + return bnPow.call(this, n); +}; + + + +// exp: -> scheme-number +// Produce e raised to the given power. + +// acos: -> scheme-number +// Produce the arc cosine. + +// asin: -> scheme-number +// Produce the arc sine. + +BigInteger.prototype.imaginaryPart = function() { + return 0; +} +BigInteger.prototype.realPart = function() { + return this; +} + +// round: -> scheme-number +// Round to the nearest integer. + + + + + +////////////////////////////////////////////////////////////////////// +// toRepeatingDecimal: jsnum jsnum {limit: number}? -> [string, string, string] +// +// Given the numerator and denominator parts of a rational, +// produces the repeating-decimal representation, where the first +// part are the digits before the decimal, the second are the +// non-repeating digits after the decimal, and the third are the +// remaining repeating decimals. +// +// An optional limit on the decimal expansion can be provided, in which +// case the search cuts off if we go past the limit. +// If this happens, the third argument returned becomes '...' to indicate +// that the search was prematurely cut off. +var toRepeatingDecimal = (function() { + var getResidue = function(r, d, limit) { + var digits = []; + var seenRemainders = {}; + seenRemainders[r] = true; + while (true) { + if (limit-- <= 0) { + return [digits.join(''), '...'] + } + + var nextDigit = quotient( + multiply(r, 10), d); + var nextRemainder = remainder( + multiply(r, 10), + d); + digits.push(nextDigit.toString()); + if (seenRemainders[nextRemainder]) { + r = nextRemainder; + break; + } else { + seenRemainders[nextRemainder] = true; + r = nextRemainder; + } + } + + var firstRepeatingRemainder = r; + var repeatingDigits = []; + while (true) { + var nextDigit = quotient(multiply(r, 10), d); + var nextRemainder = remainder( + multiply(r, 10), + d); + repeatingDigits.push(nextDigit.toString()); + if (equals(nextRemainder, firstRepeatingRemainder)) { + break; + } else { + r = nextRemainder; + } + }; + + var digitString = digits.join(''); + var repeatingDigitString = repeatingDigits.join(''); + + while (digitString.length >= repeatingDigitString.length && + (digitString.substring( + digitString.length - repeatingDigitString.length) === + repeatingDigitString)) { + digitString = digitString.substring( + 0, digitString.length - repeatingDigitString.length); + } + + return [digitString, repeatingDigitString]; + + }; + + return function(n, d, options) { + // default limit on decimal expansion; can be overridden + var limit = 512; + if (options && typeof(options.limit) !== 'undefined') { + limit = options.limit; + } + if (!isInteger(n)) { + throwRuntimeError('toRepeatingDecimal: n ' + n.toString() + + " is not an integer."); + } + if (!isInteger(d)) { + throwRuntimeError('toRepeatingDecimal: d ' + d.toString() + + " is not an integer."); + } + if (equals(d, 0)) { + throwRuntimeError('toRepeatingDecimal: d equals 0'); + } + if (lessThan(d, 0)) { + throwRuntimeError('toRepeatingDecimal: d < 0'); + } + var sign = (lessThan(n, 0) ? "-" : ""); + n = abs(n); + var beforeDecimalPoint = sign + quotient(n, d); + var afterDecimals = getResidue(remainder(n, d), d, limit); + return [beforeDecimalPoint].concat(afterDecimals); + }; +})(); +////////////////////////////////////////////////////////////////////// + + + + +// External interface of js-numbers: + +const makeRational = Rational.makeInstance; +const makeFloat = FloatPoint.makeInstance; +const makeComplex = Complex.makeInstance; +const pi = FloatPoint.pi; +const e = FloatPoint.e; +const nan = FloatPoint.nan; +const negative_inf = FloatPoint.neginf; +// const inf = FloatPoint.inf; +const negative_one = -1; +const one = 1; +const zero = 0; + +export { + fromFixnum, + fromString, + makeBignum, + makeRational, + makeFloat, + makeComplex, + makeComplexPolar, + // pi, + e, + nan, + negative_inf, + inf, + negative_one, // Rational.NEGATIVE_ONE, + zero, // Rational.ZERO, + one, // Rational.ONE, + plusI as i, + minusI as negative_i, + NEGATIVE_ZERO as negative_zero, + onThrowRuntimeError, + isSchemeNumber, + isRational, + isReal, + isExact, + isInexact, + isInteger, + toFixnum, + toExact, + toInexact, + add, + subtract, + multiply, + divide, + equals, + eqv, + approxEquals, + greaterThanOrEqual, + lessThanOrEqual, + greaterThan, + lessThan, + expt, + exp, + modulo, + numerator, + denominator, + integerSqrt, + sqrt, + abs, + quotient, + remainder, + floor, + ceiling, + conjugate, + magnitude, + log, + angle, + tan, + atan, + atan2, + cos, + sin, + acos, + asin, + cosh, + sinh, + imaginaryPart, + realPart, + round, + sqr, + gcd, + lcm, + toRepeatingDecimal, + BigInteger, + Rational, + FloatPoint, + Complex, + MIN_FIXNUM, + MAX_FIXNUM, + bitwiseAnd, + bitwiseOr, + bitwiseXor, + bitwiseNot, + arithmeticShift +}; diff --git a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js index 1defa2aa..c7b50011 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/core/struct.js +++ b/racketscript-compiler/racketscript/compiler/runtime/core/struct.js @@ -235,7 +235,7 @@ class StructTypeDescriptor extends PrintablePrimitive { C.falsy( options.superType._isSealed(), racketCoreError, - 'make-struct-type: cannot make a subtype of a sealed type', + 'make-struct-type: cannot make a subtype of a sealed type' ); this._totalInitFields += options.superType._totalInitFields; } diff --git a/racketscript-compiler/racketscript/compiler/runtime/flfxnum.rkt b/racketscript-compiler/racketscript/compiler/runtime/flfxnum.rkt index 32ddbc9e..88e193fa 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/flfxnum.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/flfxnum.rkt @@ -1,35 +1,65 @@ #lang racketscript/boot -(require racketscript/interop "lib.rkt" (for-syntax syntax/parse)) +(require racketscript/interop + racketscript/compiler/directive + "kernel.rkt" + "lib.rkt" + (for-syntax syntax/parse)) -(define+provide fl* (#js.Core.attachProcedureArity #js.Core.Number.mul 0)) -(define+provide fl/ (#js.Core.attachProcedureArity #js.Core.Number.div 1)) -(define+provide fl+ (#js.Core.attachProcedureArity #js.Core.Number.add 0)) -(define+provide fl- (#js.Core.attachProcedureArity #js.Core.Number.sub 1)) -(define+provide fl< (#js.Core.attachProcedureArity #js.Core.Number.lt 1)) -(define+provide fl> (#js.Core.attachProcedureArity #js.Core.Number.gt 1)) -(define+provide fl<= (#js.Core.attachProcedureArity #js.Core.Number.lte 1)) -(define+provide fl>= (#js.Core.attachProcedureArity #js.Core.Number.gte 1)) -(define+provide fl= (#js.Core.attachProcedureArity #js.Core.Number.equals 1)) +(define+provide fl* (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.multiply + #js.Core.Number.JS.mul ) 0)) +(define+provide fl/ (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.divide + #js.Core.Number.JS.div ) 1)) +(define+provide fl+ (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.add + #js.Core.Number.JS.add ) 0)) +(define+provide fl- (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.subtract + #js.Core.Number.JS.sub ) 1)) +(define+provide fl< (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.lessThan + #js.Core.Number.JS.lt ) 1)) +(define+provide fl> (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.greaterThan + #js.Core.Number.JS.gt ) 1)) +(define+provide fl<= (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.lessThanOrEqual + #js.Core.Number.JS.lte ) 1)) +(define+provide fl>= (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.greaterThanOrEqual + #js.Core.Number.JS.gte ) 1)) +(define+provide fl= (#js.Core.attachProcedureArity (if-scheme-numbers #js.Core.Number.Scheme.approxEquals + #js.Core.Number.JS.equals ) 1)) -(define+provide flabs #js.Math.abs) -(define+provide flmin #js.Math.min) -(define+provide flmax #js.Math.max) -(define+provide flround #js.Math.round) -(define+provide flfloor #js.Math.floor) -(define+provide flceiling #js.Math.ceil) -(define+provide fltruncate #js.Math.trunc) +(define+provide flabs (if-scheme-numbers #js.Core.Number.Scheme.abs + #js.Math.abs)) +(define+provide flmin (if-scheme-numbers min + #js.Math.min)) +(define+provide flmax (if-scheme-numbers max + #js.Math.max)) +(define+provide flround (if-scheme-numbers round + #js.Math.round)) +(define+provide flfloor (if-scheme-numbers floor + #js.Math.floor)) +(define+provide flceiling (if-scheme-numbers ceiling + #js.Math.ceil)) +(define+provide fltruncate (if-scheme-numbers truncate + #js.Math.trunc)) -(define+provide flsin #js.Math.sin) -(define+provide flcos #js.Math.cos) -(define+provide fltan #js.Math.tan) -(define+provide flasin #js.Math.asin) -(define+provide flacos #js.Math.acos) -(define+provide flatan #js.Math.atan) -(define+provide fllog #js.Math.log) -(define+provide flexp #js.Math.exp) -(define+provide flsqrt #js.Math.sqrt) -(define+provide flexpt #js.Math.pow) +(define+provide flsin (if-scheme-numbers sin + #js.Math.sin)) +(define+provide flcos (if-scheme-numbers cos + #js.Math.cos)) +(define+provide fltan (if-scheme-numbers tan + #js.Math.tan)) +(define+provide flasin (if-scheme-numbers asin + #js.Math.asin)) +(define+provide flacos (if-scheme-numbers acos + #js.Math.acos)) +(define+provide flatan (if-scheme-numbers atan + #js.Math.atan)) +(define+provide fllog (if-scheme-numbers log + #js.Math.log)) +(define+provide flexp (if-scheme-numbers exp + #js.Math.exp)) +(define+provide flsqrt (if-scheme-numbers sqrt + #js.Math.sqrt)) +(define+provide flexpt (if-scheme-numbers expt + #js.Math.pow)) (define-binop bitwise-or \|) @@ -77,7 +107,7 @@ (define-fx-binop+provide fxand &&) (define-fx-binop+provide fxior \|\|) (define-fx-binop+provide fxxor ^) -(define+provide fxnot #js.Core.bitwiseNot) +(define+provide fxnot #js.Core.bitwiseNot) (define+provide flvector #js.Array.from) ; just create regular array (define+provide flvector? #js.Array.isArray) diff --git a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt index 875156f9..daa66c5f 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/kernel.rkt @@ -2,6 +2,7 @@ (require (for-syntax syntax/parse) racketscript/interop + racketscript/compiler/directive "lib.rkt") ;; ---------------------------------------------------------------------------- @@ -50,152 +51,327 @@ ;; ---------------------------------------------------------------------------- ;; Numbers -(define+provide number? #js.Core.Number.check) -(define+provide real? #js.Core.Number.check) -(define+provide integer? #js.Number.isInteger) +(define+provide number? (if-scheme-numbers #js.Core.Number.Scheme.isSchemeNumber + #js.Core.Number.JS.check)) +(define+provide real? (if-scheme-numbers #js.Core.Number.Scheme.isReal + #js.Core.Number.JS.check)) +(define+provide integer? (if-scheme-numbers #js.Core.Number.Scheme.isInteger + #js.Number.isInteger)) + +(define-syntax (define+provide/scheme-numbers stx) + (syntax-parse stx + [(_ identifier:id binding:expr) + #`(define+provide identifier + (if-scheme-numbers binding + (lambda _ + (#js.Core.racketCoreError "Not supported with JS number semantics"))))] + [(_ (identifier:id args:expr ...) body:expr ...) + #'(define+provide/scheme-numbers identifier + (λ (args ...) body ...))])) + +(define-syntax (define-checked+provide/scheme-numbers stx) + (syntax-parse stx + [(_ (identifier:id [arg:expr pred:expr] ...) body:expr) + #`(define-checked+provide (identifier [arg pred] ...) + (if-scheme-numbers body + (lambda _ + (#js.Core.racketCoreError "Not supported with JS number semantics"))))])) + +(define+provide/scheme-numbers complex? number?) (define-checked+provide (zero? [v number?]) - (binop === v 0)) + (if-scheme-numbers (#js.Core.Number.Scheme.equals #js.Core.Number.Scheme.zero v) + (binop === v 0))) (define-checked+provide (positive? [v real?]) - (binop > v 0)) + (if-scheme-numbers (#js.Core.Number.Scheme.greaterThan v #js.Core.Number.Scheme.zero) + (binop > v 0))) (define-checked+provide (negative? [v real?]) - (binop < v 0)) + (if-scheme-numbers (#js.Core.Number.Scheme.lessThan v #js.Core.Number.Scheme.zero) + (binop < v 0))) (define-checked+provide (add1 [v number?]) - (binop + v 1)) + (if-scheme-numbers (#js.Core.Number.Scheme.add v #js.Core.Number.Scheme.one) + (binop + v 1))) (define-checked+provide (sub1 [v number?]) - (binop - v 1)) + (if-scheme-numbers (#js.Core.Number.Scheme.subtract v #js.Core.Number.Scheme.one) + (binop - v 1))) (define-checked+provide (quotient [dividend integer?] [divisor integer?]) - (binop \| (binop / dividend divisor) 0)) + (if-scheme-numbers (#js.Core.Number.Scheme.quotient dividend divisor) + (binop \| (binop / dividend divisor) 0))) (define-checked+provide (even? [v integer?]) - (binop === (binop % v 2) 0)) + (if-scheme-numbers (#js.Core.Number.Scheme.equals (#js.Core.Number.Scheme.modulo v 2) 0) + (binop === (binop % v 2) 0))) (define-checked+provide (odd? [v integer?]) - (not (binop === (binop % v 2) 0))) + (not (even? v))) (define+provide (exact-nonnegative-integer? v) - (and (#js.Number.isInteger v) (binop >= v 0))) + (if-scheme-numbers (and (integer? v) + (#js.Core.Number.Scheme.greaterThanOrEqual v 0) + (exact? v)) + (and (#js.Number.isInteger v) (binop >= v 0)))) (define+provide (exact-integer? v) - (#js.Number.isInteger v)) + (if-scheme-numbers (and (integer? v) + (exact? v)) + (#js.Number.isInteger v))) (define+provide (exact? v) - (#js.Number.isInteger v)) + (if-scheme-numbers (#js.Core.Number.Scheme.isExact v) + (#js.Number.isInteger v))) + +(define+provide (inexact? v) (not (exact? v))) ;; single-flonum not implemented -(define+provide (single-flonum-available?) #f) -(define+provide (single-flonum?) #f) -(define+provide (real->single-flonum v) v) - -(define+provide * (#js.Core.attachProcedureArity #js.Core.Number.mul 0)) -(define+provide / (#js.Core.attachProcedureArity #js.Core.Number.div 1)) -(define+provide + (#js.Core.attachProcedureArity #js.Core.Number.add 0)) -(define+provide - (#js.Core.attachProcedureArity #js.Core.Number.sub 1)) -(define+provide < (#js.Core.attachProcedureArity #js.Core.Number.lt 1)) -(define+provide > (#js.Core.attachProcedureArity #js.Core.Number.gt 1)) -(define+provide <= (#js.Core.attachProcedureArity #js.Core.Number.lte 1)) -(define+provide >= (#js.Core.attachProcedureArity #js.Core.Number.gte 1)) -(define+provide = (#js.Core.attachProcedureArity #js.Core.Number.equals 1)) +(define+provide (single-flonum-available?) (if-scheme-numbers #f + #f)) +(define+provide (single-flonum?) (if-scheme-numbers #f + #f)) +(define+provide (real->single-flonum v) (if-scheme-numbers v + v)) + +(define+provide * + (if-scheme-numbers (#js.Core.attachProcedureArity (λ nums + (cond + [(null? nums) + 1] + [(null? (cdr nums)) + (car nums)] + [else + (#js.Core.Number.Scheme.multiply (car nums) (apply * (cdr nums)))])) + 0) + (#js.Core.attachProcedureArity #js.Core.Number.JS.mul 0))) +(define+provide / + (if-scheme-numbers (#js.Core.attachProcedureArity (λ nums + (cond + [(null? (cdr nums)) + (#js.Core.Number.Scheme.divide 1 (car nums))] + [else + (foldl (λ (x y) + (#js.Core.Number.Scheme.divide y x)) + (car nums) + (cdr nums))])) + 1) + (#js.Core.attachProcedureArity #js.Core.Number.JS.div 1))) +(define+provide + + (if-scheme-numbers (#js.Core.attachProcedureArity (λ nums + (cond + [(null? nums) + 0] + [(null? (cdr nums)) + (car nums)] + [else + (#js.Core.Number.Scheme.add (car nums) (apply + (cdr nums)))])) + 0) + (#js.Core.attachProcedureArity #js.Core.Number.JS.add 0))) +(define+provide - + (if-scheme-numbers (#js.Core.attachProcedureArity (λ nums + (cond + [(null? (cdr nums)) + (#js.Core.Number.Scheme.subtract 0 (car nums))] + [else + (foldl (λ (n acc) + (#js.Core.Number.Scheme.subtract acc n)) + (car nums) + (cdr nums))])) + 1) + (#js.Core.attachProcedureArity #js.Core.Number.JS.sub 1))) + +(define-syntax-rule (make-js-comparison op jsop) + (λ nums + (cond + [(null? nums) + #t] + [(null? (cdr nums)) + #t] + [else + (and (jsop (car nums) (car (cdr nums))) + (apply op (cdr nums)))]))) + +(define+provide < + (if-scheme-numbers (#js.Core.attachProcedureArity (make-js-comparison < #js.Core.Number.Scheme.lessThan) 1) + (#js.Core.attachProcedureArity #js.Core.Number.JS.lt 1))) +(define+provide > + (if-scheme-numbers (#js.Core.attachProcedureArity (make-js-comparison > #js.Core.Number.Scheme.greaterThan) 1) + (#js.Core.attachProcedureArity #js.Core.Number.JS.gt 1))) +(define+provide <= + (if-scheme-numbers (#js.Core.attachProcedureArity (make-js-comparison <= #js.Core.Number.Scheme.lessThanOrEqual) 1) + (#js.Core.attachProcedureArity #js.Core.Number.JS.lte 1))) +(define+provide >= + (if-scheme-numbers (#js.Core.attachProcedureArity (make-js-comparison >= #js.Core.Number.Scheme.greaterThanOrEqual) 1) + (#js.Core.attachProcedureArity #js.Core.Number.JS.gte 1))) +(define+provide = + (if-scheme-numbers (#js.Core.attachProcedureArity (make-js-comparison = #js.Core.Number.Scheme.equals) 1) + (#js.Core.attachProcedureArity #js.Core.Number.JS.equals 1))) (define-checked+provide (floor [v real?]) - (#js.Math.floor v)) + (if-scheme-numbers (#js.Core.Number.Scheme.floor v) + (#js.Math.floor v))) (define-checked+provide (abs [v real?]) - (#js.Math.abs v)) -(define-checked+provide (sin [v real?]) - (#js.Math.sin v)) -(define-checked+provide (cos [v real?]) - (#js.Math.cos v)) -(define-checked+provide (tan [v real?]) - (#js.Math.tan v)) -(define-checked+provide (asin [v real?]) - (#js.Math.asin v)) -(define-checked+provide (acos [v real?]) - (#js.Math.acos v)) + (if-scheme-numbers (#js.Core.Number.Scheme.abs v) + (#js.Math.abs v))) +(define-checked+provide (sin [v number?]) + (if-scheme-numbers (#js.Core.Number.Scheme.sin v) + (#js.Math.sin v))) +(define-checked+provide (cos [v number?]) + (if-scheme-numbers (#js.Core.Number.Scheme.cos v) + (#js.Math.cos v))) +(define-checked+provide (tan [v number?]) + (if-scheme-numbers (#js.Core.Number.Scheme.tan v) + (#js.Math.tan v))) +(define-checked+provide (asin [v number?]) + (if-scheme-numbers (#js.Core.Number.Scheme.asin v) + (#js.Math.asin v))) +(define-checked+provide (acos [v number?]) + (if-scheme-numbers (#js.Core.Number.Scheme.acos v) + (#js.Math.acos v))) (define+provide atan - (case-lambda - [(v) (#js.Math.atan v)] - [(x y) (#js.Math.atan2 x y)])) + (if-scheme-numbers (case-lambda + [(x) (#js.Core.Number.Scheme.atan x)] + [(x y) (#js.Core.Number.Scheme.atan2 x y)]) + (case-lambda + [(v) (#js.Math.atan v)] + [(x y) (#js.Math.atan2 x y)]))) (define-checked+provide (ceiling [v real?]) - (#js.Math.ceil v)) + (if-scheme-numbers (#js.Core.Number.Scheme.ceiling v) + (#js.Math.ceil v))) (define-checked+provide (round [v real?]) - (#js.Math.round v)) + (if-scheme-numbers (#js.Core.Number.Scheme.round v) + (#js.Math.round v))) (define-checked+provide (min [a real?] [b real?]) - (#js.Math.min a b)) + (if-scheme-numbers (cond + [(not (and (number? a) + (number? b))) + #js.Core.Number.Scheme.nan] + [(#js.Core.Number.Scheme.lessThan a b) a] + [else b]) + (#js.Math.min a b))) (define-checked+provide (max [a real?] [b real?]) - (#js.Math.max a b)) - -(define-checked+provide (log [v real?]) - (#js.Math.log v)) + (if-scheme-numbers (cond + [(not (and (number? a) + (number? b))) + #js.Core.Number.Scheme.nan] + [(#js.Core.Number.Scheme.greaterThan a b) a] + [else b]) + (#js.Math.max a b))) + +(define-checked+provide (log [v number?]) + (if-scheme-numbers (#js.Core.Number.Scheme.log v) + (#js.Math.log v))) (define-checked+provide (exp [w number?]) - (#js.Math.exp w)) + (if-scheme-numbers (#js.Core.Number.Scheme.exp w) + (#js.Math.exp w))) (define-checked+provide (expt [w number?] [z number?]) - (#js.Math.pow w z)) + (if-scheme-numbers (#js.Core.Number.Scheme.expt w z) + (#js.Math.pow w z))) (define-checked+provide (sqrt [v number?]) - (#js.Math.sqrt v)) + (if-scheme-numbers (#js.Core.Number.Scheme.sqrt v) + (#js.Math.sqrt v))) (define-checked+provide (sqr [v number?]) - (* v v)) + (if-scheme-numbers (#js.Core.Number.Scheme.sqr v) + (* v v))) (define-checked+provide (truncate [v number?]) - (#js.Math.trunc v)) + (if-scheme-numbers (cond + [(negative? v) + (- (floor v) 1)] + [else (floor v)]) + (#js.Math.trunc v))) (define-checked+provide (remainder [a integer?] [b integer?]) - (binop % a b)) + (if-scheme-numbers (#js.Core.Number.Scheme.remainder a b) + (binop % a b))) (define-checked+provide (number->string [n number?]) (#js.Core.UString.makeMutable (#js.n.toString))) ;; TODO: only works for numbers < 32 bits (define-checked+provide (arithmetic-shift [n integer?] [m integer?]) - (if (negative? n) - (binop >> n m) - (binop << n m))) + (if-scheme-numbers (#js.Core.Number.Scheme.arithmeticShift n m) + (if (negative? m) + (binop >> n (- m)) + (binop << n m)))) ;;TODO: Support bignums -(define+provide (inexact->exact x) x) -(define+provide (exact->inexact x) x) +(define+provide (inexact->exact v) (if-scheme-numbers (#js.Core.Number.Scheme.toExact v) + v)) +(define+provide (exact->inexact v) (if-scheme-numbers (#js.Core.Number.Scheme.toInexact v) + v)) ;; complex Numbers -;; for now, use pair (wont print like Racket) (define-checked+provide (make-rectangular [x real?] [y real?]) - (#js.Core.Pair.make x y)) - -(define-checked+provide (real-part [z pair?]) #js.z.hd) -(define-checked+provide (imag-part [z pair?]) #js.z.tl) - -;; assume only ints are rational -(define+provide rational? #js.Number.isInteger) -(define-checked+provide (numerator [x number?]) x) -(define-checked+provide (denominator [x number?]) 1) + (if-scheme-numbers (#js.Core.Number.Scheme.makeComplex x y) + (#js.Core.Pair.make x y))) + + +(define-checked+provide (make-polar [m real?] [a real?]) + (if-scheme-numbers (#js.Core.Number.Scheme.makeComplexPolar m a) + (error "Complex numbers not supported with JS numerber semantics"))) + +(define-checked+provide (real-part [z (if-scheme-numbers number? pair?)]) + (if-scheme-numbers (#js.Core.Number.Scheme.realPart z) + (#js.z.hd z))) +(define-checked+provide (imag-part [z (if-scheme-numbers number? pair?)]) + (if-scheme-numbers (#js.Core.Number.Scheme.imaginaryPart z) + (#js.z.tl z))) +(define-checked+provide/scheme-numbers (magnitude [x number?]) + (#js.Core.Number.Scheme.magnitude x)) + +(define-checked+provide/scheme-numbers (conjugate [x number?]) + (#js.Core.Number.Scheme.conjugate x)) + +(define-checked+provide/scheme-numbers (angle [x number?]) + (#js.Core.Number.Scheme.angle x)) + +(define+provide rational? (if-scheme-numbers #js.Core.Number.Scheme.isRational + #js.Number.isInteger)) +(define-checked+provide (numerator [x number?]) + (if-scheme-numbers (#js.Core.Number.Scheme.numerator x) + x)) +(define-checked+provide (denominator [x number?]) + (if-scheme-numbers (#js.Core.Number.Scheme.denominator x) + 1)) ;; bitwise operators + (define+provide bitwise-and - (#js.Core.attachProcedureName - (#js.Core.attachProcedureArity #js.Core.Number.bitwiseAnd 1) - "bitwise-and")) + (if-scheme-numbers (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.Scheme.bitwiseAnd 1) + "bitwise-and") + (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.JS.bitwiseAnd 1) + "bitwise-and"))) (define+provide bitwise-ior - (#js.Core.attachProcedureName - (#js.Core.attachProcedureArity #js.Core.Number.bitwiseOr 1) - "bitwise-ior")) + (if-scheme-numbers (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.Scheme.bitwiseOr 1) + "bitwise-ior") + (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.JS.bitwiseOr 1) + "bitwise-ior"))) (define+provide bitwise-xor - (#js.Core.attachProcedureName - (#js.Core.attachProcedureArity #js.Core.Number.bitwiseXor 1) - "bitwise-xor")) + (if-scheme-numbers (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.Scheme.bitwiseXor 1) + "bitwise-xor") + (#js.Core.attachProcedureName + (#js.Core.attachProcedureArity #js.Core.Number.JS.bitwiseXor 1) + "bitwise-xor"))) (define-checked+provide (bitwise-not [v number?]) - (#js.Core.Number.bitwiseNot v)) + (if-scheme-numbers (#js.Core.Number.Scheme.bitwiseNot v) + (#js.Core.Number.JS.bitwiseNot v))) (define+provide (bitwise-bit-set? n m) (not (zero? (bitwise-and n (arithmetic-shift 1 m))))) @@ -850,15 +1026,28 @@ (define+provide (string->number s [radix 10]) (define (integer-in lo hi) (v-λ (v) #:unchecked - (and (exact-integer? v) (>= v lo) (<= v hi)))) + (and (exact-integer? v) + (>= v 2) + (<= v 16)))) + (check/raise string? s 0) (check/raise (integer-in 2 16) radix 1) - (let ([result (#js*.parseInt s radix)]) - (if (or (#js*.isNaN result) - ; Work around parseInt permissiveness. - (not (#js.s.isValidInteger radix))) - #f - result))) + + (define (js-string->number) + (let ([result (#js*.parseInt s radix)]) + (if (or (#js*.isNaN result) + ; Work around parseInt permissiveness. + (not (#js.s.isValidInteger radix))) + #f + result))) + + (if-scheme-numbers + (let ([scheme-number (#js.Core.Number.Scheme.fromString s)]) + (if (and scheme-number + (= radix 10)) + scheme-number + (js-string->number))) + (js-string->number))) (define-checked+provide (symbol-interned? [sym symbol?]) (#js.Core.PrimitiveSymbol.isInterned sym)) diff --git a/racketscript-compiler/racketscript/compiler/runtime/runtime.rkt b/racketscript-compiler/racketscript/compiler/runtime/runtime.rkt index 2c247752..c6aa4b85 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/runtime.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/runtime.rkt @@ -4,6 +4,7 @@ "lib.rkt") ;; TODO: why does this need to be here and in kernel.rkt? +;; Because the compiler hangs if it isn't here. (define+provide values (v-λ vals (if (binop === #js.vals.length 1) diff --git a/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt b/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt index ce83df7c..1a0c7b12 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt @@ -2,11 +2,11 @@ (require (for-syntax syntax/parse) racketscript/interop + racketscript/compiler/directive "lib.rkt") (define Core ($/require/* "./core.js")) - ;;----------------------------------------------------------------------------- ;; Unsafe Numeric Operations @@ -23,7 +23,8 @@ (define-unsafe-fx-binop+provide unsafe-fx+ +) (define-unsafe-fx-binop+provide unsafe-fx- -) (define-unsafe-fx-binop+provide unsafe-fx* *) -(define-unsafe-fx-binop+provide unsafe-fxquotient /) +(define+provide unsafe-fxquotient (if-scheme-numbers #js.Core.Number.Scheme.divide + #js.Core.Number.JS.divide)) (define-unsafe-fx-binop+provide unsafe-fxremainder %) (define+provide (unsafe-fxmodulo a b) diff --git a/racketscript-compiler/racketscript/compiler/transform.rkt b/racketscript-compiler/racketscript/compiler/transform.rkt index e300e529..e0552e3e 100644 --- a/racketscript-compiler/racketscript/compiler/transform.rkt +++ b/racketscript-compiler/racketscript/compiler/transform.rkt @@ -315,6 +315,17 @@ (ILAssign id v))) (ILValue (void)))] + [(PlainApp (ImportedIdent '#%rs-compiler _ _) args) + (match args + [(list (Quote 'if-scheme-numbers) consequent alternate) + (if (use-scheme-numbers?) + (absyn-expr->il consequent #f) + (absyn-expr->il alternate #f))] + [(list (Quote 'if-scheme-numbers) consequent) + (if (use-scheme-numbers?) + (absyn-expr->il consequent #f) + (values '() (ILValue (void))))] + [else (error 'absyn-expr->il "unknown RS compiler directive" args)])] [(PlainApp (ImportedIdent '#%js-ffi _ _) args) (match args [(list (Quote 'var) (Quote var)) @@ -421,16 +432,18 @@ (define (il-app/binop v arg*) (define v-il (let-values ([(_ v) (absyn-expr->il v #f)]) v)) - (cond - [(and (equal? v (ImportedIdent '- '#%kernel #t)) - (length=? arg* 1)) - (ILApp v-il arg*)] - [(and (equal? v (ImportedIdent '/ '#%kernel #t)) - (length=? arg* 1)) - (ILBinaryOp '/ (cons (ILValue 1) arg*))] - [(and (ImportedIdent? v) (member v binops) (>= (length arg* ) 2)) - (ILBinaryOp (ImportedIdent-id v) arg*)] - [else (ILApp v-il arg*)])) + (if (use-scheme-numbers?) + (ILApp v-il arg*) + (cond + [(and (equal? v (ImportedIdent '- '#%kernel #t)) + (length=? arg* 1)) + (ILApp v-il arg*)] + [(and (equal? v (ImportedIdent '/ '#%kernel #t)) + (length=? arg* 1)) + (ILBinaryOp '/ (cons (ILValue 1) arg*))] + [(and (ImportedIdent? v) (member v binops) (>= (length arg* ) 2)) + (ILBinaryOp (ImportedIdent-id v) arg*)] + [else (ILApp v-il arg*)]))) ;; If some arguements produce statement, it may have side effects ;; and hence lambda expression should be computed first. @@ -618,6 +631,13 @@ [(symbol? d) (ILApp (name-in-module 'core 'PrimitiveSymbol.make) (list (ILValue (symbol->string d))))] + [(and (complex? d) + (not (real? d))) + (if (use-scheme-numbers?) + (ILApp (name-in-module 'core 'Number.Scheme.makeComplex) + (list (absyn-value->il (real-part d)) + (absyn-value->il (imag-part d)))) + (error (~a "Complex numbers not supported with JS number semantics: " d)))] [(keyword? d) (ILApp (name-in-module 'core 'Keyword.make) (list (ILValue (keyword->string d))))] @@ -663,11 +683,15 @@ (define v (object-name d)) ; string or bytes (ILApp (name-in-module 'core 'Regexp.fromString) (list (ILValue (if (bytes? v) (bytes->string/utf-8 v) v))))] - [(or (integer? d) + [(or (exact-integer? d) (boolean? d) - (void? d) - (real? d)) + (void? d)) (ILValue d)] + [(real? d) + (if (use-scheme-numbers?) + (ILApp (name-in-module 'core 'Number.Scheme.makeFloat) + (list (ILValue d))) + (ILValue d))] [else (error (~a "unsupported value" d))])) (: expand-normal-case-lambda (-> (Listof PlainLambda) @@ -1005,7 +1029,9 @@ (list (ILVarDec 'if_res1 (~sym 'yes))) (list (ILVarDec 'if_res1 (~sym 'false)))) (ILVarDec 'a 'if_res1) - (ILVarDec 'b (ILBinaryOp '+ (list (~val 1) (~val 2))))) + (ILVarDec 'b (if (use-scheme-numbers?) + (ILApp (ILRef 'kernel '+) (list (ILValue 1) (ILValue 2))) + (ILBinaryOp '+ (list (~val 1) (~val 2)))))) (ILApp 'list '(a b)))) ;; -------------------------------------------------------------------------- @@ -1019,14 +1045,19 @@ (ILApp (ILRef 'kernel '/) '())) (check-ilexpr (PlainApp (kident '+) (list (Quote 1) (Quote 2))) '() - (ILBinaryOp '+ (list (ILValue 1) (ILValue 2)))) + (if (use-scheme-numbers?) + (ILApp (ILRef 'kernel '+) (list (ILValue 1) (ILValue 2))) + (ILBinaryOp '+ (list (ILValue 1) (ILValue 2))))) (check-ilexpr (PlainApp (kident '-) (list (Quote 1) (Quote 2) (Quote 3))) '() - (ILBinaryOp '- - (list - (ILValue 1) (ILValue 2) (ILValue 3))))) + (if (use-scheme-numbers?) + (ILApp (ILRef 'kernel '-) + (list (ILValue 1) (ILValue 2) (ILValue 3))) + (ILBinaryOp '- + (list + (ILValue 1) (ILValue 2) (ILValue 3)))))) ;; -------------------------------------------------------------------------- diff --git a/racketscript-compiler/racketscript/compiler/util-untyped.rkt b/racketscript-compiler/racketscript/compiler/util-untyped.rkt index da3c7e28..1695c32c 100644 --- a/racketscript-compiler/racketscript/compiler/util-untyped.rkt +++ b/racketscript-compiler/racketscript/compiler/util-untyped.rkt @@ -5,7 +5,8 @@ *jsident-pattern* js-identifier?) -(require setup/dirs +(require (for-syntax syntax/parse) + setup/dirs setup/link) ;; Path Path -> Boolean diff --git a/tests/basic/__complex.rkt b/tests/basic/__complex.rkt new file mode 100644 index 00000000..a5e5e0c9 --- /dev/null +++ b/tests/basic/__complex.rkt @@ -0,0 +1,52 @@ +#lang racket + +;; TODO: Make able to test with JS +;; number semantics. +(begin (+ 1.0-3i 2.0+1i) + (+ 1.0-3i 2.0) + (+ 1.0-3i 2) + (+ 1.0-3i 1.0+3i) + (+ 1.0-3i 1.0+3i 2 5.0) + (/ 1-3i 1+3i 2 5) + (* 1.0-3i 1.0+3i 2 5.0) + (- 1.0-3i 1.0+3i 2 5.0) + (add1 1.0-3i) + (sub1 1.0-3i) + (number? 1.0+1i) + (complex? 1.0+1i) + (real? 1.0+1i) + (rational? 1.0+1i) + (integer? 1.0+1i) + (zero? 0+0i) + (zero? 0-0i) + (zero? 1+0i) + (exact? 2+1i) + (exact? 2.0+1i) + (inexact? 2+3i) + (inexact? 2.0+3i) + (exact->inexact 2+3i) + (= 1.0-3i 1.0+3i 2 5.0) + (= 1.0-3i 1.0-3i 1.0-3i 1.0-3i ) + (sqrt -1) + (sqrt 100+100i) + (expt 2+3i 4) + (exp 2+3i) + (log 2+3i) + (sin 0+0i) + (cos 0+0i) + (tan 0+0i) + (asin (sin 1+1i)) + (acos (cos 1+1i)) + (atan 0+0i) + (make-rectangular 3 5) + (make-polar 3 5) + (real-part 3-5i) + (imag-part 3-5i) + (magnitude 3-5i) + (angle 3-5i) + (number->string 3-5i) + (string->number "3-5i") + (conjugate 3-5i) + (sinh 3-5i) + (cosh 3-5i) + (tanh 0+0i)) diff --git a/tests/fixture.rkt b/tests/fixture.rkt index 929589ee..62540626 100755 --- a/tests/fixture.rkt +++ b/tests/fixture.rkt @@ -8,7 +8,8 @@ racketscript/compiler/util racketscript/compiler/global racketscript/compiler/moddeps - racketscript/compiler/il-analyze) + racketscript/compiler/il-analyze + (for-syntax syntax/parse)) ;; Print Racket and JS output of test programs to stdout ;; Also show check failure @@ -129,19 +130,19 @@ (when (verbose?) ((error-display-handler) "racket->js failed" e)) #f)]) - (racket->js) - (cond [coverage-mode? (list (list "" "") (list "" ""))] - [(js-only?) - (define expected-file (path-add-extension fpath ".expected" ".")) - (define expected - (if (file-exists? expected-file) - (file->string expected-file) - "")) - (list (list expected "") - (log-and-return 'nodejs (run-in-nodejs fpath)))] - [else - (list (log-and-return 'racket (run-in-racket fpath)) - (log-and-return 'nodejs (run-in-nodejs fpath)))])))) + (racket->js)) + (cond [coverage-mode? (list (list "" "") (list "" ""))] + [(js-only?) + (define expected-file (path-add-extension fpath ".expected" ".")) + (define expected + (if (file-exists? expected-file) + (file->string expected-file) + "")) + (list (list expected "") + (log-and-return 'nodejs (run-in-nodejs fpath)))] + [else + (list (log-and-return 'racket (run-in-racket fpath)) + (log-and-return 'nodejs (run-in-nodejs fpath)))]))) ;; Path-String -> Void ;; Rackunit check for RacketScript. Executes module at file fpath ;; in Racket and NodeJS and compare their outputs @@ -252,53 +253,80 @@ (empty? failed-tests)) - -;; Runs tests with each kind of option -(define (run tc-search-patterns) - (setup) - (define passed #t) - (define (set-passed! new-value) - (set! passed (and passed new-value))) - - (displayln "-> RacketScript Fixtures Runner <-\n") - (when coverage-mode? (displayln "Running in coverage mode.")) - - (unless coverage-mode? - (parameterize ([enabled-optimizations (set)]) - (displayln "---------------------------------") - (displayln "::: Optimizations on ::: none :::") - (displayln "---------------------------------") - (set-passed! (run-tests (filter-not - (λ (s) (string-contains? s "optimize")) - tc-search-patterns))))) - - ;; (displayln "") - ;; (parameterize ([enabled-optimizations (set self-tail->loop)]) - ;; (displayln "--------------------------------") - ;; (displayln "::: Optimizations on ::: TCO :::") - ;; (displayln "--------------------------------") - ;; (run-tests tc-search-patterns)) - - ;; (displayln "") - ;; (parameterize ([enabled-optimizations (set flatten-if-else)]) - ;; (displayln "--------------------------------------------") - ;; (displayln "::: Optimizations on ::: Flatten If-Else :::") - ;; (displayln "-------------------------------------------") - ;; (run-tests tc-search-patterns)) - - (displayln "") - (parameterize ([enabled-optimizations (set flatten-if-else - self-tail->loop)]) - (displayln "--------------------------------") - (displayln "::: Optimizations on ::: All :::") - (displayln "-------------------------------") - (set-passed! (run-tests tc-search-patterns))) - - (unless passed (exit 1))) +(define-syntax (define-test-case stx) + (syntax-parse stx + [(_ test-name:id + (~optional test-desc:string) + ([param:id value] ...)) + #:do [(define test-name-length (syntax-span #'test-name))] + #`(define test-name + (lambda (paths) + (setup) + (define passed #t) + (define (set-passed! new-value) + (set! passed (and passed new-value))) + + (parameterize ([param value] ...) + (displayln 'test-name) + (displayln (make-string #,test-name-length #\-)) + (displayln test-desc) + (displayln "") + (set-passed! (run-tests paths))) + + (displayln "") + passed))])) + +(define-syntax (run-test-suite stx) + (syntax-parse stx + [(_ test-case ...+ (~seq #:with paths)) + #'(and + (test-case paths) ...)] + [(_ test-case ...+) + #'(and + (test-case) ...)])) + +(define-syntax (fixture-run stx) + (define common + #'(begin + (displayln "") + (displayln "-> RacketScript Fixtures Runner <-\n") + (when coverage-mode? (displayln "Running in coverage mode.")))) + (syntax-parse stx + [(_ test ...+) + #`(begin + #,common + (unless (andmap (lambda (x) x) + (list test ...)) + (exit 1)))])) + +(define-test-case Baseline + "Racket programs without optimization" + ([enabled-optimizations (set)])) + +(define-test-case Optimized + "Racket programs with all optimizations applied" + ([enabled-optimizations (set flatten-if-else + self-tail->loop)])) + +(define-test-case Scheme-Numbers + "Racket programs using scheme number semantics" + ([enabled-optimizations (set)] + [use-scheme-numbers? #t])) + +(define-test-case FFI-Baseline + "FFI tests without optimization" + ([js-only? #t])) + +(define-test-case FFI-Optimized + "FFI tests with all optimizations applied" + ([js-only? #t] + [enabled-optimizations (set flatten-if-else + self-tail->loop)])) (module+ main - ;; For setup we keep this on by default, and later turned off + (define quick? (make-parameter #f)) + ;; For setup we keep this on by default, and later turned off (define tc-search-pattern (command-line #:program "racketscript-fixture" @@ -311,10 +339,19 @@ [("-v" "--verbose") "Show exceptions when running tests." (racketscript-stdout? #t) (verbose? #t)] + [("--js-only") "Compare js output against .expected file." + (js-only? #t)] + [("--quick") "Only run tests with all optimizations applied." + (quick? #t)] #:args (p . ps*) (cons p ps*))) - (run tc-search-pattern)) + (fixture-run + (run-test-suite (if (quick?) + void + Baseline) + Optimized + #:with tc-search-pattern))) (module+ test (define-runtime-path fixture-module "fixture.rkt") @@ -323,14 +360,30 @@ (define (fixture-path-patterns . paths) (for/list ([p paths]) (~a (build-path fixture-module-dir p) "/*.rkt"))) - (run (fixture-path-patterns "racket-core" - "test-the-test" - "basic" - "struct" - "hash" - "wcm" - "modules" - "optimize" - "experimental")) - (parameterize ([js-only? #t]) - (run (fixture-path-patterns "ffi")))) + (define basic-tests + (fixture-path-patterns + "racket-core" + "test-the-test" + "basic" + "struct" + "hash" + "wcm" + "modules" + "experimental")) + + + (fixture-run + + (run-test-suite (if coverage-mode? + void + Baseline) + Scheme-Numbers + #:with basic-tests) + + (run-test-suite Optimized + #:with (append basic-tests + (fixture-path-patterns "optimize"))) + + (run-test-suite FFI-Baseline + FFI-Optimized + #:with (fixture-path-patterns "ffi")))) diff --git a/tests/test-utils.rkt b/tests/test-utils.rkt index 2bd5796e..5dace3c4 100644 --- a/tests/test-utils.rkt +++ b/tests/test-utils.rkt @@ -1,6 +1,10 @@ #lang racket/base -(require (for-syntax racket/base syntax/parse version/utils) + +(require (for-syntax racket/base + syntax/parse + version/utils) syntax/parse/define) + (provide (all-defined-out)) (define-syntax (run-if-version stx) From 4dc26bae5b896da6b02d28861e47b5393739141e Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Wed, 19 Apr 2023 23:42:01 -0400 Subject: [PATCH 55/61] Fix unnecessary 'links' file copying. Fixes a bug where the private/interop module was copied to the build directory if a source file required racketscript/interop. The racketscript/private/interop module includes the #%js-ffi function which raises an error if used in Racket. The compiler overrides this binding with js-ffi calls, so the module never actually needs to be copied to the build directory. --- racketscript-compiler/racketscript/compiler/main.rkt | 10 +++++----- .../racketscript/compiler/transform.rkt | 3 +-- racketscript-compiler/racketscript/compiler/util.rkt | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/main.rkt b/racketscript-compiler/racketscript/compiler/main.rkt index cde9cb4c..bc6b9ec2 100644 --- a/racketscript-compiler/racketscript/compiler/main.rkt +++ b/racketscript-compiler/racketscript/compiler/main.rkt @@ -265,11 +265,11 @@ (when (js-output-beautify?) (system (format "js-beautify -r ~a" (module-output-file next)))) - (for ([mod (in-set (Module-imports ast))]) - (match mod - [(? symbol? _) (void)] - [_ #:when (collects-module? mod) (put-to-pending! mod)] - [_ (put-to-pending! mod)])) + (for ([mod (in-set (Module-imports ast))] + #:unless (or (symbol? mod) + (set-member? ignored-module-imports-in-boot + mod))) + (put-to-pending! mod)) next)) diff --git a/racketscript-compiler/racketscript/compiler/transform.rkt b/racketscript-compiler/racketscript/compiler/transform.rkt index e300e529..547aaa36 100644 --- a/racketscript-compiler/racketscript/compiler/transform.rkt +++ b/racketscript-compiler/racketscript/compiler/transform.rkt @@ -91,8 +91,7 @@ ;; modules (if (or (and (primitive-module? mod-path) ;; a self-import cycle (equal? path (actual-module-path mod-path))) - (and (primitive-module-path? (actual-module-path path)) - (set-member? ignored-module-imports-in-boot mod-path))) + (set-member? ignored-module-imports-in-boot mod-path)) #f (ILRequire import-name mod-obj-name '*)))) diff --git a/racketscript-compiler/racketscript/compiler/util.rkt b/racketscript-compiler/racketscript/compiler/util.rkt index fc6cbd63..b3350a00 100644 --- a/racketscript-compiler/racketscript/compiler/util.rkt +++ b/racketscript-compiler/racketscript/compiler/util.rkt @@ -228,7 +228,6 @@ (build-path (output-directory) "links" name (~a rel-path ".js"))) ;; because we just created root links directory, but files could be ;; deep arbitrarily inside - (make-directory* (assert (path-only output-path) path?)) ;; TODO: doesn't handle arbitrary deep files for now (path->complete-path output-path)] [(list 'general mod-path) From eff8d97d6037d02749c8ef1ff0b3809949f8b9df Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Tue, 23 May 2023 14:11:26 -0400 Subject: [PATCH 56/61] Fix Playground compilation issue (#324) Fixes issue #324 where the racket playground wouldn't compile. Specifically, it fixes a small bug in the implementation of unsafe division. --- racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt b/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt index 1a0c7b12..db8cc125 100644 --- a/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt +++ b/racketscript-compiler/racketscript/compiler/runtime/unsafe.rkt @@ -23,8 +23,7 @@ (define-unsafe-fx-binop+provide unsafe-fx+ +) (define-unsafe-fx-binop+provide unsafe-fx- -) (define-unsafe-fx-binop+provide unsafe-fx* *) -(define+provide unsafe-fxquotient (if-scheme-numbers #js.Core.Number.Scheme.divide - #js.Core.Number.JS.divide)) +(define-unsafe-fx-binop+provide unsafe-fxquotient /) (define-unsafe-fx-binop+provide unsafe-fxremainder %) (define+provide (unsafe-fxmodulo a b) From bb14c0173e7fa762b84a40ee4f9e59c57bb28e8f Mon Sep 17 00:00:00 2001 From: Kyle Clapper <35474281+kclapper@users.noreply.github.com> Date: Tue, 23 May 2023 16:09:09 -0400 Subject: [PATCH 57/61] Revert "Fix unnecessary 'links' file copying." This reverts commit 4dc26bae5b896da6b02d28861e47b5393739141e. --- racketscript-compiler/racketscript/compiler/main.rkt | 10 +++++----- .../racketscript/compiler/transform.rkt | 3 ++- racketscript-compiler/racketscript/compiler/util.rkt | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/racketscript-compiler/racketscript/compiler/main.rkt b/racketscript-compiler/racketscript/compiler/main.rkt index 0d331a50..734aed99 100644 --- a/racketscript-compiler/racketscript/compiler/main.rkt +++ b/racketscript-compiler/racketscript/compiler/main.rkt @@ -266,11 +266,11 @@ (when (js-output-beautify?) (system (format "js-beautify -r ~a" (module-output-file next)))) - (for ([mod (in-set (Module-imports ast))] - #:unless (or (symbol? mod) - (set-member? ignored-module-imports-in-boot - mod))) - (put-to-pending! mod)) + (for ([mod (in-set (Module-imports ast))]) + (match mod + [(? symbol? _) (void)] + [_ #:when (collects-module? mod) (put-to-pending! mod)] + [_ (put-to-pending! mod)])) next)) diff --git a/racketscript-compiler/racketscript/compiler/transform.rkt b/racketscript-compiler/racketscript/compiler/transform.rkt index 7a4ab6a9..e0552e3e 100644 --- a/racketscript-compiler/racketscript/compiler/transform.rkt +++ b/racketscript-compiler/racketscript/compiler/transform.rkt @@ -91,7 +91,8 @@ ;; modules (if (or (and (primitive-module? mod-path) ;; a self-import cycle (equal? path (actual-module-path mod-path))) - (set-member? ignored-module-imports-in-boot mod-path)) + (and (primitive-module-path? (actual-module-path path)) + (set-member? ignored-module-imports-in-boot mod-path))) #f (ILRequire import-name mod-obj-name '*)))) diff --git a/racketscript-compiler/racketscript/compiler/util.rkt b/racketscript-compiler/racketscript/compiler/util.rkt index b3350a00..fc6cbd63 100644 --- a/racketscript-compiler/racketscript/compiler/util.rkt +++ b/racketscript-compiler/racketscript/compiler/util.rkt @@ -228,6 +228,7 @@ (build-path (output-directory) "links" name (~a rel-path ".js"))) ;; because we just created root links directory, but files could be ;; deep arbitrarily inside + (make-directory* (assert (path-only output-path) path?)) ;; TODO: doesn't handle arbitrary deep files for now (path->complete-path output-path)] [(list 'general mod-path) From cb1a83e2205cb0e4942ae909d80047014073c473 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Mon, 12 Jun 2023 13:56:24 -0400 Subject: [PATCH 58/61] Update node.js.yml to use v18 --- .github/workflows/node.js.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 7ae19168..360369ee 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -11,11 +11,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [14] + node-version: [18] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm ci From aace12fbd6711da9ee83d0edf6f99429fe2a9cac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jul 2023 12:52:41 +0000 Subject: [PATCH 59/61] Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 96b04128..38a9494a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1549,9 +1549,9 @@ } }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -2749,9 +2749,9 @@ } }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true }, "wrappy": { From c057b8c010af88c9e8a794108247ac2e40afc287 Mon Sep 17 00:00:00 2001 From: leiDnedyA Date: Thu, 31 Aug 2023 11:44:33 -0400 Subject: [PATCH 60/61] added name handler to rs/htdp/universe big-bang --- .../racketscript/htdp/universe.rkt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/racketscript-extras/racketscript/htdp/universe.rkt b/racketscript-extras/racketscript/htdp/universe.rkt index e41d8be4..8bbc9280 100644 --- a/racketscript-extras/racketscript/htdp/universe.rkt +++ b/racketscript-extras/racketscript/htdp/universe.rkt @@ -11,6 +11,7 @@ to-draw stop-when big-bang + name key=? mouse=?) @@ -382,3 +383,17 @@ (equal? k1 k2)) (define (mouse=? m1 m2) (equal? m1 m2)) + +(define (name name) + (λ (bb) + ($/obj + [name #js"name"] + [register + (λ () + #:with-this this + (:= #js.this.old-title #js*.document.title) + (:= #js*.document.title (js-string name)))] + [deregister + (λ () + #:with-this this + (:= #js*.document.title #js.this.old-title))]))) \ No newline at end of file From 1edf2415abec7db3ec7e4f197da5b26d0a91969b Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Tue, 17 Feb 2026 17:46:45 -0500 Subject: [PATCH 61/61] 2htdp: add "transparent" color --- racketscript-extras/racketscript/htdp/private/color.rkt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/racketscript-extras/racketscript/htdp/private/color.rkt b/racketscript-extras/racketscript/htdp/private/color.rkt index dfca1300..2bec772b 100644 --- a/racketscript-extras/racketscript/htdp/private/color.rkt +++ b/racketscript-extras/racketscript/htdp/private/color.rkt @@ -207,4 +207,5 @@ ["darkgray" (-color 169 169 169)] ["dim gray" (-color 105 105 105)] ["dimgray" (-color 105 105 105)] - ["black" (-color 0 0 0)])) + ["black" (-color 0 0 0)] + ["transparent" (-color 0 0 0 0)]))