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
111 lines (94 loc) · 2.66 KB

File metadata and controls

111 lines (94 loc) · 2.66 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
111
import {
Op,
NumFmt,
BytecodeFlag,
BinFmt,
OP_PROPS,
ObjectType,
OP_TYPES,
NumFmtSpecial,
} from "./bytecode"
import { toHex } from "./jdutil"
import { DebugInfo } from "@devicescript/interop"
export * from "./bytecode"
import type ts from "typescript"
import { ResolvedBuildConfig } from "@devicescript/interop"
import { CompileFlags } from "./compiler"
export interface SMap<T> {
[k: string]: T
}
export function opTakesNumber(op: Op) {
return !!(OP_PROPS.charCodeAt(op) & BytecodeFlag.TAKES_NUMBER)
}
export function opNumRealArgs(op: Op) {
return OP_PROPS.charCodeAt(op) & BytecodeFlag.NUM_ARGS_MASK
}
export function opNumArgs(op: Op) {
let n = opNumRealArgs(op)
if (opTakesNumber(op)) n++
return n
}
export function opType(op: Op): ObjectType {
return OP_TYPES.charCodeAt(op)
}
export function opIsStmt(op: Op) {
return !!(OP_PROPS.charCodeAt(op) & BytecodeFlag.IS_STMT)
}
export function exprIsStateful(op: Op) {
return (
opIsStmt(op) || !(OP_PROPS.charCodeAt(op) & BytecodeFlag.IS_STATELESS)
)
}
export function stmtIsFinal(op: Op) {
return opIsStmt(op) && OP_PROPS.charCodeAt(op) & BytecodeFlag.IS_FINAL_STMT
}
export interface InstrArgResolver {
describeCell?(fmt: string, idx: number): string
verboseDisasm?: boolean
}
export function bitSize(fmt: NumFmt) {
return 8 << (fmt & 0b11)
}
export function numfmtToString(v: number) {
const fmt = v & 0xf
const bitsz = bitSize(fmt)
const letter = ["u", "i", "f", "x"][fmt >> 2]
if (letter == "x") {
const idx = (v >> 4) | ((v & 3) << 4)
return NumFmtSpecial[idx] ?? "Spec." + idx
}
const shift = v >> 4
if (shift) return letter + (bitsz - shift) + "." + shift
else return letter + bitsz
}
export interface DevsDiagnostic extends ts.Diagnostic {
filename: string
line: number
column: number
endLine: number
endColumn: number
formatted: string
}
export interface Host {
write(filename: string, contents: Uint8Array | string): void
read(filename: string): string
resolvePath(filename: string): string
relativePath?(filename: string): string
log(msg: string): void
error?(err: DevsDiagnostic): void
getConfig(): ResolvedBuildConfig
verifyBytecode?(buf: Uint8Array, dbgInfo?: DebugInfo): void
isBasicOutput?(): boolean
getFlags?(): CompileFlags
}
export function parseImgVersion(v: number) {
return {
major: (v >> 24) & 0xff,
minor: (v >> 16) & 0xff,
patch: (v >> 0) & 0xffff,
}
}
export function runtimeVersion() {
const v = parseImgVersion(BinFmt.IMG_VERSION)
return `v${v.major}.${v.minor}.${v.patch}`
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.