diff --git a/.snapshots/should_build_all_internal_JS_functions/golden b/.snapshots/should_build_all_internal_JS_functions/golden index 80b14d741..23e72bde6 100644 --- a/.snapshots/should_build_all_internal_JS_functions/golden +++ b/.snapshots/should_build_all_internal_JS_functions/golden @@ -185,6 +185,17 @@ global.__listToJSArray__ = (list) => { return res } +global.__jsArrayToList__ = (arr) => { + let res = null + + for (let i = arr.length - 1; i >= 0; i--) { + let head = { v: arr[i], n: res } + res = head + } + + return res +} + global.__listCtorSpread__ = (_spread, _next) => { if (_spread === null) { return _next; diff --git a/.snapshots/should_include_coverage_trackers_when_coverage_is_True/golden b/.snapshots/should_include_coverage_trackers_when_coverage_is_True/golden index 0f09349e4..f359bb1f5 100644 --- a/.snapshots/should_include_coverage_trackers_when_coverage_is_True/golden +++ b/.snapshots/should_include_coverage_trackers_when_coverage_is_True/golden @@ -185,6 +185,17 @@ global.__listToJSArray__ = (list) => { return res } +global.__jsArrayToList__ = (arr) => { + let res = null + + for (let i = arr.length - 1; i >= 0; i--) { + let head = { v: arr[i], n: res } + res = head + } + + return res +} + global.__listCtorSpread__ = (_spread, _next) => { if (_spread === null) { return _next; diff --git a/compiler/main/Generate/JSInternals.hs b/compiler/main/Generate/JSInternals.hs index 7a788a3c6..dbae2e783 100644 --- a/compiler/main/Generate/JSInternals.hs +++ b/compiler/main/Generate/JSInternals.hs @@ -30,6 +30,8 @@ generateInternalsModuleContent target optimized coverage = <> "\n" <> listToJSArray target <> "\n" + <> jsArrayToList target + <> "\n" <> listConstructorSpreadFn target <> "\n" <> if coverage then "\n" <> hpFnWrap <> "\n" <> hpLineWrap else "" @@ -269,6 +271,21 @@ listToJSArray target = , "}" ] +jsArrayToList :: Target -> String +jsArrayToList target = + unlines + [ getGlobalForTarget target <> "." <> "__jsArrayToList__ = (arr) => {" + , " let res = null" + , "" + , " for (let i = arr.length - 1; i >= 0; i--) {" + , " let head = { v: arr[i], n: res }" + , " res = head" + , " }" + , "" + , " return res" + , "}" + ] + listConstructorSpreadFn :: Target -> String listConstructorSpreadFn target = unlines diff --git a/compiler/main/Parse/Madlib/Lexer.x b/compiler/main/Parse/Madlib/Lexer.x index ac304760f..2982d18ef 100644 --- a/compiler/main/Parse/Madlib/Lexer.x +++ b/compiler/main/Parse/Madlib/Lexer.x @@ -536,6 +536,7 @@ mapToken tokenizer (posn, prevChar, pending, input) len = do TokenLeftDoubleCurly -> if sc /= instanceHeader then do + pushStartCode 0 pushStartCode 0 return TokenLeftDoubleCurly else diff --git a/madlib.cabal b/madlib.cabal index b2c49cab3..51d8d7a20 100644 --- a/madlib.cabal +++ b/madlib.cabal @@ -4,10 +4,10 @@ cabal-version: 2.0 -- -- see: https://github.com/sol/hpack -- --- hash: 3c36d8ff8b835f63fa4e6f5a0d2d964b8ddb4de47e5e6c47dac1b4f6197d532f +-- hash: 29c5cc1908364a493c67fa28b063e90f6353a77b6c85e6fa590f941d36977473 name: madlib -version: 0.13.5 +version: 0.13.6 description: Please see the README on GitHub at homepage: https://github.com/madlib-lang/madlib#readme bug-reports: https://github.com/madlib-lang/madlib/issues diff --git a/package.yaml b/package.yaml index 4ebfd7886..a42647452 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: madlib -version: 0.13.5 +version: 0.13.6 github: "madlib-lang/madlib" license: BSD3 author: "Arnaud Boeglin, Brekk Bockrath" diff --git a/pkg/package.json b/pkg/package.json index 80eb8e3f3..94c84bc00 100644 --- a/pkg/package.json +++ b/pkg/package.json @@ -1,6 +1,6 @@ { "name": "@madlib-lang/madlib", - "version": "0.13.5", + "version": "0.13.6", "main": "./src/run.js", "bin": { "madlib": "src/run.js"