forked from adl-lang/adl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
picture.ts
108 lines (90 loc) · 4.97 KB
/
picture.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* @generated from adl module picture */
import * as ADL from './runtime/adl';
export interface Picture_Circle {
kind: 'circle';
value: Circle;
}
export interface Picture_Rectangle {
kind: 'rectangle';
value: Rectangle;
}
export interface Picture_Composed {
kind: 'composed';
value: Picture[];
}
export interface Picture_Translated {
kind: 'translated';
value: Translated<Picture>;
}
export type Picture = Picture_Circle | Picture_Rectangle | Picture_Composed | Picture_Translated;
const Picture_AST : ADL.ScopedDecl =
{"moduleName":"picture","decl":{"annotations":[],"type_":{"kind":"union_","value":{"typeParams":[],"fields":[{"annotations":[],"serializedName":"circle","default":{"kind":"nothing"},"name":"circle","typeExpr":{"typeRef":{"kind":"reference","value":{"moduleName":"picture","name":"Circle"}},"parameters":[]}},{"annotations":[],"serializedName":"rectangle","default":{"kind":"nothing"},"name":"rectangle","typeExpr":{"typeRef":{"kind":"reference","value":{"moduleName":"picture","name":"Rectangle"}},"parameters":[]}},{"annotations":[],"serializedName":"composed","default":{"kind":"nothing"},"name":"composed","typeExpr":{"typeRef":{"kind":"primitive","value":"Vector"},"parameters":[{"typeRef":{"kind":"reference","value":{"moduleName":"picture","name":"Picture"}},"parameters":[]}]}},{"annotations":[],"serializedName":"translated","default":{"kind":"nothing"},"name":"translated","typeExpr":{"typeRef":{"kind":"reference","value":{"moduleName":"picture","name":"Translated"}},"parameters":[{"typeRef":{"kind":"reference","value":{"moduleName":"picture","name":"Picture"}},"parameters":[]}]}}]}},"name":"Picture","version":{"kind":"nothing"}}};
export function texprPicture(): ADL.ATypeExpr<Picture> {
return {value : {typeRef : {kind: "reference", value : {moduleName : "picture",name : "Picture"}}, parameters : []}};
}
export interface Circle {
radius: number;
}
export function makeCircle(
input: {
radius: number,
}
): Circle {
return {
radius: input.radius,
};
}
const Circle_AST : ADL.ScopedDecl =
{"moduleName":"picture","decl":{"annotations":[],"type_":{"kind":"struct_","value":{"typeParams":[],"fields":[{"annotations":[],"serializedName":"radius","default":{"kind":"nothing"},"name":"radius","typeExpr":{"typeRef":{"kind":"primitive","value":"Double"},"parameters":[]}}]}},"name":"Circle","version":{"kind":"nothing"}}};
export function texprCircle(): ADL.ATypeExpr<Circle> {
return {value : {typeRef : {kind: "reference", value : {moduleName : "picture",name : "Circle"}}, parameters : []}};
}
export interface Rectangle {
width: number;
height: number;
}
export function makeRectangle(
input: {
width: number,
height: number,
}
): Rectangle {
return {
width: input.width,
height: input.height,
};
}
const Rectangle_AST : ADL.ScopedDecl =
{"moduleName":"picture","decl":{"annotations":[],"type_":{"kind":"struct_","value":{"typeParams":[],"fields":[{"annotations":[],"serializedName":"width","default":{"kind":"nothing"},"name":"width","typeExpr":{"typeRef":{"kind":"primitive","value":"Double"},"parameters":[]}},{"annotations":[],"serializedName":"height","default":{"kind":"nothing"},"name":"height","typeExpr":{"typeRef":{"kind":"primitive","value":"Double"},"parameters":[]}}]}},"name":"Rectangle","version":{"kind":"nothing"}}};
export function texprRectangle(): ADL.ATypeExpr<Rectangle> {
return {value : {typeRef : {kind: "reference", value : {moduleName : "picture",name : "Rectangle"}}, parameters : []}};
}
export interface Translated<T> {
xoffset: number;
yoffset: number;
object: T;
}
export function makeTranslated<T>(
input: {
xoffset?: number,
yoffset?: number,
object: T,
}
): Translated<T> {
return {
xoffset: input.xoffset === undefined ? 0 : input.xoffset,
yoffset: input.yoffset === undefined ? 0 : input.yoffset,
object: input.object,
};
}
const Translated_AST : ADL.ScopedDecl =
{"moduleName":"picture","decl":{"annotations":[],"type_":{"kind":"struct_","value":{"typeParams":["T"],"fields":[{"annotations":[],"serializedName":"xoffset","default":{"kind":"just","value":0},"name":"xoffset","typeExpr":{"typeRef":{"kind":"primitive","value":"Double"},"parameters":[]}},{"annotations":[],"serializedName":"yoffset","default":{"kind":"just","value":0},"name":"yoffset","typeExpr":{"typeRef":{"kind":"primitive","value":"Double"},"parameters":[]}},{"annotations":[],"serializedName":"object","default":{"kind":"nothing"},"name":"object","typeExpr":{"typeRef":{"kind":"typeParam","value":"T"},"parameters":[]}}]}},"name":"Translated","version":{"kind":"nothing"}}};
export function texprTranslated<T>(texprT : ADL.ATypeExpr<T>): ADL.ATypeExpr<Translated<T>> {
return {value : {typeRef : {kind: "reference", value : {moduleName : "picture",name : "Translated"}}, parameters : [texprT.value]}};
}
export const _AST_MAP: { [key: string]: ADL.ScopedDecl } = {
"picture.Picture" : Picture_AST,
"picture.Circle" : Circle_AST,
"picture.Rectangle" : Rectangle_AST,
"picture.Translated" : Translated_AST
};