mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Super hacky way to resolve type of given variables
This commit is contained in:
parent
7c8be54e5c
commit
45261c419f
1 changed files with 21 additions and 6 deletions
|
@ -42,7 +42,10 @@ module Spectator
|
||||||
include Locals
|
include Locals
|
||||||
|
|
||||||
{% unless given_vars.empty? %}
|
{% unless given_vars.empty? %}
|
||||||
def initialize({{ var_names.map { |v| "@#{v}" }.join(", ").id }})
|
def initialize({{ var_names.join(", ").id }})
|
||||||
|
{% for var_name in var_names %}
|
||||||
|
self.{{var_name}} = {{var_name}}
|
||||||
|
{% end %}
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
|
@ -50,10 +53,6 @@ module Spectator
|
||||||
Source.new({{source_file}}, {{source_line}})
|
Source.new({{source_file}}, {{source_line}})
|
||||||
end
|
end
|
||||||
|
|
||||||
def num
|
|
||||||
0
|
|
||||||
end
|
|
||||||
|
|
||||||
def run
|
def run
|
||||||
{{block.body}}
|
{{block.body}}
|
||||||
end
|
end
|
||||||
|
@ -113,7 +112,23 @@ module Spectator
|
||||||
{% var_name = block.args.empty? ? "value" : block.args.first %}
|
{% var_name = block.args.empty? ? "value" : block.args.first %}
|
||||||
|
|
||||||
module Locals
|
module Locals
|
||||||
getter {{var_name.id}}
|
@%wrapper : ValueWrapper?
|
||||||
|
|
||||||
|
private def %collection
|
||||||
|
{{collection}}
|
||||||
|
end
|
||||||
|
|
||||||
|
private def %collection_first
|
||||||
|
%collection.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def {{var_name.id}}
|
||||||
|
@%wrapper.as(TypedValueWrapper(typeof(%collection_first))).value
|
||||||
|
end
|
||||||
|
|
||||||
|
private def {{var_name.id}}=(value)
|
||||||
|
@%wrapper = TypedValueWrapper(typeof(%collection_first)).new(value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
{% GIVEN_VARIABLES << {var_name, collection} %}
|
{% GIVEN_VARIABLES << {var_name, collection} %}
|
||||||
|
|
Loading…
Reference in a new issue