2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package gov.nasa.jpf.vm;
20 import java.util.Iterator;
23 * concrete type to store execution paths. TrailInfo corresponds to Transition,
24 * i.e. all instructions executed in the context of a vm.forward() leading
27 public class Transition implements Iterable<Step>, Cloneable {
29 ChoiceGenerator<?> cg;
32 private Step first, last;
35 private Object annotation;
38 private int stateId = StateSet.UNKNOWN_ID;
40 public Transition (ChoiceGenerator<?> cg, ThreadInfo ti) {
46 public Object clone() {
48 Transition t = (Transition)super.clone();
50 // the deep copy references
52 t.ti = (ThreadInfo)ti.clone();
56 } catch (CloneNotSupportedException cnsx){
57 return null; // cannot happen
61 public String getLabel () {
63 return last.getLineString();
69 public int getStateId() {
73 public void setStateId(int id) {
77 public void setOutput (String s) {
81 public void setAnnotation (Object o) {
85 public Object getAnnotation () {
89 public String getOutput () {
93 // don't use this for step iteration - this is very inefficient
94 public Step getStep (int index) {
96 for (int i=0; s != null && i < index; i++) s = s.next;
100 public Step getLastStep () {
104 public int getStepCount () {
108 public ThreadInfo getThreadInfo() {
112 public int getThreadIndex () {
116 public ChoiceGenerator<?> getChoiceGenerator() {
120 public ChoiceGenerator<?>[] getChoiceGeneratorCascade(){
121 return cg.getCascade();
124 public void incStepCount() {
128 void addStep (Step step) {
139 public class StepIterator implements Iterator<Step> {
143 public boolean hasNext () {
144 return (cur != last);
148 public Step next () {
162 public void remove () {
167 for (s = first; s.next != cur; s = s.next);
175 public Iterator<Step> iterator () {
176 return new StepIterator();