Skip to content

Commit

Permalink
disgusting merge commit because rebasing is borked
Browse files Browse the repository at this point in the history
  • Loading branch information
katsaii authored Jul 16, 2024
2 parents 1ec8ff7 + ff755de commit d760945
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src-lts/scripts/scr_catspeak_codegen/scr_catspeak_codegen.gml
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,12 @@ function __catspeak_expr_call_0__() {
__catspeak_error_got(dbgError, callee_);
}
var shared_ = shared;
with (method_get_self(callee_) ?? (shared_.self_ ?? shared_.globals)) {

if (method_get_self(callee_) != undefined) {
return callee_();
}

with (shared_.self_ ?? shared_.globals) {
var calleeIdx = method_get_index(callee_);
return script_execute(calleeIdx);
}
Expand All @@ -1846,7 +1851,12 @@ function __catspeak_expr_call_1__() {
var values_ = args;
var arg1 = values_[0]();
var shared_ = shared;
with (method_get_self(callee_) ?? (shared_.self_ ?? shared_.globals)) {

if (method_get_self(callee_) != undefined) {
return callee_(arg1);
}

with (shared_.self_ ?? shared_.globals) {
var calleeIdx = method_get_index(callee_);
return script_execute(calleeIdx, arg1);
}
Expand All @@ -1863,7 +1873,12 @@ function __catspeak_expr_call_2__() {
var arg1 = values_[0]();
var arg2 = values_[1]();
var shared_ = shared;
with (method_get_self(callee_) ?? (shared_.self_ ?? shared_.globals)) {

if (method_get_self(callee_) != undefined) {
return callee_(arg1, arg2);
}

with (shared_.self_ ?? shared_.globals) {
var calleeIdx = method_get_index(callee_);
return script_execute(calleeIdx, arg1, arg2);
}
Expand All @@ -1881,7 +1896,12 @@ function __catspeak_expr_call_3__() {
var arg2 = values_[1]();
var arg3 = values_[2]();
var shared_ = shared;
with (method_get_self(callee_) ?? (shared_.self_ ?? shared_.globals)) {

if (method_get_self(callee_) != undefined) {
return callee_(arg1, arg2, arg3);
}

with (shared_.self_ ?? shared_.globals) {
var calleeIdx = method_get_index(callee_);
return script_execute(calleeIdx, arg1, arg2, arg3);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,37 @@ test_add(function() : Test("with-inst") constructor {
assertEq(inst2Self, result.arr[1]);
instance_destroy(inst1);
instance_destroy(inst2);
});

test_add(function() : Test("method-scope-vs-undefined") constructor {
var env = new CatspeakEnvironment();
var func = function(value) {
return value * 32;
}
env.interface.exposeFunction("func", func);
env.interface.exposeMethod("funcM", func);

var ir = env.parseString(@'
func(0.5);
');

var gmlFuncA = env.compile(ir);

ir = env.parseString(@'
funcM(0.5);
');

var gmlFuncB = env.compile(ir);

var t = get_timer();
repeat(100000) {
gmlFuncA();
}
show_debug_message("gmlFuncA (func) Time taken: " + string((get_timer() - t) / 1000) + "ms");

t = get_timer();
repeat(100000) {
gmlFuncB();
}
show_debug_message("gmlFuncB (funcM) Time taken: " + string((get_timer() - t) / 1000) + "ms");
});

0 comments on commit d760945

Please sign in to comment.