f_dot 0.0.1 → 0.0.2
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/.gitignore +2 -1
- data/Gemfile.lock +2 -2
- data/bin/f_dot +14 -1
- data/checksums/f_dot-0.0.1.gem.sha512 +1 -1
- data/checksums/f_dot-0.0.2.gem.sha512 +1 -0
- data/deserialization_testing.rb +12 -6
- data/f_dot.gemspec +1 -1
- data/lib/f_dot/based.rb +48 -13
- data/lib/f_dot/cubicus.rb +178 -0
- data/lib/f_dot/history.rb +5 -4
- data/lib/f_dot/instruction.rb +3 -3
- data/lib/f_dot/interface.rb +54 -31
- data/lib/f_dot/processor.rb +163 -91
- data/lib/f_dot/program.rb +107 -76
- data/lib/f_dot/variable.rb +2 -2
- data/lib/f_dot/version.rb +4 -2
- data/lib/f_dot.rb +11 -0
- data/lib/go/f_dot.go +243 -0
- data/lib/go/go.mod +10 -0
- data/lib/go/go.sum +6 -0
- data/lib/go/index.html +18 -0
- data/lib/go/javascript/.DS_Store +0 -0
- data/lib/go/javascript/canvas.js +33 -0
- data/lib/go/javascript/entry.js +8 -0
- data/lib/go/javascript/f_dot_go.js +250 -0
- data/lib/go/javascript/gl-matrix-min.js +28 -0
- data/lib/go/stylesheets/f_dot_go.css +64 -0
- metadata +15 -4
data/lib/f_dot/processor.rb
CHANGED
|
@@ -19,6 +19,11 @@ module FDot
|
|
|
19
19
|
attr_accessor :serialized_state
|
|
20
20
|
attr_accessor :write_state_callback
|
|
21
21
|
attr_accessor :plugin_mutex
|
|
22
|
+
attr_accessor :state_mutex
|
|
23
|
+
attr_accessor :f_dot_space_override_path
|
|
24
|
+
attr_accessor :is_processing
|
|
25
|
+
attr_accessor :processing_mode
|
|
26
|
+
attr_accessor :default_display_override
|
|
22
27
|
|
|
23
28
|
DEFAULT_SETTINGS = {
|
|
24
29
|
show_history_logging: false,
|
|
@@ -26,11 +31,21 @@ module FDot
|
|
|
26
31
|
debug_inspectors_enabled: false
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
MODES = {
|
|
35
|
+
default: 0,
|
|
36
|
+
one_move: 1
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
def initialize
|
|
30
40
|
self.user_settings = FDot::Based::Processor::DEFAULT_SETTINGS.dup
|
|
31
41
|
self.serialized_state = {}
|
|
32
42
|
self.write_state_callback = nil
|
|
33
43
|
self.plugin_mutex = Mutex.new
|
|
44
|
+
self.state_mutex = Mutex.new
|
|
45
|
+
self.f_dot_space_override_path = nil
|
|
46
|
+
self.is_processing = true
|
|
47
|
+
self.processing_mode = FDot::Based::Processor::MODES[:default]
|
|
48
|
+
self.default_display_override = false
|
|
34
49
|
|
|
35
50
|
FDot.state[:completed_programs] = {}
|
|
36
51
|
FDot.state[:program] = nil
|
|
@@ -39,10 +54,9 @@ module FDot
|
|
|
39
54
|
end
|
|
40
55
|
|
|
41
56
|
def self.serialize_state!
|
|
42
|
-
puts "calling #{self.name}.#{__method__}"
|
|
43
57
|
self.instance.serialized_state = {
|
|
44
58
|
based_uuid: FDot.state[:based_uuid],
|
|
45
|
-
completed_programs: FDot.state[:completed_programs].map{|k, v| v.compute_serialized_state!},
|
|
59
|
+
# completed_programs: FDot.state[:completed_programs].map{|k, v| v.compute_serialized_state!},
|
|
46
60
|
program: FDot.state[:program].compute_serialized_state!,
|
|
47
61
|
f_dot_queue: FDot.state[:f_dot_queue],
|
|
48
62
|
instructions: FDot.state[:instructions],
|
|
@@ -63,9 +77,23 @@ module FDot
|
|
|
63
77
|
end
|
|
64
78
|
end
|
|
65
79
|
|
|
66
|
-
def self.initialize_with_data(
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
def self.initialize_with_data(
|
|
81
|
+
override_path = nil,
|
|
82
|
+
callback = nil,
|
|
83
|
+
initialize_data = {},
|
|
84
|
+
one_move_mode = false
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if one_move_mode
|
|
88
|
+
self.instance.processing_mode = FDot::Based::Processor::MODES[:one_move]
|
|
89
|
+
self.set_user_setting(:show_history_logging, true)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
self.instance.write_state_callback = callback
|
|
93
|
+
self.instance.f_dot_space_override_path = override_path
|
|
94
|
+
|
|
95
|
+
return self.instance.run unless initialize_data.kind_of?(Hash) &&
|
|
96
|
+
!initialize_data.empty?
|
|
69
97
|
|
|
70
98
|
new_serialized_state = {}
|
|
71
99
|
|
|
@@ -80,9 +108,9 @@ module FDot
|
|
|
80
108
|
].each{|k|
|
|
81
109
|
k = k.to_sym
|
|
82
110
|
|
|
83
|
-
new_serialized_state[k] =
|
|
111
|
+
new_serialized_state[k] = initialize_data[k.to_s]
|
|
84
112
|
if new_serialized_state[k].nil?
|
|
85
|
-
puts "skipping #{k} because
|
|
113
|
+
puts "skipping #{k} because initialize_data[#{k}] is not present."
|
|
86
114
|
next
|
|
87
115
|
end
|
|
88
116
|
|
|
@@ -94,26 +122,31 @@ module FDot
|
|
|
94
122
|
when :completed_programs
|
|
95
123
|
puts :todo_initialize_completed_programs
|
|
96
124
|
when :program
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
p_serialized["history"]
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
begin
|
|
126
|
+
p_serialized = new_serialized_state[k]
|
|
127
|
+
|
|
128
|
+
program_instance = FDot::Based::Program.new(p_serialized["uuid"])
|
|
129
|
+
puts "#{__method__} init program from serialized data! #{program_instance}"
|
|
130
|
+
program_instance.uuid = p_serialized["uuid"]
|
|
131
|
+
FDot.state[:program] = program_instance
|
|
132
|
+
|
|
133
|
+
p_serialized["variables"].each{|_, serialized|
|
|
134
|
+
FDot::Based::Variable.deserialize_into!(FDot.state[:program], serialized)
|
|
135
|
+
} unless p_serialized["variables"].nil?
|
|
136
|
+
|
|
137
|
+
p_serialized["instructions"].each{|_, serialized|
|
|
138
|
+
FDot::Based::Instruction.deserialize_into!(FDot.state[:program], serialized)
|
|
139
|
+
} unless p_serialized["variables"].nil?
|
|
140
|
+
|
|
141
|
+
p_serialized["history"].map{|historical_uuid, _|
|
|
142
|
+
p_serialized["history"][historical_uuid].each{|h|
|
|
143
|
+
FDot::Based::History.deserialize_into!(FDot.state[:program], h)
|
|
144
|
+
}
|
|
145
|
+
} unless p_serialized["variables"].nil?
|
|
146
|
+
rescue StandardError => e
|
|
147
|
+
puts e.inspect
|
|
148
|
+
puts Thread.main.backtrace
|
|
149
|
+
end
|
|
117
150
|
when :f_dot_queue, :instructions
|
|
118
151
|
FDot.state[k] = new_serialized_state[k]
|
|
119
152
|
end
|
|
@@ -138,62 +171,80 @@ module FDot
|
|
|
138
171
|
def run(force = false)
|
|
139
172
|
raise "already running #{FDot.state[:program].uuid}!" if !force && !FDot.state[:program].nil?
|
|
140
173
|
|
|
141
|
-
|
|
142
|
-
|
|
174
|
+
if FDot::Based::Program.show_startup!.to_sym != :start
|
|
175
|
+
self.class.user_exited!
|
|
176
|
+
else
|
|
177
|
+
FDot.state[:program] ||= FDot::Based::Program.new
|
|
178
|
+
puts "loaded #{FDot.state[:program]}"
|
|
179
|
+
self.is_processing = true
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
while self.is_processing
|
|
143
183
|
|
|
144
|
-
loop do
|
|
145
184
|
FDot::Based::Interface.reconfigure_user_space!
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
185
|
+
if !self.default_display_override
|
|
186
|
+
FDot::Based.print_large_title!
|
|
187
|
+
self.class.print_file_contents(FDot::Based::Interface.compiler_file_path)
|
|
188
|
+
else
|
|
189
|
+
self.default_display_override = false
|
|
190
|
+
end
|
|
191
|
+
|
|
153
192
|
user_input = self.get_user_input
|
|
193
|
+
|
|
154
194
|
next if FDot::Based::Interface.open_main_menu?(user_input)
|
|
155
195
|
|
|
156
196
|
if Dir.exist?(user_input)
|
|
157
197
|
domain_name = File.basename(user_input)
|
|
158
198
|
if FDot::DOMAINS[domain_name.to_sym] == FDot::DOMAINS[:user]
|
|
159
|
-
|
|
199
|
+
FDot::Based.tty_prompt_select(
|
|
160
200
|
"select a variable: ", FDot::Based::Interface.user_input_options(user_input)
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
201
|
+
) {|selected_variable_file_path|
|
|
202
|
+
next if FDot::Based::Interface.open_main_menu?(selected_variable_file_path)
|
|
203
|
+
next if selected_variable_file_path.nil?
|
|
204
|
+
variable_uuid = FDot::Based::Interface.get_variable_uuid_from_file(
|
|
205
|
+
selected_variable_file_path
|
|
206
|
+
)
|
|
207
|
+
raise "invalid variable uuid! #{variable_uuid}" if variable_uuid.nil? ||
|
|
208
|
+
!FDot.state[:program].variables.keys.include?(variable_uuid)
|
|
209
|
+
|
|
210
|
+
if FDot::Based::Processor.user_setting!(:debug_inspectors_enabled)
|
|
211
|
+
debugger_open = true
|
|
212
|
+
while debugger_open
|
|
213
|
+
v = FDot.state[:program].variables[variable_uuid]
|
|
214
|
+
FDot::Based.tty_prompt_select(
|
|
215
|
+
"select attribute: ",
|
|
216
|
+
[{name: :close_debugger, value: :close_debugger}] + v.history_menu_options
|
|
217
|
+
) {|variable_attribute|
|
|
218
|
+
if variable_attribute == :close_debugger
|
|
219
|
+
debugger_open = false
|
|
220
|
+
else
|
|
221
|
+
self.default_display_override = true
|
|
222
|
+
puts v.send(variable_attribute)
|
|
223
|
+
end
|
|
224
|
+
}
|
|
182
225
|
end
|
|
183
226
|
end
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
227
|
+
# move for the user
|
|
228
|
+
FDot.state[:program].add_move_history(
|
|
229
|
+
FDot.state[:program].variables[variable_uuid],
|
|
230
|
+
:processor
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
# move for the programmer
|
|
234
|
+
programmer_variable_uuid = FDot.state[:programmer][:variables].sample
|
|
235
|
+
FDot.state[:program].add_move_history(
|
|
236
|
+
FDot.state[:program].variables[programmer_variable_uuid],
|
|
237
|
+
:processor
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
if self.processing_mode == FDot::Based::Processor::MODES[:one_move]
|
|
241
|
+
unless self.write_state_callback.nil?
|
|
242
|
+
self.write_state_callback.call(self.serialized_state, true)
|
|
243
|
+
end
|
|
244
|
+
FDot::Based::Interface.reconfigure_user_space!
|
|
245
|
+
self.class.user_exited!
|
|
246
|
+
end
|
|
247
|
+
}
|
|
197
248
|
else
|
|
198
249
|
listing_text = ["listing #{File.basename(user_input)} domain..."]
|
|
199
250
|
Dir[
|
|
@@ -201,49 +252,70 @@ module FDot
|
|
|
201
252
|
].each{|d|
|
|
202
253
|
listing_text << d.gsub(user_input, "")
|
|
203
254
|
}
|
|
255
|
+
self.default_display_override = true
|
|
204
256
|
FDot::Based.less(
|
|
205
257
|
listing_text.join("\n")
|
|
206
258
|
)
|
|
207
259
|
end
|
|
208
260
|
elsif File.exist?(user_input)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
file_contents["variables"] = file_contents["variables"].map{|v_uuid|
|
|
212
|
-
FDot.state[:program].variables[v_uuid].to_s
|
|
213
|
-
}
|
|
214
|
-
file_contents["instructions"] = file_contents["instructions"].map{|i_uuid|
|
|
215
|
-
FDot.state[:program].instructions[i_uuid].to_s
|
|
216
|
-
}
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
puts "reading #{File.basename(user_input)} file..."
|
|
220
|
-
FDot::Based.less(
|
|
221
|
-
JSON.pretty_generate(file_contents)
|
|
222
|
-
)
|
|
261
|
+
self.default_display_override = true
|
|
262
|
+
self.class.print_file_contents(user_input)
|
|
223
263
|
end
|
|
224
264
|
end
|
|
265
|
+
|
|
266
|
+
!self.is_processing
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def self.print_file_contents(file_path)
|
|
270
|
+
raise "invalid file_path! #{file_path}" unless File.exist?(file_path)
|
|
271
|
+
|
|
272
|
+
file_contents = JSON.parse(File.read(file_path))
|
|
273
|
+
if File.basename(file_path) == :compiler.to_s
|
|
274
|
+
file_contents["variables"] = file_contents["variables"].map{|v_uuid|
|
|
275
|
+
FDot.state[:program].variables[v_uuid].to_s
|
|
276
|
+
}
|
|
277
|
+
file_contents["instructions"] = file_contents["instructions"].map{|i_uuid|
|
|
278
|
+
FDot.state[:program].instructions[i_uuid].to_s
|
|
279
|
+
}
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
puts "reading #{File.basename(file_path)} file..."
|
|
283
|
+
FDot::Based.less(
|
|
284
|
+
JSON.pretty_generate(file_contents)
|
|
285
|
+
)
|
|
225
286
|
end
|
|
226
287
|
|
|
227
288
|
def get_user_input
|
|
228
289
|
FDot::Based.tty_prompt_select(
|
|
229
290
|
"#{self.class.name}.#{__method__}: ", FDot::Based::Interface.user_input_options
|
|
230
|
-
)
|
|
291
|
+
) {|v|
|
|
292
|
+
return v
|
|
293
|
+
}
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def self.user_exited!
|
|
297
|
+
FDot::Based::Cubicus.run_exit_cleanup!
|
|
298
|
+
self.instance.is_processing = false
|
|
231
299
|
end
|
|
232
300
|
|
|
233
301
|
def self.show_settings_menu!
|
|
234
302
|
|
|
235
303
|
settings_menu_open = true
|
|
236
304
|
while settings_menu_open
|
|
237
|
-
|
|
305
|
+
FDot::Based.tty_prompt_select(
|
|
238
306
|
"select a setting to toggle",
|
|
239
307
|
[{name: :back, value: :back}] + self.instance.user_settings.map{|k, v|
|
|
240
308
|
{name: "#{k}(#{v})", value: k}
|
|
241
309
|
}
|
|
242
|
-
)
|
|
310
|
+
) {|setting_key|
|
|
243
311
|
|
|
244
|
-
|
|
312
|
+
if setting_key == :back
|
|
313
|
+
settings_menu_open = false
|
|
314
|
+
next
|
|
315
|
+
end
|
|
245
316
|
|
|
246
|
-
|
|
317
|
+
set_user_setting(setting_key, !user_setting!(setting_key))
|
|
318
|
+
}
|
|
247
319
|
end
|
|
248
320
|
end
|
|
249
321
|
|
data/lib/f_dot/program.rb
CHANGED
|
@@ -18,6 +18,7 @@ module FDot
|
|
|
18
18
|
attr_accessor :variables
|
|
19
19
|
attr_accessor :instructions
|
|
20
20
|
attr_accessor :history
|
|
21
|
+
attr_accessor :compiler_mutex
|
|
21
22
|
|
|
22
23
|
def initialize(state_uuid = nil)
|
|
23
24
|
puts "#{self}.#{__method__}"
|
|
@@ -25,6 +26,7 @@ module FDot
|
|
|
25
26
|
self.variables = {}
|
|
26
27
|
self.instructions = {}
|
|
27
28
|
self.history = {}
|
|
29
|
+
self.compiler_mutex = Mutex.new
|
|
28
30
|
|
|
29
31
|
generate_variables!
|
|
30
32
|
end
|
|
@@ -41,18 +43,9 @@ module FDot
|
|
|
41
43
|
self.variables[new_variable.uuid] = new_variable
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
FDot::Based.print_large_title!
|
|
46
|
-
puts startup_notes
|
|
47
|
-
|
|
48
|
-
# start a new program
|
|
49
|
-
exit if :close_program == FDot::Based.tty_prompt_select(
|
|
50
|
-
"press enter to continue",
|
|
51
|
-
[{name: :start, value: :start}, {name: :close_program, value: :close_program}]
|
|
52
|
-
)
|
|
53
46
|
end
|
|
54
47
|
|
|
55
|
-
def startup_notes
|
|
48
|
+
def self.startup_notes
|
|
56
49
|
[
|
|
57
50
|
"welcome to f_dot. | f_dot is based. | this is a based f_dot program.\n",
|
|
58
51
|
"interface description:\n",
|
|
@@ -67,16 +60,17 @@ module FDot
|
|
|
67
60
|
"\tthe processor processes the f_dot_queue of variables.",
|
|
68
61
|
"\tthe processor domain is the root of the program.",
|
|
69
62
|
"programmer:",
|
|
70
|
-
"\tthe programmer is user-like domain that responds to user actions.",
|
|
63
|
+
"\tthe programmer is domain is a user-like domain that responds to user actions.",
|
|
71
64
|
"\tthe programmer is distributed variables the same way as they are given to users.",
|
|
72
65
|
"user:",
|
|
73
66
|
"\tthe user is a human operating an FDot::Based unix system.",
|
|
74
|
-
"\tthe user only able to move instructions from the user domain to the processor domain.",
|
|
67
|
+
"\tthe user is only able to move instructions from the user domain to the processor domain.",
|
|
75
68
|
"program operation:\n",
|
|
76
|
-
"\t1) the user and
|
|
77
|
-
"\t2)
|
|
78
|
-
"\t3) the
|
|
79
|
-
"\t4)
|
|
69
|
+
"\t1) the user and programmer domains receive variables from the f_dot_queue.",
|
|
70
|
+
"\t2) 11 variables are dequeued to both 3 times throughout the program.",
|
|
71
|
+
"\t3) at the end of the program both domains receive 5 variables once.",
|
|
72
|
+
"\t4) the program then calculates the based checksum.",
|
|
73
|
+
"\t5) a new program starts.\n",
|
|
80
74
|
"user usage:\n",
|
|
81
75
|
"\t=> navigate to the user menu",
|
|
82
76
|
"\t=> select a variable in the user menu to move it to the compiler.",
|
|
@@ -100,6 +94,7 @@ module FDot
|
|
|
100
94
|
|
|
101
95
|
# primary read of compiler contents
|
|
102
96
|
def compiler_contents
|
|
97
|
+
return @complier_contents unless @complier_contents.nil?
|
|
103
98
|
# a variable or instruction is considered inside of
|
|
104
99
|
# compiler_contents if it is not in any of the
|
|
105
100
|
# following domains:
|
|
@@ -110,20 +105,23 @@ module FDot
|
|
|
110
105
|
#
|
|
111
106
|
# note => :based_variable is not strictly a domain
|
|
112
107
|
#
|
|
108
|
+
# self.compiler_mutex.synchronize do
|
|
109
|
+
@complier_contents = {
|
|
110
|
+
variables: self.variables.select{|k, v|
|
|
111
|
+
k != FDot.state[:based_uuid] &&
|
|
112
|
+
!FDot.state[:f_dot_queue].include?(k) &&
|
|
113
|
+
!FDot.state[:programmer][:variables].include?(k) &&
|
|
114
|
+
!FDot.state[:user][:variables].include?(k) &&
|
|
115
|
+
!self.instructions.any?{|i_uuid, i_instance| i_instance.variable_uuids.include?(k)}
|
|
116
|
+
}.map{|k, v| k},
|
|
117
|
+
instructions: self.instructions.select{|k, v|
|
|
118
|
+
!FDot.state[:programmer][:instructions].include?(k) &&
|
|
119
|
+
!FDot.state[:user][:instructions].include?(k)
|
|
120
|
+
}.map{|k, v| k},
|
|
121
|
+
}
|
|
122
|
+
# end
|
|
113
123
|
|
|
114
|
-
|
|
115
|
-
variables: self.variables.select{|k, v|
|
|
116
|
-
k != FDot.state[:based_uuid] &&
|
|
117
|
-
!FDot.state[:f_dot_queue].include?(k) &&
|
|
118
|
-
!FDot.state[:programmer][:variables].include?(k) &&
|
|
119
|
-
!FDot.state[:user][:variables].include?(k) &&
|
|
120
|
-
!self.instructions.any?{|i_uuid, i_instance| i_instance.variable_uuids.include?(k)}
|
|
121
|
-
}.map{|k, v| k},
|
|
122
|
-
instructions: self.instructions.select{|k, v|
|
|
123
|
-
!FDot.state[:programmer][:instructions].include?(k) &&
|
|
124
|
-
!FDot.state[:user][:instructions].include?(k)
|
|
125
|
-
}.map{|k, v| k},
|
|
126
|
-
}
|
|
124
|
+
@complier_contents
|
|
127
125
|
end
|
|
128
126
|
|
|
129
127
|
# deal out one variable
|
|
@@ -163,7 +161,7 @@ module FDot
|
|
|
163
161
|
allowed_intersection = (
|
|
164
162
|
allowed_const_types & [const_one, const_two]
|
|
165
163
|
)
|
|
166
|
-
|
|
164
|
+
|
|
167
165
|
unless allowed_intersection.all?{|c| allowed_const_types.map{|c| c.name}.include?(c.name)}
|
|
168
166
|
raise "invalid const(s)! #{const_one}:#{const_two}"
|
|
169
167
|
end
|
|
@@ -223,6 +221,7 @@ module FDot
|
|
|
223
221
|
|
|
224
222
|
def compile!(lineage_uuid)
|
|
225
223
|
raise "invalid lineage_uuid" unless history.keys.include?(lineage_uuid)
|
|
224
|
+
@complier_contents = nil
|
|
226
225
|
history_instance = history[lineage_uuid].last
|
|
227
226
|
compile_instructions!(history_instance)
|
|
228
227
|
compile_variables!(history_instance)
|
|
@@ -232,25 +231,29 @@ module FDot
|
|
|
232
231
|
def show_history_interface!
|
|
233
232
|
history_menu_open = true
|
|
234
233
|
while history_menu_open
|
|
235
|
-
|
|
234
|
+
FDot::Based.tty_prompt_select(
|
|
236
235
|
"which item do you want to view the history for?",
|
|
237
236
|
[{name: :back, value: :back}] + self.history_menu_options
|
|
238
|
-
)
|
|
239
|
-
|
|
240
|
-
break if to_show_history_uuid == :back
|
|
237
|
+
) {|to_show_history_uuid|
|
|
241
238
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
239
|
+
if to_show_history_uuid == :back
|
|
240
|
+
history_menu_open = false
|
|
241
|
+
next
|
|
242
|
+
end
|
|
243
|
+
FDot::Based.tty_prompt_select(
|
|
244
|
+
"which record would you like to open?",
|
|
245
|
+
[{name: :back, value: :back}] + self.history_menu_options_for(to_show_history_uuid)
|
|
246
|
+
) {|history_timestamp|
|
|
246
247
|
|
|
247
|
-
|
|
248
|
+
next if history_timestamp == :back
|
|
248
249
|
|
|
249
|
-
|
|
250
|
+
history_instance = self.history[to_show_history_uuid].select{|h| h.timestamp == history_timestamp}.first
|
|
250
251
|
|
|
251
|
-
|
|
252
|
+
raise "invalid history_instance!" if history_instance.nil?
|
|
252
253
|
|
|
253
|
-
|
|
254
|
+
history_instance.show_interface!
|
|
255
|
+
}
|
|
256
|
+
}
|
|
254
257
|
end
|
|
255
258
|
|
|
256
259
|
end
|
|
@@ -328,8 +331,8 @@ module FDot
|
|
|
328
331
|
|
|
329
332
|
def check_for_based_conditions!
|
|
330
333
|
return unless ready_to_based?
|
|
331
|
-
|
|
332
334
|
puts "running based checksum"
|
|
335
|
+
@complier_contents = nil
|
|
333
336
|
compile_variables = compiler_contents[:variables]
|
|
334
337
|
(compile_variables + [FDot.state[:based_uuid]]).each{|v_uuid|
|
|
335
338
|
variable = self.variables[v_uuid]
|
|
@@ -339,7 +342,7 @@ module FDot
|
|
|
339
342
|
raise "checksum failed!" if ordinal_instruction.nil?
|
|
340
343
|
variable.combine_with_instruction(ordinal_instruction)
|
|
341
344
|
}
|
|
342
|
-
|
|
345
|
+
@complier_contents = nil
|
|
343
346
|
compile_variables = compiler_contents[:variables]
|
|
344
347
|
raise "based failed!" unless compile_variables.count == 0
|
|
345
348
|
|
|
@@ -347,11 +350,32 @@ module FDot
|
|
|
347
350
|
puts "#{self.class.name} completed."
|
|
348
351
|
FDot.state[:completed_programs][self.uuid] = self
|
|
349
352
|
|
|
350
|
-
puts "listing completed programs:"
|
|
351
|
-
puts FDot.state[:completed_programs]
|
|
353
|
+
# puts "listing completed programs:"
|
|
354
|
+
# puts FDot.state[:completed_programs]
|
|
352
355
|
|
|
353
356
|
FDot.state[:based_uuid] = nil
|
|
354
|
-
|
|
357
|
+
@complier_contents = nil
|
|
358
|
+
if FDot::Based::Program.show_startup!.to_sym == :start
|
|
359
|
+
FDot.state[:program] = FDot::Based::Program.new
|
|
360
|
+
else
|
|
361
|
+
FDot::Based::Processor.user_exited!
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def self.show_startup!(force = false)
|
|
366
|
+
return :start unless force ||
|
|
367
|
+
FDot::Based::Processor.instance.processing_mode != FDot::Based::Processor::MODES[:one_move]
|
|
368
|
+
|
|
369
|
+
FDot::Based.print_large_title!
|
|
370
|
+
puts self.startup_notes
|
|
371
|
+
|
|
372
|
+
# start a new program or close f_dot
|
|
373
|
+
FDot::Based.tty_prompt_select(
|
|
374
|
+
"press enter to continue",
|
|
375
|
+
[{name: :start, value: :start}, {name: :close_program, value: :close_program}]
|
|
376
|
+
) {|v|
|
|
377
|
+
return v
|
|
378
|
+
}
|
|
355
379
|
end
|
|
356
380
|
|
|
357
381
|
def f_dot_de_queue!
|
|
@@ -367,7 +391,9 @@ module FDot
|
|
|
367
391
|
|
|
368
392
|
def compile_variables!(history_instance)
|
|
369
393
|
if history_instance.to_domain == FDot::DOMAINS[:processor]
|
|
370
|
-
if FDot::Based::Processor.user_setting!(:auto_compile_enabled)
|
|
394
|
+
if FDot::Based::Processor.user_setting!(:auto_compile_enabled) ||
|
|
395
|
+
FDot::Based::Processor.instance.processing_mode == FDot::Based::Processor::MODES[:one_move]
|
|
396
|
+
|
|
371
397
|
while get_combinable_variables.any?
|
|
372
398
|
combinable_variables = get_combinable_variables
|
|
373
399
|
to_combine_instance = combinable_variables.first
|
|
@@ -380,25 +406,27 @@ module FDot
|
|
|
380
406
|
while get_combinable_variables.any?
|
|
381
407
|
puts JSON.pretty_generate(get_combinable_variables)
|
|
382
408
|
# prompt user to choose an instruction to combine
|
|
383
|
-
|
|
409
|
+
FDot::Based.tty_prompt_select(
|
|
384
410
|
"combinable_variables: ",
|
|
385
411
|
get_combinable_variables.map{|variable_instance|
|
|
386
412
|
{name: variable_instance.to_s, value: variable_instance.uuid}
|
|
387
413
|
}
|
|
388
|
-
)
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
414
|
+
) {|to_combine_variable_uuid|
|
|
415
|
+
to_combine_instance = self.variables[to_combine_variable_uuid]
|
|
416
|
+
raise "invalid to_combine_instance!" if to_combine_instance.nil?
|
|
417
|
+
|
|
418
|
+
puts "listing variables combinable with #{to_combine_instance.to_s}..."
|
|
419
|
+
FDot::Based.tty_prompt_select(
|
|
420
|
+
"combine #{to_combine_instance.to_s} with?",
|
|
421
|
+
get_variables_combinable_with(to_combine_variable_uuid).map{|variable_instance|
|
|
422
|
+
{name: variable_instance.to_s, value: variable_instance.uuid}
|
|
423
|
+
}
|
|
424
|
+
) {|with_variable_uuid|
|
|
425
|
+
with_instance = self.variables[with_variable_uuid]
|
|
426
|
+
|
|
427
|
+
add_combine_history(to_combine_instance, with_instance)
|
|
397
428
|
}
|
|
398
|
-
|
|
399
|
-
with_instance = self.variables[with_variable_uuid]
|
|
400
|
-
|
|
401
|
-
add_combine_history(to_combine_instance, with_instance)
|
|
429
|
+
}
|
|
402
430
|
end
|
|
403
431
|
end
|
|
404
432
|
end
|
|
@@ -406,7 +434,8 @@ module FDot
|
|
|
406
434
|
|
|
407
435
|
def compile_instructions!(history_instance)
|
|
408
436
|
while get_combinable_instructions.any?
|
|
409
|
-
if FDot::Based::Processor.user_setting!(:auto_compile_enabled)
|
|
437
|
+
if FDot::Based::Processor.user_setting!(:auto_compile_enabled) ||
|
|
438
|
+
FDot::Based::Processor.instance.processing_mode == FDot::Based::Processor::MODES[:one_move]
|
|
410
439
|
while get_combinable_instructions.any?
|
|
411
440
|
combinable_instructions = get_combinable_instructions
|
|
412
441
|
to_combine_instance = combinable_instructions.first
|
|
@@ -417,25 +446,27 @@ module FDot
|
|
|
417
446
|
# manually compile
|
|
418
447
|
puts "#{__method__}"
|
|
419
448
|
puts "listing instructions to compile..."
|
|
420
|
-
|
|
449
|
+
FDot::Based.tty_prompt_select(
|
|
421
450
|
"combinable_instructions: ",
|
|
422
451
|
get_combinable_instructions.map{|instruction_instance|
|
|
423
452
|
{name: instruction_instance.to_s, value: instruction_instance.uuid}
|
|
424
453
|
}
|
|
425
|
-
)
|
|
426
|
-
|
|
427
|
-
|
|
454
|
+
) {|to_combine_instruction_uuid|
|
|
455
|
+
to_combine_instance = self.instructions[to_combine_instruction_uuid]
|
|
456
|
+
raise "invalid to_combine_instance!" if to_combine_instance.nil?
|
|
428
457
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
458
|
+
puts "listing instructions combinable with #{to_combine_instance.to_s}..."
|
|
459
|
+
FDot::Based.tty_prompt_select(
|
|
460
|
+
"combine #{to_combine_instance.to_s} with?",
|
|
461
|
+
get_instructions_combinable_with(to_combine_instruction_uuid).map{|instruction_instance|
|
|
462
|
+
{name: instruction_instance.to_s, value: instruction_instance.uuid}
|
|
463
|
+
}
|
|
464
|
+
) {|with_instruction_uuid|
|
|
465
|
+
with_instance = self.instructions[with_instruction_uuid]
|
|
437
466
|
|
|
438
|
-
|
|
467
|
+
add_combine_history(to_combine_instance, with_instance)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
439
470
|
end
|
|
440
471
|
end
|
|
441
472
|
end
|