-
Notifications
You must be signed in to change notification settings - Fork 23
What's new in 0.4
szegedi edited this page Oct 25, 2012
·
2 revisions
-
dyn:callPropWithThis
has been renamed todyn:callMethod
to be consistent with bothdyn:getMethod
anddyn:call
.
-
dyn:getMethod
anddyn:call
operations. Instead of usingdyn:callMethod
(formerlydyn:callPropWithThis
), you can separate the invocation intodyn:getMethod
to retrieve an object that represents a method on an object (not bound to the object used to retrieve it), and thendyn:call
to invoke the method (still passing a receiver, since the method is not bound to a receiver). It allows more flexibility in implementations, and also allows calls of first-class function objects that didn't originate from a lookup on an object (global functions, closures, etc.). In order to not confuse various namespaces,dyn:getMethod
was introduced in addition todyn:getProp
anddyn:getElem
as the preferred way to lookup a method on an object. BeansLinker returns objects that correctly represent POJO methods throughdyn:getMethod
, and react correctly todyn:call
. - Composite operations: you can now specify multiple get or set operations at a single call site. I.e. if your language has no syntactic distinction between namespaces for properties and elements, you can use
dyn:getProp|getElem:color
to tell the linkers that at the call site you wish to retrieve a property named 'color', but if it isn't available, it should try to retrieve a container element named 'color' instead. By varying the order of the operations, you can give them different priorities. It is perfectly legal to compileobj.color
intodyn:getProp|getElem|getMethod:color
,obj['color']
intodyn:getElem|getProp|getMethod:color
,obj.color()
intodyn:getMethod|getProp|getElem:color
(followed bydyn:call
), and so on. The built-in BeansLinker makes sure to create as efficient linkage for composite operations as possible (i.e. if it knows that the object will always have a property with the requested name, it'll just ignore the rest of the operations.)
- org.dynalang.dynalink.support.NameCodec class for standardized name mangling/demangling as per John Rose's "Symbolic Freedom in the VM" article. Demangling works automatically as long as you use CallSiteDescriptorFactory.tokenizeName(), mangling needs to be done from your language compiler's bytecode emitter using NameCodec.encode().
Guards.isNotNull
-
Lookup.findGetter
andLookup.findOwnStatic
-
CallSiteDescriptorFactory
now has a method for tokenizing composite operations. -
DynamicLinker.getLinkerServices()
for a wholesale access to the linker's underlying services.
-
CallSiteDescriptor
now has constants for standard indexing of name tokens, i.e. SCHEME for 0, OPERATION for 1, and NAME_OPERAND for 2. - We now allow unqualified names in explicit signature selectors, i.e.
dyn:getMethod:read(InputStream)
instead ofdyn:getMethod:read(java.io.InputStream)
. The resolver is smart enough to match them to actual signature types; you only need fully qualified names if you'd have a conflict in the unqualified name between multiple overloaded methods in that argument position, which is extremely unlikely. - LinkerServices.asType() now does a conversion of return types too.