Mercurial > hg > truffle
comparison graal/com.oracle.max.asm/src/com/oracle/max/asm/Buffer.java @ 4142:bc8527f3071c
Adjust code base to new level of warnings.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 18 Dec 2011 05:24:06 +0100 |
parents | e233f5660da4 |
children |
comparison
equal
deleted
inserted
replaced
4141:04d21be7a24f | 4142:bc8527f3071c |
---|---|
110 position = emitLong(b, position); | 110 position = emitLong(b, position); |
111 } | 111 } |
112 | 112 |
113 public int emitByte(int b, int pos) { | 113 public int emitByte(int b, int pos) { |
114 assert NumUtil.isUByte(b); | 114 assert NumUtil.isUByte(b); |
115 ensureSize(pos + 1); | 115 int newPos = pos + 1; |
116 data[pos++] = (byte) (b & 0xFF); | 116 ensureSize(newPos); |
117 return pos; | 117 data[pos] = (byte) (b & 0xFF); |
118 return newPos; | |
118 } | 119 } |
119 | 120 |
120 public abstract int emitShort(int b, int pos); | 121 public abstract int emitShort(int b, int pos); |
121 | 122 |
122 public abstract int emitInt(int b, int pos); | 123 public abstract int emitInt(int b, int pos); |
133 | 134 |
134 public static final class BigEndian extends Buffer { | 135 public static final class BigEndian extends Buffer { |
135 @Override | 136 @Override |
136 public int emitShort(int b, int pos) { | 137 public int emitShort(int b, int pos) { |
137 assert NumUtil.isUShort(b); | 138 assert NumUtil.isUShort(b); |
139 int newPos = pos + 2; | |
138 ensureSize(pos + 2); | 140 ensureSize(pos + 2); |
139 data[pos++] = (byte) ((b >> 8) & 0xFF); | 141 data[pos] = (byte) ((b >> 8) & 0xFF); |
140 data[pos++] = (byte) (b & 0xFF); | 142 data[pos + 1] = (byte) (b & 0xFF); |
141 return pos; | 143 return newPos; |
142 } | 144 } |
143 | 145 |
144 @Override | 146 @Override |
145 public int emitInt(int b, int pos) { | 147 public int emitInt(int b, int pos) { |
146 ensureSize(pos + 4); | 148 int newPos = pos + 4; |
147 data[pos++] = (byte) ((b >> 24) & 0xFF); | 149 ensureSize(newPos); |
148 data[pos++] = (byte) ((b >> 16) & 0xFF); | 150 data[pos] = (byte) ((b >> 24) & 0xFF); |
149 data[pos++] = (byte) ((b >> 8) & 0xFF); | 151 data[pos + 1] = (byte) ((b >> 16) & 0xFF); |
150 data[pos++] = (byte) (b & 0xFF); | 152 data[pos + 2] = (byte) ((b >> 8) & 0xFF); |
151 return pos; | 153 data[pos + 3] = (byte) (b & 0xFF); |
154 return newPos; | |
152 } | 155 } |
153 | 156 |
154 @Override | 157 @Override |
155 public int emitLong(long b, int pos) { | 158 public int emitLong(long b, int pos) { |
156 ensureSize(pos + 8); | 159 int newPos = pos + 8; |
157 data[pos++] = (byte) ((b >> 56) & 0xFF); | 160 ensureSize(newPos); |
158 data[pos++] = (byte) ((b >> 48) & 0xFF); | 161 data[pos] = (byte) ((b >> 56) & 0xFF); |
159 data[pos++] = (byte) ((b >> 40) & 0xFF); | 162 data[pos + 1] = (byte) ((b >> 48) & 0xFF); |
160 data[pos++] = (byte) ((b >> 32) & 0xFF); | 163 data[pos + 2] = (byte) ((b >> 40) & 0xFF); |
161 data[pos++] = (byte) ((b >> 24) & 0xFF); | 164 data[pos + 3] = (byte) ((b >> 32) & 0xFF); |
162 data[pos++] = (byte) ((b >> 16) & 0xFF); | 165 data[pos + 4] = (byte) ((b >> 24) & 0xFF); |
163 data[pos++] = (byte) ((b >> 8) & 0xFF); | 166 data[pos + 5] = (byte) ((b >> 16) & 0xFF); |
164 data[pos++] = (byte) (b & 0xFF); | 167 data[pos + 6] = (byte) ((b >> 8) & 0xFF); |
165 return pos; | 168 data[pos + 7] = (byte) (b & 0xFF); |
169 return newPos; | |
166 } | 170 } |
167 | 171 |
168 @Override | 172 @Override |
169 public int getShort(int pos) { | 173 public int getShort(int pos) { |
170 return | 174 return |
184 | 188 |
185 public static final class LittleEndian extends Buffer { | 189 public static final class LittleEndian extends Buffer { |
186 @Override | 190 @Override |
187 public int emitShort(int b, int pos) { | 191 public int emitShort(int b, int pos) { |
188 assert NumUtil.isUShort(b); | 192 assert NumUtil.isUShort(b); |
189 ensureSize(pos + 2); | 193 int newPos = pos + 2; |
190 data[pos++] = (byte) (b & 0xFF); | 194 ensureSize(newPos); |
191 data[pos++] = (byte) ((b >> 8) & 0xFF); | 195 data[pos] = (byte) (b & 0xFF); |
192 return pos; | 196 data[pos + 1] = (byte) ((b >> 8) & 0xFF); |
197 return newPos; | |
193 } | 198 } |
194 | 199 |
195 @Override | 200 @Override |
196 public int emitInt(int b, int pos) { | 201 public int emitInt(int b, int pos) { |
197 ensureSize(pos + 4); | 202 int newPos = pos + 4; |
198 data[pos++] = (byte) (b & 0xFF); | 203 ensureSize(newPos); |
199 data[pos++] = (byte) ((b >> 8) & 0xFF); | 204 data[pos] = (byte) (b & 0xFF); |
200 data[pos++] = (byte) ((b >> 16) & 0xFF); | 205 data[pos + 1] = (byte) ((b >> 8) & 0xFF); |
201 data[pos++] = (byte) ((b >> 24) & 0xFF); | 206 data[pos + 2] = (byte) ((b >> 16) & 0xFF); |
202 return pos; | 207 data[pos + 3] = (byte) ((b >> 24) & 0xFF); |
208 return newPos; | |
203 } | 209 } |
204 | 210 |
205 @Override | 211 @Override |
206 public int emitLong(long b, int pos) { | 212 public int emitLong(long b, int pos) { |
207 ensureSize(pos + 8); | 213 int newPos = pos + 8; |
208 data[pos++] = (byte) (b & 0xFF); | 214 ensureSize(newPos); |
209 data[pos++] = (byte) ((b >> 8) & 0xFF); | 215 data[pos] = (byte) (b & 0xFF); |
210 data[pos++] = (byte) ((b >> 16) & 0xFF); | 216 data[pos + 1] = (byte) ((b >> 8) & 0xFF); |
211 data[pos++] = (byte) ((b >> 24) & 0xFF); | 217 data[pos + 2] = (byte) ((b >> 16) & 0xFF); |
212 data[pos++] = (byte) ((b >> 32) & 0xFF); | 218 data[pos + 3] = (byte) ((b >> 24) & 0xFF); |
213 data[pos++] = (byte) ((b >> 40) & 0xFF); | 219 data[pos + 4] = (byte) ((b >> 32) & 0xFF); |
214 data[pos++] = (byte) ((b >> 48) & 0xFF); | 220 data[pos + 5] = (byte) ((b >> 40) & 0xFF); |
215 data[pos++] = (byte) ((b >> 56) & 0xFF); | 221 data[pos + 6] = (byte) ((b >> 48) & 0xFF); |
216 return pos; | 222 data[pos + 7] = (byte) ((b >> 56) & 0xFF); |
223 return newPos; | |
217 } | 224 } |
218 | 225 |
219 @Override | 226 @Override |
220 public int getShort(int pos) { | 227 public int getShort(int pos) { |
221 return | 228 return |