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

Ensure that this doesn't cause code bloat in dart2js #6

Open
jakemac53 opened this issue Mar 31, 2015 · 1 comment
Open

Ensure that this doesn't cause code bloat in dart2js #6

jakemac53 opened this issue Mar 31, 2015 · 1 comment

Comments

@jakemac53
Copy link

In terms of the actual implementation, we need to make sure that there is some path for dart2js to implement this without an unacceptable amount of code bloat. Specifically, I am concerned about having to create a class which extends Member for each field which is annotated, like this example from the getter section:

class _$nameMember extends Member {
  const _$nameMember() : super(#name);
  get(target) => target._$name;
  set(target, value) { target._$name = value; }
  invoke(target, positional, named) =>
      Function.apply(target._$name, positional, named);
}

I think there are a few ways to get around this, but just want to make sure its highlighted as something which should be watched.

@sigmundch
Copy link
Owner

Yes - given that the code is completely known statically, my hope is that dart2js can avoid creating these objects if possible.

So if you write:

class InterceptorExample {
  get(o, member) => member.get(o) + 1
}

class ExampleUsage {
  @InterceptorExample() int get x => 2;
}

dart2js can do enough inlining to generate the equivalent of this code:

class ExampleUsage {
  int get _x => 2;
  // instead of: int get x => const InterceptorExample().get(this, const _xMember);
  int get x => _x + 1;
}

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

No branches or pull requests

2 participants