Make macros private

This commit is contained in:
bakaq
2024-09-06 16:51:10 -03:00
parent 806e980cca
commit ada9ba98cc
15 changed files with 20 additions and 86 deletions

View File

@@ -3281,14 +3281,14 @@ pub fn generate_instructions_rs() -> TokenStream {
} }
} }
#[macro_export]
macro_rules! _instr { macro_rules! _instr {
#( #(
#instr_macro_arms #instr_macro_arms
);* );*
} }
pub use _instr as instr; // https://github.com/rust-lang/rust/pull/52234#issuecomment-976702997 // https://github.com/rust-lang/rust/pull/52234#issuecomment-976702997
pub(crate) use _instr as instr;
} }
} }

View File

@@ -164,7 +164,6 @@ pub fn index_static_strings(instruction_rs_path: &std::path::Path) -> TokenStrea
)* )*
]; ];
#[macro_export]
macro_rules! atom { macro_rules! atom {
#((#static_strs) => { Atom { index: #indices_iter } };)* #((#static_strs) => { Atom { index: #indices_iter } };)*
} }

View File

@@ -29,7 +29,6 @@ use std::ptr::addr_of_mut;
use std::ptr::NonNull; use std::ptr::NonNull;
use std::sync::RwLock; use std::sync::RwLock;
#[macro_export]
macro_rules! arena_alloc { macro_rules! arena_alloc {
($e:expr, $arena:expr) => {{ ($e:expr, $arena:expr) => {{
let result = $e; let result = $e;
@@ -37,7 +36,6 @@ macro_rules! arena_alloc {
}}; }};
} }
#[macro_export]
macro_rules! float_alloc { macro_rules! float_alloc {
($e:expr, $arena:expr) => {{ ($e:expr, $arena:expr) => {{
let result = $e; let result = $e;

View File

@@ -124,7 +124,6 @@ impl Hash for Atom {
} }
} }
#[macro_export]
macro_rules! is_char { macro_rules! is_char {
($s:expr) => { ($s:expr) => {
!$s.is_empty() && $s.chars().nth(1).is_none() !$s.is_empty() && $s.chars().nth(1).is_none()

View File

@@ -8,11 +8,9 @@ use crate::instructions::*;
use crate::iterators::*; use crate::iterators::*;
use crate::parser::ast::*; use crate::parser::ast::*;
use crate::targets::*; use crate::targets::*;
use crate::temp_v;
use crate::types::*; use crate::types::*;
use crate::variable_records::*; use crate::variable_records::*;
use crate::instr;
use crate::machine::disjuncts::*; use crate::machine::disjuncts::*;
use crate::machine::machine_errors::*; use crate::machine::machine_errors::*;

View File

@@ -4,11 +4,6 @@ use crate::parser::ast::*;
use crate::parser::dashu::base::RemEuclid; use crate::parser::dashu::base::RemEuclid;
use crate::parser::dashu::integer::Sign; use crate::parser::dashu::integer::Sign;
use crate::parser::dashu::{ibig, Integer, Rational}; use crate::parser::dashu::{ibig, Integer, Rational};
use crate::{
alpha_numeric_char, capital_letter_char, cut_char, decimal_digit_char, graphic_token_char,
semicolon_char, sign_char, single_quote_char, small_letter_char, solo_char,
variable_indicator_char,
};
use crate::forms::*; use crate::forms::*;
use crate::heap_iter::*; use crate::heap_iter::*;

View File

@@ -15,8 +15,6 @@ use crate::parser::ast::*;
use crate::parser::dashu::{Integer, Rational}; use crate::parser::dashu::{Integer, Rational};
use crate::types::*; use crate::types::*;
use crate::fixnum;
use ordered_float::{Float, OrderedFloat}; use ordered_float::{Float, OrderedFloat};
use std::cmp; use std::cmp;
@@ -24,7 +22,6 @@ use std::convert::TryFrom;
use std::f64; use std::f64;
use std::mem; use std::mem;
#[macro_export]
macro_rules! try_numeric_result { macro_rules! try_numeric_result {
($e: expr, $stub_gen: expr) => { ($e: expr, $stub_gen: expr) => {
match $e { match $e {

View File

@@ -1,7 +1,6 @@
use crate::heap_iter::*; use crate::heap_iter::*;
use crate::machine::*; use crate::machine::*;
use crate::parser::ast::*; use crate::parser::ast::*;
use crate::temp_v;
use crate::types::*; use crate::types::*;
use indexmap::IndexSet; use indexmap::IndexSet;

View File

@@ -7,8 +7,6 @@ use crate::machine::machine_state::*;
use crate::machine::*; use crate::machine::*;
use crate::types::*; use crate::types::*;
use crate::try_numeric_result;
use fxhash::FxBuildHasher; use fxhash::FxBuildHasher;
macro_rules! step_or_fail { macro_rules! step_or_fail {

View File

@@ -211,7 +211,6 @@ impl PredicateQueue {
} }
} }
#[macro_export]
macro_rules! predicate_queue { macro_rules! predicate_queue {
[$($v:expr),*] => ( [$($v:expr),*] => (
PredicateQueue { PredicateQueue {

View File

@@ -1,4 +1,5 @@
pub mod args; pub mod args;
#[macro_use]
pub mod arithmetic_ops; pub mod arithmetic_ops;
pub mod attributed_variables; pub mod attributed_variables;
pub mod code_walker; pub mod code_walker;

View File

@@ -7,8 +7,6 @@ use crate::parser::ast::*;
use crate::parser::parser::*; use crate::parser::parser::*;
use crate::read::devour_whitespace; use crate::read::devour_whitespace;
use crate::predicate_queue;
use fxhash::FxBuildHasher; use fxhash::FxBuildHasher;
use indexmap::IndexSet; use indexmap::IndexSet;

View File

@@ -144,7 +144,6 @@ macro_rules! stack_loc_as_cell {
}; };
} }
#[macro_export]
macro_rules! heap_loc_as_cell { macro_rules! heap_loc_as_cell {
($h:expr) => { ($h:expr) => {
HeapCellValue::build_with(HeapCellValueTag::Var, $h as u64) HeapCellValue::build_with(HeapCellValueTag::Var, $h as u64)

View File

@@ -139,7 +139,6 @@ pub const BTERM: u32 = 0x11000;
pub const NEGATIVE_SIGN: u32 = 0x0200; pub const NEGATIVE_SIGN: u32 = 0x0200;
#[macro_export]
macro_rules! fixnum { macro_rules! fixnum {
($wrapper:tt, $n:expr, $arena:expr) => { ($wrapper:tt, $n:expr, $arena:expr) => {
Fixnum::build_with_checked($n) Fixnum::build_with_checked($n)
@@ -180,21 +179,18 @@ macro_rules! is_negate {
}; };
} }
#[macro_export]
macro_rules! is_prefix { macro_rules! is_prefix {
($x:expr) => { ($x:expr) => {
$x as u32 & ($crate::parser::ast::FX as u32 | $crate::parser::ast::FY as u32) != 0 $x as u32 & ($crate::parser::ast::FX as u32 | $crate::parser::ast::FY as u32) != 0
}; };
} }
#[macro_export]
macro_rules! is_postfix { macro_rules! is_postfix {
($x:expr) => { ($x:expr) => {
$x as u32 & ($crate::parser::ast::XF as u32 | $crate::parser::ast::YF as u32) != 0 $x as u32 & ($crate::parser::ast::XF as u32 | $crate::parser::ast::YF as u32) != 0
}; };
} }
#[macro_export]
macro_rules! is_infix { macro_rules! is_infix {
($x:expr) => { ($x:expr) => {
($x as u32 ($x as u32
@@ -205,48 +201,41 @@ macro_rules! is_infix {
}; };
} }
#[macro_export]
macro_rules! is_xfx { macro_rules! is_xfx {
($x:expr) => { ($x:expr) => {
($x as u32 & $crate::parser::ast::XFX as u32) != 0 ($x as u32 & $crate::parser::ast::XFX as u32) != 0
}; };
} }
#[macro_export]
macro_rules! is_xfy { macro_rules! is_xfy {
($x:expr) => { ($x:expr) => {
($x as u32 & $crate::parser::ast::XFY as u32) != 0 ($x as u32 & $crate::parser::ast::XFY as u32) != 0
}; };
} }
#[macro_export]
macro_rules! is_yfx { macro_rules! is_yfx {
($x:expr) => { ($x:expr) => {
($x as u32 & $crate::parser::ast::YFX as u32) != 0 ($x as u32 & $crate::parser::ast::YFX as u32) != 0
}; };
} }
#[macro_export]
macro_rules! is_yf { macro_rules! is_yf {
($x:expr) => { ($x:expr) => {
($x as u32 & $crate::parser::ast::YF as u32) != 0 ($x as u32 & $crate::parser::ast::YF as u32) != 0
}; };
} }
#[macro_export]
macro_rules! is_xf { macro_rules! is_xf {
($x:expr) => { ($x:expr) => {
($x as u32 & $crate::parser::ast::XF as u32) != 0 ($x as u32 & $crate::parser::ast::XF as u32) != 0
}; };
} }
#[macro_export]
macro_rules! is_fx { macro_rules! is_fx {
($x:expr) => { ($x:expr) => {
($x as u32 & $crate::parser::ast::FX as u32) != 0 ($x as u32 & $crate::parser::ast::FX as u32) != 0
}; };
} }
#[macro_export]
macro_rules! is_fy { macro_rules! is_fy {
($x:expr) => { ($x:expr) => {
($x as u32 & $crate::parser::ast::FY as u32) != 0 ($x as u32 & $crate::parser::ast::FY as u32) != 0
@@ -317,14 +306,12 @@ impl Default for VarReg {
} }
} }
#[macro_export]
macro_rules! temp_v { macro_rules! temp_v {
($x:expr) => { ($x:expr) => {
$crate::parser::ast::RegType::Temp($x) $crate::parser::ast::RegType::Temp($x)
}; };
} }
#[macro_export]
macro_rules! perm_v { macro_rules! perm_v {
($x:expr) => { ($x:expr) => {
$crate::parser::ast::RegType::Perm($x) $crate::parser::ast::RegType::Perm($x)

View File

@@ -1,237 +1,204 @@
#[macro_export]
macro_rules! char_class { macro_rules! char_class {
($c: expr, [$head:expr]) => ($c == $head); ($c: expr, [$head:expr]) => ($c == $head);
($c: expr, [$head:expr $(, $cs:expr)+]) => ($c == $head || $crate::char_class!($c, [$($cs),*])); ($c: expr, [$head:expr $(, $cs:expr)+]) => ($c == $head || char_class!($c, [$($cs),*]));
} }
#[macro_export]
macro_rules! alpha_char { macro_rules! alpha_char {
($c: expr) => { ($c: expr) => {
(!$c.is_numeric() (!$c.is_numeric()
&& !$c.is_whitespace() && !$c.is_whitespace()
&& !$c.is_control() && !$c.is_control()
&& !$crate::graphic_token_char!($c) && !graphic_token_char!($c)
&& !$crate::layout_char!($c) && !layout_char!($c)
&& !$crate::meta_char!($c) && !meta_char!($c)
&& !$crate::solo_char!($c)) && !solo_char!($c))
|| $c == '_' || $c == '_'
}; };
} }
#[macro_export]
macro_rules! alpha_numeric_char { macro_rules! alpha_numeric_char {
($c: expr) => { ($c: expr) => {
$crate::alpha_char!($c) || $c.is_numeric() alpha_char!($c) || $c.is_numeric()
}; };
} }
#[macro_export]
macro_rules! backslash_char { macro_rules! backslash_char {
($c: expr) => { ($c: expr) => {
$c == '\\' $c == '\\'
}; };
} }
#[macro_export]
macro_rules! back_quote_char { macro_rules! back_quote_char {
($c: expr) => { ($c: expr) => {
$c == '`' $c == '`'
}; };
} }
#[macro_export]
macro_rules! octet_char { macro_rules! octet_char {
($c: expr) => { ($c: expr) => {
('\u{0000}'..='\u{00FF}').contains(&$c) ('\u{0000}'..='\u{00FF}').contains(&$c)
}; };
} }
#[macro_export]
macro_rules! capital_letter_char { macro_rules! capital_letter_char {
($c: expr) => { ($c: expr) => {
$c.is_uppercase() $c.is_uppercase()
}; };
} }
#[macro_export]
macro_rules! comment_1_char { macro_rules! comment_1_char {
($c: expr) => { ($c: expr) => {
$c == '/' $c == '/'
}; };
} }
#[macro_export]
macro_rules! comment_2_char { macro_rules! comment_2_char {
($c: expr) => { ($c: expr) => {
$c == '*' $c == '*'
}; };
} }
#[macro_export]
macro_rules! cut_char { macro_rules! cut_char {
($c: expr) => { ($c: expr) => {
$c == '!' $c == '!'
}; };
} }
#[macro_export]
macro_rules! decimal_digit_char { macro_rules! decimal_digit_char {
($c: expr) => { ($c: expr) => {
$c.is_ascii_digit() $c.is_ascii_digit()
}; };
} }
#[macro_export]
macro_rules! decimal_point_char { macro_rules! decimal_point_char {
($c: expr) => { ($c: expr) => {
$c == '.' $c == '.'
}; };
} }
#[macro_export]
macro_rules! double_quote_char { macro_rules! double_quote_char {
($c: expr) => { ($c: expr) => {
$c == '"' $c == '"'
}; };
} }
#[macro_export]
macro_rules! end_line_comment_char { macro_rules! end_line_comment_char {
($c: expr) => { ($c: expr) => {
$c == '%' $c == '%'
}; };
} }
#[macro_export]
macro_rules! exponent_char { macro_rules! exponent_char {
($c: expr) => { ($c: expr) => {
$c == 'e' || $c == 'E' $c == 'e' || $c == 'E'
}; };
} }
#[macro_export]
macro_rules! graphic_char { macro_rules! graphic_char {
($c: expr) => ($crate::char_class!($c, ['#', '$', '&', '*', '+', '-', '.', '/', ':', ($c: expr) => (char_class!($c, ['#', '$', '&', '*', '+', '-', '.', '/', ':',
'<', '=', '>', '?', '@', '^', '~'])) '<', '=', '>', '?', '@', '^', '~']))
} }
#[macro_export]
macro_rules! graphic_token_char { macro_rules! graphic_token_char {
($c: expr) => { ($c: expr) => {
$crate::graphic_char!($c) || $crate::backslash_char!($c) graphic_char!($c) || backslash_char!($c)
}; };
} }
#[macro_export]
macro_rules! hexadecimal_digit_char { macro_rules! hexadecimal_digit_char {
($c: expr) => { ($c: expr) => {
$c.is_ascii_digit() || ('A'..='F').contains(&$c) || ('a'..='f').contains(&$c) $c.is_ascii_digit() || ('A'..='F').contains(&$c) || ('a'..='f').contains(&$c)
}; };
} }
#[macro_export]
macro_rules! layout_char { macro_rules! layout_char {
($c: expr) => { ($c: expr) => {
$crate::char_class!($c, [' ', '\r', '\n', '\t', '\u{0B}', '\u{0C}']) char_class!($c, [' ', '\r', '\n', '\t', '\u{0B}', '\u{0C}'])
}; };
} }
#[macro_export]
macro_rules! meta_char { macro_rules! meta_char {
($c: expr) => { ($c: expr) => {
$crate::char_class!($c, ['\\', '\'', '"', '`']) char_class!($c, ['\\', '\'', '"', '`'])
}; };
} }
#[macro_export]
macro_rules! new_line_char { macro_rules! new_line_char {
($c: expr) => { ($c: expr) => {
$c == '\n' $c == '\n'
}; };
} }
#[macro_export]
macro_rules! octal_digit_char { macro_rules! octal_digit_char {
($c: expr) => { ($c: expr) => {
('0'..='7').contains(&$c) ('0'..='7').contains(&$c)
}; };
} }
#[macro_export]
macro_rules! binary_digit_char { macro_rules! binary_digit_char {
($c: expr) => { ($c: expr) => {
$c == '0' || $c == '1' $c == '0' || $c == '1'
}; };
} }
#[macro_export]
macro_rules! prolog_char { macro_rules! prolog_char {
($c: expr) => { ($c: expr) => {
$crate::graphic_char!($c) graphic_char!($c)
|| $crate::alpha_numeric_char!($c) || alpha_numeric_char!($c)
|| $crate::solo_char!($c) || solo_char!($c)
|| $crate::layout_char!($c) || layout_char!($c)
|| $crate::meta_char!($c) || meta_char!($c)
}; };
} }
#[macro_export]
macro_rules! semicolon_char { macro_rules! semicolon_char {
($c: expr) => { ($c: expr) => {
$c == ';' $c == ';'
}; };
} }
#[macro_export]
macro_rules! sign_char { macro_rules! sign_char {
($c: expr) => { ($c: expr) => {
$c == '-' || $c == '+' $c == '-' || $c == '+'
}; };
} }
#[macro_export]
macro_rules! single_quote_char { macro_rules! single_quote_char {
($c: expr) => { ($c: expr) => {
$c == '\'' $c == '\''
}; };
} }
#[macro_export]
macro_rules! small_letter_char { macro_rules! small_letter_char {
($c: expr) => { ($c: expr) => {
$c.is_alphabetic() && !$c.is_uppercase() $c.is_alphabetic() && !$c.is_uppercase()
}; };
} }
#[macro_export]
macro_rules! solo_char { macro_rules! solo_char {
($c: expr) => { ($c: expr) => {
$crate::char_class!($c, ['!', '(', ')', ',', ';', '[', ']', '{', '}', '|', '%']) char_class!($c, ['!', '(', ')', ',', ';', '[', ']', '{', '}', '|', '%'])
}; };
} }
#[macro_export]
macro_rules! space_char { macro_rules! space_char {
($c: expr) => { ($c: expr) => {
$c == ' ' $c == ' '
}; };
} }
#[macro_export]
macro_rules! symbolic_control_char { macro_rules! symbolic_control_char {
($c: expr) => { ($c: expr) => {
$crate::char_class!($c, ['a', 'b', 'f', 'n', 'r', 't', 'v', '0']) char_class!($c, ['a', 'b', 'f', 'n', 'r', 't', 'v', '0'])
}; };
} }
#[macro_export]
macro_rules! symbolic_hexadecimal_char { macro_rules! symbolic_hexadecimal_char {
($c: expr) => { ($c: expr) => {
$c == 'x' $c == 'x'
}; };
} }
#[macro_export]
macro_rules! variable_indicator_char { macro_rules! variable_indicator_char {
($c: expr) => { ($c: expr) => {
$c == '_' $c == '_'