Merge branch 'master' of https://github.com/mthom/rusty-wam
This commit is contained in:
@@ -3064,10 +3064,12 @@ is_false(var(X)) :- nonvar(X).
|
|||||||
|
|
||||||
:- dynamic(goal_expansion/1).
|
:- dynamic(goal_expansion/1).
|
||||||
|
|
||||||
user:goal_expansion(Goal0, Goal) :-
|
% goal expansion is disabled for now, until #445 is resolved
|
||||||
\+ goal_expansion(false),
|
%
|
||||||
clpz_expandable(Goal0),
|
% user:goal_expansion(Goal0, Goal) :-
|
||||||
clpz_expansion(Goal0, Goal).
|
% \+ goal_expansion(false),
|
||||||
|
% clpz_expandable(Goal0),
|
||||||
|
% clpz_expansion(Goal0, Goal).
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ shift(Ball) :-
|
|||||||
'$nextEP'(first, E, P),
|
'$nextEP'(first, E, P),
|
||||||
get_chunks(E, P, L),
|
get_chunks(E, P, L),
|
||||||
( L == [] ->
|
( L == [] ->
|
||||||
Cont = none
|
Cont = cont(true)
|
||||||
; Cont = cont(call_continuation(L))
|
; Cont = cont(call_continuation(L))
|
||||||
),
|
),
|
||||||
'$write_cont_and_term'(_, _, Cont, Ball),
|
'$write_cont_and_term'(_, _, Cont, Ball),
|
||||||
|
|||||||
@@ -136,18 +136,14 @@ activate(Wrapper,Worker,T) :-
|
|||||||
delim(Wrapper,Worker,Table) :-
|
delim(Wrapper,Worker,Table) :-
|
||||||
% debug(tabling, 'ACT: ~p on ~p', [Wrapper, Table]),
|
% debug(tabling, 'ACT: ~p on ~p', [Wrapper, Table]),
|
||||||
reset(Worker,SourceCall,Continuation),
|
reset(Worker,SourceCall,Continuation),
|
||||||
( Continuation == none, var(SourceCall) ->
|
( Continuation = none ->
|
||||||
( add_answer(Table,Wrapper)
|
( add_answer(Table,Wrapper)
|
||||||
-> true %debug(tabling, 'ADD: ~p', [Wrapper])
|
-> true %debug(tabling, 'ADD: ~p', [Wrapper])
|
||||||
; %debug(tabling, 'DUP: ~p', [Wrapper]),
|
; %debug(tabling, 'DUP: ~p', [Wrapper]),
|
||||||
fail
|
fail
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
( Continuation = cont(Cont) ->
|
Continuation = cont(Cont),
|
||||||
true
|
|
||||||
; Continuation = none ->
|
|
||||||
Cont = true
|
|
||||||
),
|
|
||||||
SourceCall = call_info(_,SourceTable),
|
SourceCall = call_info(_,SourceTable),
|
||||||
TargetCall = call_info(Wrapper,Table),
|
TargetCall = call_info(Wrapper,Table),
|
||||||
Dependency = dependency(SourceCall,Cont,TargetCall),
|
Dependency = dependency(SourceCall,Cont,TargetCall),
|
||||||
|
|||||||
@@ -30,33 +30,28 @@ use std::rc::Rc;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use cpu_time::ProcessTime;
|
use cpu_time::ProcessTime;
|
||||||
|
|
||||||
use crate::crossterm::event::{read, Event, KeyCode, KeyEvent};
|
use crate::crossterm::event::{read, Event, KeyCode, KeyEvent, KeyModifiers};
|
||||||
use crate::crossterm::terminal::{enable_raw_mode, disable_raw_mode};
|
use crate::crossterm::terminal::{enable_raw_mode, disable_raw_mode};
|
||||||
|
|
||||||
pub fn get_single_char() -> char {
|
pub fn get_key() -> KeyEvent {
|
||||||
let c;
|
let key;
|
||||||
enable_raw_mode().expect("failed to enable raw mode");
|
enable_raw_mode().expect("failed to enable raw mode");
|
||||||
loop {
|
loop {
|
||||||
if let Ok(Event::Key(KeyEvent { code, .. })) = read() {
|
let key_ = read();
|
||||||
match code {
|
if let Ok(key_) = key_ {
|
||||||
KeyCode::Char(ch) => {
|
if let Event::Key(key_) = key_ {
|
||||||
c = ch;
|
match key_.code {
|
||||||
break;
|
KeyCode::Char(_) | KeyCode::Enter | KeyCode::Tab => {
|
||||||
},
|
key = key_;
|
||||||
KeyCode::Enter => {
|
break;
|
||||||
c = '\n';
|
},
|
||||||
break;
|
_ => ()
|
||||||
},
|
}
|
||||||
KeyCode::Tab => {
|
|
||||||
c = '\t';
|
|
||||||
break;
|
|
||||||
},
|
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disable_raw_mode().expect("failed to disable raw mode");
|
disable_raw_mode().expect("failed to disable raw mode");
|
||||||
c
|
key
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -1652,7 +1647,27 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
&SystemClauseType::GetSingleChar => {
|
&SystemClauseType::GetSingleChar => {
|
||||||
let c = get_single_char();
|
let ctrl_c = KeyEvent {
|
||||||
|
code: KeyCode::Char('c'),
|
||||||
|
modifiers: KeyModifiers::CONTROL
|
||||||
|
};
|
||||||
|
let key = get_key();
|
||||||
|
if key == ctrl_c {
|
||||||
|
let stub = MachineError::functor_stub(
|
||||||
|
clause_name!("get_single_char"),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
let err = MachineError::interrupt_error();
|
||||||
|
let err = self.error_form(err, stub);
|
||||||
|
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
let c = match key.code {
|
||||||
|
KeyCode::Enter => '\n',
|
||||||
|
KeyCode::Tab => '\t',
|
||||||
|
KeyCode::Char(c) => c,
|
||||||
|
_ => unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
let a1 = self[temp_v!(1)];
|
let a1 = self[temp_v!(1)];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user