Skip to content

Commit 29fc1d8

Browse files
committed
feat: simplify Args, make it plain array
1 parent e748541 commit 29fc1d8

File tree

8 files changed

+3210
-5954
lines changed

8 files changed

+3210
-5954
lines changed

examples/golang/tasm-go/spec/spec.go

Lines changed: 23 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/golang/tasm-go/tasm/decompile.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,23 @@ func loader(instructions []spec.Instruction) loaderFunc {
262262

263263
var args []any
264264

265-
switch layout.Args.Empty {
266-
case spec.SimpleArgs:
267-
for _, child := range layout.Args.Children {
265+
// Process DICTPUSHCONST-like instructions with separate logic
266+
if len(layout.Args) == 2 && layout.Args[0].Empty == "dict" {
267+
keyLength := slice.MustLoadUInt(10)
268+
dictCell, _ := slice.LoadRefCell()
269+
dict := dictCell.AsDict(uint(keyLength))
270+
keyValues, _ := dict.LoadAll()
271+
272+
methods := make([]DecompiledMethod, 0, len(keyValues))
273+
for _, kv := range keyValues {
274+
id := kv.Key.MustLoadUInt(uint(keyLength))
275+
code := decompileCell(kv.Value.MustToCell())
276+
methods = append(methods, DecompiledMethod{id, code.instructions})
277+
}
278+
279+
args = append(args, keyLength, DecompiledDict{methods})
280+
} else {
281+
for _, child := range layout.Args {
268282
switch child.Empty {
269283
case "delta":
270284
switch child.Arg.Empty {
@@ -328,20 +342,6 @@ func loader(instructions []spec.Instruction) loaderFunc {
328342
log.Fatalf("unhandled type of arg: %v", child)
329343
}
330344
}
331-
case spec.Dictpush:
332-
keyLength := slice.MustLoadUInt(10)
333-
dictCell, _ := slice.LoadRefCell()
334-
dict := dictCell.AsDict(uint(keyLength))
335-
all, _ := dict.LoadAll()
336-
337-
methods := make([]DecompiledMethod, 0, len(all))
338-
for _, kv := range all {
339-
id := kv.Key.MustLoadUInt(uint(keyLength))
340-
code := decompileCell(kv.Value.MustToCell())
341-
methods = append(methods, DecompiledMethod{id, code.instructions})
342-
}
343-
344-
args = append(args, keyLength, DecompiledDict{methods})
345345
}
346346

347347
return DeserializedInstruction{

gen/schema.json

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -381,40 +381,11 @@
381381
"additionalProperties": false
382382
},
383383
"Args": {
384-
"description": "Arguments structure for instruction operands",
385-
"oneOf": [
386-
{
387-
"type": "object",
388-
"description": "Plain arguments with children",
389-
"properties": {
390-
"$": {
391-
"type": "string",
392-
"const": "simpleArgs"
393-
},
394-
"children": {
395-
"type": "array",
396-
"description": "List of child argument structures",
397-
"items": {
398-
"$ref": "#/definitions/Arg"
399-
}
400-
}
401-
},
402-
"required": ["$", "children"],
403-
"additionalProperties": false
404-
},
405-
{
406-
"type": "object",
407-
"description": "Dictionary push arguments (key length and dictionary)",
408-
"properties": {
409-
"$": {
410-
"type": "string",
411-
"const": "dictpush"
412-
}
413-
},
414-
"required": ["$"],
415-
"additionalProperties": false
416-
}
417-
]
384+
"description": "Instruction arguments",
385+
"type": "array",
386+
"items": {
387+
"$ref": "#/definitions/Arg"
388+
}
418389
},
419390
"ArgRange": {
420391
"type": "object",
@@ -478,6 +449,9 @@
478449
{
479450
"$ref": "#/definitions/InlineCodeSliceArg"
480451
},
452+
{
453+
"$ref": "#/definitions/InlineDictArg"
454+
},
481455
{
482456
"$ref": "#/definitions/ExoticCellArg"
483457
},
@@ -727,6 +701,17 @@
727701
"required": ["$", "bits"],
728702
"additionalProperties": false
729703
},
704+
"InlineDictArg": {
705+
"type": "object",
706+
"properties": {
707+
"$": {
708+
"type": "string",
709+
"const": "dict"
710+
}
711+
},
712+
"required": ["$"],
713+
"additionalProperties": false
714+
},
730715
"ExoticCellArg": {
731716
"type": "object",
732717
"properties": {

0 commit comments

Comments
 (0)