Skip to content

Commit a36309b

Browse files
committed
Made integer type 64-bits rather than machine-size
This is necessary so we can load constants from bytecode cross-platform-ly. I'm expecting most targets will be 64-bit anyway.
1 parent 5b31fc5 commit a36309b

File tree

2 files changed

+153
-59
lines changed

2 files changed

+153
-59
lines changed

seax_svm/src/cell.rs

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ impl fmt::Debug for SVMCell {
4242
#[derive(PartialEq,PartialOrd,Copy,Clone)]
4343
#[stable(feature="vm_core", since="0.1.0")]
4444
pub enum Atom {
45-
/// Unsigned integer atom (machine size)
46-
#[stable(feature="vm_core", since="0.1.0")]
47-
UInt(usize),
48-
/// Signed integer atom (machine size)
49-
#[stable(feature="vm_core", since="0.1.0")]
50-
SInt(isize),
45+
/// Unsigned integer atom (machine 64)
46+
#[stable(feature="vm_core", since="0.3.0")]
47+
UInt(u64),
48+
/// Signed integer atom (machine 64)
49+
#[stable(feature="vm_core", since="0.3.0")]
50+
SInt(i64),
5151
/// Floating point number atom (64-bits)
5252
#[stable(feature="vm_core", since="0.1.0")]
5353
Float(f64),
@@ -81,11 +81,11 @@ impl fmt::Debug for Atom {
8181
}
8282
}
8383

84-
#[stable(feature="vm_core", since="0.1.0")]
84+
#[stable(feature="vm_core", since="0.3.0")]
8585
impl ops::Add for Atom {
86-
#[stable(feature="vm_core", since="0.1.0")]
86+
#[stable(feature="vm_core", since="0.3.0")]
8787
type Output = Atom;
88-
#[stable(feature="vm_core", since="0.1.0")]
88+
#[stable(feature="vm_core", since="0.3.0")]
8989
fn add(self, other: Atom) -> Atom {
9090
match (self, other) {
9191
// same type: no coercion
@@ -99,10 +99,10 @@ impl ops::Add for Atom {
9999
(SInt(a), Float(b)) => Float(a as f64 + b),
100100
(UInt(a), Float(b)) => Float(a as f64 + b),
101101
// uint + sint: coerce to sint
102-
(UInt(a), SInt(b)) => SInt(a as isize + b),
103-
(SInt(a), UInt(b)) => SInt(a + b as isize),
102+
(UInt(a), SInt(b)) => SInt(a as i64 + b),
103+
(SInt(a), UInt(b)) => SInt(a + b as i64),
104104
// char + any: coerce to char
105-
// because of the supported operations on Rusizet chars,
105+
// because of the supported operations on Ru64t chars,
106106
// everything has to be cast to u8 (byte) to allow
107107
// arithmetic ops and then cast back to char.
108108
(Char(a), UInt(b)) => Char((a as u8 + b as u8) as char),
@@ -115,11 +115,11 @@ impl ops::Add for Atom {
115115
}
116116

117117
}
118-
#[stable(feature="vm_core", since="0.1.0")]
118+
#[stable(feature="vm_core", since="0.3.0")]
119119
impl ops::Sub for Atom {
120-
#[stable(feature="vm_core", since="0.1.0")]
120+
#[stable(feature="vm_core", since="0.3.0")]
121121
type Output = Atom;
122-
#[stable(feature="vm_core", since="0.1.0")]
122+
#[stable(feature="vm_core", since="0.3.0")]
123123
fn sub(self, other: Atom) -> Atom {
124124
match (self, other) {
125125
// same type: no coercion
@@ -133,8 +133,8 @@ impl ops::Sub for Atom {
133133
(SInt(a), Float(b)) => Float(a as f64 - b),
134134
(UInt(a), Float(b)) => Float(a as f64 - b),
135135
// uint + sint: coerce to sint
136-
(UInt(a), SInt(b)) => SInt(a as isize - b),
137-
(SInt(a), UInt(b)) => SInt(a - b as isize),
136+
(UInt(a), SInt(b)) => SInt(a as i64 - b),
137+
(SInt(a), UInt(b)) => SInt(a - b as i64),
138138
// char + any: coerce to char
139139
(Char(a), UInt(b)) => Char((a as u8 - b as u8) as char),
140140
(Char(a), SInt(b)) => Char((a as u8 - b as u8) as char),
@@ -146,11 +146,11 @@ impl ops::Sub for Atom {
146146
}
147147

148148
}
149-
#[stable(feature="vm_core", since="0.1.0")]
149+
#[stable(feature="vm_core", since="0.3.0")]
150150
impl ops::Div for Atom {
151-
#[stable(feature="vm_core", since="0.1.0")]
151+
#[stable(feature="vm_core", since="0.3.0")]
152152
type Output = Atom;
153-
#[stable(feature="vm_core", since="0.1.0")]
153+
#[stable(feature="vm_core", since="0.3.0")]
154154
fn div(self, other: Atom) -> Atom {
155155
match (self, other) {
156156
// same type: no coercion
@@ -164,8 +164,8 @@ impl ops::Div for Atom {
164164
(SInt(a), Float(b)) => Float(a as f64 / b),
165165
(UInt(a), Float(b)) => Float(a as f64 / b),
166166
// uint + sint: coerce to sint
167-
(UInt(a), SInt(b)) => SInt(a as isize / b),
168-
(SInt(a), UInt(b)) => SInt(a / b as isize),
167+
(UInt(a), SInt(b)) => SInt(a as i64 / b),
168+
(SInt(a), UInt(b)) => SInt(a / b as i64),
169169
// char + any: coerce to char
170170
(Char(a), UInt(b)) => Char((a as u8 / b as u8) as char),
171171
(Char(a), SInt(b)) => Char((a as u8 / b as u8) as char),
@@ -177,12 +177,12 @@ impl ops::Div for Atom {
177177
}
178178

179179
}
180-
#[stable(feature="vm_core", since="0.1.0")]
180+
#[stable(feature="vm_core", since="0.3.0")]
181181
impl ops::Mul for Atom {
182-
#[stable(feature="vm_core", since="0.1.0")]
182+
#[stable(feature="vm_core", since="0.3.0")]
183183
type Output = Atom;
184184

185-
#[stable(feature="vm_core", since="0.1.0")]
185+
#[stable(feature="vm_core", since="0.3.0")]
186186
fn mul(self, other: Atom) -> Atom {
187187
match (self, other) {
188188
// same type: no coercion
@@ -196,8 +196,8 @@ impl ops::Mul for Atom {
196196
(SInt(a), Float(b)) => Float(a as f64* b),
197197
(UInt(a), Float(b)) => Float(a as f64* b),
198198
// uint + sint: coerce to sint
199-
(UInt(a), SInt(b)) => SInt(a as isize * b),
200-
(SInt(a), UInt(b)) => SInt(a * b as isize),
199+
(UInt(a), SInt(b)) => SInt(a as i64 * b),
200+
(SInt(a), UInt(b)) => SInt(a * b as i64),
201201
// char + any: coerce to char
202202
(Char(a), UInt(b)) => Char((a as u8 * b as u8) as char),
203203
(Char(a), SInt(b)) => Char((a as u8 * b as u8) as char),
@@ -209,12 +209,12 @@ impl ops::Mul for Atom {
209209
}
210210

211211
}
212-
#[stable(feature="vm_core", since="0.1.0")]
212+
#[stable(feature="vm_core", since="0.3.0")]
213213
impl ops::Rem for Atom {
214-
#[stable(feature="vm_core", since="0.1.0")]
214+
#[stable(feature="vm_core", since="0.3.0")]
215215
type Output = Atom;
216216

217-
#[stable(feature="vm_core", since="0.1.0")]
217+
#[stable(feature="vm_core", since="0.3.0")]
218218
fn rem(self, other: Atom) -> Atom {
219219
match (self, other) {
220220
// same type: no coercion
@@ -228,8 +228,8 @@ impl ops::Rem for Atom {
228228
(SInt(a), Float(b)) => Float(a as f64 % b),
229229
(UInt(a), Float(b)) => Float(a as f64 % b),
230230
// uint + sint: coerce to sint
231-
(UInt(a), SInt(b)) => SInt(a as isize % b),
232-
(SInt(a), UInt(b)) => SInt(a % b as isize),
231+
(UInt(a), SInt(b)) => SInt(a as i64 % b),
232+
(SInt(a), UInt(b)) => SInt(a % b as i64),
233233
// char + any: coerce to char
234234
(Char(a), UInt(b)) => Char((a as u8 % b as u8) as char),
235235
(Char(a), SInt(b)) => Char((a as u8 % b as u8) as char),
@@ -279,15 +279,15 @@ pub enum Inst {
279279
///
280280
/// Takes one list argument representing a function and constructs
281281
/// a closure (a pair containing the function and the current
282-
/// environment) and pusizehes that onto the stack.
282+
/// environment) and pu64hes that onto the stack.
283283
///
284284
/// _Operational semantics_: `(s, e, (LDF f.c), d) → ( ([f e].s), e, c, d)`
285285
///
286286
#[stable(feature="vm_core", since="0.2.4")]
287287
LDF,
288288
/// `join`
289289
///
290-
/// Pops a list reference from the dump and makes thisize the new value
290+
/// Pops a list reference from the dump and makes thi64 the new value
291291
/// of `C`. This instruction occurs at the end of both alternatives of
292292
/// a `sel`.
293293
///
@@ -311,7 +311,7 @@ pub enum Inst {
311311
/// `ret`: `Ret`urn.
312312
///
313313
/// Pops one return value from the stack, restores
314-
/// `S`, `E`, and `C` from the dump, and pusizehes
314+
/// `S`, `E`, and `C` from the dump, and pu64hes
315315
/// the return value onto the now-current stack.
316316
#[stable(feature="vm_core", since="0.1.0")]
317317
RET,
@@ -322,7 +322,7 @@ pub enum Inst {
322322
DUM,
323323
/// `rap`: `R`ecursive `Ap`ply.
324324
/// Works like `ap`, only that it replaces an occurrence of a
325-
/// dummy environment with the current one, thusize making recursive
325+
/// dummy environment with the current one, thu64 making recursive
326326
/// functions possible.
327327
#[stable(feature="vm_core", since="0.1.0")]
328328
RAP,
@@ -340,47 +340,47 @@ pub enum Inst {
340340
SEL,
341341
/// `add`
342342
///
343-
/// Pops two numbers off of the stack and adds them, pusizehing the
344-
/// result onto the stack. Thisize will up-convert integers to floating
343+
/// Pops two numbers off of the stack and adds them, pu64hing the
344+
/// result onto the stack. Thi64 will up-convert integers to floating
345345
/// point if necessary.
346346
///
347347
/// TODO: figure out what happens when you try to add things that aren't
348-
/// numbers (maybe the compiler won't let thisize happen?).
348+
/// numbers (maybe the compiler won't let thi64 happen?).
349349
#[stable(feature="vm_core", since="0.1.0")]
350350
ADD,
351351
/// `sub`: `Sub`tract
352352
///
353353
/// Pops two numbers off of the stack and subtracts the first from the
354-
/// second, pusizehing the result onto the stack. This will up-convert
354+
/// second, pu64hing the result onto the stack. This will up-convert
355355
/// integers to floating point if necessary.
356356
///
357357
/// TODO: figure out what happens when you try to subtract things that
358-
/// aren't numbers (maybe the compiler won't let thisize happen?).
358+
/// aren't numbers (maybe the compiler won't let thi64 happen?).
359359
#[stable(feature="vm_core", since="0.1.0")]
360360
SUB,
361361
/// `mul`: `Mul`tiply
362362
///
363-
/// Pops two numbers off of the stack and multiplies them, pusizehing the
363+
/// Pops two numbers off of the stack and multiplies them, pu64hing the
364364
/// result onto the stack. This will up-convert integers to floating
365365
/// point if necessary.
366366
///
367367
/// TODO: figure out what happens when you try to multiply things that
368-
/// aren't numbers (maybe the compiler won't let thisize happen?).
368+
/// aren't numbers (maybe the compiler won't let thi64 happen?).
369369
#[stable(feature="vm_core", since="0.1.0")]
370370
MUL,
371371
/// `div`: `Div`ide
372372
///
373373
/// Pops two numbers off of the stack and divides the first by the second,
374-
/// pushing the result onto the stack. This performs integer divisizeion.
374+
/// pushing the result onto the stack. This performs integer divi64ion.
375375
///
376376
/// TODO: figure out what happens when you try to divide things that
377-
/// aren't numbers (maybe the compiler won't let thisize happen?).
377+
/// aren't numbers (maybe the compiler won't let thi64 happen?).
378378
#[stable(feature="vm_core", since="0.1.0")]
379379
DIV,
380380
/// `fdiv`: `F`loating-point `div`ide
381381
///
382382
/// Pops two numbers off of the stack and divides the first by the second,
383-
/// pusizehing the result onto the stack. This performs float divisizeion.
383+
/// pu64hing the result onto the stack. This performs float divi64ion.
384384
///
385385
/// TODO: figure out what happens when you try to divide things that
386386
/// aren't numbers (maybe the compiler won't let this happen?).
@@ -404,7 +404,7 @@ pub enum Inst {
404404
/// `gt`: `G`reater `t`han
405405
///
406406
/// Pops two numbers on the stack and puts a 'true' on the stack
407-
/// if the first atom isize greater than the other atom, false otherwisizee.
407+
/// if the first atom i64 greater than the other atom, false otherwi64e.
408408
#[stable(feature="vm_core", since="0.1.0")]
409409
GT,
410410
/// `gte`: `G`reater `t`han or `e`qual
@@ -467,7 +467,7 @@ pub enum Inst {
467467
/// Applies a closure and captures the continuation that can
468468
/// then be applied with `ap`.
469469
#[unstable(feature="callcc")]
470-
APCC
470+
APCC,
471471
}
472472

473473
#[cfg(test)]
@@ -481,13 +481,13 @@ mod tests {
481481
a = Char('a');
482482
assert_eq!(format!("{}", a), "'a'");
483483

484-
a = UInt(1usize);
484+
a = UInt(1u64);
485485
assert_eq!(format!("{}", a), "1");
486486

487-
a = SInt(42isize);
487+
a = SInt(42i64);
488488
assert_eq!(format!("{}", a), "42");
489489

490-
a = SInt(-1isize);
490+
a = SInt(-1i64);
491491
assert_eq!(format!("{}", a), "-1");
492492

493493
a = Float(5.55f64);

0 commit comments

Comments
 (0)