-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/Visp.Compiler.UnitTests/snapshots/tests_while_while-1.can parse.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// This file is auto-generated | ||
|
||
#nowarn "0020" // unused results from functions | ||
|
||
open Visp.Runtime.Library | ||
|
||
let state = { Todo = () } | ||
// line 8 @"while-1.visp" | ||
let inline DiffByOne (lhs: array<'T>) (rhs: array<'T>) = | ||
// line 9 @"while-1.visp" | ||
let mutable index = 0 | ||
// line 10 @"while-1.visp" | ||
let mutable loop = true | ||
// line 11 @"while-1.visp" | ||
let mutable diff = 0 | ||
// line 13 @"while-1.visp" | ||
while CoreMethods.isTruthy( | ||
if CoreMethods.isTruthy( | ||
loop) | ||
then | ||
// line 13 @"while-1.visp" | ||
CoreMethods.``lt``(index, (lhs.Length)) | ||
else | ||
false) do | ||
// line 14 @"while-1.visp" | ||
let lhs = | ||
// line 14 @"while-1.visp" | ||
(lhs.[index]) | ||
// line 15 @"while-1.visp" | ||
let rhs = | ||
// line 15 @"while-1.visp" | ||
(rhs.[index]) | ||
// line 17 @"while-1.visp" | ||
if CoreMethods.isTruthy( | ||
CoreMethods.``not``(CoreMethods.``eq?``(lhs, rhs))) | ||
then | ||
// line 17 @"while-1.visp" | ||
|
||
// line 17 @"while-1.visp" | ||
diff <- inc (diff) | ||
// line 20 @"while-1.visp" | ||
if CoreMethods.isTruthy( | ||
CoreMethods.``gt``(diff, 1)) | ||
then | ||
// line 20 @"while-1.visp" | ||
|
||
// line 20 @"while-1.visp" | ||
loop <- false | ||
// line 23 @"while-1.visp" | ||
index <- inc (index) | ||
// line 26 @"while-1.visp" | ||
CoreMethods.``eq?``(diff, 1) | ||
|
||
// line 29 @"while-1.visp" | ||
let visp_result_todo = | ||
// line 29 @"while-1.visp" | ||
printfn ("OK") | ||
// line 29 @"while-1.visp" | ||
printfn ("%A") (visp_result_todo) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/Visp.ExecutionTests/snapshots/tests_while_while-1.can execute.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
OK | ||
() | ||
|
||
ExitCode: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
;; Copyright 2023 Ville Penttinen | ||
;; Distributed under the MIT License. | ||
;; https://github.com/vipentti/visp-fs/blob/main/LICENSE.md | ||
;; | ||
;; for basic syntax highlighting | ||
;; vim: set syntax=clojure: | ||
|
||
(fn inline DiffByOne ([lhs: array<^T>] [rhs: array<^T>]) | ||
(mut index 0) | ||
(mut loop true) | ||
(mut diff 0) | ||
|
||
(while (and loop (< index (+Length lhs))) | ||
(let lhs (.[index] lhs)) | ||
(let rhs (.[index] rhs)) | ||
|
||
(unless (= lhs rhs) | ||
(set! diff (inc diff))) | ||
|
||
(when (> diff 1) | ||
(set! loop false)) | ||
|
||
(set! index (inc index)) | ||
) | ||
|
||
(= diff 1)) | ||
|
||
|
||
(printfn "OK") |