Class: RedShift::Expr
- Defined in:
- lib/redshift/component.rb,
lib/redshift/target/c/flow/expr.rb
Overview
Kinda funny…
Direct Known Subclasses
Constant Summary collapse
- @@serial =
0
Constants inherited from Flow
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Flow
Instance Method Summary collapse
-
#initialize(f, type = "double") ⇒ Expr
constructor
A new instance of Expr.
-
#wrapper(cl) ⇒ Object
clis the component class.
Methods inherited from Flow
#external_constant?, #make_ct_struct, #translate, #translate_link
Constructor Details
#initialize(f, type = "double") ⇒ Expr
Returns a new instance of Expr.
62 63 64 65 |
# File 'lib/redshift/target/c/flow/expr.rb', line 62 def initialize f, type = "double" super nil, f @type = type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
60 61 62 |
# File 'lib/redshift/target/c/flow/expr.rb', line 60 def type @type end |
Instance Method Details
#wrapper(cl) ⇒ Object
cl is the component class
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/redshift/target/c/flow/expr.rb', line 70 def wrapper(cl) expr = self cl_cname = CGenerator.make_c_name cl.name ex_cname = "Expr_#{@@serial}"; @@serial += 1 expr_name = "expr_#{cl_cname}_#{ex_cname}" Component::ExprWrapper.make_subclass expr_name do @inspect_str = "#{cl.name}: #{expr.formula}" ssn = cl.shadow_struct.name cont_state_ssn = cl.cont_state_class.shadow_struct.name # We need the struct shadow_library_source_file.include(cl.shadow_library_include_file) shadow_library_source_file.define(expr_name).instance_eval do arguments "ComponentShadow *comp_shdw" return_type expr.type declare :shadow => %{ struct #{ssn} *shadow; struct #{cont_state_ssn} *cont_state; ContVar *var; } setup :shadow => %{ shadow = (#{ssn} *)comp_shdw; cont_state = (#{cont_state_ssn} *)shadow->cont_state; } declare :result => "#{expr.type} result" translation = expr.translate(self, "result", 0, cl) body %{ #{translation.join(" ")}; return result; } end define_c_method :calc_function_pointer do body "shadow->expr = &#{expr_name}" end end end |