class AdLint::Exam::CBuiltin::DirectiveExtraction
Public Class Methods
new(phase_ctxt)
click to toggle source
Calls superclass method
AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 103 def initialize(phase_ctxt) super trav = phase_ctxt[:cpp_ast_traversal] trav.enter_if_statement += T(:extract_if) trav.enter_ifdef_statement += T(:extract_ifdef) trav.enter_ifndef_statement += T(:extract_ifndef) trav.enter_elif_statement += T(:extract_elif) trav.enter_else_statement += T(:extract_else) trav.enter_endif_line += T(:extract_endif) trav.enter_user_include_line += T(:extract_usr_include) trav.enter_system_include_line += T(:extract_sys_include) trav.enter_object_like_define_line += T(:extract_define) trav.enter_function_like_define_line += T(:extract_define) trav.enter_va_function_like_define_line += T(:extract_define) trav.enter_undef_line += T(:extract_undef) trav.enter_line_line += T(:extract_line) trav.enter_error_line += T(:extract_error) trav.enter_pragma_line += T(:extract_pragma) trav.enter_null_directive += T(:extract_null) end
Private Instance Methods
do_execute(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 126 def do_execute(*) end
do_prepare(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 125 def do_prepare(*) end
extract_define(define_line)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 166 def extract_define(define_line) PP_DIRECTIVE(define_line.location, define_line.keyword.value, define_line.identifier.value) end
extract_elif(elif_stmt)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 143 def extract_elif(elif_stmt) PP_DIRECTIVE(elif_stmt.location, elif_stmt.keyword.value, elif_stmt.expression.to_s) end
extract_else(else_stmt)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 148 def extract_else(else_stmt) PP_DIRECTIVE(else_stmt.location, else_stmt.keyword.value, nil) end
extract_endif(endif_line)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 152 def extract_endif(endif_line) PP_DIRECTIVE(endif_line.location, endif_line.keyword.value, nil) end
extract_error(error_line)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 181 def extract_error(error_line) PP_DIRECTIVE(error_line.location, error_line.keyword.value, error_line.pp_tokens.tokens.map { |t| t.value }.join(" ")) end
extract_if(if_stmt)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 128 def extract_if(if_stmt) PP_DIRECTIVE(if_stmt.location, if_stmt.keyword.value, if_stmt.expression.to_s) end
extract_ifdef(ifdef_stmt)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 133 def extract_ifdef(ifdef_stmt) PP_DIRECTIVE(ifdef_stmt.location, ifdef_stmt.keyword.value, ifdef_stmt.identifier.value) end
extract_ifndef(ifndef_stmt)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 138 def extract_ifndef(ifndef_stmt) PP_DIRECTIVE(ifndef_stmt.location, ifndef_stmt.keyword.value, ifndef_stmt.identifier.value) end
extract_line(line_line)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 176 def extract_line(line_line) PP_DIRECTIVE(line_line.location, line_line.keyword.value, line_line.pp_tokens ? line_line.pp_tokens.to_s : "") end
extract_null(null_directive)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 191 def extract_null(null_directive) PP_DIRECTIVE(null_directive.location, null_directive.token.value, nil) end
extract_pragma(pragma_line)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 186 def extract_pragma(pragma_line) PP_DIRECTIVE(pragma_line.location, pragma_line.keyword.value, pragma_line.pp_tokens ? pragma_line.pp_tokens.to_s : "") end
extract_sys_include(sys_include_line)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 161 def extract_sys_include(sys_include_line) PP_DIRECTIVE(sys_include_line.location, sys_include_line.keyword.value, sys_include_line.header_name.value) end
extract_undef(undef_line)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 171 def extract_undef(undef_line) PP_DIRECTIVE(undef_line.location, undef_line.keyword.value, undef_line.identifier.value) end
extract_usr_include(usr_include_line)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_code.rb, line 156 def extract_usr_include(usr_include_line) PP_DIRECTIVE(usr_include_line.location, usr_include_line.keyword.value, usr_include_line.header_name.value) end