io.sarl.lang.typesystem
Class SARLOperationHelper
All Superinterfaces:
IOperationHelper
@javax.inject.Singleton
class SARLOperationHelper
extends java.lang.Object
implements IOperationHelper
Helper on operations.

This implementation extends the Xtend expression helper by assuming that any function with a name starting with "get", "is", "has" is a pure function. It also assumes that "equals", "hashCode", "clone" and "toString" are also pure functions.
Maven Group Identifier:
io.sarl.lang
Maven Artifact Identifier:
compiler
Since:
0.6
Nested Type Summary
Modifier and type Type and description
class SARLOperationHelper.AnnotationJavaGenerationAdapter
Adapter that enables to adda annotation when generating the Java code.
class SARLOperationHelper.SideEffectContext
Context for the side effect.
Constructor Summary
Constructor and description
new
Constructor.
Action Summary
Modifier and type Action and description
protected java.lang.Boolean _hasSideEffects(SarlAssertExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(SarlBreakExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(SarlContinueExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XAbstractWhileExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XAssignment,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XBasicForLoopExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XBinaryOperation,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XBlockExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XCastedExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XCollectionLiteral,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XConstructorCall,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XFeatureCall,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XForLoopExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XIfExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XMemberFeatureCall,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XPostfixOperation,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XReturnExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XSwitchExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XSynchronizedExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XThrowExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XTryCatchFinallyExpression,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XUnaryOperation,ISideEffectContext)
Test if the given expression has side effects.
protected java.lang.Boolean _hasSideEffects(XVariableDeclaration,ISideEffectContext)
Test if the given expression has side effects.
void attachPureAnnotationAdapter(JvmOperation,Function2<P1,P2,Result>)
boolean evaluatePureAnnotationAdapters(JvmOperation)
InferredPrototype getInferredPrototype(XtendConstructor)
Replies the inferred prototype of the given constructor.
InferredPrototype getInferredPrototype(XtendFunction)
Replies the inferred prototype of the given operation.
InferredPrototype getInferredPrototype(JvmConstructor)
Replies the inferred prototype of the given constructor.
InferredPrototype getInferredPrototype(JvmOperation)
Replies the inferred prototype of the given operation.
java.lang.Iterable<T> getSideEffectExpressions(InferredPrototype,XExpression)
boolean hasSideEffects(InferredPrototype,XExpression)
protected java.lang.Boolean hasSideEffects(XExpression,ISideEffectContext)
Determine if the given expression has a side effect.
protected java.lang.Boolean hasSideEffects(InferredPrototype,XExpression,ISideEffectContext)
Determine if the given expression has a side effect.
boolean isPurableOperation(XtendFunction)
boolean isPureOperation(JvmOperation)
boolean isPureOperation(JvmOperation,ISideEffectContext)
Check if the given operation is annoted with @Pure.
protected boolean isPureStateAmbiguous(XtendFunction)
Replies if it is impossible to determine the pure state of the given function .
protected boolean isPureStateForbidden(XtendFunction)
Replies if the given function is purable according to its modifiers and prototype.
protected boolean isReassignmentOperator(XBinaryOperation)
Replies if the given operator is a reassignment operator.
Constructor Details
new
new
Constructor.
Action Details
_hasSideEffects(SarlAssertExpression,ISideEffectContext)
protected def _hasSideEffects(SarlAssertExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(SarlBreakExpression,ISideEffectContext)
protected def _hasSideEffects(SarlBreakExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(SarlContinueExpression,ISideEffectContext)
protected def _hasSideEffects(SarlContinueExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
Since:
0.7
_hasSideEffects(XAbstractWhileExpression,ISideEffectContext)
protected def _hasSideEffects(XAbstractWhileExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XAssignment,ISideEffectContext)
protected def _hasSideEffects(XAssignment,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XBasicForLoopExpression,ISideEffectContext)
protected def _hasSideEffects(XBasicForLoopExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XBinaryOperation,ISideEffectContext)
protected def _hasSideEffects(XBinaryOperation,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XBlockExpression,ISideEffectContext)
protected def _hasSideEffects(XBlockExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XCastedExpression,ISideEffectContext)
protected def _hasSideEffects(XCastedExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XCollectionLiteral,ISideEffectContext)
protected def _hasSideEffects(XCollectionLiteral,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XConstructorCall,ISideEffectContext)
protected def _hasSideEffects(XConstructorCall,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XFeatureCall,ISideEffectContext)
protected def _hasSideEffects(XFeatureCall,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XForLoopExpression,ISideEffectContext)
protected def _hasSideEffects(XForLoopExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XIfExpression,ISideEffectContext)
protected def _hasSideEffects(XIfExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XMemberFeatureCall,ISideEffectContext)
protected def _hasSideEffects(XMemberFeatureCall,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XPostfixOperation,ISideEffectContext)
protected def _hasSideEffects(XPostfixOperation,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XReturnExpression,ISideEffectContext)
protected def _hasSideEffects(XReturnExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XSwitchExpression,ISideEffectContext)
protected def _hasSideEffects(XSwitchExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XSynchronizedExpression,ISideEffectContext)
protected def _hasSideEffects(XSynchronizedExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XThrowExpression,ISideEffectContext)
protected def _hasSideEffects(XThrowExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XTryCatchFinallyExpression,ISideEffectContext)
protected def _hasSideEffects(XTryCatchFinallyExpression,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XUnaryOperation,ISideEffectContext)
protected def _hasSideEffects(XUnaryOperation,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
_hasSideEffects(XVariableDeclaration,ISideEffectContext)
protected def _hasSideEffects(XVariableDeclaration,ISideEffectContext) : java.lang.Boolean
Test if the given expression has side effects.
Parameters:
expression - the expression.
context - the list of context expressions.
Returns:
true if the expression has side effects.
attachPureAnnotationAdapter(JvmOperation,Function2<P1,P2,Result>)
def attachPureAnnotationAdapter(JvmOperation,Function2<P1,P2,Result>)
evaluatePureAnnotationAdapters(JvmOperation)
def evaluatePureAnnotationAdapters(JvmOperation) : boolean
getInferredPrototype(XtendConstructor)
def getInferredPrototype(XtendConstructor) : InferredPrototype
Replies the inferred prototype of the given constructor.
Parameters:
constructor - the constructor.
Returns:
the inferred prototype.
Since:
0.12
getInferredPrototype(XtendFunction)
def getInferredPrototype(XtendFunction) : InferredPrototype
Replies the inferred prototype of the given operation.
Parameters:
operation - the operation.
Returns:
the inferred prototype.
Since:
0.12
getInferredPrototype(JvmConstructor)
def getInferredPrototype(JvmConstructor) : InferredPrototype
Replies the inferred prototype of the given constructor.
Parameters:
constructor - the constructor.
Returns:
the inferred prototype.
Since:
0.12
getInferredPrototype(JvmOperation)
def getInferredPrototype(JvmOperation) : InferredPrototype
Replies the inferred prototype of the given operation.
Parameters:
operation - the operation.
Returns:
the inferred prototype.
Since:
0.12
getSideEffectExpressions(InferredPrototype,XExpression)
def getSideEffectExpressions(InferredPrototype,XExpression) : java.lang.Iterable<T>
hasSideEffects(InferredPrototype,XExpression)
def hasSideEffects(InferredPrototype,XExpression) : boolean
hasSideEffects(XExpression,ISideEffectContext)
protected def hasSideEffects(XExpression,ISideEffectContext) : java.lang.Boolean
Determine if the given expression has a side effect.
Parameters:
expr - the expression.
context - the context.
Returns:
true if the expression has a side effect.
hasSideEffects(InferredPrototype,XExpression,ISideEffectContext)
protected def hasSideEffects(InferredPrototype,XExpression,ISideEffectContext) : java.lang.Boolean
Determine if the given expression has a side effect.
Parameters:
calledOperation - the called operation, not yet in the call stack.
expr - the expression.
context - the context.
Returns:
true if the expression has a side effect.
isPurableOperation(XtendFunction)
def isPurableOperation(XtendFunction) : boolean
isPureOperation(JvmOperation)
def isPureOperation(JvmOperation) : boolean
isPureOperation(JvmOperation,ISideEffectContext)
def isPureOperation(JvmOperation,ISideEffectContext) : boolean
Check if the given operation is annoted with @Pure.
Parameters:
operation - the operation to test.
context - the context of the purity evaluation.
Returns:
true if the operation is marked as pure; otherwise false .
Since:
0.13
See:
org.eclipse.xtext.xbase.lib.Pure , isPurableOperation(XtendFunction,ISideEffectContext)
isPureStateAmbiguous(XtendFunction)
protected def isPureStateAmbiguous(XtendFunction) : boolean
Replies if it is impossible to determine the pure state of the given function .
Parameters:
operation - the operation to test.
Returns:
true if the pure state of the operation cannot be determined.
Since:
0.10
isPureStateForbidden(XtendFunction)
protected def isPureStateForbidden(XtendFunction) : boolean
Replies if the given function is purable according to its modifiers and prototype.

Basically, an operation cannot be pure if:
  • native,
  • the return type is void.

This function is called usually before testing the pattern of the function's name.
Parameters:
operation - the operation to test.
Returns:
true if the operation is not pure according to the prototype.
Since:
0.10
isReassignmentOperator(XBinaryOperation)
protected def isReassignmentOperator(XBinaryOperation) : boolean
Replies if the given operator is a reassignment operator. A reassignment operator changes its left operand.
Parameters:
operator - the operator.
Returns:
true if the operator changes its left operand.