Format code using 'cargo fmt'

This commit is contained in:
Atul Bhosale
2019-09-23 19:35:37 +07:00
parent 8207fdea40
commit 1273e2d52d
36 changed files with 8738 additions and 6375 deletions

View File

@@ -1,40 +1,40 @@
macro_rules! interm {
($n: expr) => (
($n: expr) => {
ArithmeticTerm::Interm($n)
)
};
}
macro_rules! heap_str {
($s:expr) => (
($s:expr) => {
HeapCellValue::Addr(Addr::Str($s))
)
};
}
macro_rules! heap_integer {
($i:expr) => (
($i:expr) => {
HeapCellValue::Addr(Addr::Con(Constant::Integer($i)))
)
};
}
macro_rules! heap_cell {
($i:expr) => (
($i:expr) => {
HeapCellValue::Addr(Addr::HeapCell($i))
)
};
}
macro_rules! heap_con {
($i:expr) => (
($i:expr) => {
HeapCellValue::Addr(Addr::Con($i))
)
};
}
macro_rules! heap_atom {
($name:expr) => (
($name:expr) => {
HeapCellValue::Addr(Addr::Con(atom!($name)))
);
($name:expr, $tbl:expr) => (
};
($name:expr, $tbl:expr) => {
HeapCellValue::Addr(Addr::Con(atom!($name, $tbl)))
)
};
}
macro_rules! functor {
@@ -53,147 +53,158 @@ macro_rules! functor {
}
macro_rules! is_atom {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsAtom($r)), 1, 0)
)
};
}
macro_rules! is_atomic {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsAtomic($r)), 1, 0)
)
};
}
macro_rules! is_integer {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsInteger($r)), 1, 0)
)
};
}
macro_rules! is_compound {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsCompound($r)), 1, 0)
)
};
}
macro_rules! is_float {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsFloat($r)), 1, 0)
)
};
}
macro_rules! is_rational {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsRational($r)), 1, 0)
)
};
}
macro_rules! is_nonvar {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsNonVar($r)), 1, 0)
)
};
}
macro_rules! is_string {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsString($r)), 1, 0)
)
};
}
macro_rules! is_var {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsVar($r)), 1, 0)
)
};
}
macro_rules! is_partial_string {
($r:expr) => (
call_clause!(ClauseType::Inlined(InlinedClauseType::IsPartialString($r)), 1, 0)
)
($r:expr) => {
call_clause!(
ClauseType::Inlined(InlinedClauseType::IsPartialString($r)),
1,
0
)
};
}
macro_rules! call_clause {
($ct:expr, $arity:expr, $pvs:expr) => (
Line::Control(ControlInstruction::CallClause($ct, $arity, $pvs, false, false))
);
($ct:expr, $arity:expr, $pvs:expr, $lco:expr) => (
Line::Control(ControlInstruction::CallClause($ct, $arity, $pvs, $lco, false))
)
($ct:expr, $arity:expr, $pvs:expr) => {
Line::Control(ControlInstruction::CallClause(
$ct, $arity, $pvs, false, false,
))
};
($ct:expr, $arity:expr, $pvs:expr, $lco:expr) => {
Line::Control(ControlInstruction::CallClause(
$ct, $arity, $pvs, $lco, false,
))
};
}
macro_rules! call_clause_by_default {
($ct:expr, $arity:expr, $pvs:expr) => (
Line::Control(ControlInstruction::CallClause($ct, $arity, $pvs, false, true))
);
($ct:expr, $arity:expr, $pvs:expr, $lco:expr) => (
Line::Control(ControlInstruction::CallClause($ct, $arity, $pvs, $lco, true))
)
($ct:expr, $arity:expr, $pvs:expr) => {
Line::Control(ControlInstruction::CallClause(
$ct, $arity, $pvs, false, true,
))
};
($ct:expr, $arity:expr, $pvs:expr, $lco:expr) => {
Line::Control(ControlInstruction::CallClause(
$ct, $arity, $pvs, $lco, true,
))
};
}
macro_rules! proceed {
() => (
() => {
Line::Control(ControlInstruction::Proceed)
)
};
}
macro_rules! is_call {
($r:expr, $at:expr) => (
($r:expr, $at:expr) => {
call_clause!(ClauseType::BuiltIn(BuiltInClauseType::Is($r, $at)), 2, 0)
)
};
}
macro_rules! is_call_by_default {
($r:expr, $at:expr) => (
($r:expr, $at:expr) => {
call_clause_by_default!(ClauseType::BuiltIn(BuiltInClauseType::Is($r, $at)), 2, 0)
)
};
}
macro_rules! set_cp {
($r:expr) => (
($r:expr) => {
call_clause!(ClauseType::System(SystemClauseType::SetCutPoint($r)), 1, 0)
)
};
}
macro_rules! succeed {
() => (
() => {
call_clause!(ClauseType::System(SystemClauseType::Succeed), 0, 0)
)
};
}
macro_rules! fail {
() => (
() => {
call_clause!(ClauseType::System(SystemClauseType::Fail), 0, 0)
)
};
}
macro_rules! compare_number_instr {
($cmp: expr, $at_1: expr, $at_2: expr) => {{
let ct = ClauseType::Inlined(InlinedClauseType::CompareNumber($cmp, $at_1, $at_2));
call_clause!(ct, 2, 0)
}}
}};
}
macro_rules! jmp_call {
($arity:expr, $offset:expr, $pvs:expr) => (
($arity:expr, $offset:expr, $pvs:expr) => {
Line::Control(ControlInstruction::JmpBy($arity, $offset, $pvs, false))
)
};
}
macro_rules! try_eval_session {
($e:expr) => (
($e:expr) => {
match $e {
Ok(result) => result,
Err(e) => return EvalSession::from(e)
Err(e) => return EvalSession::from(e),
}
)
};
}
macro_rules! return_from_clause {
($lco:expr, $machine_st:expr) => {{
if let CodePtr::VerifyAttrInterrupt(_) = $machine_st.p {
return Ok(());
}
if $lco {
$machine_st.p = CodePtr::Local($machine_st.cp);
} else {
@@ -201,19 +212,19 @@ macro_rules! return_from_clause {
}
Ok(())
}}
}};
}
macro_rules! dir_entry {
($idx:expr) => (
($idx:expr) => {
CodePtr::Local(LocalCodePtr::DirEntry($idx))
)
};
}
macro_rules! in_situ_dir_entry {
($idx:expr) => (
($idx:expr) => {
CodePtr::Local(LocalCodePtr::InSituDirEntry($idx))
)
};
}
macro_rules! set_code_index {
@@ -222,64 +233,69 @@ macro_rules! set_code_index {
idx.0 = $ip;
idx.1 = $mod_name.clone();
}}
}};
}
macro_rules! index_store {
($atom_tbl:expr, $code_dir:expr, $op_dir:expr, $modules:expr) => (
IndexStore { atom_tbl: $atom_tbl,
code_dir: $code_dir,
dynamic_code_dir: DynamicCodeDir::new(),
global_variables: GlobalVarDir::new(),
in_situ_code_dir: InSituCodeDir::new(),
op_dir: $op_dir,
modules: $modules }
)
($atom_tbl:expr, $code_dir:expr, $op_dir:expr, $modules:expr) => {
IndexStore {
atom_tbl: $atom_tbl,
code_dir: $code_dir,
dynamic_code_dir: DynamicCodeDir::new(),
global_variables: GlobalVarDir::new(),
in_situ_code_dir: InSituCodeDir::new(),
op_dir: $op_dir,
modules: $modules,
}
};
}
macro_rules! default_index_store {
($atom_tbl:expr) => (
($atom_tbl:expr) => {
index_store!($atom_tbl, CodeDir::new(), default_op_dir(), IndexMap::new())
)
};
}
macro_rules! put_constant {
($lvl:expr, $cons:expr, $r:expr) => (
($lvl:expr, $cons:expr, $r:expr) => {
QueryInstruction::PutConstant($lvl, $cons, $r)
)
};
}
macro_rules! top_level_code_ptr {
($p:expr, $q_sz:expr) => (
($p:expr, $q_sz:expr) => {
CodePtr::Local(LocalCodePtr::TopLevel($p, $q_sz))
)
};
}
macro_rules! get_level_and_unify {
($r: expr) => (
($r: expr) => {
Line::Cut(CutInstruction::GetLevelAndUnify($r))
)
};
}
macro_rules! unwind_protect {
($e: expr, $protected: expr) => (
($e: expr, $protected: expr) => {
match $e {
Err(e) => { $protected; return Err(e); },
Err(e) => {
$protected;
return Err(e);
}
_ => {}
}
)
};
}
macro_rules! discard_result {
($f: expr) => (
($f: expr) => {
match $f {
_ => ()
_ => (),
}
)
};
}
macro_rules! ar_reg {
($r: expr) => (
($r: expr) => {
ArithmeticTerm::Reg($r)
)
};
}