Skip to content

[FEATURE] Support for get and set functions #191

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

KoloInDaCrib
Copy link

@KoloInDaCrib KoloInDaCrib commented Feb 19, 2025

Fixes FunkinCrew/Funkin#3781

Doesn't have any other PR that has to be merged in order to work, hooray!!!

for getting the variable, the words supported are "get", "null" and everything else (i.e. "default")
for setting the variable, the words supported are "set", "never", "null" and everything else (i.e. "default")

also uhh haven't had the chance to test this that much so like if you want to uh test it yourself n stuff

Copy link

@AbnormalPoof AbnormalPoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to review this but I don't think it's compiling properly...

ERROR  /Volumes/THE HOLE/FNF STUFF/FNF Repos/Funkin-Base/.haxelib/polymod/git/polymod/hscript/_internal/PolymodInterpEx.hx:286: characters 29-37

286 |        var v = fop(expr(e1),expr(e2));
    |                             ^^^^^^^^
    | Too many arguments

ERROR  /Volumes/THE HOLE/FNF STUFF/FNF Repos/Funkin-Base/.haxelib/polymod/git/polymod/hscript/_internal/PolymodInterpEx.hx:302: characters 33-36

302 |   return super.evalAssignOp(op, fop, e1, e2);
    |                                 ^^^
    | (Dynamic -> Dynamic) -> Dynamic should be (Dynamic, Dynamic) -> Unknown<0>
    | For function argument 'fop'

ERROR  /Volumes/THE HOLE/FNF STUFF/FNF Repos/Funkin-Base/.haxelib/polymod/git/polymod/hscript/_internal/PolymodInterpEx.hx:274: characters 20-32

274 |  override function evalAssignOp(op:String, fop:(Dynamic->Dynamic)->Dynamic, e1:Expr, e2:Expr)
    |                    ^^^^^^^^^^^^
    | Field evalAssignOp overrides parent class with different or incomplete type

     ->  /Volumes/THE HOLE/FNF STUFF/FNF Repos/Funkin-Base/.haxelib/hscript/git/hscript/Interp.hx:152: characters 11-23

     152 |  function evalAssignOp(op,fop,e1,e2) : Dynamic {
         |           ^^^^^^^^^^^^
         | Base field is defined here

         | error: (Dynamic -> Dynamic) -> Dynamic should be (Dynamic, Dynamic) -> Unknown<0>
         | have: (..., (..., ...) -> ..., ..., ...) -> ...
         | want: (..., ... -> ..., ..., ...) -> ...

Copy link

@AbnormalPoof AbnormalPoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

holy shit peak PR:

var test(get, set):Bool;
var _test:Bool = false;

function get_test():Bool {
  trace("TEST");
  return _test;
}

function set_test(value) {
  trace("TEST");
  _test = value;
}
public function new()
{
  trace(test);
  test = true;
  trace(test);
}
hscriptClass(assets/test.hxc):32: TEST
hscriptClass(assets/test.hxc):49: false
hscriptClass(assets/test.hxc):37: TEST
hscriptClass(assets/test.hxc):32: TEST
hscriptClass(assets/test.hxc):51: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants