Skip to content
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

E2 Functions do not add their op cost #2958

Closed
Denneisk opened this issue Dec 27, 2023 · 0 comments · Fixed by #2959
Closed

E2 Functions do not add their op cost #2958

Denneisk opened this issue Dec 27, 2023 · 0 comments · Fixed by #2959
Labels

Comments

@Denneisk
Copy link
Member

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.

Vurv78 added a commit to Vurv78/wire that referenced this issue Dec 27, 2023
@Denneisk Denneisk linked a pull request Dec 27, 2023 that will close this issue
thegrb93 pushed a commit that referenced this issue Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant