-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature: Function/Pointer syntax #45
Comments
Or like this
|
@XMDS thanks for the feedback.
IDE should highlight a callable label: Does that work for you? Regarding functions. Yes I want to expand on functions syntax more. Gosubs were just an easy change and I want to implement a similar syntax for SCM functions and call opcodes. You don't have to specify calling convention (stdcall/cdecl) each time you call a function. Basically I would introduce a new syntax for functions declaration where you can tell the compiler how many arguments it takes and other information. Something like:
then
or
or
or
changing still not sure about multiple returning values syntax, but this is a draft. |
@x87 Should it be like the function syntax, instead of using the class form, but using the independent form, for example:
Can be declared for people, cars, and obj pointers:
Should also support const……end instruction to define pointer writing of variable names. The above are all my personal suggestions. If there is a better grammar, I can discuss it |
My proposal would be a syntax similar to Rust - adding
this won't have collisions with ADMA syntax as ADMA variables are always numeric. for entities:
not sure about syntax for the script pointer. maybe leave it as a keyword: 0@ = get_this_script_struct |
I very much agree, because I also thought of using * or &, indeed the latter is better |
Functions implemented in 4.0.0 For pointers see #323 |
In fact, it may not make sense to do so. But in theory, I hope that the sb tool can add more new OP writing methods. Essentially, I think we should add a new simple syntax to the frequently used basic OP and SA (CLEO4).VC.3 (CLEO2.0) OP
In fact, I got the idea from gosub:
gosub @xxxx
xxxx ()
But actually you should add highlighting to the above code
Back to the topic, I have an example:
0AA5: call 0x123456 num_params 3 pop 3 0@ 1@ 2@
Maybe this:
call 0x123456 (3 2@ 1@ 0@)
call 0x123456 3(2@ 1@ 0@)
By writing call address + (parameter), the SB tool can automatically detect the number of parameters (num_params) in () when compiling.
In fact (3 2@ 1@ 0@), the 3 in () should be the pop parameter. In fact, OP 0AA5 fills the parameters in CLEO upside down, which is very uncomfortable. 2@ should be the first parameter
More examples:
0AA5: call 0x123456 num_params 3 pop 3 0@ 1@ 2@
call 0x123456 (3 2@ 1@ 0@)
0AA6: call_method 0x123456 struct 30@ num_params 3 pop 3 0@ 1@ 2@
call 0x123456 30@(3 2@ 1@ 0@)
0AA7: call_function 0x123456 num_params 3 pop 3 0@ 1@ 2@ ret 3@
call 0x123456 (3 2@ 1@ 0@) ret 3@
0AA8: call_function_method 0x123456 struct 30@ num_params 3 pop 3 0@ 1@ 2@ ret 3@
call 0x123456 30@(3 2@ 1@ 0@) ret 3@
0AB1: call_scm_func @xxxx 3 0@ 1@ 2@ ret 3@ 4@ 5@
call xxxx (3 0@ 1@ 2@)ret 3@ 4@ 5@
:xxxx
0AB2: ret 3 3@ 4@ 5@
ret (3@ 4@ 5@)
ret 0 = ret
Just like the example, the sb tool automatically detects the number of parameters (). But the above code is still not good. Such as pop and struct parameters. Maybe it can be declared at the beginning:
var
this 30@
stdcall 0x654321
cdecl 0x123456
end
call 0x123456 (30@ 2@ 1@ 0@}
call 0x654321 (30@ 2@ 1@ 0@}
In the end I suggest this
call address + (parameter)
pop and struct can be declared at the beginning
The text was updated successfully, but these errors were encountered: