5 @METHODDEFAULT("O<V,V<C,C<IN,THISLOC=O,C*")
8 @LOC("V") char value[];
11 @LOC("V") private int cachedHashcode;
16 public String(byte str[]) {
17 char charstr[]=new char[str.length];
18 for(int i=0; i<str.length; i++)
19 charstr[i]=(char)str[i];
21 this.count=str.length;
26 public String(byte str[], String encoding) {
27 int length = this.count;
28 if (length>(str.length))
30 char charstr[]=new char[length];
31 for(int i=0; i<length; i++)
32 charstr[i]=(char)str[i];
38 public String(@LOC("IN") String str) {
41 this.offset=str.offset;
44 public String(@LOC("IN") char c) {
45 @LOC("V") char[] str = new char[1];
50 public String(@LOC("IN") char str[]) {
51 @LOC("V") char charstr[]=new char[str.length];
52 for(@LOC("C") int i=0; i<str.length; i++)
56 this.count=str.length;
60 @LATTICE("O<V,V<C,C<IN,THISLOC=IN,C*")
62 public String concat(@LOC("IN") String str) {
63 @LOC("O") String newstr=new String(); // create new one, it has OUT location
64 @LOC("C") int newCount=this.count+str.count;
66 @LOC("V") char charstr[]=new char[newCount];
68 // here, for loop introduces indirect flow from [C] to [V]
69 for(@LOC("C") int i=0; i<count; i++) {
70 // value flows from GLB(THISLOC,C,THISLOC.V)=(THISLOC,TOP) to [V]
71 charstr[i]=value[i+offset];
73 for(@LOC("C") int i=0; i<str.count; i++) {
74 charstr[i+count]=str.value[i+str.offset];
79 // LOC(newstr.value)=[O,V]
87 public boolean equals(@LOC("IN") Object o) {
88 if (o.getType()!=getType()) // values are coming from [IN] and [THISLOC]
90 @LOC("V") String s=(String)o;
94 for(@LOC("C") int i=0; i<count; i++) {
95 if (s.value[i+s.offset]!=value[i+offset])
102 public static String valueOf(@LOC("IN") Object o) {
109 public static String valueOf(boolean b) {
111 return new String("true");
113 return new String("false");
116 public static String valueOf(char c) {
117 char ar[]=new char[1];
119 return new String(ar);
122 public static String valueOf(int x) {
136 chararray=new char[length+1];
138 chararray=new char[length];
148 chararray[--length+voffset]=(char)(x%10+'0');
151 return new String(chararray);
154 public static String valueOf(double val) {
155 char[] chararray=new char[20];
156 String s=new String();
158 s.count=convertdoubletochar(val, chararray);
163 public static String valueOf(long x) {
177 chararray=new char[length+1];
179 chararray=new char[length];
189 chararray[--length+voffset]=(char)(x%10+'0');
192 return new String(chararray);
195 @LATTICE("O<V,V<C,C<IN,THISLOC=IN,C*")
197 public byte[] getBytes() {
198 @LOC("V") byte str[]=new byte[count];
199 for(@LOC("C") int i=0; i<count; i++)
200 str[i]=(byte)value[i+offset];
207 public int length() {
212 public char charAt(@LOC("IN") int index){
216 //public static native int convertdoubletochar(double val, char [] chararray);