BOAST 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BOAST.gemspec +1 -1
- data/lib/BOAST.rb +5 -1
- data/lib/BOAST/Language/Algorithm.rb +104 -22
- data/lib/BOAST/Language/Annotation.rb +55 -0
- data/lib/BOAST/Language/Arithmetic.rb +44 -10
- data/lib/BOAST/Language/Case.rb +89 -52
- data/lib/BOAST/Language/CodeBlock.rb +17 -0
- data/lib/BOAST/Language/Comment.rb +38 -0
- data/lib/BOAST/Language/ControlStructure.rb +7 -0
- data/lib/BOAST/Language/Error.rb +7 -0
- data/lib/BOAST/Language/Expression.rb +4 -5
- data/lib/BOAST/Language/For.rb +59 -27
- data/lib/BOAST/Language/If.rb +12 -17
- data/lib/BOAST/Language/Index.rb +5 -5
- data/lib/BOAST/Language/Intrinsics.rb +38 -32
- data/lib/BOAST/Language/OpenMP.rb +1 -1
- data/lib/BOAST/Language/Operators.rb +208 -53
- data/lib/BOAST/Language/Pragma.rb +3 -3
- data/lib/BOAST/Language/Print.rb +3 -3
- data/lib/BOAST/Language/Procedure.rb +15 -8
- data/lib/BOAST/Language/Variable.rb +45 -87
- data/lib/BOAST/Language/While.rb +3 -0
- data/lib/BOAST/Optimization/Optimization.rb +241 -0
- metadata +7 -4
- data/lib/BOAST/Language/Optimization.rb +0 -74
- data/lib/BOAST/Language/Vector.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59589a610dd30134353d9aa38e9ea1de00b43a9a
|
4
|
+
data.tar.gz: 4eec51beee55795b76432c1c4b12502113a7fe3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a190b47611875b112f027e5b3e4bf292d331f4029ee47d581493fd6d3d4c88d807f98b91887f7602a9e922a2744f48d5965de4f5ce7103597b52886a5eea6f02
|
7
|
+
data.tar.gz: 24c85287f04dae5ce701e11099ef562fb97e81f89fc7ca15105593dee7746a141d1124ab7e1d593193e63f5aeb56bb598a2c986f6c470a91b4fe6b8cfd4c5527
|
data/BOAST.gemspec
CHANGED
data/lib/BOAST.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'BOAST/Language/Error.rb'
|
1
2
|
require 'BOAST/Language/State.rb'
|
2
3
|
require 'BOAST/Language/Functors.rb'
|
3
4
|
require 'BOAST/Language/Inspectable.rb'
|
5
|
+
require 'BOAST/Language/Comment.rb'
|
6
|
+
require 'BOAST/Language/Annotation.rb'
|
4
7
|
require 'BOAST/Language/Transitions.rb'
|
5
8
|
require 'BOAST/Language/Arithmetic.rb'
|
6
9
|
require 'BOAST/Language/Architectures.rb'
|
@@ -15,6 +18,7 @@ require 'BOAST/Language/Slice.rb'
|
|
15
18
|
require 'BOAST/Language/FuncCall.rb'
|
16
19
|
require 'BOAST/Language/Procedure.rb'
|
17
20
|
require 'BOAST/Language/Algorithm.rb'
|
21
|
+
require 'BOAST/Language/CodeBlock.rb'
|
18
22
|
require 'BOAST/Language/ControlStructure.rb'
|
19
23
|
require 'BOAST/Language/OpenMP.rb'
|
20
24
|
require 'BOAST/Language/If.rb'
|
@@ -37,5 +41,5 @@ require 'BOAST/Runtime/CKernel.rb'
|
|
37
41
|
require 'BOAST/Runtime/NonRegression.rb'
|
38
42
|
require 'BOAST/Language/Parens.rb'
|
39
43
|
require 'BOAST/Language/BOAST_OpenCL.rb'
|
40
|
-
require 'BOAST/
|
44
|
+
require 'BOAST/Optimization/Optimization.rb'
|
41
45
|
require 'BOAST/Language/Print.rb'
|
@@ -17,6 +17,10 @@ module BOAST
|
|
17
17
|
private_state_accessor :default_align
|
18
18
|
private_state_accessor :array_start
|
19
19
|
private_state_accessor :indent_level, :indent_increment
|
20
|
+
private_state_accessor :annotate_list
|
21
|
+
private_state_accessor :annotate_indepth_list
|
22
|
+
private_state_accessor :annotate_level
|
23
|
+
private_state_accessor :optimizer_log_file
|
20
24
|
|
21
25
|
private_boolean_state_accessor :replace_constants
|
22
26
|
private_boolean_state_accessor :default_int_signed
|
@@ -24,6 +28,8 @@ module BOAST
|
|
24
28
|
private_boolean_state_accessor :debug
|
25
29
|
private_boolean_state_accessor :use_vla
|
26
30
|
private_boolean_state_accessor :decl_module
|
31
|
+
private_boolean_state_accessor :annotate
|
32
|
+
private_boolean_state_accessor :optimizer_log
|
27
33
|
|
28
34
|
private
|
29
35
|
def push_env(*args)
|
@@ -46,6 +52,18 @@ module BOAST
|
|
46
52
|
BOAST::indent
|
47
53
|
end
|
48
54
|
|
55
|
+
def get_architecture_name
|
56
|
+
BOAST::get_architecture_name
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_lang_name
|
60
|
+
BOAST::get_lang_name
|
61
|
+
end
|
62
|
+
|
63
|
+
def annotate_number(*args)
|
64
|
+
BOAST::annotate_number(*args)
|
65
|
+
end
|
66
|
+
|
49
67
|
end
|
50
68
|
|
51
69
|
state_accessor :output, :lang, :architecture, :model, :address_size
|
@@ -53,6 +71,10 @@ module BOAST
|
|
53
71
|
state_accessor :default_align
|
54
72
|
state_accessor :array_start
|
55
73
|
state_accessor :indent_level, :indent_increment
|
74
|
+
state_accessor :annotate_list
|
75
|
+
state_accessor :annotate_indepth_list
|
76
|
+
state_accessor :annotate_level
|
77
|
+
state_accessor :optimizer_log_file
|
56
78
|
|
57
79
|
boolean_state_accessor :replace_constants
|
58
80
|
boolean_state_accessor :default_int_signed
|
@@ -60,20 +82,28 @@ module BOAST
|
|
60
82
|
boolean_state_accessor :debug
|
61
83
|
boolean_state_accessor :use_vla
|
62
84
|
boolean_state_accessor :decl_module
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
default_state_getter :
|
67
|
-
default_state_getter :
|
68
|
-
default_state_getter :
|
69
|
-
default_state_getter :
|
70
|
-
default_state_getter :
|
71
|
-
default_state_getter :
|
72
|
-
default_state_getter :
|
73
|
-
default_state_getter :
|
74
|
-
default_state_getter :
|
75
|
-
default_state_getter :
|
76
|
-
default_state_getter :
|
85
|
+
boolean_state_accessor :annotate
|
86
|
+
boolean_state_accessor :optimizer_log
|
87
|
+
|
88
|
+
default_state_getter :address_size, OS.bits/8
|
89
|
+
default_state_getter :lang, FORTRAN, '"const_get(#{envs})"', :BOAST_LANG
|
90
|
+
default_state_getter :model, "native"
|
91
|
+
default_state_getter :debug, false
|
92
|
+
default_state_getter :use_vla, false
|
93
|
+
default_state_getter :replace_constants, true
|
94
|
+
default_state_getter :default_int_signed, true
|
95
|
+
default_state_getter :default_int_size, 4
|
96
|
+
default_state_getter :default_real_size, 8
|
97
|
+
default_state_getter :default_align, 1
|
98
|
+
default_state_getter :indent_level, 0
|
99
|
+
default_state_getter :indent_increment, 2
|
100
|
+
default_state_getter :array_start, 1
|
101
|
+
default_state_getter :annotate, false
|
102
|
+
default_state_getter :annotate_list, ["For"], '"#{envs}.split(\",\").collect { |arg| YAML::load(arg) }"'
|
103
|
+
default_state_getter :annotate_indepth_list, ["For"], '"#{envs}.split(\",\").collect { |arg| YAML::load(arg) }"'
|
104
|
+
default_state_getter :annotate_level, 0
|
105
|
+
default_state_getter :optimizer_log, false
|
106
|
+
default_state_getter :optimizer_log_file, nil
|
77
107
|
|
78
108
|
alias use_vla_old? use_vla?
|
79
109
|
class << self
|
@@ -97,10 +127,39 @@ module BOAST
|
|
97
127
|
return X86
|
98
128
|
end
|
99
129
|
|
130
|
+
def get_architecture_name
|
131
|
+
case architecture
|
132
|
+
when X86
|
133
|
+
return :X86
|
134
|
+
when ARM
|
135
|
+
return :ARM
|
136
|
+
when MPPA
|
137
|
+
return :MPPA
|
138
|
+
else
|
139
|
+
return nil
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def get_lang_name
|
144
|
+
case lang
|
145
|
+
when C
|
146
|
+
return :C
|
147
|
+
when FORTRAN
|
148
|
+
return :FORTRAN
|
149
|
+
when CL
|
150
|
+
return :CL
|
151
|
+
when CUDA
|
152
|
+
return :CUDA
|
153
|
+
else
|
154
|
+
nil
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
100
158
|
@@output = STDOUT
|
101
159
|
@@chain_code = false
|
102
160
|
@@architecture = get_default_architecture
|
103
161
|
@@decl_module = false
|
162
|
+
@@annotate_numbers = Hash::new { |h,k| h[k] = 0 }
|
104
163
|
|
105
164
|
@@env = Hash::new{|h, k| h[k] = []}
|
106
165
|
|
@@ -108,12 +167,12 @@ module BOAST
|
|
108
167
|
vars.each { |key,value|
|
109
168
|
var = nil
|
110
169
|
begin
|
111
|
-
var = class_variable_get("@@"+key.to_s)
|
170
|
+
var = BOAST::class_variable_get("@@"+key.to_s)
|
112
171
|
rescue
|
113
172
|
raise "Unknown module variable #{key}!"
|
114
173
|
end
|
115
174
|
@@env[key].push(var)
|
116
|
-
class_variable_set("@@"+key.to_s, value)
|
175
|
+
BOAST::class_variable_set("@@"+key.to_s, value)
|
117
176
|
}
|
118
177
|
end
|
119
178
|
|
@@ -122,7 +181,7 @@ module BOAST
|
|
122
181
|
raise "Unknown module variable #{key}!" unless @@env.has_key?(key)
|
123
182
|
ret = @@env[key].pop
|
124
183
|
raise "No stored value for #{key}!" if ret.nil?
|
125
|
-
class_variable_set("@@"+key.to_s, ret)
|
184
|
+
BOAST::class_variable_set("@@"+key.to_s, ret)
|
126
185
|
}
|
127
186
|
end
|
128
187
|
|
@@ -134,12 +193,31 @@ module BOAST
|
|
134
193
|
set_indent_level( get_indent_level - increment )
|
135
194
|
end
|
136
195
|
|
196
|
+
def annotate_number(name)
|
197
|
+
num = @@annotate_numbers[name]
|
198
|
+
@@annotate_numbers[name] = num + 1
|
199
|
+
return num
|
200
|
+
end
|
201
|
+
|
137
202
|
def indent
|
138
203
|
return " "*get_indent_level
|
139
204
|
end
|
140
205
|
|
141
|
-
def
|
142
|
-
a.
|
206
|
+
def pr_annotate(a)
|
207
|
+
name = a.class.name.gsub("BOAST::","")
|
208
|
+
if annotate_list.include?(name) then
|
209
|
+
description = nil
|
210
|
+
if a.is_a?(Annotation) and a.annotate_indepth?(0) then
|
211
|
+
description = a.annotation(0)
|
212
|
+
end
|
213
|
+
annotation = { "#{name}#{annotate_number(name)}" => description }
|
214
|
+
Comment(YAML::dump(annotation)).pr
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def pr(a, *args)
|
219
|
+
pr_annotate(a) if annotate?
|
220
|
+
a.pr(*args)
|
143
221
|
end
|
144
222
|
|
145
223
|
def decl(*a)
|
@@ -185,16 +263,20 @@ ConvolutionGenerator = BOAST
|
|
185
263
|
class Integer
|
186
264
|
def to_var
|
187
265
|
if self < 0 then
|
188
|
-
|
266
|
+
v = BOAST::Variable::new("#{self}", BOAST::Int, :signed => true, :constant => self )
|
189
267
|
else
|
190
|
-
|
268
|
+
v = BOAST::Variable::new("#{self}", BOAST::Int, :signed => false, :constant => self )
|
191
269
|
end
|
270
|
+
v.force_replace_constant = true
|
271
|
+
return v
|
192
272
|
end
|
193
273
|
end
|
194
274
|
|
195
275
|
class Float
|
196
276
|
def to_var
|
197
|
-
|
277
|
+
v = BOAST::Variable::new("#{self}", BOAST::Real, :constant => self )
|
278
|
+
v.force_replace_constant = true
|
279
|
+
return v
|
198
280
|
end
|
199
281
|
end
|
200
282
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module BOAST
|
2
|
+
|
3
|
+
module Annotation
|
4
|
+
include PrivateStateAccessor
|
5
|
+
|
6
|
+
def annotate_indepth?(level)
|
7
|
+
return false if level > annotate_level
|
8
|
+
return false unless annotate_indepth_list.include?(self.class.name.gsub("BOAST::", ""))
|
9
|
+
return true
|
10
|
+
end
|
11
|
+
|
12
|
+
def annotation_identifier
|
13
|
+
name = self.class.name.gsub("BOAST::", "")
|
14
|
+
return "#{name}#{annotate_number(name)}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def annotate_scalar(s, level)
|
18
|
+
if s.is_a?(Annotation) and s.annotate_indepth?(level + 1) then
|
19
|
+
return { s.annotation_identifier => s.annotation(level + 1) }
|
20
|
+
elsif s.is_a?(Numeric)
|
21
|
+
return s
|
22
|
+
else
|
23
|
+
str = s.to_s
|
24
|
+
str = nil if str == ''
|
25
|
+
return str
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def annotate_array(a, level)
|
30
|
+
return a.collect { |e|
|
31
|
+
annotate_var(e, level)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def annotate_var(v, level)
|
36
|
+
if v.is_a?(Array) then
|
37
|
+
return annotate_array(v, level)
|
38
|
+
else
|
39
|
+
return annotate_scalar(v, level)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def annotation(level)
|
44
|
+
anns = {}
|
45
|
+
self.class.const_get(:ANNOTATIONS).each { |a|
|
46
|
+
var_sym = ("@" + a.to_s).to_sym
|
47
|
+
var = self.instance_variable_get(var_sym)
|
48
|
+
anns[a] = annotate_var(var, level)
|
49
|
+
}
|
50
|
+
return anns
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -1,6 +1,25 @@
|
|
1
1
|
module BOAST
|
2
|
+
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def Return(value)
|
6
|
+
return Expression::new("return",nil, value)
|
7
|
+
end
|
8
|
+
|
9
|
+
def And(a, b)
|
10
|
+
return Expression::new(And, a, b)
|
11
|
+
end
|
12
|
+
|
13
|
+
def Or(a, b)
|
14
|
+
return Expression::new(Or, a, b)
|
15
|
+
end
|
16
|
+
|
2
17
|
module Arithmetic
|
3
18
|
|
19
|
+
def **(x)
|
20
|
+
return Expression::new(Exponentiation,self,x)
|
21
|
+
end
|
22
|
+
|
4
23
|
def ===(x)
|
5
24
|
return Expression::new(Affectation,self,x)
|
6
25
|
end
|
@@ -10,7 +29,7 @@ module BOAST
|
|
10
29
|
end
|
11
30
|
|
12
31
|
def ==(x)
|
13
|
-
return Expression::new(
|
32
|
+
return Expression::new(Equal,self,x)
|
14
33
|
end
|
15
34
|
|
16
35
|
def !=(x)
|
@@ -18,19 +37,19 @@ module BOAST
|
|
18
37
|
end
|
19
38
|
|
20
39
|
def >(x)
|
21
|
-
return Expression::new(
|
40
|
+
return Expression::new(Greater,self,x)
|
22
41
|
end
|
23
42
|
|
24
43
|
def <(x)
|
25
|
-
return Expression::new(
|
44
|
+
return Expression::new(Less,self,x)
|
26
45
|
end
|
27
46
|
|
28
47
|
def >=(x)
|
29
|
-
return Expression::new(
|
48
|
+
return Expression::new(GreaterOrEqual,self,x)
|
30
49
|
end
|
31
50
|
|
32
51
|
def <=(x)
|
33
|
-
return Expression::new(
|
52
|
+
return Expression::new(LessOrEqual,self,x)
|
34
53
|
end
|
35
54
|
|
36
55
|
def +(x)
|
@@ -53,20 +72,35 @@ module BOAST
|
|
53
72
|
return Expression::new(Minus,nil,self)
|
54
73
|
end
|
55
74
|
|
56
|
-
def
|
57
|
-
return Expression::new(
|
75
|
+
def +@
|
76
|
+
return Expression::new(Plus,nil,self)
|
77
|
+
end
|
78
|
+
|
79
|
+
def reference
|
80
|
+
return Expression::new(Reference,nil,self)
|
58
81
|
end
|
82
|
+
|
83
|
+
alias address reference
|
59
84
|
|
60
85
|
def dereference
|
61
|
-
return
|
86
|
+
return Index::new(self, *(self.dimension.collect(&:start))) if lang == FORTRAN
|
87
|
+
return Expression::new(Dereference,nil,self)
|
62
88
|
end
|
63
89
|
|
64
90
|
def and(x)
|
65
|
-
return Expression::new(
|
91
|
+
return Expression::new(And, self, x)
|
66
92
|
end
|
67
93
|
|
94
|
+
alias & and
|
95
|
+
|
68
96
|
def or(x)
|
69
|
-
return Expression::new(
|
97
|
+
return Expression::new(Or, self, x)
|
98
|
+
end
|
99
|
+
|
100
|
+
alias | or
|
101
|
+
|
102
|
+
def cast(type)
|
103
|
+
return type.copy("(#{type.type.decl} *)#{self}")
|
70
104
|
end
|
71
105
|
|
72
106
|
def components( range )
|
data/lib/BOAST/Language/Case.rb
CHANGED
@@ -1,43 +1,97 @@
|
|
1
1
|
module BOAST
|
2
2
|
|
3
|
+
class CaseCondition < ControlStructure
|
4
|
+
attr_reader :block
|
5
|
+
attr_reader :constants
|
6
|
+
|
7
|
+
def initialize(constants = nil, &block)
|
8
|
+
@constants = constants
|
9
|
+
@block = block
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_c_strings
|
13
|
+
return { :case => '"case #{constants.join(" : case ")} :"',
|
14
|
+
:default => '"default :"',
|
15
|
+
:break => '"break;"' }
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_fortran_strings
|
19
|
+
return { :case => '"case (#{constants.join(", ")})"',
|
20
|
+
:default => '"case default"',
|
21
|
+
:break => 'nil' }
|
22
|
+
end
|
23
|
+
|
24
|
+
alias get_cl_strings get_c_strings
|
25
|
+
alias get_cuda_strings get_c_strings
|
26
|
+
|
27
|
+
eval token_string_generator( * %w{case constants})
|
28
|
+
eval token_string_generator( * %w{default})
|
29
|
+
eval token_string_generator( * %w{break})
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
s = ""
|
33
|
+
if @constants then
|
34
|
+
s += case_string(@constants)
|
35
|
+
else
|
36
|
+
s += default_string
|
37
|
+
end
|
38
|
+
return s
|
39
|
+
end
|
40
|
+
|
41
|
+
def open
|
42
|
+
s = ""
|
43
|
+
s += indent
|
44
|
+
s += to_s
|
45
|
+
output.puts s
|
46
|
+
increment_indent_level
|
47
|
+
return self
|
48
|
+
end
|
49
|
+
|
50
|
+
def close
|
51
|
+
if @constants and break_string then
|
52
|
+
s = ""
|
53
|
+
s += indent
|
54
|
+
s += break_string
|
55
|
+
output.puts s
|
56
|
+
end
|
57
|
+
decrement_indent_level
|
58
|
+
return self
|
59
|
+
end
|
60
|
+
|
61
|
+
def pr(*args)
|
62
|
+
args = @args if args.length == 0 and @args
|
63
|
+
open
|
64
|
+
if @block then
|
65
|
+
@block.call(*args)
|
66
|
+
close
|
67
|
+
end
|
68
|
+
return self
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
3
73
|
class Case < ControlStructure
|
4
74
|
|
5
75
|
attr_reader :expression
|
6
|
-
attr_reader :
|
76
|
+
attr_reader :case_conditions
|
7
77
|
|
8
|
-
def initialize(expression, *control)
|
78
|
+
def initialize(expression, *control, &block)
|
9
79
|
@expression = expression
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
elsif control.size.even? then
|
15
|
-
(0..control.size-1).step(2) { |i|
|
16
|
-
@constants_list[i/2] = [control[i]].flatten
|
17
|
-
@blocks[i/2] = control[i+1]
|
18
|
-
}
|
19
|
-
else
|
20
|
-
(0..control.size-2).step(2) { |i|
|
21
|
-
@constants_list[i/2] = [control[i]].flatten
|
22
|
-
@blocks[i/2] = control[i+1]
|
23
|
-
}
|
24
|
-
@blocks.push(control.last)
|
80
|
+
@case_conditions = []
|
81
|
+
control.push(block) if block
|
82
|
+
while control.size >= 2 do
|
83
|
+
@case_conditions.push CaseCondition::new([control.shift].flatten, &(control.shift))
|
25
84
|
end
|
85
|
+
@case_conditions.push CaseCondition::new(&(control.shift)) if control.size > 0
|
26
86
|
end
|
27
87
|
|
28
88
|
def get_c_strings
|
29
89
|
return { :switch => '"switch (#{expr}) {"',
|
30
|
-
:case => '"case #{constants.join(" : case")} :"',
|
31
|
-
:default => '"default :"',
|
32
|
-
:break => '"break;"',
|
33
90
|
:end => '"}"' }
|
34
91
|
end
|
35
92
|
|
36
93
|
def get_fortran_strings
|
37
94
|
return { :switch => '"select case (#{expr})"',
|
38
|
-
:case => '"case (#{constants.join(" : ")})"',
|
39
|
-
:default => '"case default"',
|
40
|
-
:break => 'nil',
|
41
95
|
:end => '"end select"' }
|
42
96
|
end
|
43
97
|
|
@@ -45,44 +99,29 @@ module BOAST
|
|
45
99
|
alias get_cuda_strings get_c_strings
|
46
100
|
|
47
101
|
eval token_string_generator( * %w{switch expr})
|
48
|
-
eval token_string_generator( * %w{case constants})
|
49
|
-
eval token_string_generator( * %w{default})
|
50
|
-
eval token_string_generator( * %w{break})
|
51
102
|
eval token_string_generator( * %w{end})
|
52
103
|
|
53
|
-
def to_s
|
104
|
+
def to_s
|
54
105
|
s = ""
|
55
|
-
|
56
|
-
if block_number != 0 then
|
57
|
-
s += indent + break_string + "\n" if break_string
|
58
|
-
decrement_indent_level
|
59
|
-
end
|
60
|
-
s += indent
|
61
|
-
if @constants_list[block_number] and @constants_list[block_number].size > 0 then
|
62
|
-
s += case_string(@constants_list[block_number])
|
63
|
-
else
|
64
|
-
s += default_string
|
65
|
-
end
|
66
|
-
else
|
67
|
-
s += indent
|
68
|
-
s += switch_string(@expression)
|
69
|
-
end
|
70
|
-
increment_indent_level
|
106
|
+
s += switch_string(@expression)
|
71
107
|
return s
|
72
108
|
end
|
73
109
|
|
74
110
|
def open
|
75
|
-
|
111
|
+
s = ""
|
112
|
+
s += indent
|
113
|
+
s += to_s
|
114
|
+
output.puts s
|
115
|
+
increment_indent_level
|
76
116
|
return self
|
77
117
|
end
|
78
118
|
|
79
119
|
def pr(*args)
|
120
|
+
args = @args if args.length == 0 and @args
|
80
121
|
open
|
81
|
-
if @
|
82
|
-
@
|
83
|
-
|
84
|
-
output.puts s
|
85
|
-
@blocks[indx].call(*args)
|
122
|
+
if @case_conditions.size > 0 then
|
123
|
+
@case_conditions.each { |cond|
|
124
|
+
cond.pr(*args)
|
86
125
|
}
|
87
126
|
close
|
88
127
|
end
|
@@ -90,12 +129,10 @@ module BOAST
|
|
90
129
|
end
|
91
130
|
|
92
131
|
def close
|
132
|
+
decrement_indent_level
|
93
133
|
s = ""
|
94
|
-
s += indent + break_string + "\n" if break_string
|
95
|
-
decrement_indent_level
|
96
134
|
s += indent
|
97
135
|
s += end_string
|
98
|
-
decrement_indent_level
|
99
136
|
output.puts s
|
100
137
|
return self
|
101
138
|
end
|