wiremod/wire

E2 Functions do not add their op cost

Denneisk opened this issue · 0 comments

E2 functions do not apply their op cost to the running chip.

Given the following code, one would expect the output to be above 5000.

@strict
soundDuration("")
print(opcounter())

However, the output will be a resounding 1.

Operators apply ops as expected.

@strict
1 + 2 + 3
print(opcounter())

Outputs 3.

I believe this is an oversight.

function Compiler:GetOperator(variant, types, trace)
local fn = wire_expression2_funcs["op:" .. variant .. "(" .. table.concat(types) .. ")"]
if fn then
self.scope.data.ops = self.scope.data.ops + (fn[4] or 2) + (fn.attributes.legacy and 1 or 0)

As shown above, Compiler.GetOperator adds to the op count as expected. Compiler.GetFunction lacks this feature.