Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Array-based List type #2154

Draft
wants to merge 3 commits into
base: fable3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ let buildLibraryIfNotExists() =
if not (pathExists (baseDir </> "build/fable-library")) then
buildLibrary()

// runFableWithArgs ("watch " + libDir) [
// "--outDir " + buildDir
// "--fableLib " + buildDir
// "--exclude Fable.Core"
// "--define FX_NO_BIGINT"
// "--define FABLE_LIBRARY"
// ]

let buildLibraryTs() =
let projectDir = "src/fable-library"
let buildDirTs = "build/fable-library-ts"
Expand Down Expand Up @@ -178,6 +186,7 @@ let testJsFast() =
]

runFableWithArgs "src/fable-compiler-js/src" [
"--forcePkgs"
"--exclude Fable.Core"
"--define LOCAL_TEST"
]
Expand Down
12 changes: 6 additions & 6 deletions src/Fable.Transforms/Fable2Babel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -943,13 +943,13 @@ module Util =
| [TransformExpr com ctx expr], None ->
libCall com ctx r "List" "singleton" [|expr|]
| exprs, None ->
[|makeArray com ctx exprs|]
|> libCall com ctx r "List" "ofArray"
[|List.rev exprs |> makeArray com ctx|]
|> libCall com ctx r "List" "newList"
| [TransformExpr com ctx head], Some(TransformExpr com ctx tail) ->
libCall com ctx r "List" "cons" [|head; tail|]
| exprs, Some(TransformExpr com ctx tail) ->
[|makeArray com ctx exprs; tail|]
|> libCall com ctx r "List" "ofArrayWithTail"
[|List.rev exprs |> makeArray com ctx; tail|]
|> libCall com ctx r "List" "newListWithTail"
| Fable.NewOption (value, t) ->
match value with
| Some (TransformExpr com ctx e) ->
Expand Down Expand Up @@ -1204,11 +1204,11 @@ module Util =

| Fable.ListHead ->
// get range (com.TransformAsExpr(ctx, fableExpr)) "head"
libCall com ctx range "List" "head" [|com.TransformAsExpr(ctx, fableExpr)|]
libCall com ctx range "List" "head_" [|com.TransformAsExpr(ctx, fableExpr)|]

| Fable.ListTail ->
// get range (com.TransformAsExpr(ctx, fableExpr)) "tail"
libCall com ctx range "List" "tail" [|com.TransformAsExpr(ctx, fableExpr)|]
libCall com ctx range "List" "tail_" [|com.TransformAsExpr(ctx, fableExpr)|]

| Fable.TupleIndex index ->
match fableExpr with
Expand Down
Loading