Class: HDLRuby::High::TypeGen
- Defined in:
- lib/HDLRuby/hruby_high.rb
Overview
Describes a high-level generic type definition.
NOTE: this type does not correspond to any low-level type
Constant Summary collapse
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary
Attributes inherited from Low::Type
Attributes included from Low::Hparent
Instance Method Summary collapse
-
#generate(*args) ⇒ Object
Generates the type with +args+ generic parameters.
-
#initialize(name, &ruby_block) ⇒ TypeGen
constructor
Creates a new generic type definition producing a new type by executing +ruby_block+.
-
#to_low(name = self.name) ⇒ Object
Converts the type to HDLRuby::Low and set its +name+.
Methods included from Htype
#[], #binary, #comp_operator, #constant, #define_operator, #each_overload, #htype?, included, #inner, #inout, #input, #left, #name=, #output, #register, #right, #to_type, #typedef, #unary
Methods included from Tprocess
#&, #*, #+, #+@, #-@, #/, #<<, #==, #abs, #lr, #make, #resolve, #slice, #~
Methods inherited from Low::Type
#base, #base?, #boolean?, #break_types!, #direction, #each_type_deep, #eql?, #equivalent?, #fixed?, #float?, #hash, #leaf?, #range, #range?, #regular?, #set_name!, #signed?, #struct?, #to_c, #to_high, #to_vector, #to_verilog, #to_vhdl, #types?, #unsigned?, #width
Methods included from Low::Low2Symbol
Methods included from Low::Hparent
Methods included from Low::Ltype
Constructor Details
#initialize(name, &ruby_block) ⇒ TypeGen
Creates a new generic type definition producing a new type by executing +ruby_block+.
1649 1650 1651 1652 1653 1654 1655 |
# File 'lib/HDLRuby/hruby_high.rb', line 1649 def initialize(name,&ruby_block) # Initialize the type structure. super(name) # Sets the block to execute when instantiating the type. @instance_proc = ruby_block end |
Instance Method Details
#generate(*args) ⇒ Object
Generates the type with +args+ generic parameters.
1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 |
# File 'lib/HDLRuby/hruby_high.rb', line 1658 def generate(*args) # Generate the resulting type. gtype = High.top_user.instance_exec(*args,&@instance_proc) # Ensures a type has been produced. gtype = gtype.to_type if gtype.respond_to?(:to_type) unless gtype.is_a?(HDLRuby::Low::Type) then raise AnyError, "Generic type #{self.name} did not produce a valid type: #{gtype.class}" end # Create a new type definition from it. gtype = TypeDef.new(self.name.to_s + "_#{args.join(":")}", gtype) # Adds the possible overloaded operators. self.each_overload do |op,ruby_block| gtype.define_operator(op,&(ruby_block.curry[*args])) end # Returns the resulting type return gtype end |