Class: AdLint::Cc1::EvalFunction

Inherits:
BuiltinFunction show all
Defined in:
lib/adlint/cc1/builtin.rb

Instance Attribute Summary

Attributes included from Nameable

#name

Attributes inherited from TypedObject

#type

Attributes inherited from Object

#declarations_and_definitions

Attributes included from Bindable

#binding

Instance Method Summary collapse

Methods inherited from BuiltinFunction

#builtin?, #explicit?

Methods inherited from NamedFunction

#designated_by_lvalue?, #signature

Methods included from Nameable

#named?

Methods inherited from Function

#builtin?, #explicit?, #function?, #implicit?, #name, #named?, #signature, #temporary?, #variable?

Methods inherited from TypedObject

#to_pointer, #to_pointer_value, #to_value, #to_variable

Methods inherited from Object

#declared_as_auto?, #declared_as_extern?, #declared_as_register?, #declared_as_static?, #designated_by_lvalue?, #function?, #named?, #storage_class_specifiers, #temporary?, #variable?

Methods included from Bindable

#be_alias_to, #bind_to

Constructor Details

#initialize(type_tbl) ⇒ EvalFunction

Returns a new instance of EvalFunction.



70
71
72
# File 'lib/adlint/cc1/builtin.rb', line 70

def initialize(type_tbl)
  super(type_tbl, "__adlint__eval")
end

Instance Method Details

#call(interp, args) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/adlint/cc1/builtin.rb', line 74

def call(interp, *, args)
  puts "__adlint__eval"
  char_ary = args.first.first
  if char_ary.type.array?
    without_nil = char_ary.value.to_single_value.values[0..-2]
    prog_text = without_nil.map { |char| char.unique_sample.chr }.join
    if prog_text.empty?
      puts "no program text"
    else
      eval prog_text
    end
    puts "EOM"
  end
  super
end