Browse Source

Fixes/renames in property reference search code.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@4503 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 14 years ago
parent
commit
b870e550e7
  1. 11
      prism/src/parser/ast/ASTElement.java
  2. 73
      prism/src/parser/visitor/GetAllPropRefsRecursively.java
  3. 51
      prism/src/parser/visitor/GetAllReferencedProperties.java
  4. 6
      prism/src/userinterface/properties/GUIProperty.java

11
prism/src/parser/ast/ASTElement.java

@ -368,6 +368,17 @@ public abstract class ASTElement
return v;
}
/**
* Get all references to properties (by name) (i.e. ExpressionProp objects) recursively, store names in set.
*/
public Vector<String> getAllPropRefsRecursively(PropertiesFile propertiesFile) throws PrismLangException
{
Vector<String> v = new Vector<String>();
GetAllPropRefsRecursively visitor = new GetAllPropRefsRecursively(v, propertiesFile);
accept(visitor);
return v;
}
/**
* Find all references to action labels, check they exist and, if required,
* store their index locally (as defined by the containing ModuleFile).

73
prism/src/parser/visitor/GetAllPropRefsRecursively.java

@ -0,0 +1,73 @@
//==============================================================================
//
// Copyright (c) 2002-
// Authors:
// * Vojtech Forejt <vojtech.forejt@cs.ox.ac.uk> (University of Oxford)
// * Dave Parker <david.parker@comlab.ox.ac.uk> (University of Oxford)
//
//------------------------------------------------------------------------------
//
// This file is part of PRISM.
//
// PRISM is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// PRISM is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with PRISM; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//==============================================================================
package parser.visitor;
import java.util.Vector;
import parser.ast.ExpressionLabel;
import parser.ast.ExpressionProp;
import parser.ast.PropertiesFile;
import parser.ast.Property;
import prism.PrismLangException;
/**
* Get all references to properties (by name) (i.e. ExpressionProp objects) recursively, store names in set.
*/
public class GetAllPropRefsRecursively extends ASTTraverse
{
private Vector<String> v;
private PropertiesFile pf;
public GetAllPropRefsRecursively(Vector<String> v, PropertiesFile pf)
{
this.v = v;
this.pf = pf;
}
public void visitPost(ExpressionProp e) throws PrismLangException
{
if (!v.contains(e.getName())) {
v.addElement(e.getName());
}
}
public void visitPost(ExpressionLabel e) throws PrismLangException
{
String name;
Property prop = null;
// See if identifier corresponds to a property
name = e.getName();
if (prop == null && pf != null) {
prop = pf.lookUpPropertyObjectByName(name);
}
if (prop != null) {
// If so, add the name
v.addElement(e.getName());
}
}
}

51
prism/src/parser/visitor/GetAllReferencedProperties.java

@ -1,51 +0,0 @@
package parser.visitor;
import java.util.Vector;
import parser.ast.ExpressionFormula;
import parser.ast.ExpressionLabel;
import parser.ast.ExpressionProp;
import parser.ast.ModulesFile;
import parser.ast.PropertiesFile;
import parser.ast.Property;
import prism.PrismLangException;
public class GetAllReferencedProperties extends ASTTraverse
{
private Vector<String> v;
private ModulesFile mf;
private PropertiesFile pf;
public GetAllReferencedProperties(Vector<String> v, ModulesFile mf, PropertiesFile pf)
{
this.v = v;
this.mf = mf;
this.pf = pf;
}
public void visitPost(ExpressionProp e) throws PrismLangException
{
if (!v.contains(e.getName())) {
v.addElement(e.getName());
}
}
public void visitPost(ExpressionLabel e) throws PrismLangException
{
String name;
Property prop = null;
// See if identifier corresponds to a property
name = e.getName();
if (mf != null) {
prop = mf.getPropertyByName(name);
}
if (prop == null && pf != null) {
prop = pf.getPropertyObjectByName(name);
}
if (prop != null) {
// If so, add the name
v.addElement(e.getName());
}
}
}

6
prism/src/userinterface/properties/GUIProperty.java

@ -35,7 +35,6 @@ import javax.swing.*;
import userinterface.GUIPrism;
import parser.*;
import parser.ast.*;
import parser.visitor.GetAllReferencedProperties;
import prism.*;
/**
@ -411,9 +410,8 @@ public class GUIProperty
if (getStatus() == STATUS_PARSE_ERROR)
setStatus(STATUS_NOT_DONE);
//get the referenced names
this.referencedNames = new Vector<String>();
(new GetAllReferencedProperties(this.referencedNames, m, ff)).visit(ff.getPropertyObject(namedCount));
// get the referenced names
this.referencedNames = ff.getPropertyObject(namedCount).getAllPropRefsRecursively(ff);
} catch (PrismException ex) {
this.expr = null;

Loading…
Cancel
Save