Skip to content

Commit

Permalink
Handle match in new interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
StachuDotNet committed Aug 15, 2024
1 parent 4b5b486 commit 6ae7196
Show file tree
Hide file tree
Showing 15 changed files with 1,475 additions and 1,052 deletions.
3 changes: 1 addition & 2 deletions backend/src/BuiltinExecution/Builtin.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ let fnRenames =

let builtins : Builtins =
Builtin.combine
[
// Libs.NoModule.builtins
[ Libs.NoModule.builtins

// Libs.Bool.builtins

Expand Down
2 changes: 1 addition & 1 deletion backend/src/BuiltinExecution/BuiltinExecution.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<None Include="paket.references" />

<!--Compile Include="Libs/NoModule.fs" /-->
<Compile Include="Libs/NoModule.fs" />

<!--Compile Include="Libs/Bool.fs" /-->

Expand Down
69 changes: 34 additions & 35 deletions backend/src/BuiltinExecution/Libs/Int64.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,42 @@ module PackageIDs = LibExecution.PackageIDs


let fns : List<BuiltInFn> =
[
// { name = fn "int64Mod" 0
// typeParams = []
// parameters = [ Param.make "a" TInt64 ""; Param.make "b" TInt64 "" ]
// returnType = TInt64
// description =
// "Returns the result of wrapping <param a> around so that {{0 <= res < b}}.
[ { name = fn "int64Mod" 0
typeParams = []
parameters = [ Param.make "a" TInt64 ""; Param.make "b" TInt64 "" ]
returnType = TInt64
description =
"Returns the result of wrapping <param a> around so that {{0 <= res < b}}.
// The modulus <param b> must be greater than 0.
The modulus <param b> must be greater than 0.
// Use <fn Int64.remainder> if you want the remainder after division, which has
// a different behavior for negative numbers."
// fn =
// (function
// | state, _, [ DInt64 v; DInt64 m ] ->
// if m = 0L then
// IntRuntimeError.Error.ZeroModulus
// |> IntRuntimeError.RTE.toRuntimeError
// |> raiseRTE state.tracing.callStack
// |> Ply
// else if m < 0L then
// IntRuntimeError.Error.NegativeModulus
// |> IntRuntimeError.RTE.toRuntimeError
// |> raiseRTE state.tracing.callStack
// |> Ply
// else
// let result = v % m
// let result = if result < 0L then m + result else result
// Ply(DInt64(result))
// | _ -> incorrectArgs ())
// sqlSpec = SqlBinOp "%"
// previewable = Pure
// // TODO: Deprecate this when we can version infix operators
// // and when infix operators support Result return types
// // (https://github.com/darklang/dark/issues/4267)
// // The current function returns an RTE (it used to rollbar) on negative `b`.
// deprecated = NotDeprecated }
Use <fn Int64.remainder> if you want the remainder after division, which has
a different behavior for negative numbers."
fn =
(function
| _state, _, _, [ DInt64 v; DInt64 m ] ->
// if m = 0L then
// IntRuntimeError.Error.ZeroModulus
// |> IntRuntimeError.RTE.toRuntimeError
// |> raiseRTE state.tracing.callStack
// |> Ply
// else if m < 0L then
// IntRuntimeError.Error.NegativeModulus
// |> IntRuntimeError.RTE.toRuntimeError
// |> raiseRTE state.tracing.callStack
// |> Ply
// else
let result = v % m
let result = if result < 0L then m + result else result
Ply(DInt64(result))
| _ -> incorrectArgs ())
//sqlSpec = SqlBinOp "%"
previewable = Pure
// TODO: Deprecate this when we can version infix operators
// and when infix operators support Result return types
// (https://github.com/darklang/dark/issues/4267)
// The current function returns an RTE (it used to rollbar) on negative `b`.
deprecated = NotDeprecated }


// See above for when to uncomment this
Expand Down
Loading

0 comments on commit 6ae7196

Please sign in to comment.