Skip to content

Commit

Permalink
Move code to replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrattli committed Nov 28, 2023
1 parent cd5d962 commit 2293f71
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
27 changes: 0 additions & 27 deletions src/Fable.Transforms/Python/Fable2Python.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3959,14 +3959,6 @@ module Util =
_,
_range) -> transformAsArray com ctx expr info

| Fable.Call(Fable.Get(expr, Fable.FieldGet { Name = name }, _, _),
_info,
_,
_range) when name.ToLower() = "tostring" ->
let func = Expression.name "str"
let left, stmts = com.TransformAsExpr(ctx, expr)
Expression.call (func, [ left ]), stmts

| Fable.Call(Fable.Get(expr, Fable.FieldGet { Name = "Equals" }, _, _),
{ Args = [ arg ] },
_,
Expand All @@ -3975,25 +3967,6 @@ module Util =
let left, stmts' = com.TransformAsExpr(ctx, expr)
Expression.compare (left, [ Eq ], [ right ]), stmts @ stmts'

| Fable.Call(Fable.Get(expr, Fable.FieldGet { Name = "split" }, _, _),
{ Args = [ Fable.Value(kind = Fable.StringConstant "") ] },
_,
_range) ->
let func = Expression.name "list"
let value, stmts = com.TransformAsExpr(ctx, expr)
Expression.call (func, [ value ]), stmts

| Fable.Call(Fable.Get(expr,
Fable.FieldGet { Name = "charCodeAt" },
_,
_),
_info,
_,
_range) ->
let func = Expression.name "ord"
let value, stmts = com.TransformAsExpr(ctx, expr)
Expression.call (func, [ value ]), stmts

| Fable.Call(callee, info, _, range) ->
transformCall com ctx range callee info

Expand Down
4 changes: 3 additions & 1 deletion src/Fable.Transforms/Python/Replacements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,9 @@ let toList com returnType expr =
Helper.LibCall(com, "list", "ofSeq", returnType, [ expr ])

let stringToCharArray t e =
Helper.InstanceCall(e, "split", t, [ makeStrConst "" ])
//Helper.InstanceCall(e, "split", t, [ makeStrConst "" ])
// Write as global call `list` instead
Helper.GlobalCall("list", t, [ e ])

let toSeq t (e: Expr) =
match e.Type with
Expand Down

0 comments on commit 2293f71

Please sign in to comment.