Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
110 lines (98 loc) · 2.86 KB

File metadata and controls

110 lines (98 loc) · 2.86 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
109
110
import { BinFmt, ObjectType, OBJECT_TYPE, Op } from "./bytecode"
import { opType } from "./format"
import { assert } from "./jdutil"
export enum ValueKind {
ANY = ObjectType.ANY,
NUMBER = ObjectType.NUMBER,
BUFFER = ObjectType.BUFFER,
MAP = ObjectType.MAP,
ARRAY = ObjectType.ARRAY,
NULL = ObjectType.NULL,
FIBER = ObjectType.FIBER,
BOOL = ObjectType.BOOL,
ROLE = ObjectType.ROLE,
VOID = ObjectType.VOID,
ERROR = 0x10000, // BinFmt.FIRST_NON_OPCODE - esbuild fails with subsequent values when enum not a constant is used here
JD_EVENT,
JD_REG,
JD_VALUE_SEQ,
JD_COMMAND,
JD_CLIENT_COMMAND,
}
export class ValueType {
constructor(
public kind: ValueKind,
public roleSpec?: jdspec.ServiceSpec,
public packetSpec?: jdspec.PacketInfo
) {
assert(this.kind != null)
}
get isRole() {
return this.kind == ValueKind.ROLE
}
get canIndex() {
return this.kind == ValueKind.ARRAY || this.kind == ValueKind.BUFFER
}
equals(other: ValueType) {
if (!other) return false
return (
this.kind == other.kind &&
this.roleSpec == other.roleSpec &&
this.packetSpec == other.packetSpec
)
}
toString() {
let r = valueKindToString(this.kind)
if (this.roleSpec) r += " " + this.roleSpec.camelName
if (this.packetSpec) r += "." + this.packetSpec.name
return r
}
static infer(op: Op) {
const k = opType(op)
return (
ValueType.all_static.find(
t => t.kind == (k as number as ValueKind)
) ?? ValueType.ANY
)
}
static ROLE(spec: jdspec.ServiceSpec) {
return new ValueType(ValueKind.ROLE, spec)
}
static ANY = new ValueType(ValueKind.ANY)
static NUMBER = new ValueType(ValueKind.NUMBER)
static BUFFER = new ValueType(ValueKind.BUFFER)
static MAP = new ValueType(ValueKind.MAP)
static ARRAY = new ValueType(ValueKind.ARRAY)
static NULL = new ValueType(ValueKind.NULL)
static FIBER = new ValueType(ValueKind.FIBER)
static BOOL = new ValueType(ValueKind.BOOL)
static VOID = new ValueType(ValueKind.VOID)
static ERROR = new ValueType(ValueKind.ERROR)
static all_static = [
ValueType.ANY,
ValueType.NUMBER,
ValueType.BUFFER,
ValueType.MAP,
ValueType.ARRAY,
ValueType.NULL,
ValueType.FIBER,
ValueType.BOOL,
ValueType.VOID,
ValueType.ERROR,
]
}
export const valueTypes = [
"(error node)",
"Jacdac event",
"Jacdac register",
"multi-field value",
"Jacdac command",
"Jacdac client command",
]
export function valueKindToString(vk: ValueKind) {
return (
OBJECT_TYPE[vk] ||
valueTypes[vk - BinFmt.FIRST_NON_OPCODE] ||
"ValueType " + vk
)
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.