cosmetic changes.
This commit is contained in:
@@ -139,7 +139,9 @@ pub fn compile_fact<'a>(t: &'a Term) -> Program {
|
||||
while let Some(t) = queue.pop_front() {
|
||||
match t {
|
||||
(r, &Term::Clause(ref atom, ref terms)) => {
|
||||
fact.push(MachineInstruction::GetStructure(atom.clone(), terms.len(), r));
|
||||
fact.push(MachineInstruction::GetStructure(atom.clone(),
|
||||
terms.len(),
|
||||
r));
|
||||
|
||||
let mut counter : usize = reg;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ type Heap = Vec<HeapCell>;
|
||||
|
||||
type Registers = Vec<HeapCell>;
|
||||
|
||||
pub struct MachineState {
|
||||
pub struct Machine {
|
||||
h : usize,
|
||||
s : usize,
|
||||
pub fail : bool,
|
||||
@@ -30,9 +30,9 @@ pub struct MachineState {
|
||||
registers : Registers
|
||||
}
|
||||
|
||||
impl MachineState {
|
||||
pub fn new() -> MachineState {
|
||||
MachineState { h : 0,
|
||||
impl Machine {
|
||||
pub fn new() -> Machine {
|
||||
Machine { h : 0,
|
||||
s : 0,
|
||||
fail : false,
|
||||
heap : Vec::with_capacity(256),
|
||||
@@ -195,7 +195,7 @@ impl MachineState {
|
||||
pub fn reset_heap(&mut self) {
|
||||
let program = self.program.take();
|
||||
|
||||
*self = MachineState::new();
|
||||
*self = Machine::new();
|
||||
self.program = program;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ mod l0;
|
||||
|
||||
use l0::ast::{Atom, Program, Term, TopLevel, Var};
|
||||
use l0::codegen::{compile_fact, compile_query};
|
||||
use l0::machine::{MachineState};
|
||||
use l0::machine::{Machine};
|
||||
|
||||
use std::io::{self, Write};
|
||||
|
||||
@@ -13,7 +13,7 @@ fn print_instructions(program : &Program) {
|
||||
}
|
||||
|
||||
fn l0_repl() {
|
||||
let mut ms = MachineState::new();
|
||||
let mut ms = Machine::new();
|
||||
|
||||
loop {
|
||||
print!("l0> ");
|
||||
@@ -27,14 +27,14 @@ fn l0_repl() {
|
||||
if &*buffer == "quit\n" {
|
||||
break;
|
||||
} else if &*buffer == "clear\n" {
|
||||
ms = MachineState::new();
|
||||
ms = Machine::new();
|
||||
}
|
||||
|
||||
match result {
|
||||
Ok(TopLevel::Fact(fact)) => {
|
||||
let program = compile_fact(&fact);
|
||||
|
||||
ms = MachineState::new();
|
||||
ms = Machine::new();
|
||||
ms.program = Some(program);
|
||||
|
||||
println!("Program stored.");
|
||||
|
||||
Reference in New Issue
Block a user