STUDIO HAZE · topaz
Topaz source
Open by house policy. Topaz is our own language.
Topaz 5.20 · 56 files
compiler/crates/topaz_self_frontend/topaz/stage1_types.tpz
Topaz · 3875 B · Original file
1
import types { PreviewTypeAtom }3
export const STAGE1_EXCHANGE_SCHEMA = "topaz.compiler.stage1-exchange/v2"4
export const STAGE1_IR_SCHEMA = "topaz.compiler.stage1-ir/v5"5
const STAGE1_PROVENANCE_SCHEMA = "topaz.compiler.stage1-provenance/v1"7
export record Stage1Module derives JSON {8
schema: string,9
identity: string,10
path: string,11
sourceOrdinal: int,12
initializationOrdinal: int,13
entry: bool,14
extern: bool,15
operationIds: Array<string>,16
generatedStd: bool,17
// The package language mode the module was checked under, e.g. `topaz-5.20`.18
languageMode: string,19
// Target module identities of this module's import edges, in the20
// resolver's edge order (one per import item).21
importEdges: Array<string>,22
}24
export record Stage1Operation derives JSON {25
schema: string,26
id: string,27
module: string,28
lo: int,29
hi: int,30
parentId: string,31
role: string,32
kind: string,33
detail: string,34
operands: Array<string>,35
operandLabels: Array<string>,36
semanticType: string,37
representation: string,38
referenceIdentity: string,39
bindingName: string,40
// On a `binding/capture` for a closure, nested function, or `defer`, whether41
// this captured reference is an assignment target.42
bindingMutable: bool,43
bindingStorage: string,44
declarationIdentity: string,45
controlKind: string,46
controlTarget: string,47
cleanupIds: Array<string>,48
callTarget: string,49
callCalleeKind: string,50
callMethod: string,51
callMethodClass: string,52
callOptional: bool,53
callShadowFirst: bool,54
callStageMethod: string,55
callArguments: Array<string>,56
callEvaluations: Array<string>,57
runtimeLeaf: string,58
generatedNameSeed: string,59
// Full checked type of `semanticType` as the checker's preorder atom list.60
// A value identifier or shorthand record pattern field the checker leaves61
// untyped carries its declaration's type here with `semanticType` empty.62
semanticTypeAtoms: Array<PreviewTypeAtom>,63
// Source-declared type: parameter, function signature, annotated let/const.64
// Nonempty lists have exactly one root.65
declaredTypeAtoms: Array<PreviewTypeAtom>,66
// Source-written call type arguments in source order, one rooted tree each.67
callTypeArguments: Array<Array<PreviewTypeAtom>>,68
// Type declaration signature: root identity, typeParameters, fields,69
// variants with payload types, or newtype/alias base. Empty on other operations.70
typeDefinition: Array<PreviewTypeAtom>,71
importModule: string,72
// `kind|sourceName|boundName|lo|hi` per bound import name.73
importBindings: Array<string>,74
// Runtime file of this operation's span: the source ordinal of its module.75
sourceOrdinal: int,76
}78
export record Stage1Provenance derives JSON {79
schema: string,80
engine: string,81
producerStage: int,82
resultStage: int,83
defaultEngine: string,84
exchangeSchema: string,85
irSchema: string,86
sourceSetId: string,87
fixedPoint: string,88
}90
export record Stage1Response derives JSON {91
schema: string,92
status: string,93
frontEnd: string,94
loweredModules: Array<Stage1Module>,95
loweredOperations: Array<Stage1Operation>,96
generatedRust: string,97
unsupported: Array<string>,98
provenance: Stage1Provenance,99
}101
export function decodeStage1Response(text: string) -> Result<Stage1Response, string> {102
JSON.parseAs<Stage1Response>(text)103
}105
export function compilerProvenance(106
sourceSetId: string,107
producer: string,108
producerStage: int,109
) -> Stage1Provenance {110
Stage1Provenance {111
schema: STAGE1_PROVENANCE_SCHEMA,112
engine: producer,113
producerStage: producerStage,114
resultStage: producerStage,115
defaultEngine: "rust-stage0",116
exchangeSchema: STAGE1_EXCHANGE_SCHEMA,117
irSchema: STAGE1_IR_SCHEMA,118
sourceSetId: sourceSetId,119
fixedPoint: "not-run",120
}121
}123
export record LoweringOutput {124
modules: Array<Stage1Module>,125
operations: Array<Stage1Operation>,126
unsupported: Array<string>,127
}SHA256 36a356c4859e269b818f0668ec52592e9cebacc9e04ed000b28ad36b3dc8e545