Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bin/
.settings
.project
.classpath
.factorypath

# Files generated by IntelliJ ANTLR plugin
key.core/src/main/gen
Expand Down
1 change: 1 addition & 0 deletions key.core/src/main/antlr4/KeYLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ MAXEXPANDMETHOD : '\\mayExpandMethod';
STRICT : '\\strict';
TYPEOF : '\\typeof';
INSTANTIATE_GENERIC : '\\instantiateGeneric';
HAS_ANNOTATION: '\\hasAnnotation';

// Quantifiers, binding, substitution
FORALL : '\\forall' | '\u2200';
Expand Down
1 change: 1 addition & 0 deletions key.core/src/main/antlr4/KeYParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ varexpId: // weigl, 2021-03-12: This will be later just an arbitrary identifier.
| GET_VARIANT
| IS_LABELED
| ISINSTRICTFP
| HAS_ANNOTATION
;

varexp_argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
*
* It manages the entire contact with the recoder framework and ensures that their cross-referencing
* data is always uptodate. Prior to reading any source code, special classes (i.e. stubs for some
* needed library classes) are parsed in to have them available at any time.
* needed library classes) are parsed in order to have them available at any time.
*
* To use a Recoder2KeY bridge to convert data structures you can use the functions:
* {@link #readCompilationUnit(String)}, {@link #readCompilationUnitsAsFiles(String[], FileRepo)} or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ public Instanceof convert(recoder.java.expression.operator.Instanceof rio) {
public NewArray convert(recoder.java.expression.operator.NewArray newArr) {
// first we need to collect all children
ExtList children = collectChildren(newArr);

// annotations are collected separatly as they are not tracked
var annots = newArr.getAnnotations();
for (int i = annots.size() - 1; i >= 0; i--)
children.add(convert(annots.get(i)));

// now we have to extract the array initializer
// is stored separately and must not appear in the children list
ArrayInitializer arrInit = children.get(ArrayInitializer.class);
Expand Down Expand Up @@ -1751,6 +1757,17 @@ public New convert(recoder.java.expression.operator.New n) {
}
}

// annotations are collected separatly as they are not tracked
var annots = n.getAnnotations();
ImmutableArray<AnnotationUseSpecification> immutableAnnots = null;
if (annots != null) {
var annotArr = new AnnotationUseSpecification[annots.size()];
for (int i = annots.size() - 1; i >= 0; i--) {
annotArr[i] = convert(annots.get(i));
}
immutableAnnots = new ImmutableArray<>(annotArr);
}

TypeReference maybeAnonClass = (TypeReference) callConvert(tr);
if (n.getClassDeclaration() != null) {
callConvert(n.getClassDeclaration());
Expand All @@ -1759,9 +1776,10 @@ public New convert(recoder.java.expression.operator.New n) {
}

if (rp == null) {
return new New(arguments, maybeAnonClass, null);
return new New(arguments, maybeAnonClass, null, immutableAnnots);
} else {
return new New(arguments, maybeAnonClass, (ReferencePrefix) callConvert(rp));
return new New(arguments, maybeAnonClass, (ReferencePrefix) callConvert(rp),
immutableAnnots);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,17 @@ public LocalVariableDeclaration convert(recoder.java.declaration.LocalVariableDe
SchemaVariable typesv = ((TypeSVWrapper) lvd.getTypeReference()).getSV();

List<recoder.java.declaration.Modifier> mods = lvd.getModifiers();
Modifier[] modifiers = new Modifier[mods == null ? 0 : mods.size()];
for (int i = 0; i < modifiers.length; i++) {
List<recoder.java.declaration.AnnotationUseSpecification> annots = lvd.getAnnotations();
var modCount = mods == null ? 0 : mods.size();
var annotCount = annots == null ? 0 : annots.size();
Modifier[] modifiers = new Modifier[modCount + annotCount];

for (int i = 0; i < modCount; i++) {
modifiers[i] = (Modifier) callConvert(mods.get(i));
}
for (int i = 0; i < annotCount; i++) {
modifiers[i + modCount] = (Modifier) callConvert(annots.get(i));
}

return new LocalVariableDeclaration(modifiers, (ProgramSV) typesv, varspecs);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
package de.uka.ilkd.key.java.declaration.modifier;

import de.uka.ilkd.key.java.ProgramElement;
import de.uka.ilkd.key.java.SourceData;
import de.uka.ilkd.key.java.declaration.Modifier;
import de.uka.ilkd.key.java.reference.TypeReference;
import de.uka.ilkd.key.java.reference.TypeReferenceContainer;
import de.uka.ilkd.key.rule.MatchConditions;

import org.key_project.logic.SyntaxElement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AnnotationUseSpecification extends Modifier implements TypeReferenceContainer {
private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationUseSpecification.class);

protected final TypeReference tr;

Expand All @@ -18,7 +26,7 @@ public AnnotationUseSpecification(TypeReference tr) {
}

protected String getSymbol() {
return "@" + tr.toString();
return "@" + tr.getName();
}

public TypeReference getTypeReferenceAt(int index) {
Expand All @@ -39,8 +47,25 @@ public ProgramElement getChildAt(int index) {
throw new ArrayIndexOutOfBoundsException();
}

@Override
public SyntaxElement getChild(int index) {
return getChildAt(index);
}

public int getChildCount() {
return 1;
}

@Override
public MatchConditions match(SourceData source, MatchConditions matchCond) {
final ProgramElement pe = source.getSource();
matchCond = super.match(source, matchCond);

if (matchCond != null
&& !tr.getName().equals(((AnnotationUseSpecification) pe).tr.getName())) {
return null;
}

return matchCond;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import de.uka.ilkd.key.java.declaration.ClassDeclaration;
import de.uka.ilkd.key.java.declaration.TypeDeclaration;
import de.uka.ilkd.key.java.declaration.TypeDeclarationContainer;
import de.uka.ilkd.key.java.declaration.modifier.AnnotationUseSpecification;
import de.uka.ilkd.key.java.expression.ExpressionStatement;
import de.uka.ilkd.key.java.reference.ConstructorReference;
import de.uka.ilkd.key.java.reference.ReferencePrefix;
Expand All @@ -15,6 +16,7 @@
import de.uka.ilkd.key.java.visitor.Visitor;

import org.key_project.util.ExtList;
import org.key_project.util.collection.ImmutableArray;

/**
* The object allocation operator. There are two variants for New:
Expand Down Expand Up @@ -72,10 +74,10 @@ public New(ExtList children, ReferencePrefix rp, PositionInfo pi) {
accessPath = rp;
}


/**
* Constructor for the transformation of COMPOST ASTs to KeY.
*
* @param arguments the arguments to the constructor
* @param type a TypeReference (the referred type)
* @param rp a ReferencePrefix as access path for the constructor
*/
Expand All @@ -85,6 +87,21 @@ public New(Expression[] arguments, TypeReference type, ReferencePrefix rp) {
accessPath = rp;
}

/**
* Constructor for the transformation of COMPOST ASTs to KeY.
*
* @param arguments the arguments to the constructor
* @param type a TypeReference (the referred type)
* @param rp a ReferencePrefix as access path for the constructor
* @param annotations the annotations on the constructor call
*/
public New(Expression[] arguments, TypeReference type, ReferencePrefix rp,
ImmutableArray<AnnotationUseSpecification> annotations) {
super(arguments, type, annotations);
anonymousClass = null;
accessPath = rp;
}


@Override
public SourceElement getFirstElement() {
Expand Down Expand Up @@ -156,6 +173,9 @@ public int getChildCount() {
if (anonymousClass != null) {
result++;
}
if (annotations != null) {
result += annotations.size();
}
return result;
}

Expand Down Expand Up @@ -186,6 +206,13 @@ public ProgramElement getChildAt(int index) {
if (index == 0) {
return anonymousClass;
}
index--;
}
if (annotations != null) {
len = annotations.size();
if (len > index) {
return annotations.get(index);
}
}
throw new ArrayIndexOutOfBoundsException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public int getChildCount() {
if (arrayInitializer != null) {
result++;
}
if (annotations != null) {
result += annotations.size();
}
return result;
}

Expand Down Expand Up @@ -189,6 +192,13 @@ public ProgramElement getChildAt(int index) {
if (index == 0) {
return arrayInitializer;
}
index--;
}
if (annotations != null) {
len = annotations.size();
if (len > index) {
return annotations.get(index);
}
}
throw new ArrayIndexOutOfBoundsException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import de.uka.ilkd.key.java.PositionInfo;
import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.java.abstraction.KeYJavaType;
import de.uka.ilkd.key.java.declaration.modifier.AnnotationUseSpecification;
import de.uka.ilkd.key.java.expression.Operator;
import de.uka.ilkd.key.java.reference.ExecutionContext;
import de.uka.ilkd.key.java.reference.TypeReference;
import de.uka.ilkd.key.java.reference.TypeReferenceContainer;

import org.key_project.util.ExtList;
import org.key_project.util.collection.ImmutableArray;

/**
* Type operator.
Expand All @@ -27,6 +29,11 @@ public abstract class TypeOperator extends Operator implements TypeReferenceCont
*/
protected final TypeReference typeReference;

/**
* Annotations.
*/
protected final ImmutableArray<AnnotationUseSpecification> annotations;


/**
* Constructor for the transformation of COMPOST ASTs to KeY.
Expand All @@ -38,6 +45,8 @@ public abstract class TypeOperator extends Operator implements TypeReferenceCont
protected TypeOperator(ExtList children) {
super(children);
typeReference = children.get(TypeReference.class);
annotations = new ImmutableArray<>(
children.collect(AnnotationUseSpecification.class));
}

/**
Expand All @@ -50,20 +59,32 @@ protected TypeOperator(ExtList children) {
protected TypeOperator(ExtList children, PositionInfo pi) {
super(children);
typeReference = children.get(TypeReference.class);
annotations = new ImmutableArray<>(
children.collect(AnnotationUseSpecification.class));
}

protected TypeOperator(Expression unaryChild, TypeReference typeref) {
super(unaryChild);
typeReference = typeref;
annotations = null;
}

protected TypeOperator(Expression[] arguments, TypeReference typeref) {
super(arguments);
typeReference = typeref;
annotations = null;
}

protected TypeOperator(Expression[] arguments, TypeReference typeref,
ImmutableArray<AnnotationUseSpecification> annotations) {
super(arguments);
typeReference = typeref;
this.annotations = annotations;
}

protected TypeOperator() {
typeReference = null;
annotations = null;
}

/**
Expand Down Expand Up @@ -110,6 +131,12 @@ public KeYJavaType getKeYJavaType(Services javaServ) {
return getTypeReference().getKeYJavaType();
}



/**
* Get the annotations.
*
* @return the annotations.
*/
public ImmutableArray<AnnotationUseSpecification> getAnnotations() {
return annotations;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.key_project.logic.Namespace;
import org.key_project.logic.op.sv.SchemaVariable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import recoder.ParserException;
import recoder.convenience.TreeWalker;
import recoder.java.*;
Expand All @@ -34,6 +36,7 @@
import recoder.list.generic.ASTList;

public class SchemaJavaProgramFactory extends JavaProgramFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaJavaProgramFactory.class);

protected Namespace<SchemaVariable> svns;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.key_project.util.ExtList;

/**
* The JavaDL theory class provides access to function symvols, sorts that are part of the core
* The JavaDL theory class provides access to function symbols, sorts that are part of the core
* logic
* like cast or instanceof functions.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,35 @@ public String getDescription() {
"wellFormedAnonEQ", "wellFormedMemsetArrayObjectEQ", "wellFormedMemsetArrayPrimitiveEQ",
"wellFormedMemsetObjectEQ", "wellFormedMemsetLocSetEQ", "wellFormedMemsetPrimitiveEQ",

// universe rules
"createdRepfpElement",

"dismissSelectOfDominatedObject", "dismissSelectOfDominatingObject",
"dismissSelectOfDominatedAnon", "dismissSelectOfDominatedCreatedAnon",

"dismissSelectOfSelfRepfpComplementAnon", "dismissSelectOfSelfCreatedRepfpComplementAnon",
"dismissSelectOfDominatingRepfpComplementAnon",
"dismissSelectOfDominatingCreatedRepfpComplementAnon",

"dismissSelectOfDominatedObjectEQ", "dismissSelectOfDominatingObjectEQ",
"dismissSelectOfDominatedAnonEQ", "dismissSelectOfDominatedCreatedAnonEQ",

"dismissSelectOfSelfRepfpComplementAnonEQ",
"dismissSelectOfSelfCreatedRepfpComplementAnonEQ",
"dismissSelectOfDominatingRepfpComplementAnonEQ",
"dismissSelectOfDominatingCreatedRepfpComplementAnonEQ",

"simplifySelectOfDominatedAnon", "simplifySelectOfDominatedCreatedAnon",
"simplifySelectOfSelfRepfpComplementAnon", "simplifySelectOfSelfCreatedRepfpComplementAnon",
"simplifySelectOfDominatingRepfpComplementAnon",
"simplifySelectOfDominatingCreatedRepfpComplementAnon",

"simplifySelectOfDominatedAnonEQ", "simplifySelectOfDominatedCreatedAnonEQ",
"simplifySelectOfSelfRepfpComplementAnonEQ",
"simplifySelectOfSelfCreatedRepfpComplementAnonEQ",
"simplifySelectOfDominatingRepfpComplementAnonEQ",
"simplifySelectOfDominatingCreatedRepfpComplementAnonEQ",

// locset rules
"elementOfEmpty", "elementOfAllLocs", "elementOfSingleton", "elementOfUnion",
"elementOfIntersect", "elementOfSetMinus", "elementOfAllFields", "elementOfAllObjects",
Expand Down
Loading