Skip to content

Commit

Permalink
Add go globals implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
upamanyus committed Dec 5, 2024
1 parent 8e16dbb commit 1639e56
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion new/golang/defn.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From Perennial.goose_lang Require Export lang notation.
From New.golang.defn Require Export exception list typing noop loop struct mem
slice map string interface defer chan builtin array.
slice map string interface defer chan builtin array globals.
Open Scope struct_scope.
24 changes: 24 additions & 0 deletions new/golang/defn/globals.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From New.golang.defn Require Export mem typing.

Module globals.
Section defns.
Context `{ffi_syntax}.

Definition get : val :=
λ: "x", match: GlobalGet "x" with
SOME "x" => "x"
| NONE => #() #()
end.

Definition put: val :=
λ: "x" "y", GlobalPut "x" "y".

Definition is_uninitialized : val :=
λ: "pkgId",
match: GlobalGet "pkgId" with
SOME <> => #false
| NONE => #true
end.

End defns.
End globals.

0 comments on commit 1639e56

Please sign in to comment.