aboutsummaryrefslogtreecommitdiffstats
path: root/types.html
blob: 81da334ffc6bb497615d0ac9a7b4ded6ecec37be (plain) (blame)
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
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width">
	<title>Document</title>

	<script src="/lib/util.js"></script>
	<script src="/lib/chips2.js"></script>
	<link href="/lib/chips.css" rel="stylesheet"></link>

	<style>
		table {
			background: #333;
			color: white;
		}
		table * {
			border: solid #888 1px;
		}
		table th {
			background: #222;
		}
		table td {
			font-family: sans-serif;
		}
	</style>
	
</head>
<body>
	<table><thead><tr id="head"><th>Type</th></tr></thead><tbody id="body"></tbody></table>
	<script>
		console.log("Testing type parsing...")
		console.log(new Type("int"))
		console.log(new Type("List<int>"))
		console.log(new Type("(int, T1)", ["T1"]))
		console.log(new Type("List<(T,int)>", ["T"]))
		console.log(new Type("(int|float|Vector3)"))
		console.log(new Type("List<(int|float|Vector3)>"))
		console.log(new Type("(List<List<(int|float|Vector3)>>|List<any>)"))
		console.log("Done!")
		
		console.log("Testing type intersections");
		const tistart = performance.now();
		const types = [
			//standard
			new Type("int"),
			new Type("bool"),
			//template
			new Type("List<int>"),
			new Type("List<float>"),
			new Type("List<List<int>>"),
			new Type("List<List<any>>"),
			new Type("List<(int|float)>"),
			new Type("List<(float|Vector3)>"),
			new Type("List<any>"),
			//union
			new Type("(int|float|bool)"),
			new Type("(List<any>|bool)"),
			//any
			new Type("any"),
			//dumb shit
			new Type("List<(List<(int|float)>|Vector3)>"),
		];
		const head = document.getElementById("head");
		const body = document.getElementById("body");
		
		for (const t of types) {
			const headel = document.createElement("th");
			headel.innerText = t;
			head.appendChild(headel);
			
			const row = document.createElement("tr");
			body.appendChild(row);
			const title = document.createElement("th");
			title.innerText = t;
			row.appendChild(title);
			for (const t2 of types) {
				const sect = document.createElement("td");
				sect.innerText = intersect(t,t2);
				row.appendChild(sect);
			}
		}
		
		console.log(`Done in ${performance.now() - tistart}ms!`)
		
		console.log("Testing chip class...")
		const node = {"ReadonlyPaletteName": "Set Rotation","ReadonlyChipName": "Set Rotation","Description": "Sets the rotation of the target player or object. Players will rotate about the vertical axis only. Will fail in the following cases: If the target object is currently held, select/frozen by the maker pen, or is the child of a gizmo. Will also fail on players that are seated.","IsBetaChip": true,"DeprecationStage": "Active","PaletteNameSource": "FirstNodeDesc","ChipNameSource": "FirstNodeDesc","NodeDescs": [{"Name": "Set Rotation","ReadonlyTypeParams": {"T": "(Player | Rec Room Object)","U": "(Vector3 | Quaternion)"},"Inputs": [{"Name": "","ReadonlyType": "exec","Description": ""},{"Name": "Target","ReadonlyType": "T","Description": ""},{"Name": "Rotation","ReadonlyType": "U","Description": ""}],"Outputs": [{"Name": "","ReadonlyType": "exec","Description": ""},{"Name": "Success","ReadonlyType": "bool","Description": ""}]}],"NodeFilters": [{"FilterPath": ["Player","Physics"]},{"FilterPath": ["Object","Physics"]}]};
		document.body.append((x=new Chip(node).root));
		document.body.appendChild(x);
		
	</script>
</body>
</html>