tealrb 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tealrb/contract.rb +6 -1
- data/lib/tealrb/opcode_modules.rb +11 -13
- data/lib/tealrb/rewriters.rb +27 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ebe163f8903cf66046698ddfebe36e615359bd568e76be4eb30f368011b1ce0
|
4
|
+
data.tar.gz: 64db7183fe7b170d7b80881cd66272e5016e6a50cb6886a5300df729520d539d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94f4791ca50e11afb7937670b976a87f75aaeaa4b364e5eea104541c571fce4f2b41e73c05c7d743772fb37657cf9dc3690e869d49007b3bd77ea4c5168ff1e5
|
7
|
+
data.tar.gz: f77f3513679a82d255a8a1e10cc51c8e593b66d0faae844df461a36d50b211a62b5cd9761a93c1f34591b375439766eba38238f4670a7205cc00eb72bd553c57
|
data/lib/tealrb/contract.rb
CHANGED
@@ -86,6 +86,11 @@ module TEALrb
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
# return the input without transpiling to TEAL
|
90
|
+
def rb(input)
|
91
|
+
input
|
92
|
+
end
|
93
|
+
|
89
94
|
# defines a method that is transpiled to TEAL
|
90
95
|
# @param name [Symbol] name of the method
|
91
96
|
# @param definition [Lambda, Proc, UnboundMethod] the method definition
|
@@ -206,7 +211,7 @@ module TEALrb
|
|
206
211
|
puts ''
|
207
212
|
end
|
208
213
|
|
209
|
-
[CommentRewriter, ComparisonRewriter, IfRewriter, OpRewriter, AssignRewriter].each do |rw|
|
214
|
+
[CommentRewriter, ComparisonRewriter, WhileRewriter, IfRewriter, OpRewriter, AssignRewriter].each do |rw|
|
210
215
|
string = rewrite_with_rewriter(string, rw)
|
211
216
|
end
|
212
217
|
|
@@ -667,10 +667,8 @@ module TEALrb
|
|
667
667
|
class TxnaField
|
668
668
|
include Opcodes
|
669
669
|
|
670
|
-
def initialize(field
|
670
|
+
def initialize(field)
|
671
671
|
@field = field
|
672
|
-
@teal = TEALrb::TEAL.current[Thread.current]
|
673
|
-
txna(field, index) if index
|
674
672
|
end
|
675
673
|
|
676
674
|
def [](index)
|
@@ -680,24 +678,24 @@ module TEALrb
|
|
680
678
|
end
|
681
679
|
|
682
680
|
module Txna
|
683
|
-
def self.application_args
|
684
|
-
TxnaField.new('ApplicationArgs'
|
681
|
+
def self.application_args
|
682
|
+
TxnaField.new('ApplicationArgs')
|
685
683
|
end
|
686
684
|
|
687
|
-
def self.accounts
|
688
|
-
TxnaField.new('Accounts'
|
685
|
+
def self.accounts
|
686
|
+
TxnaField.new('Accounts')
|
689
687
|
end
|
690
688
|
|
691
|
-
def self.assets
|
692
|
-
TxnaField.new('Assets'
|
689
|
+
def self.assets
|
690
|
+
TxnaField.new('Assets')
|
693
691
|
end
|
694
692
|
|
695
|
-
def self.applications
|
696
|
-
TxnaField.new('Applications'
|
693
|
+
def self.applications
|
694
|
+
TxnaField.new('Applications')
|
697
695
|
end
|
698
696
|
|
699
|
-
def self.logs
|
700
|
-
TxnaField.new('Logs'
|
697
|
+
def self.logs
|
698
|
+
TxnaField.new('Logs')
|
701
699
|
end
|
702
700
|
end
|
703
701
|
|
data/lib/tealrb/rewriters.rb
CHANGED
@@ -130,8 +130,8 @@ module TEALrb
|
|
130
130
|
params = TEALrb::Opcodes.instance_method(meth_name).parameters
|
131
131
|
@skips = params.count { |param| param[0] == :req }
|
132
132
|
end
|
133
|
-
elsif %i[comment placeholder].include? meth_name
|
134
|
-
@skips =
|
133
|
+
elsif %i[comment placeholder rb].include? meth_name
|
134
|
+
@skips = node.children.last.children.size
|
135
135
|
end
|
136
136
|
super
|
137
137
|
end
|
@@ -168,5 +168,30 @@ module TEALrb
|
|
168
168
|
super
|
169
169
|
end
|
170
170
|
end
|
171
|
+
|
172
|
+
class WhileRewriter < Rewriter
|
173
|
+
class << self
|
174
|
+
attr_accessor :while_count
|
175
|
+
end
|
176
|
+
|
177
|
+
def initialize(*args)
|
178
|
+
self.class.while_count = {}
|
179
|
+
self.class.while_count[Thread.current] ||= 0
|
180
|
+
super
|
181
|
+
end
|
182
|
+
|
183
|
+
def while_count
|
184
|
+
self.class.while_count[Thread.current]
|
185
|
+
end
|
186
|
+
|
187
|
+
def on_while(node)
|
188
|
+
cond_node = node.children.first
|
189
|
+
replace(node.loc.keyword, ":while#{while_count}\n#{cond_node.source}\nbz :end_while#{while_count}")
|
190
|
+
replace(node.loc.begin, '') if node.loc.begin
|
191
|
+
replace(node.loc.end, "b :while#{while_count}\n:end_while#{while_count}")
|
192
|
+
replace(cond_node.loc.expression, '')
|
193
|
+
super
|
194
|
+
end
|
195
|
+
end
|
171
196
|
end
|
172
197
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tealrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Polny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|