add string table, StringList representation

This commit is contained in:
Mark Thom
2018-08-21 00:22:16 -06:00
parent 01d6ef099f
commit 013eb29e2b
11 changed files with 36 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ use prolog::machine::machine_errors::*;
use prolog::num::{BigInt, BigUint, Zero, One};
use prolog::or_stack::*;
use prolog::read::*;
use prolog::string_list::*;
use prolog::tabled_rc::*;
use downcast::Any;
@@ -288,6 +289,7 @@ impl Default for MachineFlags {
pub struct MachineState {
pub(crate) atom_tbl: TabledData<Atom>,
pub(crate) string_tbl: TabledData<StringListWrapper>,
pub(super) s: usize,
pub(super) p: CodePtr,
pub(super) b: usize,

View File

@@ -9,8 +9,8 @@ use prolog::num::{Integer, Signed, ToPrimitive, Zero};
use prolog::num::bigint::{BigInt, BigUint};
use prolog::num::rational::Ratio;
use prolog::or_stack::*;
use prolog::tabled_rc::*;
use std::cell::RefCell;
use std::cmp::{max, Ordering};
use std::collections::{HashMap, HashSet};
use std::rc::Rc;
@@ -28,9 +28,10 @@ macro_rules! try_or_fail {
}
impl MachineState {
pub(super) fn new(atom_tbl: TabledData<Atom>) -> MachineState {
pub(super) fn new() -> Self {
MachineState {
atom_tbl,
atom_tbl: Rc::new(RefCell::new(HashSet::new())),
string_tbl: Rc::new(RefCell::new(HashSet::new())),
s: 0,
p: CodePtr::default(),
b: 0,

View File

@@ -1,6 +1,7 @@
use prolog::ast::*;
use prolog::compile::*;
use prolog::heap_print::*;
use prolog::string_list::StringListWrapper;
use prolog::tabled_rc::*;
mod machine_errors;
@@ -11,8 +12,7 @@ mod system_calls;
use prolog::machine::machine_state::*;
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::mem::swap;
use std::ops::Index;
use std::rc::Rc;
@@ -99,7 +99,7 @@ static QUEUES: &str = include_str!("../lib/queues.pl");
impl Machine {
pub fn new() -> Self {
let mut wam = Machine {
ms: MachineState::new(Rc::new(RefCell::new(HashSet::new()))),
ms: MachineState::new(),
call_policy: Box::new(DefaultCallPolicy {}),
cut_policy: Box::new(DefaultCutPolicy {}),
code: Code::new(),
@@ -177,6 +177,10 @@ impl Machine {
self.ms.atom_tbl.clone()
}
pub fn string_tbl(&self) -> TabledData<StringListWrapper> {
self.ms.string_tbl.clone()
}
pub fn use_qualified_module_in_toplevel(&mut self, name: ClauseName, exports: Vec<PredicateKey>)
-> EvalSession
{