From cdb5492bfe4ffd15ea34b7ba528e7abcfe7ff591 Mon Sep 17 00:00:00 2001 From: xaseiresh Date: Mon, 24 Apr 2023 09:20:31 +0200 Subject: [PATCH] wip: more comfpile work --- bin/console | 7 ---- lib/comfpile/context.rb | 79 ++++++++++++++++++++++++++++------------- lib/comfpile/core.rb | 2 ++ 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/bin/console b/bin/console index db8daa8..f444b3d 100755 --- a/bin/console +++ b/bin/console @@ -145,13 +145,6 @@ $core.add_artefact_engine do |engine| end end -t_start = Time.now() -dep_art = $core.craft_and_complete(:gtkwave_output, "spi_master_tb.vhd") -t_end = Time.now() - -puts "Full dependency list is: #{dep_art.dependencies.map(&:target)} (took #{t_end - t_start})" -puts "Includes of all source files:" - # (If you use this, don't forget to add pry to your Gemfile!) require "pry" Pry.start diff --git a/lib/comfpile/context.rb b/lib/comfpile/context.rb index 6d1d957..4562ece 100644 --- a/lib/comfpile/context.rb +++ b/lib/comfpile/context.rb @@ -2,37 +2,68 @@ module Comfpile class ContextTag - def initialize(tag) - @@known_tags ||= {} + attr_reader :tag, :taglist + + def self.form_context(tag) + @known_tags ||= {} case tag - when Symbol, String - precompiled = @@known_tags[tag.to_sym] + when Symbol + tag_instance = @known_tags[tag] - if not precompiled.nil? - @tag = precompiled[:tag] - @tag_array = precompiled[:array] - else - @tag_array = tag.to_s.split('_').uniq.sort - - end - when Array - @tag_array = tag.map(&:to_s).uniq.sort - @tag = @tag_array + return tag_instance unless tag_instance.nil? + + tag_instance = ContextTag.new(tag) + tag_instance = (@known_tags[tag_instance] ||= tag_instance) + + @known_tags[tag] ||= tag_instance + @known_tags[tag_instance.tag] ||= tag_instance end - - @tag ||= @tag_array.join('_').to_sym - - tag_data = { - tag: @tag, - array: @ŧag_array - } - - @@known_tags[@tag] ||= tag_data - @@known_tags[tag] ||= tag_data end + def initialize(tag) + process_tag(tag) + end + private def process_tag(tag) + case tag + when Symbol, String + @taglist = tag.to_s.split('_').uniq.sort + when Array + @taglist = tag.map(&:to_s).uniq.sort + end + + @tag = @taglist.join('_').to_sym + @taghash = {} + @taglist.each do |tag| + @taghash[tag] = true + end + end + + def include?(*tags) + tags = tags - @tag_array + + tags.empy? + end + alias include_all? include? + + def include_any?(*tags) + tags = tags & @tag_array + + tags.empty? + end + + def hash + @tag.hash + end + + def eql?(other) + if(other.is_a? Symbol) + @tag.eql? other + elsif(other.is_a? ContextTag) + @tag.eql? other.tag + end + end end # diff --git a/lib/comfpile/core.rb b/lib/comfpile/core.rb index 883bccd..3a9bb05 100644 --- a/lib/comfpile/core.rb +++ b/lib/comfpile/core.rb @@ -1,6 +1,8 @@ require_relative 'artefact_engine.rb' +require_relative 'context.rb' + module Comfpile class Core attr_reader :processing_stack