00001 package edu.ksu.cis.bandera.bir;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import ca.mcgill.sable.util.*;
00036
00037 import java.io.*;
00038 import java.util.*;
00039
00040
00041
00042
00043
00044 public class StateVar implements Expr, BirConstants {
00045
00046 int id;
00047 String name;
00048 BirThread thread;
00049 boolean constant;
00050 Type type;
00051 Expr initVal;
00052 TransSystem system;
00053 int offset;
00054 int actualSize;
00055 int actualBaseTypeSize;
00056 int actualBaseTypeExtent;
00057
00058 static int varCount = 0;
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 public StateVar(String name, BirThread thread, Type type,
00069 Expr initVal, TransSystem system) {
00070 this.name = name;
00071 this.id = ++varCount;
00072 this.thread = thread;
00073 this.type = type;
00074 this.system = system;
00075 if (initVal != null)
00076 this.initVal = initVal;
00077 else
00078 this.initVal = type.defaultVal();
00079 }
00080 public void apply(Switch sw)
00081 {
00082 ((ExprSwitch) sw).caseStateVar(this);
00083 }
00084 public int getActualBaseTypeExtent() { return actualBaseTypeExtent; }
00085 public int getActualBaseTypeSize() { return actualBaseTypeSize; }
00086 public int getActualSize() { return actualSize; }
00087 public Expr getInitVal() { return initVal; }
00088 public String getName() { return name; }
00089 public int getOffset() { return offset; }
00090 public TransSystem getSystem() { return system; }
00091 public BirThread getThread() { return thread; }
00092 public Type getType() { return type; }
00093 public boolean isConstant() { return constant; }
00094 public boolean isLocal() { return (thread != null); }
00095 public void print() {
00096 System.out.print(getName());
00097 }
00098 public void setActualBaseTypeExtent(int actualBaseTypeExtent) {
00099 this.actualBaseTypeExtent = actualBaseTypeExtent;
00100 }
00101 public void setActualBaseTypeSize(int actualBaseTypeSize) {
00102 this.actualBaseTypeSize = actualBaseTypeSize;
00103 }
00104 public void setActualSize(int actualSize) { this.actualSize = actualSize; }
00105 public void setConstant(boolean constant) { this.constant = constant; }
00106 public void setInitVal(Expr val) { this.initVal = val; }
00107 public void setOffset(int offset) { this.offset = offset; }
00108 public void setThread(BirThread thread) { this.thread = thread; }
00109 public String toString() {
00110 String isLocal = isLocal() ? "" : "* ";
00111 return "<StateVar " + id + " " + name + " "
00112 + isLocal + type.toString() + ">";
00113 }
00114 }