00001 package gov.nasa.arc.ase.jpf;
00002
00003 import java.util.*;
00004 import gov.nasa.arc.ase.util.Debug;
00005 import gov.nasa.arc.ase.jpf.jvm.SystemState;
00006 import gov.nasa.arc.ase.jpf.jvm.ArrayWrapper;
00007
00008 public class StateStack extends Stack implements iStateStack {
00009 int max_depth = 0;
00010
00011 public boolean Full() {
00012 return (size() == max_depth);
00013 }
00014 public boolean Full(int extra) {
00015 return ((max_depth != -1) &&
00016 (size() == (max_depth+extra)));
00017 }
00018 public iSystemState Peek() {
00019 return (iSystemState)peek();
00020 }
00021 public iSystemState Pop() {
00022 pop();
00023 return TopOfStack();
00024 }
00025 public boolean Push(iSystemState s) {
00026 push(s);
00027 if (size() > Runner.max_stack_depth)
00028 Runner.max_stack_depth = size();
00029 return (size() != max_depth);
00030 }
00031 public void setMaxDepth(int value) {
00032 max_depth = value;
00033 }
00034 iSystemState TopOfStack() {
00035 if (isEmpty())
00036 return null;
00037 else
00038 return (iSystemState)peek();
00039 }
00040 public void UpdateTop(iScheduler current) {
00041 iSystemState s = TopOfStack();
00042 Scheduler sch = s.getScheduler();
00043
00044 if (TransitionResult.isRandom()) {
00045
00046
00047
00048 sch.incCurrentRandom(current);
00049 } else if (TransitionResult.isNotified() && Engine.options.notify) {
00050
00051
00052
00053 sch.incCurrentNotify(current);
00054
00055 } else {
00056
00057
00058
00059 sch.incCurrentThread(current);
00060
00061 }
00062 }
00063 public void UpdateTopExtra(iSystemState ss) {
00064 iSystemState top = TopOfStack();
00065
00066 top.updateExtra(ss);
00067 }
00068 }