dtr_core 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6eb9933172ea48536b0efceffe9e9e222a54e37f214b8041dc5edd40c01f2d6
4
- data.tar.gz: 731d58a093c47bfd2b63f4ea884d4422d703b2c2ba47baacbda105bfb02e2264
3
+ metadata.gz: ad7236ff8c846c7126d0d8e53f3d7cd5d6635eeefbca857dafdf22e85473cbe6
4
+ data.tar.gz: d8741a66894615c02d59be5ba8884f165acdcfdb045c2243c07c57c3116cb699
5
5
  SHA512:
6
- metadata.gz: '04824f70c5646161afb24637f614f1ba2431414cc5f98b8847b15f74299ba563957586ba40a88d36847d1cfce649462199a42508a0d276397dbe3f38d1ee7e59'
7
- data.tar.gz: 106a92f8de4ca9385d44f510dbb942b05d073bd2584d7dabbfe7d3003d348a121c21765da246e2c450a25df92cfb5151d1b541cf5b28029d96acd6ff1875c423
6
+ metadata.gz: 83a20837017ec8a60ae948918f6b1947332516248bac6f805bdfc12b7b2a5636d5f01157739c81167113a873218da6cf55b22c297e1903718c9913b29322f2f7
7
+ data.tar.gz: 42b2bd3b5ef207d88fe3a955a9358ea54270979115df12e10d2318d6d230c80e8d858979d9d91df91bd2158153dd93f0d2e8efd15e0e27c4f261dee6432d660d
@@ -55,31 +55,31 @@ module DTRCore
55
55
  end
56
56
 
57
57
  def state_to_s
58
- return '' if @state.nil?
58
+ return '' if @state.nil? || @state.empty?
59
59
 
60
60
  "[State]:\n#{@state&.map(&:to_s)&.join("\n")}\n:[State]\n"
61
61
  end
62
62
 
63
63
  def interface_to_s
64
- return '' if @state.nil?
64
+ return '' if @interface.nil? || @interface.empty?
65
65
 
66
66
  "[Interface]:\n#{@interface&.map(&:to_s)&.join("\n")}\n:[Interface]\n"
67
67
  end
68
68
 
69
69
  def user_defined_types_to_s
70
- return '' if @user_defined_types.nil?
70
+ return '' if @user_defined_types.nil? || @user_defined_types.empty?
71
71
 
72
72
  "[User Defined Types]:\n#{@user_defined_types&.map(&:to_s)&.join("\n")}\n:[User Defined Types]\n"
73
73
  end
74
74
 
75
75
  def helpers_to_s
76
- return '' if @helpers.nil?
76
+ return '' if @helpers.nil? || @helpers.empty?
77
77
 
78
78
  "[Helpers]:\n#{@helpers&.map(&:to_s)&.join("\n")}\n:[Helpers]\n"
79
79
  end
80
80
 
81
81
  def non_translatables_to_s
82
- return '' if @non_translatables.nil?
82
+ return '' if @non_translatables.nil? || @non_translatables.empty?
83
83
 
84
84
  "[NonTranslatable]:\n#{@non_translatables}\n:[NonTranslatable]"
85
85
  end
@@ -98,7 +98,8 @@ module DTRCore
98
98
  instruction[/instruction:\s*(?<all>[^\s,]+)/, 1],
99
99
  parse_function_instruction_input(instruction),
100
100
  instruction[/\s*assign:\s*\[?(?<all>[^\s\,\]]+)\]?/, 1],
101
- instruction[/\s*scope:\s*(?<all>[^\s\,]+)/, 1].to_i || 0
101
+ instruction[/\s*scope:\s*(?<all>[^\s\,]+)/, 1].to_i || 0,
102
+ instruction[/\sid:\s*(?<all>[^\s,]+)/, 1].to_i || 0
102
103
  )
103
104
 
104
105
  raise "Invalid instruction: #{instruction}" unless instruction.valid?
@@ -3,26 +3,29 @@
3
3
  module DTRCore
4
4
  # Instruction class
5
5
  class Instruction
6
- attr_reader :instruction, :inputs, :assign, :scope
6
+ attr_reader :instruction, :inputs, :assign, :scope, :id
7
7
 
8
- def initialize(instruction, inputs, assign, scope)
8
+ def initialize(instruction, inputs, assign, scope, id)
9
9
  @instruction = instruction
10
10
  @inputs = inputs
11
11
  @assign = assign
12
12
  @scope = scope
13
+ @id = id
13
14
  end
14
15
 
15
16
  def ==(other)
16
17
  instruction == other.instruction &&
17
18
  inputs == other.inputs &&
18
19
  assign == other.assign &&
19
- scope == other.scope
20
+ scope == other.scope &&
21
+ id == other.id
20
22
  end
21
23
 
22
24
  def to_s
23
- "{ instruction: #{instruction}, " \
25
+ assignment = @assign.nil? ? '' : "assign: #{@assign}, "
26
+ "{ id: #{id}, instruction: #{instruction}, " \
24
27
  "input: (#{inputs&.join(', ')}), " \
25
- "assign: #{assign}, scope: #{scope} }"
28
+ "#{assignment}scope: #{scope} }"
26
29
  end
27
30
 
28
31
  def to_json(*_args)
@@ -30,7 +33,8 @@ module DTRCore
30
33
  instruction:,
31
34
  inputs:,
32
35
  assign:,
33
- scope:
36
+ scope:,
37
+ id:
34
38
  }.to_json
35
39
  end
36
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtr_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Durst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-07 00:00:00.000000000 Z
11
+ date: 2024-07-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Core smart contract intermediate language (Digicus Textual Representation)
14
14
  parser.