Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(codegen): inline contract router #1968

Merged
merged 6 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 20 additions & 82 deletions src/cli/unboc/__snapshots__/e2e.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ PROGRAM{
DECLPROC recv_internal
78250 DECLMETHOD ?fun_78250
DECLPROC ?fun_ref_0cd12ec96bb24bd7
DECLPROC ?fun_ref_272cf0193c781008
DECLPROC ?fun_ref_92183b49329bb4e4
recv_internal PROC:<{
SWAP
DROP
CTOS
TWO
SDSKIPFIRST
Expand All @@ -22,22 +21,15 @@ PROGRAM{
LDMSGADDR
OVER
s3 s4 XCHG
s6 s6 XCHG2
s5 s5 XCHG2
4 TUPLE
1 SETGLOB
s0 s2 XCHG
SWAP
2 SETGLOB
?fun_ref_0cd12ec96bb24bd7 INLINECALLDICT
s0 s2 XCHG
?fun_ref_272cf0193c781008 INLINECALLDICT
130 THROWIFNOT
DROP
NEWC
-1 PUSHINT
SWAP
1 STI
ENDC
POPROOT
IFRET
130 THROW
}>
?fun_78250 PROC:<{
?fun_ref_0cd12ec96bb24bd7 INLINECALLDICT
Expand All @@ -55,14 +47,6 @@ PROGRAM{
IFJMP
NULL
}>
?fun_ref_272cf0193c781008 PROCREF:<{
NIP
<{
-1 PUSHINT
}> PUSHCONT
IFJMP
ZERO
}>
?fun_ref_92183b49329bb4e4 PROCREF:<{
x{68656C6C6F20776F726C64} PUSHSLICE
}>
Expand All @@ -81,10 +65,9 @@ PROGRAM{
DECLPROC recv_internal
78250 DECLMETHOD ?fun_78250
DECLPROC ?fun_ref_0cd12ec96bb24bd7
DECLPROC ?fun_ref_272cf0193c781008
DECLPROC ?fun_ref_92183b49329bb4e4
recv_internal PROC:<{
SWAP // 0x0 1
DROP // 0x3 0
CTOS // 0xD0
TWO // 0x7 2
SDSKIPFIRST // 0xD721
Expand All @@ -93,22 +76,15 @@ PROGRAM{
LDMSGADDR // 0xFA40
OVER // 0x2 1
s3 s4 XCHG // 0x10 3 4
s6 s6 XCHG2 // 0x50 6 6
s5 s5 XCHG2 // 0x50 5 5
4 TUPLE // 0x6F0 4
1 SETGLOB // 0xF87_ 0C_
s0 s2 XCHG // 0x0 2
SWAP // 0x0 1
2 SETGLOB // 0xF87_ 14_
?fun_ref_0cd12ec96bb24bd7 INLINECALLDICT // 0x
s0 s2 XCHG // 0x0 2
?fun_ref_272cf0193c781008 INLINECALLDICT // 0x
130 THROWIFNOT // 0xF2E4_ 105_
DROP // 0x3 0
NEWC // 0xC8
-1 PUSHINT // 0x7 F
SWAP // 0x0 1
1 STI // 0xCA 00
ENDC // 0xC9
POPROOT // 0xED5 4
IFRET // 0xDC
130 THROW // 0xF2C4_ 105_
}>
?fun_78250 PROC:<{
?fun_ref_0cd12ec96bb24bd7 INLINECALLDICT // 0x
Expand All @@ -126,14 +102,6 @@ PROGRAM{
IFJMP // 0xE0
NULL // 0x6D
}>
?fun_ref_272cf0193c781008 PROCREF:<{
NIP // 0x3 1
<{
-1 PUSHINT // 0x7 F
}> PUSHCONT // 0x9 7F
IFJMP // 0xE0
ZERO // 0x7 0
}>
?fun_ref_92183b49329bb4e4 PROCREF:<{
x{68656C6C6F20776F726C64} PUSHSLICE // 0x8B 68656C6C6F20776F726C64
}>
Expand All @@ -152,10 +120,9 @@ PROGRAM{
DECLPROC recv_internal
78250 DECLMETHOD ?fun_78250
DECLPROC ?fun_ref_0cd12ec96bb24bd7
DECLPROC ?fun_ref_272cf0193c781008
DECLPROC ?fun_ref_92183b49329bb4e4
recv_internal PROC:<{
s0 s1 XCHG
s0 POP
CTOS
2 PUSHINT
SDSKIPFIRST
Expand All @@ -164,22 +131,15 @@ PROGRAM{
LDMSGADDR
s1 PUSH
s3 s4 XCHG
s6 s6 XCHG2
s5 s5 XCHG2
4 TUPLE
1 SETGLOB
s0 s2 XCHG
s0 s1 XCHG
2 SETGLOB
?fun_ref_0cd12ec96bb24bd7 INLINECALLDICT
s0 s2 XCHG
?fun_ref_272cf0193c781008 INLINECALLDICT
130 THROWIFNOT
s0 POP
NEWC
-1 PUSHINT
s0 s1 XCHG
1 STI
ENDC
c4 POPCTR
IFRET
130 THROW
}>
?fun_78250 PROC:<{
?fun_ref_0cd12ec96bb24bd7 INLINECALLDICT
Expand All @@ -197,14 +157,6 @@ PROGRAM{
IFJMP
NULL
}>
?fun_ref_272cf0193c781008 PROCREF:<{
s1 POP
<{
-1 PUSHINT
}> PUSHCONT
IFJMP
0 PUSHINT
}>
?fun_ref_92183b49329bb4e4 PROCREF:<{
x{68656C6C6F20776F726C64} PUSHSLICE
}>
Expand All @@ -223,7 +175,7 @@ PROGRAM{
DECLPROC recv_internal
78250 DECLMETHOD ?fun_78250
recv_internal PROC:<{
SWAP
DROP
CTOS
TWO
SDSKIPFIRST
Expand All @@ -232,10 +184,10 @@ PROGRAM{
LDMSGADDR
OVER
s3 s4 XCHG
s6 s6 XCHG2
s5 s5 XCHG2
4 TUPLE
1 SETGLOB
s0 s2 XCHG
SWAP
2 SETGLOB
<{
PUSHROOT
Expand All @@ -248,23 +200,9 @@ PROGRAM{
IFJMP
NULL
}>c CALLREF
s0 s2 XCHG
<{
NIP
<{
-1 PUSHINT
}> PUSHCONT
IFJMP
ZERO
}>c CALLREF
130 THROWIFNOT
DROP
NEWC
-1 PUSHINT
SWAP
1 STI
ENDC
POPROOT
IFRET
130 THROW
}>
?fun_78250 PROC:<{
<{
Expand Down
17 changes: 0 additions & 17 deletions src/generator/writers/ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,6 @@ export const ops = {
used(`$${type}$_contract_load`, ctx),
contractStore: (type: string, ctx: WriterContext) =>
used(`$${type}$_contract_store`, ctx),
contractRouter: (type: string, kind: "internal" | "external") =>
`$${type}$_contract_router_${kind}`, // Not rendered as dependency

// Router operations
receiveEmpty: (type: string, kind: "internal" | "external") =>
`%$${type}$_${kind}_empty`,
receiveType: (type: string, kind: "internal" | "external", msg: string) =>
`$${type}$_${kind}_binary_${msg}`,
receiveAnyText: (type: string, kind: "internal" | "external") =>
`$${type}$_${kind}_any_text`,
receiveText: (type: string, kind: "internal" | "external", hash: string) =>
`$${type}$_${kind}_text_${hash}`,
receiveAny: (type: string, kind: "internal" | "external") =>
`$${type}$_${kind}_any`,
receiveTypeBounce: (type: string, msg: string) =>
`$${type}$_receive_binary_bounce_${msg}`,
receiveBounceAny: (type: string) => `$${type}$_receive_bounce_fallback`,

// Functions
extension: (type: string, name: string) => `$${type}$_fun_${name}`,
Expand Down
Loading