diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-03-22 09:54:27 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-03-22 10:16:02 +0000 |
| commit | 47442811098a6ed4d8a6ae80f06c13f47451a4d9 (patch) | |
| tree | 4e7549a4816ed082719da49d7ebab10cb91f9b22 /flatbuffers | |
| parent | 6e2425bfc5ad9bfac68289a9dcc2cccee1441fd9 (diff) | |
Add flatbuffers schema
Diffstat (limited to 'flatbuffers')
| -rw-r--r-- | flatbuffers/patio.fbs | 484 | ||||
| -rw-r--r-- | flatbuffers/sources.fbs | 25 |
2 files changed, 509 insertions, 0 deletions
diff --git a/flatbuffers/patio.fbs b/flatbuffers/patio.fbs new file mode 100644 index 00000000..7ffcb051 --- /dev/null +++ b/flatbuffers/patio.fbs @@ -0,0 +1,484 @@ +include "sources.fbs"; + +namespace Patio; + +// == Data layouts == + +union PatioDataLayout { + PatioDataLayoutArray, + PatioDataLayoutBool, + PatioDataLayoutByte, + PatioDataLayoutDataPtr, + PatioDataLayoutFunctionPtr, + PatioDataLayoutInt, + PatioDataLayoutInt32, + PatioDataLayoutStruct, +} + +table PatioDataLayoutArray { + element:PatioDataLayout; + size:uint; +} + +table PatioDataLayoutBool { +} + +table PatioDataLayoutByte { +} + +table PatioDataLayoutDataPtr { +} + +table PatioDataLayoutFunctionPtr { +} + +table PatioDataLayoutInt { +} + +table PatioDataLayoutInt32 { +} + +table PatioDataLayoutStruct { + elements:[PatioDataLayout]; +} + +// == Data ptr values == + +union PatioDataPtrValue { + PatioDataPtrValueDataElement, + PatioDataPtrValueNull, +} + +table PatioDataPtrValueDataElement { + name:string; +} + +table PatioDataPtrValueNull { +} + +// == Int values == + +union PatioIntValue { + PatioIntValueByteOffsetOf, + PatioIntValueByteSizeOf, + PatioIntValueLiteral, +} + +table PatioIntValueByteOffsetOf { + layout:PatioDataLayout; + offset:[uint]; +} + +table PatioIntValueByteSizeOf { + layout:PatioDataLayout; +} + +table PatioIntValueLiteral { + value:int; +} + +// == Data values == + +union PatioDataValue { + PatioDataValueArray, + PatioDataValueBool, + PatioDataValueByte, + PatioDataValueDataPtr, + PatioDataValueInt, + PatioDataValueInt32, + PatioDataValueStruct, +} + +table PatioDataValueArray { + element_layout:PatioDataLayout; + elements:[PatioDataValue]; +} + +table PatioDataValueBool { + value:bool; +} + +table PatioDataValueByte { + value:uint; +} + +table PatioDataValueDataPtr { + value:PatioDataPtrValue; +} + +table PatioDataValueInt { + value:PatioIntValue; +} + +table PatioDataValueInt32 { + value:PatioIntValue; +} + +table PatioDataValueStruct { + elements:[PatioDataValue]; +} + +// == Types == + +union PatioType { + PatioBoolType, + PatioByteType, + PatioDataPtrType, + PatioFunctionPtrType, + PatioIntType, + PatioInt32Type, + PatioVoidType, +} + +table PatioBoolType { +} + +table PatioByteType { +} + +table PatioDataPtrType { +} + +table PatioFunctionPtrType { +} + +table PatioIntType { +} + +table PatioInt32Type { +} + +table PatioVoidType { +} + +// == Operands == + +union PatioOperand { + PatioBoolConst, + PatioByteConst, + PatioDataPtrConst, + PatioFunctionPtrConst, + PatioIntConst, + PatioInt32Const, + PatioLocalRef, +} + +table PatioBoolConst { + value:bool; +} + +table PatioByteConst { + value:uint; +} + +table PatioDataPtrConst { + value:PatioDataPtrValue; +} + +table PatioFunctionPtrConst { + name:string; +} + +table PatioIntConst { + value:PatioIntValue; +} + +table PatioInt32Const { + value:PatioIntValue; +} + +table PatioLocalRef { + name:string; +} + +// == Instructions == + +union PatioInstruction { + PatioBlock, + PatioBoolToInt, + PatioCall, + PatioCallPointer, + PatioDataPtrToInt, + PatioIf, + PatioIntAdd, + PatioIntEquals, + PatioIntNotEqual, + PatioIntSub, + PatioIntToBool, + PatioIntToDataPtr, + PatioLocalStore, + PatioLoop, + PatioLoopBreak, + PatioLoopContinue, + PatioMemoryLoad, + PatioMemoryStore, + PatioResume, + PatioReturn, + PatioReturnVoid, + PatioSwitch, + PatioThrow, + PatioTry, + PatioUnreachable, + PatioVarLoad, + PatioVarStore, +} + +table PatioBlock { + source:Sources.Source; + body:[PatioInstruction]; + results:[PatioOperand]; +} + +table PatioBoolToInt { + source:Sources.Source; + destination:PatioLocalRef; + value:PatioOperand; +} + +table PatioCall { + source:Sources.Source; + destination:PatioLocalRef; + function_name:string; + args:[PatioOperand]; +} + +table PatioCallPointer { + source:Sources.Source; + destination:PatioLocalRef; + function_pointer:PatioOperand; + args:[PatioOperand]; +} + +table PatioDataPtrToInt { + source:Sources.Source; + destination:PatioLocalRef; + value:PatioOperand; +} + +table PatioIf { + source:Sources.Source; + destinations:[PatioLocalRef]; + condition:PatioOperand; + true_body:PatioBlock; + false_body:PatioBlock; +} + +table PatioIntAdd { + source:Sources.Source; + destination:PatioLocalRef; + left:PatioOperand; + right:PatioOperand; +} + +table PatioIntEquals { + source:Sources.Source; + destination:PatioLocalRef; + left:PatioOperand; + right:PatioOperand; +} + +table PatioIntNotEqual { + source:Sources.Source; + destination:PatioLocalRef; + left:PatioOperand; + right:PatioOperand; +} + +table PatioIntSub { + source:Sources.Source; + destination:PatioLocalRef; + left:PatioOperand; + right:PatioOperand; +} + +table PatioIntToBool { + source:Sources.Source; + destination:PatioLocalRef; + value:PatioOperand; +} + +table PatioIntToDataPtr { + source:Sources.Source; + destination:PatioLocalRef; + value:PatioOperand; +} + +table PatioLocalStore { + source:Sources.Source; + destination:PatioLocalRef; + value:PatioOperand; +} + +table PatioLoop { + source:Sources.Source; + body:[PatioInstruction]; +} + +table PatioLoopBreak { + source:Sources.Source; +} + +table PatioLoopContinue { + source:Sources.Source; +} + +table PatioMemoryLoad { + source:Sources.Source; + destination:PatioLocalRef; + pointer:PatioOperand; + layout:PatioDataLayout; + offset:[uint]; +} + +table PatioMemoryStore { + source:Sources.Source; + pointer:PatioOperand; + layout:PatioDataLayout; + offset:[uint]; + value:PatioOperand; +} + +table PatioResume { + source:Sources.Source; + value:PatioOperand; +} + +table PatioReturn { + source:Sources.Source; + value:PatioOperand; +} + +table PatioReturnVoid { + source:Sources.Source; +} + +table PatioSwitch { + source:Sources.Source; + destinations:[PatioLocalRef]; + value:PatioOperand; + cases:[PatioSwitchCase]; + default_body:PatioBlock; +} + +table PatioSwitchCase { + source:Sources.Source; + value:uint; + body:PatioBlock; +} + +table PatioThrow { + source:Sources.Source; + exception_type_name:string; + value:PatioOperand; +} + +table PatioTry { + source:Sources.Source; + destinations:[PatioLocalRef]; + catch_clauses:[PatioCatchClause]; + body:PatioBlock; +} + +table PatioCatchClause { + source:Sources.Source; + exception_type_name:string; + destination:PatioLocalRef; + body:PatioBlock; +} + +table PatioUnreachable { + source:Sources.Source; +} + +table PatioVarLoad { + source:Sources.Source; + destination:PatioLocalRef; + var:PatioLocalRef; +} + +table PatioVarStore { + source:Sources.Source; + var:PatioLocalRef; + value:PatioOperand; +} + +// == Visibility == + +enum PatioVisibility : int { + PRIVATE = 0, + PUBLIC = 1, +} + +// == Locals == + +enum PatioLocalType : int { + PARAM = 0, + VAL = 1, + VAR = 2, +} + +table PatioLocal { + name:string; + type:PatioType; + local_type:PatioLocalType; +} + +// == Compilation unit elements == + +union PatioCompilationUnitElement { + PatioDataElementImmutableDefinition, + PatioDataElementMutableDeclaration, + PatioDataElementMutableDefinition, + PatioExceptionTypeDefinition, + PatioFunctionDeclaration, + PatioFunctionDefinition, +} + +table PatioDataElementImmutableDefinition { + source:Sources.Source; + name:string; + visibility:PatioVisibility; + value:PatioDataValue; +} + +table PatioDataElementMutableDeclaration { + source:Sources.Source; + name:string; + layout:PatioDataLayout; +} + +table PatioDataElementMutableDefinition { + source:Sources.Source; + name:string; + visibility:PatioVisibility; + initial_value:PatioDataValue; +} + +table PatioExceptionTypeDefinition { + source:Sources.Source; + name:string; + value_type:PatioType; +} + +table PatioFunctionDeclaration { + source:Sources.Source; + name:string; + params:[PatioLocal]; + return_type:PatioType; +} + +table PatioFunctionDefinition { + source:Sources.Source; + name:string; + visibility:PatioVisibility; + locals:[PatioLocal]; + return_type:PatioType; + body:[PatioInstruction]; +} + +// == Compilation unit == + +table PatioCompilationUnit { + source:Sources.Source; + elements:[PatioCompilationUnitElement]; +} diff --git a/flatbuffers/sources.fbs b/flatbuffers/sources.fbs new file mode 100644 index 00000000..b39d65f5 --- /dev/null +++ b/flatbuffers/sources.fbs @@ -0,0 +1,25 @@ +namespace Sources; + +union Source { + NullSource, + RuntimeSource, + FileFragmentSource, +} + +table NullSource { +} + +table RuntimeSource { +} + +table FileFragmentSource { + source_text:SourceText; + start_character_index:uint; + end_character_index:uint; +} + +table SourceText { + name:string; + contents:string; +} + |
