@Check public void checkAssignment(XBinaryOperation binaryOperation) { if (binaryOperation.isReassignFirstArgument()) { XExpression leftOperand = binaryOperation.getLeftOperand(); checkAssignment(leftOperand, false); } }
protected boolean startsWithUnaryOperator(EObject obj) { if(obj instanceof XUnaryOperation) return true; if(obj instanceof XBinaryOperation) return startsWithUnaryOperator(((XBinaryOperation)obj).getLeftOperand()); if(obj instanceof XPostfixOperation) { return startsWithUnaryOperator(((XPostfixOperation)obj).getOperand()); } return false; }
protected boolean startsWithUnaryOperator(EObject obj) { if(obj instanceof XUnaryOperation) return true; if(obj instanceof XBinaryOperation) return startsWithUnaryOperator(((XBinaryOperation)obj).getLeftOperand()); if(obj instanceof XPostfixOperation) { return startsWithUnaryOperator(((XPostfixOperation)obj).getOperand()); } return false; }
private void buildLeftOperand(XAbstractFeatureCall expr, List<Object> output) { final XBinaryOperation binaryOperation = (XBinaryOperation) expr; final XAbstractFeatureCall leftOperand = (XAbstractFeatureCall) binaryOperation.getLeftOperand(); final JvmIdentifiableElement feature = leftOperand.getFeature(); if (this.codeReceiver.hasName(feature)) { output.add(this.codeReceiver.getName(feature)); return; } buildCallReceiver(leftOperand, getExtraLanguageKeywordProvider().getThisKeywordLambda(), this.referenceNameLambda, output); output.add(feature.getSimpleName()); }
/** Test if the given expression has side effects. * * @param expression the expression. * @param context the list of context expressions. * @return {@code true} if the expression has side effects. */ protected Boolean _hasSideEffects(XBinaryOperation expression, ISideEffectContext context) { if (isReassignmentOperator(expression)) { if (!isLocalExpression(expression.getLeftOperand(), context, false)) { return true; } } else { if (expression.isTypeLiteral() || expression.isPackageFragment()) { return false; } if (hasSideEffects(expression.getLeftOperand(), context)) { return true; } } if (hasSideEffects(expression.getRightOperand(), context)) { return true; } return false; }
protected Object _internalEvaluate(final XBinaryOperation it, final Context ctx) { Object _xblockexpression = null; { final Context context = ctx.cloneWithExpectation(null); final Object left = this.evaluate(it.getLeftOperand(), context); final Object right = this.evaluate(it.getRightOperand(), context); _xblockexpression = this.evaluateBinaryOperation(it, left, right); } return _xblockexpression; }
public XExpression getSyntacticReceiver(XExpression expression) { if (expression instanceof XAbstractFeatureCall) { if (expression instanceof XFeatureCall) { return null; } if (expression instanceof XMemberFeatureCall) { return ((XMemberFeatureCall) expression).getMemberCallTarget(); } if (expression instanceof XAssignment) { return ((XAssignment) expression).getAssignable(); } if (expression instanceof XBinaryOperation) { return ((XBinaryOperation) expression).getLeftOperand(); } if (expression instanceof XUnaryOperation) { return ((XUnaryOperation) expression).getOperand(); } if (expression instanceof XPostfixOperation) { return ((XPostfixOperation) expression).getOperand(); } } return null; }
protected Object _doEvaluate(XSetLiteral literal, IEvaluationContext context, CancelIndicator indicator) { if(isType(literal, Map.class)) { Map<Object, Object> map = newHashMap(); for(XExpression element: literal.getElements()) { if (indicator.isCanceled()) throw new InterpreterCanceledException(); if (expressionHelper.isOperatorFromExtension(element, OperatorMapping.MAPPED_TO, ObjectExtensions.class)) { map.put(internalEvaluate(((XBinaryOperation)element).getLeftOperand(), context, indicator), internalEvaluate(((XBinaryOperation)element).getRightOperand(), context, indicator)); } else if (isType(element, Pair.class)) { Pair<?, ?> pair = (Pair<?, ?>) internalEvaluate(element, context, indicator); map.put(pair == null ? null : pair.getKey(), pair == null ? null : pair.getValue()); } } return Collections.unmodifiableMap(map); } else { Set<Object> set = newHashSet(); for(XExpression element: literal.getElements()) { if (indicator.isCanceled()) throw new InterpreterCanceledException(); set.add(internalEvaluate(element, context, indicator)); } return Collections.unmodifiableSet(set); } }
protected ITreeAppendable appendLeftOperand(final XAbstractFeatureCall expr, ITreeAppendable appendable, boolean isExpressionContext) { XBinaryOperation binaryOperation = (XBinaryOperation) expr; XAbstractFeatureCall leftOperand = (XAbstractFeatureCall) binaryOperation.getLeftOperand(); JvmIdentifiableElement feature = leftOperand.getFeature(); if (appendable.hasName(feature)) { return appendable.append(appendable.getName(feature)); } boolean hasReceiver = appendReceiver(leftOperand, appendable, isExpressionContext); if (hasReceiver) { appendable.append("."); } return appendable.append(feature.getSimpleName()); }
protected Object _doEvaluate(XAbstractFeatureCall featureCall, IEvaluationContext context, CancelIndicator indicator) { if (expressionHelper.isShortCircuitOperation(featureCall)) { XExpression leftOperand = ((XBinaryOperation)featureCall).getLeftOperand(); Object result = internalEvaluate(leftOperand, context, indicator); String operatorName = featureCall.getConcreteSyntaxFeatureName(); XBinaryOperation binaryOperation = (XBinaryOperation) featureCall; if (binaryOperation.isReassignFirstArgument()) { XAbstractFeatureCall leftOperand = (XAbstractFeatureCall) binaryOperation.getLeftOperand(); assignValueTo(leftOperand.getFeature(), featureCall, result, context, indicator);
if (operator != null) { it.append("("); //$NON-NLS-1$ generate(operation.getLeftOperand(), it, context); switch (operator) { case "-": //$NON-NLS-1$
} else { AbstractElement _terminal_1 = assignment.getTerminal(); this.createReceiverProposals(((XBinaryOperation)model).getLeftOperand(), ((CrossReference) _terminal_1), context, acceptor);
@Check public void checkOperandTypesForTripleEquals(XBinaryOperation binaryOperation) { if(isTripleEqualsOperation(binaryOperation)){ LightweightTypeReference left = getActualType(binaryOperation.getLeftOperand()); LightweightTypeReference right = getActualType(binaryOperation.getRightOperand()); if(left.isArray() != right.isArray()) { if (left.isArray()) { if (right.isAny() || right.isType(Object.class) || right.isType(Serializable.class) || right.isType(Cloneable.class)) { return; } } else { if (left.isAny() || left.isType(Object.class) || left.isType(Serializable.class) || left.isType(Cloneable.class)) { return; } } error("Incompatible operand types " + left.getHumanReadableName() + " and " + right.getHumanReadableName(), null, INVALID_OPERAND_TYPES); } } }
context = ((XBinaryOperation) context).getLeftOperand(); anchor = IExpressionScope.Anchor.RECEIVER; } else if (context instanceof XMemberFeatureCall) {
top = ((XBinaryOperation) top).getLeftOperand();
protected void generateShortCircuitInvocation(final XAbstractFeatureCall featureCall, final ITreeAppendable b) { final XBinaryOperation binaryOperation = (XBinaryOperation) featureCall; final XExpression leftOperand = binaryOperation.getLeftOperand(); final XExpression rightOperand = binaryOperation.getRightOperand(); declareSyntheticVariable(binaryOperation, b);
top = ((XBinaryOperation) top).getLeftOperand();
protected EvaluationResult _internalEvaluate(final XBinaryOperation it, final EvaluationContext context) { if ((this.isFromXbaseLibrary(it, context) && (it.getRightOperand() != null))) { final EvaluationResult left = this.doEvaluate(it.getLeftOperand(), context); final EvaluationResult right = this.doEvaluate(it.getRightOperand(), context); try {
} else if (expressionHelper.isShortCircuitOperation(expr)) { final XBinaryOperation binaryOperation = (XBinaryOperation) expr; final XExpression leftOperand = binaryOperation.getLeftOperand(); final XExpression rightOperand = binaryOperation.getRightOperand();
@Check public void checkPrimitiveComparedToNull(XBinaryOperation binaryOperation) { String operatorSymbol = binaryOperation.getConcreteSyntaxFeatureName(); XExpression left = binaryOperation.getLeftOperand(); XExpression right = binaryOperation.getRightOperand(); if (right != null && right.eClass() == XbasePackage.Literals.XNULL_LITERAL || left != null && left.eClass() == XbasePackage.Literals.XNULL_LITERAL) {