Class: AdLint::Cpp::ObjectLikeMacro

Inherits:
Macro
  • Object
show all
Defined in:
lib/adlint/cpp/macro.rb

Direct Known Subclasses

SpecialMacro

Instance Attribute Summary

Attributes inherited from Macro

#define_line

Instance Method Summary collapse

Methods inherited from Macro

#initialize, #location, #name, #replacement_list

Methods included from LocationHolder

#analysis_target?

Constructor Details

This class inherits a constructor from AdLint::Cpp::Macro

Instance Method Details

#expand(toks, macro_tbl, repl_ctxt) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/adlint/cpp/macro.rb', line 80

def expand(toks, macro_tbl, repl_ctxt)
  super

  if repl_list = self.replacement_list
    loc = toks.first.location
    rslt_toks = repl_list.tokens.map { |tok|
      ReplacedToken.new(tok.type, tok.value, loc, tok.type_hint, false)
    }
  else
    rslt_toks = []
  end

  macro_tbl.notify_object_like_macro_replacement(self, toks, rslt_toks)
  rslt_toks
end

#function_like?Boolean

Returns:

  • (Boolean)


96
# File 'lib/adlint/cpp/macro.rb', line 96

def function_like?; false end

#replaceable_size(toks) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/adlint/cpp/macro.rb', line 72

def replaceable_size(toks)
  if toks.first.value == "NULL" then
    0
  else
    name.value == toks.first.value ? 1 : 0
  end
end