Class BaseBHDescriptor
- java.lang.Object
 - 
- jetbrains.mps.core.aspects.behaviour.BaseBHDescriptor
 
 
- 
- All Implemented Interfaces:
 BHDescriptor
- Direct Known Subclasses:
 EmptyBHDescriptor
public abstract class BaseBHDescriptor extends Object implements BHDescriptor
Common ancestor for all the generated behavior aspects (per concept). Exploiting the idea of virtual table to yield the dynamic dispatch for behavior methods' invocation.TODO Features: Multiple dispatch? Default parameter values?
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseBHDescriptor.BHNotInitializedException 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedBaseBHDescriptor(BehaviorRegistry behaviorRegistry) 
- 
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract List<SMethod<?>>getDeclaredMethods()Returns list ofSMethodobjects reflecting all the methods (from private to public) of the concept represented by this descriptor EXCLUDING those inherited from super concepts.List<SMethod<?>>getMethods()Returns list ofSMethodobjects reflecting all the public (!) methods of the concept represented by this descriptor INCLUDING those declared by the concept itself and including those inherited from super concepts.voidinit()Intended to be executed during concept behavior constructionvoidinitNode(SNode node)Presumably to move upwards to the interface however the status of node construction is not clear in the project MPS.protected abstract voidinitNode(SNode node, SConstructor constructor, Object[] parameters)<T> Tinvoke(SAbstractConcept operand, SMethod<T> method, Object... parameters)invokes a static method (trying to resolve the right method on runtime if it is virtual)<T> Tinvoke(SNode operand, SMethod<T> method, Object... parameters)invokes a method (trying to resolve the right method on runtime if it is virtual) one could ask why we have three concepts accessible from here? the answer: suppose we haveconcepts A extends B extends C C has a virtual method #foo declared (which is abstract and overridden both in A and B) node n = new node(); n.foo();then we have BHDescriptor#getConcept == A, operand.getConcept == B, method.getConcept == A|B|C (any of this yields the same)<T> TinvokeSpecial(SAbstractConcept operand, SMethod<T> method, Object... parameters)invokes a method without dynamic binding (not trying to resolve the right method on runtime if it is virtual) E.g.<T> TinvokeSpecial(SNode operand, SMethod<T> method, Object... parameters)invokes a method without dynamic binding (not trying to resolve the right method on runtime if it is virtual) E.g.protected abstract <T> TinvokeSpecial0(SAbstractConcept concept, SMethod<T> method, Object[] parameters)invokes a static method without dynamic resolutionprotected abstract <T> TinvokeSpecial0(SNode node, SMethod<T> method, Object[] parameters)invokes a method without dynamic resolution<T> TinvokeSuper(SAbstractConcept operand, SMethod<T> method, Object... parameters)invokes a virtual static method, see above for details<T> TinvokeSuper(SNode operand, SMethod<T> method, Object... parameters)invokes a virtual method, selecting from the ancestors of the given node concept.SNodenewNode(SModel model, SConstructor constructor, Object... parameters)invokes the behavior constructorStringtoString()- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface jetbrains.mps.core.aspects.behaviour.api.BHDescriptor
getConcept, getDeclaredMethod, getMethod 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
BaseBHDescriptor
protected BaseBHDescriptor(BehaviorRegistry behaviorRegistry)
 
 - 
 
- 
Method Detail
- 
init
public void init()
Intended to be executed during concept behavior construction 
- 
newNode
@NotNull public SNode newNode(@Nullable SModel model, @NotNull SConstructor constructor, Object... parameters)
Description copied from interface:BHDescriptorinvokes the behavior constructor- Specified by:
 newNodein interfaceBHDescriptor- Parameters:
 model- a container for the new nodeconstructor- constructor to invokeparameters- parameters to pass- Returns:
 - new SNode which is initialized and constructed
 
 
- 
initNode
public void initNode(@NotNull SNode node)
Presumably to move upwards to the interface however the status of node construction is not clear in the project MPS. There are already several similar approaches to construct a node and not everybody agrees that the main point for this activity is here, behavior rt. 
- 
invoke
public final <T> T invoke(@NotNull SNode operand, @NotNull SMethod<T> method, Object... parameters)
Description copied from interface:BHDescriptorinvokes a method (trying to resolve the right method on runtime if it is virtual) one could ask why we have three concepts accessible from here? the answer: suppose we haveconcepts A extends B extends C C has a virtual method #foo declared (which is abstract and overridden both in A and B) node n = new node(); n.foo();then we have BHDescriptor#getConcept == A, operand.getConcept == B, method.getConcept == A|B|C (any of this yields the same)- Specified by:
 invokein interfaceBHDescriptor
 
- 
invoke
public final <T> T invoke(@NotNull SAbstractConcept operand, @NotNull SMethod<T> method, Object... parameters)
Description copied from interface:BHDescriptorinvokes a static method (trying to resolve the right method on runtime if it is virtual)- Specified by:
 invokein interfaceBHDescriptor
 
- 
invokeSuper
public final <T> T invokeSuper(@NotNull SNode operand, @NotNull SMethod<T> method, Object... parameters)
Description copied from interface:BHDescriptorinvokes a virtual method, selecting from the ancestors of the given node concept. the difference with the#invokemethod is only that we do not include the node concept itself in the scope.- Specified by:
 invokeSuperin interfaceBHDescriptor
 
- 
invokeSuper
public final <T> T invokeSuper(@NotNull SAbstractConcept operand, @NotNull SMethod<T> method, Object... parameters)
Description copied from interface:BHDescriptorinvokes a virtual static method, see above for details- Specified by:
 invokeSuperin interfaceBHDescriptor
 
- 
invokeSpecial
public <T> T invokeSpecial(@NotNull SNode operand, @NotNull SMethod<T> method, Object... parameters)
Description copied from interface:BHDescriptorinvokes a method without dynamic binding (not trying to resolve the right method on runtime if it is virtual) E.g. used when calling 'this' or 'super' non-virtual method from the behavior or calling a private method- Specified by:
 invokeSpecialin interfaceBHDescriptor
 
- 
invokeSpecial
public <T> T invokeSpecial(@NotNull SAbstractConcept operand, @NotNull SMethod<T> method, Object... parameters)
Description copied from interface:BHDescriptorinvokes a method without dynamic binding (not trying to resolve the right method on runtime if it is virtual) E.g. used when calling 'this' or 'super' non-virtual method from the behavior or calling a private method- Specified by:
 invokeSpecialin interfaceBHDescriptor
 
- 
getMethods
@NotNull public List<SMethod<?>> getMethods()
Description copied from interface:BHDescriptorReturns list ofSMethodobjects reflecting all the public (!) methods of the concept represented by this descriptor INCLUDING those declared by the concept itself and including those inherited from super concepts.- Specified by:
 getMethodsin interfaceBHDescriptor
 
- 
getDeclaredMethods
@NotNull public abstract List<SMethod<?>> getDeclaredMethods()
Description copied from interface:BHDescriptorReturns list ofSMethodobjects reflecting all the methods (from private to public) of the concept represented by this descriptor EXCLUDING those inherited from super concepts.- Specified by:
 getDeclaredMethodsin interfaceBHDescriptor
 
- 
initNode
protected abstract void initNode(@NotNull SNode node, @NotNull SConstructor constructor, @Nullable Object[] parameters)
- Parameters:
 node- -- the new node to initializeconstructor- -- constructor to invokeparameters- -- parameters to pass to the constructor
 
- 
invokeSpecial0
protected abstract <T> T invokeSpecial0(@NotNull SNode node, @NotNull SMethod<T> method, @Nullable Object[] parameters)
invokes a method without dynamic resolution- Parameters:
 parameters- is an array of arguments. NB: in the case of the last var arg parameter, the last array member is actually packed into another array- Throws:
 BHMethodNotFoundException- if the method has not been found
 
- 
invokeSpecial0
protected abstract <T> T invokeSpecial0(@NotNull SAbstractConcept concept, @NotNull SMethod<T> method, @Nullable Object[] parameters)
invokes a static method without dynamic resolution- Throws:
 BHMethodNotFoundException- if the method has not been found
 
 - 
 
 -