Class: AdLint::Cpp::PreprocessContext

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/adlint/cpp/eval.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(phase_ctxt) ⇒ PreprocessContext

Returns a new instance of PreprocessContext.



840
841
842
843
844
845
846
# File 'lib/adlint/cpp/eval.rb', line 840

def initialize(phase_ctxt)
  @phase_ctxt          = phase_ctxt
  @deferred_text_lines = []
  @lexer_stack         = []
  @branch_stack        = []
  @once_set            = Set.new
end

Instance Attribute Details

#deferred_text_linesObject (readonly)

Returns the value of attribute deferred_text_lines.



848
849
850
# File 'lib/adlint/cpp/eval.rb', line 848

def deferred_text_lines
  @deferred_text_lines
end

#once_setObject (readonly)

Returns the value of attribute once_set.



849
850
851
# File 'lib/adlint/cpp/eval.rb', line 849

def once_set
  @once_set
end

Instance Method Details

#branch_evaluated=(evaluated) ⇒ Object



920
921
922
# File 'lib/adlint/cpp/eval.rb', line 920

def branch_evaluated=(evaluated)
  @branch_stack[-1] = evaluated
end

#branch_evaluated?Boolean

Returns:

  • (Boolean)


924
925
926
# File 'lib/adlint/cpp/eval.rb', line 924

def branch_evaluated?
  @branch_stack.last
end

#include_depthObject



928
929
930
# File 'lib/adlint/cpp/eval.rb', line 928

def include_depth
  @lexer_stack.size
end

#macro_tableObject



876
877
878
# File 'lib/adlint/cpp/eval.rb', line 876

def macro_table
  @phase_ctxt[:cpp_macro_table]
end

#next_tokenObject



897
898
899
900
901
902
903
# File 'lib/adlint/cpp/eval.rb', line 897

def next_token
  if top_token
    @lexer_stack.last.next_token
  else
    nil
  end
end

#pop_branchObject



916
917
918
# File 'lib/adlint/cpp/eval.rb', line 916

def pop_branch
  @branch_stack.pop
end

#push_branchObject



912
913
914
# File 'lib/adlint/cpp/eval.rb', line 912

def push_branch
  @branch_stack.push(false)
end

#push_lexer(lexer) ⇒ Object



880
881
882
# File 'lib/adlint/cpp/eval.rb', line 880

def push_lexer(lexer)
  @lexer_stack.push(lexer)
end

#skip_groupObject



905
906
907
908
909
910
# File 'lib/adlint/cpp/eval.rb', line 905

def skip_group
  until @lexer_stack.last.skip_group
    @lexer_stack.pop
    break if @lexer_stack.empty?
  end
end

#sourceObject



864
865
866
# File 'lib/adlint/cpp/eval.rb', line 864

def source
  @phase_ctxt[:cc1_source]
end

#sourcesObject



868
869
870
# File 'lib/adlint/cpp/eval.rb', line 868

def sources
  @phase_ctxt[:sources]
end

#symbol_tableObject



872
873
874
# File 'lib/adlint/cpp/eval.rb', line 872

def symbol_table
  @phase_ctxt[:symbol_table]
end

#top_tokenObject



884
885
886
887
888
889
890
891
892
893
894
895
# File 'lib/adlint/cpp/eval.rb', line 884

def top_token
  unless @lexer_stack.empty?
    unless tok = @lexer_stack.last.top_token
      @lexer_stack.pop
      top_token
    else
      tok
    end
  else
    nil
  end
end

#tunit_root_fpathObject



860
861
862
# File 'lib/adlint/cpp/eval.rb', line 860

def tunit_root_fpath
  @phase_ctxt[:sources].first.fpath
end