|
| 1 | +namespace Fable.Core.Quotations |
| 2 | + |
| 3 | +/// Serializable representation of literal values in quotations. |
| 4 | +/// All cases use primitive types for reliable cross-platform JSON serialization. |
| 5 | +[<RequireQualifiedAccess>] |
| 6 | +type QuotLiteral = |
| 7 | + | Bool of bool |
| 8 | + | SByte of sbyte |
| 9 | + | Byte of byte |
| 10 | + | Int16 of int16 |
| 11 | + | UInt16 of uint16 |
| 12 | + | Int of int |
| 13 | + | UInt32 of uint32 |
| 14 | + | Int64 of int64 |
| 15 | + | UInt64 of uint64 |
| 16 | + | Float32 of float32 |
| 17 | + | Float of float |
| 18 | + | Char of char |
| 19 | + | String of string |
| 20 | + | Decimal of decimal |
| 21 | + | Unit |
| 22 | + | Null of typeName: string |
| 23 | + |
| 24 | +/// Serializable representation of an F# quotation variable. |
| 25 | +type QuotVar = |
| 26 | + { |
| 27 | + Name: string |
| 28 | + Type: string |
| 29 | + IsMutable: bool |
| 30 | + } |
| 31 | + |
| 32 | +/// Serializable representation of an F# quotation expression tree. |
| 33 | +/// Designed for cross-platform JSON serialization via Thoth.Json or Fable.Remoting. |
| 34 | +/// On Fable/JS: constructed by the compiler when you write <@ expr @>. |
| 35 | +/// On .NET: deserialize from JSON using the same type definitions. |
| 36 | +[<RequireQualifiedAccess>] |
| 37 | +type QuotExpr = |
| 38 | + | Value of literal: QuotLiteral |
| 39 | + | Var of var: QuotVar |
| 40 | + | Lambda of var: QuotVar * body: QuotExpr |
| 41 | + | Application of func: QuotExpr * arg: QuotExpr |
| 42 | + | Let of var: QuotVar * value: QuotExpr * body: QuotExpr |
| 43 | + | LetRecursive of bindings: (QuotVar * QuotExpr) array * body: QuotExpr |
| 44 | + | IfThenElse of guard: QuotExpr * thenExpr: QuotExpr * elseExpr: QuotExpr |
| 45 | + | Call of instance: QuotExpr option * methodName: string * declaringType: string * args: QuotExpr array |
| 46 | + | Sequential of first: QuotExpr * second: QuotExpr |
| 47 | + | NewTuple of elements: QuotExpr array |
| 48 | + | TupleGet of tuple: QuotExpr * index: int |
| 49 | + | NewUnionCase of typeName: string * tag: int * fields: QuotExpr array |
| 50 | + | UnionCaseTag of expr: QuotExpr |
| 51 | + | UnionCaseField of expr: QuotExpr * index: int |
| 52 | + | NewRecord of typeName: string * fieldNames: string array * fields: QuotExpr array |
| 53 | + | FieldGet of instance: QuotExpr option * fieldName: string |
| 54 | + | FieldSet of instance: QuotExpr option * fieldName: string * value: QuotExpr |
| 55 | + | VarSet of var: QuotVar * value: QuotExpr |
| 56 | + | NewList of elements: QuotExpr array * elementType: string |
| 57 | + | NewOption of value: QuotExpr option * elementType: string |
0 commit comments