Skip to content

Commit

Permalink
add type calculators for simple first order operations
Browse files Browse the repository at this point in the history
  • Loading branch information
pkourouklidis committed Jan 16, 2025
1 parent efb2f11 commit 16d6a02
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.eclipse.epsilon.eol.execute.operations.declarative;

import org.eclipse.epsilon.eol.execute.operations.ITypeCalculator;
import org.eclipse.epsilon.eol.staticanalyser.types.EolPrimitiveType;
import org.eclipse.epsilon.eol.staticanalyser.types.EolType;

public class BooleanTypeCalculator implements ITypeCalculator {

@Override
public EolType calculateType(EolType contextType, EolType iteratorType, EolType expressionType) {
return EolPrimitiveType.Boolean;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.epsilon.eol.dom.Parameter;
import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
import org.eclipse.epsilon.eol.execute.context.IEolContext;
import org.eclipse.epsilon.eol.execute.operations.TypeCalculator;
import org.eclipse.epsilon.eol.function.CheckedEolPredicate;

/**
Expand All @@ -23,6 +24,7 @@
* @author Sina Madani
* @since 1.6
*/
@TypeCalculator(klass = IntegerTypeCalculator.class)
public class CountOperation extends FirstOrderOperation {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import org.eclipse.epsilon.eol.dom.Parameter;
import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
import org.eclipse.epsilon.eol.execute.context.IEolContext;
import org.eclipse.epsilon.eol.execute.operations.TypeCalculator;

@TypeCalculator(klass = BooleanTypeCalculator.class)
public class ExistsOperation extends SelectBasedOperation {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import org.eclipse.epsilon.eol.dom.Parameter;
import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
import org.eclipse.epsilon.eol.execute.context.IEolContext;
import org.eclipse.epsilon.eol.execute.operations.TypeCalculator;

@TypeCalculator(klass = BooleanTypeCalculator.class)
public class ForAllOperation extends SelectBasedOperation {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.eclipse.epsilon.eol.execute.operations.declarative;

import org.eclipse.epsilon.eol.execute.operations.ITypeCalculator;
import org.eclipse.epsilon.eol.staticanalyser.types.EolPrimitiveType;
import org.eclipse.epsilon.eol.staticanalyser.types.EolType;

public class IntegerTypeCalculator implements ITypeCalculator {

@Override
public EolType calculateType(EolType contextType, EolType iteratorType, EolType expressionType) {
return EolPrimitiveType.Integer;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.epsilon.eol.exceptions.EolIllegalOperationParametersException;
import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
import org.eclipse.epsilon.eol.execute.context.IEolContext;
import org.eclipse.epsilon.eol.execute.operations.TypeCalculator;
import org.eclipse.epsilon.eol.function.CheckedEolPredicate;

/**
Expand All @@ -27,6 +28,7 @@
* @author Sina Madani
* @since 1.6
*/
@TypeCalculator(klass = BooleanTypeCalculator.class)
public class NMatchOperation extends FirstOrderOperation {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*Boolean*/Sequence{0..9}.atLeastNMatch(i:Integer | i < 5, 1);
/*Boolean*/Sequence{0..9}.atMostNMatch(i:Integer | i < 5, 1);
/*Boolean*/Sequence{0..9}.nMatch(i:Integer | i < 5, 1);
/*Boolean*/Sequence{0..9}.exists(i:Integer | i < 5);
/*Boolean*/Sequence{0..9}.forAll(i:Integer | i < 5);
/*Boolean*/Sequence{0..9}.none(i:Integer | i < 5);
/*Boolean*/Sequence{0..9}.one(i:Integer | i < 5);
/*Integer*/Sequence{0..9}.count(i:Integer | i < 5);

0 comments on commit 16d6a02

Please sign in to comment.