1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
pub use self::SVMCell::*;
pub use self::Atom::*;

use super::List;

use std::{fmt,ops};

#[cfg(test)]
mod tests;

#[macro_export]
#[cfg_attr(feature = "unstable",
    stable(feature = "list", since = "0.1.1") )]
macro_rules! list_cell {
    [ $first:expr, $($rest:expr),+ ] => {
        ListCell(Box::new( list!( $first, $( $rest),+ ) ))
    };
    [ $e:expr ] => {
        ListCell(Box::new( list!($e) ))
    };
    [] => { ListCell(Box::new(Nil)) };

}

#[derive(PartialEq,Clone)]
#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
pub enum SVMCell {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    AtomCell(Atom),
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    ListCell(Box<List<SVMCell>>),
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    InstCell(Inst)
}

#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl fmt::Display for SVMCell {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self)
    }
}

#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl fmt::Debug for SVMCell {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            &AtomCell(atom) => write!(f, "{:?}", atom),
            &ListCell(ref list) => write!(f, "{:?}", list),
            &InstCell(inst) => write!(f, "{:?}", inst)
        }
    }
}

/// SVM atom types.
///
/// A VM atom can be either an unsigned int, signed int, float, or char.
#[derive(PartialEq,PartialOrd,Copy,Clone)]
#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
pub enum Atom {
    /// Unsigned integer atom (machine 64)
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    UInt(u64),
    /// Signed integer atom (machine 64)
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    SInt(i64),
    /// Floating point number atom (64-bits)
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    Float(f64),
    /// UTF-8 character atom
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    Char(char)
}
#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl fmt::Display for Atom {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            &Atom::UInt(value) => write!(f, "{}", value),
            &Atom::SInt(value) => write!(f, "{}", value),
            &Atom::Float(value) => write!(f, "{}", value),
            &Atom::Char(value) => write!(f, "'{}'", value),
        }
    }
}

#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl fmt::Debug for Atom {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            &Atom::UInt(value) => write!(f, "{:?}u", value),
            &Atom::SInt(value) => write!(f, "{:?}", value),
            &Atom::Float(value) => write!(f, "{:?}f", value),
            &Atom::Char(value) => write!(f, "'{}'", value),
        }
    }
}

#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl ops::Add for Atom {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    type Output = Atom;
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    fn add(self, other: Atom) -> Atom {
        match (self, other) {
            // same type:  no coercion
            (SInt(a), SInt(b))      => SInt(a + b),
            (UInt(a), UInt(b))      => UInt(a + b),
            (Float(a), Float(b))    => Float(a + b),
            (Char(a), Char(b))      => Char((a as u8 + b as u8) as char),
            // float + int: coerce to float
            (Float(a), SInt(b))     => Float(a + b as f64),
            (Float(a), UInt(b))     => Float(a + b as f64),
            (SInt(a), Float(b))     => Float(a as f64 + b),
            (UInt(a), Float(b))     => Float(a as f64 + b),
            // uint + sint: coerce to sint
            (UInt(a), SInt(b))      => SInt(a as i64 + b),
            (SInt(a), UInt(b))      => SInt(a + b as i64),
            // char + any: coerce to char
            // because of the supported operations on Ru64t chars,
            // everything has to be cast to u8 (byte) to allow
            // arithmetic ops and then cast back to char.
            (Char(a), UInt(b))      => Char((a as u8 + b as u8) as char),
            (Char(a), SInt(b))      => Char((a as u8 + b as u8) as char),
            (Char(a), Float(b))     => Char((a as u8 + b as u8) as char),
            (UInt(a), Char(b))      => Char((a as u8 + b as u8) as char),
            (SInt(a), Char(b))      => Char((a as u8 + b as u8) as char),
            (Float(a), Char(b))     => Char((a as u8 + b as u8) as char)
        }
    }

}
#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl ops::Sub for Atom {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    type Output = Atom;
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    fn sub(self, other: Atom) -> Atom {
        match (self, other) {
            // same type:  no coercion
            (SInt(a), SInt(b))      => SInt(a - b),
            (UInt(a), UInt(b))      => UInt(a - b),
            (Float(a), Float(b))    => Float(a - b),
            (Char(a), Char(b))      => Char((a as u8 - b as u8) as char),
            // float + int: coerce to float
            (Float(a), SInt(b))     => Float(a - b as f64),
            (Float(a), UInt(b))     => Float(a - b as f64),
            (SInt(a), Float(b))     => Float(a as f64 - b),
            (UInt(a), Float(b))     => Float(a as f64 - b),
            // uint + sint: coerce to sint
            (UInt(a), SInt(b))      => SInt(a as i64 - b),
            (SInt(a), UInt(b))      => SInt(a - b as i64),
            // char + any: coerce to char
            (Char(a), UInt(b))      => Char((a as u8 - b as u8) as char),
            (Char(a), SInt(b))      => Char((a as u8 - b as u8) as char),
            (Char(a), Float(b))     => Char((a as u8 - b as u8) as char),
            (UInt(a), Char(b))      => Char((a as u8 - b as u8) as char),
            (SInt(a), Char(b))      => Char((a as u8 - b as u8) as char),
            (Float(a), Char(b))     => Char((a as u8 - b as u8) as char)
        }
    }

}
#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl ops::Div for Atom {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    type Output = Atom;
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    fn div(self, other: Atom) -> Atom {
        match (self, other) {
            // same type:  no coercion
            (SInt(a), SInt(b))      => SInt(a / b),
            (UInt(a), UInt(b))      => UInt(a / b),
            (Float(a), Float(b))    => Float(a / b),
            (Char(a), Char(b))      => Char((a as u8 / b as u8) as char),
            // float + int: coerce to float
            (Float(a), SInt(b))     => Float(a / b as f64),
            (Float(a), UInt(b))     => Float(a / b as f64),
            (SInt(a), Float(b))     => Float(a as f64 / b),
            (UInt(a), Float(b))     => Float(a as f64 / b),
            // uint + sint: coerce to sint
            (UInt(a), SInt(b))      => SInt(a as i64 / b),
            (SInt(a), UInt(b))      => SInt(a / b as i64),
            // char + any: coerce to char
            (Char(a), UInt(b))      => Char((a as u8 / b as u8) as char),
            (Char(a), SInt(b))      => Char((a as u8 / b as u8) as char),
            (Char(a), Float(b))     => Char((a as u8 / b as u8) as char),
            (UInt(a), Char(b))      => Char((a as u8 / b as u8) as char),
            (SInt(a), Char(b))      => Char((a as u8 / b as u8) as char),
            (Float(a), Char(b))     => Char((a as u8 / b as u8) as char)
        }
    }

}
#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl ops::Mul for Atom {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    type Output = Atom;

    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    fn mul(self, other: Atom) -> Atom {
        match (self, other) {
            // same type:  no coercion
            (SInt(a), SInt(b))      => SInt(a * b),
            (UInt(a), UInt(b))      => UInt(a * b),
            (Float(a), Float(b))    => Float(a * b),
            (Char(a), Char(b))      => Char((a as u8 * b as u8) as char),
            // float + int: coerce to float
            (Float(a), SInt(b))     => Float(a * b as f64),
            (Float(a), UInt(b))     => Float(a * b as f64),
            (SInt(a), Float(b))     => Float(a as f64* b),
            (UInt(a), Float(b))     => Float(a as f64* b),
            // uint + sint: coerce to sint
            (UInt(a), SInt(b))      => SInt(a as i64 * b),
            (SInt(a), UInt(b))      => SInt(a * b as i64),
            // char + any: coerce to char
            (Char(a), UInt(b))      => Char((a as u8 * b as u8) as char),
            (Char(a), SInt(b))      => Char((a as u8 * b as u8) as char),
            (Char(a), Float(b))     => Char((a as u8 * b as u8) as char),
            (UInt(a), Char(b))      => Char((a as u8 * b as u8) as char),
            (SInt(a), Char(b))      => Char((a as u8 * b as u8) as char),
            (Float(a), Char(b))     => Char((a as u8 * b as u8) as char)
        }
    }

}
#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
impl ops::Rem for Atom {
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    type Output = Atom;

    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    fn rem(self, other: Atom) -> Atom {
        match (self, other) {
            // same type:  no coercion
            (SInt(a), SInt(b))      => SInt(a % b),
            (UInt(a), UInt(b))      => UInt(a % b),
            (Float(a), Float(b))    => Float(a % b),
            (Char(a), Char(b))      => Char((a as u8 % b as u8) as char),
            // float + int: coerce to float
            (Float(a), SInt(b))     => Float(a % b as f64),
            (Float(a), UInt(b))     => Float(a % b as f64),
            (SInt(a), Float(b))     => Float(a as f64 % b),
            (UInt(a), Float(b))     => Float(a as f64 % b),
            // uint + sint: coerce to sint
            (UInt(a), SInt(b))      => SInt(a as i64 % b),
            (SInt(a), UInt(b))      => SInt(a % b as i64),
            // char + any: coerce to char
            (Char(a), UInt(b))      => Char((a as u8 % b as u8) as char),
            (Char(a), SInt(b))      => Char((a as u8 % b as u8) as char),
            (Char(a), Float(b))     => Char((a as u8 % b as u8) as char),
            (UInt(a), Char(b))      => Char((a as u8 % b as u8) as char),
            (SInt(a), Char(b))      => Char((a as u8 % b as u8) as char),
            (Float(a), Char(b))     => Char((a as u8 % b as u8) as char)
        }
    }

}

/// SVM instruction types.
///
/// Each SVM instruction will be described using operational
/// semantics through the use of the following notation:
///
///  + a state is written `(s, e, c, d)`
///  + `(x.y)` is `Cons(x, y)`. The empty list is `nil`.
///  + each instruction is described as a state transition `(s, e, c, d) → (s´, e´, c´, d´)`
#[derive(Debug,Copy,Clone,PartialEq)]
#[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
pub enum Inst {
    /// `nil`
    ///
    /// Pushes an empty list (nil) onto the stack.
    ///
    /// __Operational semantics__: `(s, e, (NIL.c), d) → ( (nil.s), e, c, d )`
    ///
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    NIL = 0x00,
    /// `ldc`: `L`oa`d` `C`onstant. Loads a constant (atom)
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    LDC = 0x1C,
    /// `ld`: `L`oa`d`. Pushes a variable onto the stack.
    ///
    /// The variable is indicated by the argument, a pair.
    /// The pair's `car` specifies the level, the `cdr` the position.
    /// So `(1 . 3)` gives the current function's (level 1) third
    /// parameter.
    ///
    /// __Operational semantics__: `(s, e, LDC.v.c, d) → (v.s, e, c, d)`
    ///
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    LD = 0x01,
    /// `ldf`: `L`oa`d` `F`unction.
    ///
    ///  Takes one list argument representing a function and constructs
    ///  a closure (a pair containing the function and the current
    ///  environment) and pushes that onto the stack.
    ///
    /// _Operational semantics_: `(s, e, (LDF f.c), d) → ( ([f e].s), e, c, d)`
    ///
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    LDF = 0x02,
    /// `join`
    ///
    /// Pops a list reference from the dump and makes thi64 the new value
    /// of `C`. This instruction occurs at the end of both alternatives of
    ///  a `sel`.
    ///
    /// __Operational semantics__: `(s, e, JOIN.c, c´.d) → (s, e, c´, d)`
    ///
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    JOIN = 0x05,
    /// `ap`: `Ap`ply.
    ///
    /// Pops a closure and a list of parameter values from the stack.
    /// The closure is applied to the parameters by installing its
    /// environment as the current one, pushing the parameter list
    /// in front of that, clearing the stack, and setting `c` to the
    /// closure's function pointer. The previous values of `s`, `e`,
    ///  and the next value of `c` are saved on the dump.
    ///
    /// __Operational semantics__: `(([f e´] v.s), e, (AP.c), d) → (nil, (v.e&prime), f, (s e c.d))`
    ///
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    AP = 0x03,
    /// `ret`: `Ret`urn.
    ///
    /// Pops one return value from the stack, restores
    /// `$s`, `$e`, and `$c` from the dump, and pushes
    /// the return value onto the now-current stack.
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    RET = 0x07,
    /// `dum`: `Dum`my.
    ///
    /// Pops a dummy environment (an empty list) onto the `$e` stack.
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    DUM = 0x08,
    /// `rap`: `R`ecursive `Ap`ply.
    /// Works like `ap`, only that it replaces an occurrence of a
    /// dummy environment with the current one, thus making recursive
    ///  functions possible.
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    RAP = 0x06,
    /// `sel`: `Sel`ect branch
    ///
    /// Expects two list arguments on the control stack, and pops a value
    /// from the stack. The first list is executed if the popped value
    /// was non-nil, the second list otherwise. Before one of these list
    /// pointers is made the new `$c`, a pointer to the instruction
    /// following `sel` is saved on the dump.
    ///
    /// __Operational semantics__: `(v.s, e, SEL.true.false.c, d) → (s, e, (if v then true else false), c.d)`
    ///
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    SEL = 0x09,
    /// `add`
    ///
    /// Pops two numbers off of the stack and adds them, pu64hing the
    /// result onto the stack. This will up-convert integers to floating
    /// point if necessary.
    ///
    /// TODO: figure out what happens when you try to add things that aren't
    /// numbers (maybe the compiler won't let this happen?).
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    ADD = 0x0A,
    /// `sub`: `Sub`tract
    ///
    /// Pops two numbers off of the stack and subtracts the first from the
    /// second, pu64hing the result onto the stack. This will up-convert
    /// integers to floating point if necessary.
    ///
    /// TODO: figure out what happens when you try to subtract things that
    /// aren't numbers (maybe the compiler won't let thi64 happen?).
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    SUB = 0x0B,
    /// `mul`: `Mul`tiply
    ///
    /// Pops two numbers off of the stack and multiplies them, pu64hing the
    /// result onto the stack. This will up-convert integers to floating
    /// point if necessary.
    ///
    /// TODO: figure out what happens when you try to multiply things that
    /// aren't numbers (maybe the compiler won't let thi64 happen?).
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    MUL = 0x0C,
    /// `div`: `Div`ide
    ///
    /// Pops two numbers off of the stack and divides the first by the second,
    /// pushing the result onto the stack. This performs integer divi64ion.
    ///
    /// TODO: figure out what happens when you try to divide things that
    /// aren't numbers (maybe the compiler won't let thi64 happen?).
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    DIV = 0x0D,
    /// `fdiv`: `F`loating-point `div`ide
    ///
    /// Pops two numbers off of the stack and divides the first by the second,
    /// pu64hing the result onto the stack. This performs float divi64ion.
    ///
    /// TODO: figure out what happens when you try to divide things that
    /// aren't numbers (maybe the compiler won't let this happen?).
    ///
    /// TODO: Not sure if there should be separate float and int divide words
    /// I guess the compiler can figure this out
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    FDIV = 0x0F,
    /// `mod`: `Mod`ulo
    ///
    /// Pops two numbers off of the stack and divides the first by the second,
    /// pushing the remainder onto the stack.
    ///
    /// TODO: figure out what happens when you try to modulo things that
    /// aren't numbers (maybe the compiler won't let this happen?).
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    MOD = 0x0E,
    /// `eq`: `Eq`uality of atoms
    #[cfg_attr(feature = "unstable",
    stable(feature="vm_core", since="0.1.0") )]
    EQ = 0x10,
    /// `gt`: `G`reater `t`han
    ///
    /// Pops two numbers on the stack and puts a 'true' on the stack
    /// if the first atom i64 greater than the other atom, false otherwi64e.
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    GT = 0x11,
    /// `gte`: `G`reater `t`han or `e`qual
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    GTE = 0x12,
    /// `lt`: `L`ess `t`han
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    LT = 0x13,
    /// `lte`: `L`ess `t`han or `e`qual
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    LTE = 0x14,
    /// `atom`: test if `atom`
    ///
    /// Pops an item from the stack and returns true if it's an atom, false
    /// otherwise.
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    ATOM = 0x15,
    /// `car`: `C`ontents of `A`ddress `R`egister
    ///
    /// Pops a list from the stack and returns the list's `car` (head)
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    CAR = 0x1A,
    /// `cdr`: `C`ontents of `D`ecrement `R`egister
    ///
    /// Pops a list from the stack and returns the list's `cdr` (tail)
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    CDR = 0x1B,
    /// `cons`: `Cons`truct
    ///
    /// Pops an item and a list from the stack and returns the list, with
    /// the item prepended.
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    CONS = 0x19,
    /// `null`: test if `null`
    ///
    ///  Pops an item from the stack and returns true if it is `nil`, false
    ///  otherwise.
    #[cfg_attr(feature = "unstable",
        stable(feature="vm_core", since="0.1.0") )]
    NULL = 0x16,
    /// `stop`: `stop` execution
    ///
    /// Terminates program execution. The `eval_program()` function will return
    /// the last state of the VM.
    #[cfg_attr(feature = "unstable",
        stable(feature = "vm_core", since="0.1.0") )]
    STOP = 0x1D,
    /// `readc`: `read` `c`haracter
    ///
    /// Reads a character from the machine's input stream and places it
    /// on top of the stack
    #[cfg_attr(feature = "unstable",
        stable(feature = "vm_core", since="0.1.0") )]
    READC = 0x17,
    /// `writec`: `write` `c`haracter
    ///
    /// Writes a character from the top of the stack to the machine's
    /// output stream.
    #[cfg_attr(feature = "unstable",
        stable(feature = "vm_core", since="0.1.0") )]
    WRITEC = 0x18,
    /// `apcc`: `ap`ply with `c`urrent `c`ontinuation
    ///
    /// Applies a closure and captures the continuation that can
    /// then be applied with `ap`.
    #[cfg_attr(feature = "unstable",
        unstable(feature = "callcc", issue = "69"))]
    APCC = 0x04,
}