crosslang/golang-lean/GolangLean/Value.lean
Maximus Gorog fd3d42ae33 Add 'golang-lean/' from commit 'f5f17019224c6a6c319387214ceb8e29d09251c6'
git-subtree-dir: golang-lean
git-subtree-mainline: 6487c7046f
git-subtree-split: f5f1701922
2026-05-12 02:59:14 -06:00

34 lines
1.1 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import GolangLean.AST
namespace GolangLean
/-! # Runtime values.
Go is statically typed, so a faithful runtime keeps a `GoType` alongside each
value. For the first cut we keep things untyped (a tagged union) and recover
type safety later by adding a static type-checker pass on the AST. The shape
mirrors octive-lean's `Value`. -/
mutual
inductive Value where
| nil
| boolV : Bool → Value
| intV : Int → Value
| floatV : Float → Value
| stringV : String → Value
| sliceV : Array Value → Value
| mapV : Array (Value × Value) → Value -- ordered list, equality via key
| structV : Array (String × Value) → Value
| ptrV : Nat → Value -- index into heap
| funcV : Closure → Value
| chanV : Nat → Value -- index into channel table
| tupleV : Array Value → Value -- multi-return packs
/-- A function closure: signature + body + captured environment. -/
inductive Closure where
| mk : FuncType → Array Stmt → List (String × Value) → Closure
end
end GolangLean