Class: AdLint::Cpp::MacroTable
- Inherits:
-
Object
- Object
- AdLint::Cpp::MacroTable
- Extended by:
- Pluggable
- Defined in:
- lib/adlint/cpp/macro.rb
Instance Method Summary collapse
- #define(macro) ⇒ Object
-
#initialize ⇒ MacroTable
constructor
A new instance of MacroTable.
- #lookup(name_str) ⇒ Object
- #notify_function_like_macro_replacement(macro, replacing_toks, args, rslt_toks) ⇒ Object
- #notify_last_backslash_ignored(tok) ⇒ Object
- #notify_object_like_macro_replacement(macro, replacing_toks, rslt_toks) ⇒ Object
- #notify_sharpsharp_operator_evaled(lhs_tok, rhs_tok, new_toks) ⇒ Object
- #replace(toks, repl_ctxt = nil) ⇒ Object
- #undef(name_str) ⇒ Object
Methods included from Pluggable
Constructor Details
#initialize ⇒ MacroTable
703 704 705 706 |
# File 'lib/adlint/cpp/macro.rb', line 703 def initialize @macros = {} predefine_special_macros end |
Instance Method Details
#define(macro) ⇒ Object
715 716 717 718 |
# File 'lib/adlint/cpp/macro.rb', line 715 def define(macro) @macros[macro.name.value] = macro self end |
#lookup(name_str) ⇒ Object
725 726 727 |
# File 'lib/adlint/cpp/macro.rb', line 725 def lookup(name_str) @macros[name_str] end |
#notify_function_like_macro_replacement(macro, replacing_toks, args, rslt_toks) ⇒ Object
759 760 761 762 763 |
# File 'lib/adlint/cpp/macro.rb', line 759 def notify_function_like_macro_replacement(macro, replacing_toks, args, rslt_toks) on_function_like_macro_replacement.invoke(macro, replacing_toks, args, rslt_toks) end |
#notify_last_backslash_ignored(tok) ⇒ Object
769 770 771 |
# File 'lib/adlint/cpp/macro.rb', line 769 def notify_last_backslash_ignored(tok) on_last_backslash_ignored.invoke(tok) end |
#notify_object_like_macro_replacement(macro, replacing_toks, rslt_toks) ⇒ Object
755 756 757 |
# File 'lib/adlint/cpp/macro.rb', line 755 def notify_object_like_macro_replacement(macro, replacing_toks, rslt_toks) on_object_like_macro_replacement.invoke(macro, replacing_toks, rslt_toks) end |
#notify_sharpsharp_operator_evaled(lhs_tok, rhs_tok, new_toks) ⇒ Object
765 766 767 |
# File 'lib/adlint/cpp/macro.rb', line 765 def notify_sharpsharp_operator_evaled(lhs_tok, rhs_tok, new_toks) on_sharpsharp_operator_evaled.invoke(lhs_tok, rhs_tok, new_toks) end |
#replace(toks, repl_ctxt = nil) ⇒ Object
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
# File 'lib/adlint/cpp/macro.rb', line 729 def replace(toks, repl_ctxt = nil) replaced = false idx = 0 while tok = toks[idx] case tok.value when "defined" in_defined = true when "(", ")" ; else if in_defined in_defined = false else if new_idx = do_replace(toks, idx, repl_ctxt) idx = new_idx replaced = true end end end idx += 1 end replaced end |
#undef(name_str) ⇒ Object
720 721 722 723 |
# File 'lib/adlint/cpp/macro.rb', line 720 def undef(name_str) @macros.delete(name_str) self end |