Removed every single script resource and .sc file from a fresh project and made a blank script 0. Here's what I put in:
(script# 0)
(public
WeirdThing 0
)
(instance WeirdThing
(method (play)
(Display {Hello, world!} 100 10 0 102 15)
(Animate)
(Wait 100)
)
)
Aaaand yeah, it compiles. 108 bytes, and when you run it it prints "Hello, world!" at effectively 10x10 (because lol invisible status line), waits a bit so you can tell it's there, and self-terminates.
Here's what SV made of those 108 bytes:
export000_0 = WeirdThing
WeirdThing::play:
pushi $6 ; loop
lofss string_0048 ; "Hello, world!"
pushi $64 ; 100, 'd', allTrue
pushi $a ; 10, nsLeft
push0
pushi $66 ; 102, 'f', isEmpty
pushi $f ; 15, lsBottom
callk Display, $c
push0
callk Animate, $0
push1
pushi $64 ; 100, 'd', allTrue
callk Wait, $2
ret
; export000_0
instance WeirdThing of Object
{
play()
}
string_0048 = "Hello, world!"
string_0056 = "WeirdThing"
But what if... what if I were to buy fast food and disguise it as my own cooking try compiling it in SC instead? Let's see. First, I'll adjust the definition a little bit:
(instance WeirdThing of RootObj
(properties name "WeirdThing") ;if left out, the instance is nameless and that's cheating a bit
(methods play)
And then because SC insists on having a system.sh despite my script not using it, I'll whip up a minimal one:
(global
)
(extern
Animate $ffff 11
Display $ffff 27
Wait $ffff 69
)
End result is almost the same basic bytecode:
export000_0 = WeirdThing
WeirdThing::play:
pushi $6 ; loop
lofsa string_0055 ; "Hello, world!"
push ;<-- this was a lofss in Companion.
pushi $64 ; 100, 'd', allTrue
pushi $a ; 10, nsLeft
push0
pushi $66 ; 102, 'f', isEmpty
pushi $f ; 15, lsBottom
callk Display, $c
push0
callk Animate, $0
push1
pushi $64 ; 100, 'd', allTrue
callk Wait, $2
ret
; export000_0
instance WeirdThing of Object
{
play()
}
;interesting how this is in the opposite order...
string_004a = "WeirdThing"
string_0055 = "Hello, world!"
I learned nothing today.