Commit Graph

326 Commits

Author SHA1 Message Date
rmacnak@google.com 2f192be945 Provide a way to get a Type back from a ClassMirror.
BUG= http://dartbug.com/6433
R=asiva@google.com

Review URL: https://codereview.chromium.org//22849015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26407 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-20 23:05:31 +00:00
mlippautz@google.com 187ec3d4fc Fix ClassMirror.typeArguments handling for dynamic only type arguments.
Addresses an issue where we did not return the appropriate type arguments for instances with all dynamic type arguments.

Example:
Class <E> {}

main() {
  var cm = reflectClass(new C()).type;
  print(cm.typeArguments);
  // now prints: {Symbol("E"): TypeMirror on 'dynamic'}
  // previously: crashed
}

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//23133003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26135 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-14 18:41:30 +00:00
rmacnak@google.com 0d665249d7 Hide methods marked as not-visible from reflective member lists and invocation.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//22961004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26093 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-13 23:17:44 +00:00
mlippautz@google.com c79874a413 ParameterMirror: Implement some missing getters.
Fixes issue 11334 and issue 11684 and issue 11567.

R=asiva@google.com

Review URL: https://codereview.chromium.org//21624006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26086 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-13 21:38:36 +00:00
rmacnak@google.com 1edde1e0bf Ensure the classes void and dynamic have empty arrays for fields, functions, etc. Move their Types to the VM isolate, and as a side-effect they are now canonicalized.
BUG=http://dartbug.com/12071
BUG=http://dartbug.com/12246
R=asiva@google.com, iposva@google.com, regis@google.com

Review URL: https://codereview.chromium.org//22902002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26043 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-13 00:11:42 +00:00
rmacnak@google.com 5c63370d25 Make ClosureMirror handle instances of user-defined classes that implement call.
R=asiva@google.com

Review URL: https://codereview.chromium.org//22625003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25944 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-08 20:25:46 +00:00
rmacnak@google.com fe85bf84bb Reflection on generics.
BUG=
R=ahe@google.com, regis@google.com

Review URL: https://codereview.chromium.org//22292002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25942 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-08 20:06:56 +00:00
rmacnak@google.com ce55909b63 Deal with "classes" that don't belong to any library. Addresses issue 12231.
Review URL: https://codereview.chromium.org/22043005/



git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25785 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-05 18:54:01 +00:00
rmacnak@google.com 6ab88ae6d5 Implement metadata for libraries. Partially addresses issue 10906.
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25721 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-01 20:45:49 +00:00
mlippautz@google.com f1dcf02f75 Inline CreateClassMirror and remove dead code.
(Almost) no more embedding API, yay!

Fixes issue 12135.

R=asiva@google.com

Review URL: https://codereview.chromium.org//21440002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25717 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-01 18:27:32 +00:00
rmacnak@google.com 409f02d3f9 Implement mirror equality on the VM. Resolves issue 12026.
R=asiva@google.com

Review URL: https://codereview.chromium.org//21381002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25711 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-01 16:40:10 +00:00
rmacnak@google.com 8ee3299833 Allow InstanceMirror.invoke to find private members. Resolves issue 11771.
R=asiva@google.com

Review URL: https://codereview.chromium.org//21430002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25690 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-31 23:45:12 +00:00
mlippautz@google.com 9f602cfa83 Also fixes issue 11897.
R=asiva@google.com

Review URL: https://codereview.chromium.org//21124011

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25689 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-31 23:31:14 +00:00
mlippautz@google.com c5c6df3548 BUG=
R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org//20216002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25651 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-30 22:57:59 +00:00
mlippautz@google.com 58beb194dc Hoist .simpleName and .qualifiedName up to _LocalDeclarationMirrorImpl.
Current tests already cover this change.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//21281002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25647 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-30 22:22:17 +00:00
mlippautz@google.com 8bfc72b1b9 Inline CreateLibraryMirror.
BUG=
R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org//21092004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25640 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-30 20:52:44 +00:00
rmacnak@google.com b68bc10c6c Create the local MirrorSystem with internal code.
R=asiva@google.com

Review URL: https://codereview.chromium.org//20851002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25601 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-30 01:09:05 +00:00
rmacnak@google.com 47f7d23626 Ensure FunctionTypeMirrors have a proper reflectee and implement ClassMirror.superinterfaces with internal code. Remove some unnecessary fields and constructor arguments.
R=asiva@google.com

Review URL: https://codereview.chromium.org//21010005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25599 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-30 00:29:52 +00:00
rmacnak@google.com 844a406c8a Implement reflect() with Dart code, InstanceMirror.type and ClosureMirror.function with internal code.
R=asiva@google.com

Review URL: https://codereview.chromium.org//21119002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25594 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-29 23:57:31 +00:00
mlippautz@google.com 5f4e6e6000 Remove dead code from native mirrors library.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//21047005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25576 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-29 17:49:04 +00:00
rmacnak@google.com bd07e14c9a Make ClassMirror.constructors an internal native and lazy.
R=asiva@google.com

Review URL: https://codereview.chromium.org//20564002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25533 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-26 18:29:38 +00:00
rmacnak@google.com b0cd678f0c Implement ClassMirror.superclass with internal code for ordinary (but not function type) classes. Resolves issue 5794 and issue 9434.
R=asiva@google.com

Review URL: https://codereview.chromium.org//20465002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25508 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-25 22:45:07 +00:00
mlippautz@google.com 4415c965d1 BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//20208002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25499 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-25 21:10:09 +00:00
rmacnak@google.com 670a0345ca Wrap lazy compilation errors when parsing metadata. Addresses the poor error reporting in issue 12027.
R=asiva@google.com

Review URL: https://codereview.chromium.org//20458002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25498 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-25 20:49:59 +00:00
rmacnak@google.com 4a98a91696 Change the return value of setField to be in line with non-reflective assignments. Complete unwrapping of exceptions for the InstanceMirror invokes. Resolves issue 11219 and issue 11943.
R=asiva@google.com

Review URL: https://codereview.chromium.org//20066004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25457 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-25 00:18:42 +00:00
rmacnak@google.com 8ebdd7f9d8 Make LibraryMirror.members an internal native and lazy.
R=asiva@google.com

Review URL: https://codereview.chromium.org//20119002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25451 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-24 23:51:15 +00:00
mlippautz@google.com db8354cd4b Inline CreateParameterMirrorList() functionality.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//19856003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25450 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-24 23:35:15 +00:00
rmacnak@google.com 1a0b3c7871 Make reflective invocations raise NoSuchMethodErrors in the cases where non-reflective invocations do so. Resolves issues 11187 and 11957.
R=asiva@google.com

Review URL: https://codereview.chromium.org//19819003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25387 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-24 00:29:17 +00:00
rmacnak@google.com c745da73af Make ClassMirror.members internal-native and lazy.
R=asiva@google.com

Review URL: https://codereview.chromium.org//19496003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25384 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-23 23:54:16 +00:00
mlippautz@google.com 9d367d788d Local change to make the type getter lazy.
This change adds the last piece missing to inline functionality of CreateMethodMirror and its parameters. (Separate CL.)

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//19983003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25325 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-23 00:39:28 +00:00
regis@google.com 9581071936 Refactor resolution code in the vm to properly handle ambiguity errors.
Add test.

R=asiva@google.com

Review URL: https://codereview.chromium.org//19662003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25324 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-23 00:19:39 +00:00
rmacnak@google.com 9c4fef756b Implement VariableMirror creation with non-API code. To break circular initialization, have them find their type lazily.
R=asiva@google.com

Review URL: https://codereview.chromium.org//19512003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25317 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-22 23:05:54 +00:00
mlippautz@google.com b58e38269b This change introduces nothing new. It only fixes the native entrypoints to use the right macros.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//19500016

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25315 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-22 22:49:08 +00:00
mlippautz@google.com b3cb27a829 Since returnType is represented by a mirror, we make it lazy. We do not use a lazy mirror anymore, but instead create a type mirror upon first access.
CreateTypeMirror is already factored out of MethodMirror_return_type since it is needed by others mirrors (future CLs). Also introduces CreateMirror() which will be used in future CLs.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//19780002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25252 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-19 23:17:47 +00:00
rmacnak@google.com 448dbb1017 Make the ClassMirrors created through reflectClass() find their owners (libraries) lazily.
Remove an unused parameter that was threaded through a number of mirror creation functions.

R=asiva@google.com

Review URL: https://codereview.chromium.org//19188004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25193 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-19 00:44:36 +00:00
rmacnak@google.com 08e322a197 Introduce an abstract DeclarationMirror in the implementation hierarchy; add a MirrorReference reflectee to TypedefMirror and TypeVariableMirror.
R=asiva@google.com

Review URL: https://codereview.chromium.org//19604004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25187 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-18 22:13:55 +00:00
mlippautz@google.com 61bae883ed If we have the owner mirror at creation time (which right now is a lazy mirror), we will use it. Eventually lazy mirrors will go away and we will not have to resolve() in dart code anymore.
If we don't have it, for example for a nested closure, we set it null and construct it lazily at access time.

Example:

outer() {
  inner() {}
  var closureMirror = reflect(inner);
  print(closureMirror.function.owner);  // Should be a MethodMirror on outer, that is constructed lazily.
}

Since we need to be able to construct the chain of owners (back up to library), we need to handle all cases in the lazy creation.

The CL also adds wrappers that can be called with native objects. At some point these wrapper will create the mirrors without referring to the ones using embedded API.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//19579006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25186 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-18 22:04:57 +00:00
rmacnak@google.com 31145d5478 Implement metadata as an internal native. Be honest about which mirrors don't yet support metadata introspection.
R=asiva@google.com

Review URL: https://codereview.chromium.org//19235015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25126 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-17 21:50:54 +00:00
mlippautz@google.com 8b65384ede Moved some MethodMirror getters from embedded API to lazy native calls.
The more complex ones (creating LazyXXXMirror) are still left and will be handled in a separate CL.

Tests are (still) excluded from dart2js, because of one regression test in the same file.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//19299003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25081 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-17 00:42:30 +00:00
fschneider@google.com dfd21c06e0 Change resolving of instance methods to check early for name mismatch.
The names of actual arguments are checked at resolving time
for a mismatch instead of deferring this check to the function
prologue (emitted as part of the CopyParameters() prologue).

For example:

class A {
  foo({a:42}) => null;
}

main() {
  var a = new A();
  a.foo(b:123);  // noSuchMethod: no named parameter named "b".
}

This enables e.g. fast noSuchMethod invocation in the case
of a named argument mismatch.

It also makes the function prologue for instance functions that
use optional parameters shorter by omitting the check for a 
name mismatch there.

R=regis@google.com

Review URL: https://codereview.chromium.org//19200002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25041 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-16 09:38:13 +00:00
rmacnak@google.com 87ddfa603f Fix the build on 64-bit.
Review URL: https://codereview.chromium.org//19289002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25025 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-15 21:27:59 +00:00
rmacnak@google.com 39bf0aca44 Implement the invoke methods (invoke, getField, setField, newInstance, apply) as internal natives.
R=asiva@google.com

Review URL: https://codereview.chromium.org//18463003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25024 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-15 21:14:43 +00:00
mlippautz@google.com 3b5ba678cd Add a MirrorReference reflectee to MethodMirrors. Name getter now refers to
internal function object, providing a name for for all cases and not only for
the ones a name has been provided in the constructor.

Fixes http://dartbug.com/6335

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org//18473005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24872 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-10 01:08:19 +00:00
rmacnak@google.com bba532bc7d Add a MirrorReference reflectee for ClassMirrors. Rewrite the name accessor in terms of it, at least for the non-special cases.
(This is a continuation of 18562005.)

R=asiva@google.com

Review URL: https://codereview.chromium.org//18465006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24826 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-08 22:05:15 +00:00
asiva@google.com e16291b973 Convert implementation in mirrors.cc to use Dart_GetType instead of Dart_GetClass.
R=regis@google.com

Review URL: https://codereview.chromium.org//17582016

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24491 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-26 21:30:18 +00:00
asiva@google.com 51651ee00b Split dart_api.h into multiple parts:
dart_api.h - Has the core API functions
dart_mirrors_api.h - Has API functions to support Mirrors or reflection
dart_native_api.h - Has parts which support the native message handling,
                    profilling and other internal tools

R=sgjesse@google.com, vsm@google.com

Review URL: https://codereview.chromium.org//16973003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24062 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-14 23:47:40 +00:00
gbracha@google.com c78462c2ad Changes to mirrors in support of metadata access at runtime.
R=iposva@google.com

Review URL: https://codereview.chromium.org//16757007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24050 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-14 21:12:58 +00:00
iposva@google.com b60d09b1fb - Add different types for persistent and weak persistent handles
in the Dart C API.
- Adapt code in the runtime.

R=asiva@google.com

Review URL: https://codereview.chromium.org//15772005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23421 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-30 15:55:59 +00:00
iposva@google.com 7ce7e98194 - Do not include unneeded platform/json.h.
Review URL: https://codereview.chromium.org//14476002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21949 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 14:04:13 +00:00
johnniwinther@google.com f721629103 Change libraries map to use Uri.
Review URL: https://codereview.chromium.org//14178010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21929 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 08:19:24 +00:00