Skip to content

Commit b91b4d1

Browse files
cleanup: cleanup some assembly/token-related types: now low_level_code/Instructions
Co-authored-by: Madman10K <[email protected]>
1 parent 972df9b commit b91b4d1

File tree

3 files changed

+1
-62
lines changed

3 files changed

+1
-62
lines changed

src/common/common_types/language_features/tokens.nim

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,6 @@ type
3131
TkIndent,
3232
TkWhitespace
3333

34-
Token* = object
35-
kind*: TokenKind
36-
tokenName*: cstring
37-
raw*: langstring
38-
line*: int
39-
column*: int
40-
41-
# support bytecode in general
42-
AssemblyToken* = ref object
43-
offset*: int
44-
highLevelLine*: int
45-
opcode*: cstring
46-
address*: cstring
47-
value*: seq[Token]
48-
help*: cstring
49-
5034
const
5135
TOKEN_TEXTS*: array[Lang, array[TokenText, string]] = [
5236
# InstanceOpen InstanceClose ArrayOpen ArrayClose SeqOpen SeqClose

src/frontend/index_config.nim

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,6 @@ proc initDebugger*(main: js, trace: Trace, config: Config, helpers: Helpers) {.a
304304
proc loadAsm*(data: ServerData, functionLocation: FunctionLocation): Future[Instructions] {.async.}
305305

306306

307-
proc mapAssemblyFunctions(data: ServerData, functions: seq[tuple[name: string, line: int]], functionName: cstring, savedFunctions: JsAssoc[cstring, seq[AssemblyToken]]): Future[JsAssoc[cstring, seq[AssemblyToken]]] {.async.} =
308-
var res = savedFunctions
309-
let raw = await data.toAsm($functionName)
310-
let tokens: seq[AssemblyToken] = @[] #raw.mapIt(assemblyTokenize(it))
311-
res[functionName] = tokens
312-
return res
313-
314307
proc basename(filename: cstring): cstring =
315308
var t = ($filename).rsplit("/", 1)[1]
316309
return j(t)
@@ -723,7 +716,7 @@ proc openTab*(main: js, location: types.Location, lang: Lang, editorView: Editor
723716

724717
proc open*(data: ServerData, main: js, location: types.Location, editorView: EditorView, messagePath: string, replay: bool, exe: seq[cstring], lang: Lang, line: int): Future[void] {.async.} =
725718
var source = j""
726-
var tokens: seq[seq[Token]] = @[]
719+
# var tokens: seq[seq[Token]] = @[]
727720
var symbols = JsAssoc[cstring, seq[js]]{}
728721
if location.highLevelPath == j"unknown":
729722
return

src/frontend/ui/editor.nim

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -216,35 +216,6 @@ proc closeActiveTab*(data: Data) {.locks: 0.} =
216216

217217
proc getBoundingClientRect(s: js): HTMLBoundingRect {.importcpp: "#.getBoundingClientRect()".}
218218

219-
proc assemblyTokenView(token: Token): VNode =
220-
buildHtml(td(class = &"token-{($token.kind).toLowerAscii[2..^1]} assembly-token")):
221-
text(token.raw)
222-
223-
proc assemblyLineView(
224-
self: EditorViewComponent,
225-
assemblyToken: AssemblyToken,
226-
nextOffset: int,
227-
index: int
228-
): VNode =
229-
let location = self.data.services.debugger.location
230-
let currentOpcode =
231-
if assemblyToken.offset <= location.offset and nextOffset > location.offset:
232-
"on"
233-
else:
234-
""
235-
236-
if currentOpcode == "on":
237-
scrollAssembly = index
238-
239-
buildHtml(
240-
tr(class = &"low-level-assembly-line {currentOpcode}")
241-
):
242-
tdiv(class = "assembly-offset", onclick=proc(ev: Event, v: VNode) =
243-
self.data.services.debugger.toggleAssemblyBreakpoint(assemblyToken.address)):
244-
text($assemblyToken.offset)
245-
for token in assemblyToken.value:
246-
assemblyTokenView(token)
247-
248219
proc assemblyRegisterView(state: JsAssoc[cstring, cstring]): VNode =
249220
buildHtml(table(class = "assembly-registers")):
250221
for label, value in state:
@@ -254,15 +225,6 @@ proc assemblyRegisterView(state: JsAssoc[cstring, cstring]): VNode =
254225
td(class = "assembly-register-value"):
255226
text(value)
256227

257-
proc assemblyFunctionView(self: EditorViewComponent, fn: cstring, tokens: seq[AssemblyToken]): VNode =
258-
buildHtml(tdiv):
259-
tdiv(class = "assembly-function"):
260-
tdiv(class = "assembly-function-name"):
261-
text(fn)
262-
tdiv(class = "assembly-function-code"):
263-
for i, token in tokens:
264-
assemblyLineView(self, token, if i < tokens.len - 1: tokens[i + 1].offset else: -1, i)
265-
assemblyRegisterView(self.data.services.debugger.registerState)
266228

267229
proc removeClasses(index: int, class: cstring, name: string) =
268230
let elements = jqall(&"#{name}-{index} .{class}")

0 commit comments

Comments
 (0)