Skip to content
This repository has been archived by the owner on Jan 20, 2018. It is now read-only.

Transform constructor arguments correctly. #5

Closed
jakemac53 opened this issue Jan 16, 2015 · 2 comments
Closed

Transform constructor arguments correctly. #5

jakemac53 opened this issue Jan 16, 2015 · 2 comments

Comments

@jakemac53
Copy link
Contributor

Currently, only things like @foo('bar') are supported. We should support passing other values as well, to support cases like:

String name = 'bar';
@foo(name)

@jakemac53
Copy link
Contributor Author

From the code review:

Siggi Cherem (dart-lang) 2015/01/16 19:46:29
Note that we need to check whether or not we need to transform the arguments
too, for example, if you have:

a.dart:
const theName = 'x-foo';

b.dart:
@CustomTag(theName)
class XFoo {}

we need to import a.dart also to be able to refer to theName. This can get quite
complex if you have nested expressions and what not.

Now that I think more about it, I realized that smoke creates a table that
includes annotations, so we had to do it there. Here is the example output:
https://github.com/dart-lang/smoke/blob/master/test/static_test.dart#L83

And here is the logic we did for it:
https://github.com/dart-lang/smoke/blob/master/lib/codegen/recorder.dart#L247

Feel free to copy it, or maybe change smoke to make some of these helpers
public. The codegen/generator.dart file also has some useful bits, like the
CodeAsConstExpression and other bits that help generate code that use library
prefixes (see
https://github.com/dart-lang/smoke/blob/master/lib/codegen/generator.dart#L321)

@jakemac53
Copy link
Contributor Author

https://codereview.chromium.org/865293002/ is out to fix this.

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

No branches or pull requests

1 participant