[3.1.2] Patch


  • Add codegen for simple calls with 4 and 5 parameters (gets around an LTS runner bug). (Harlem512) (Addendum #1)
  • Added catspeak_get_self and catspeak_get_index. (tabularelf) (Addendum #2)
  • Further patch for built-in functions with optional args.

Addendum #1 (written by Harlem512)

script_execute_ext<br> has issues with optional arguments for built-in functions. The following code fails:
// expected output is `[ ]`, however this returns `["","","",""]`
var ext = script_execute_ext(string_split, ["AAAA", "A", true])
var normal = string_split("AAAA", "A", true)
// fails
assertEq(array_length(ext), array_length(normal)) 
For most functions this isn't a problem, since __compileCall does some short-cutting based on number of arguments (and the shortcuts use script_execute, which does allow for optional arguments). However, some built-in functions (notably instance_create_depth and  instance_create_layer) have more than 3 arguments and fail.
var parsed = Catspeak.parseString("instance_create_depth(0,0, -100, dummy_object, {my_var:20})")
var compiled = Catspeak.compile(parsed)
var inst = compiled()
// fails
assertEq(inst.my_var, 20) 
This pr adds __catspeak_expr_call_4__ and __catspeak_expr_call_5__ to bypass this issue.

Addendum #2 (written by tabularelf)

This PR introduces catspeak_get_self and catspeak_get_index, which play as counterparts to method_get_self and method_get_index. The reason for this is that method_get_index will return __catspeak_function__ or __catspeak_method__ from Catspeak programs. And even then, not as a method but as a GML function index. That's likely to cause all sorts of issues.

method_get_self also has the unfortunate issue where it could return the Catspeak program struct itself. Which may also be unintended depending on who you ask.

catspeak_get_index resolves this by always returning a method. Never a function ID. This means that any Catspeak functions or Catspeak methods, will always return their callee program "as is". And any GML function will be returned as a method with a bound to undefined.

catspeak_get_self resolves this by returning self from only GML functions and Catspeak methods. Anything marked as a Catspeak function (via is_catspeak) will retrieve self_ via accessor (if it exists), or returns undefined.

Files

catspeak_3.1.2.yymps 86 kB
2 days ago

Get Catspeak

Leave a comment

Log in with itch.io to leave a comment.