asmrb 0.0.2.6.1.6 → 0.0.2.6.1.7
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/asmrb.rb +64 -10
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a31c679f3270d1b696aa42d53bbe503f7365534
|
|
4
|
+
data.tar.gz: 8e49fbe0da1b1ffff62ef5ff101029a91a129e1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c2ea67ec5870af0c5a355cc9ed02e7dbce0379be1529cbf1a8e44c44bf481f1cd0199276f8284fe8786c36e472dce4feaa4d664b1326fdcb5196fcef53b3a5d3
|
|
7
|
+
data.tar.gz: 07eb3305d4be92cf73c188d1917801930141104f52c71ec54c1cba12d949acd81432123d2295653a99425eba9588af3526670700bb0a2e8da4d290bbc85f66f5
|
data/lib/asmrb.rb
CHANGED
|
@@ -218,7 +218,11 @@ class Asmrb
|
|
|
218
218
|
"inv" => lambda { |obj, f|
|
|
219
219
|
args = Array.new
|
|
220
220
|
@stack.each { args << @stack.pop } if @stack.length > 0
|
|
221
|
-
|
|
221
|
+
if args.length > 0
|
|
222
|
+
@stack.push @variables[obj].send(f, eval("args.join(', ')"))
|
|
223
|
+
else
|
|
224
|
+
@stack.push @variables[obj].send f
|
|
225
|
+
end
|
|
222
226
|
},
|
|
223
227
|
|
|
224
228
|
"cal" => lambda {|fname|
|
|
@@ -271,7 +275,7 @@ class Asmrb
|
|
|
271
275
|
|
|
272
276
|
when "fun"
|
|
273
277
|
@name = args.first
|
|
274
|
-
|
|
278
|
+
create_label @name
|
|
275
279
|
|
|
276
280
|
else
|
|
277
281
|
return name
|
|
@@ -395,13 +399,21 @@ class Asmrb
|
|
|
395
399
|
@partitions = { @name => @program }
|
|
396
400
|
else
|
|
397
401
|
@partitions = Hash.new
|
|
398
|
-
@
|
|
402
|
+
@limitation = 0
|
|
403
|
+
@jump_points = @labels.map &:last
|
|
404
|
+
@labels.each.with_index do |label, label_index|
|
|
405
|
+
if label_index != @jump_points.length-1
|
|
406
|
+
@limitation = @jump_points[label_index+1]
|
|
407
|
+
else
|
|
408
|
+
@limitation = @program.length-1
|
|
409
|
+
end
|
|
399
410
|
puts "#{label[1]+1}:#{label[0]}".magenta
|
|
400
411
|
partition = Array.new
|
|
401
|
-
#
|
|
402
|
-
code_segment = @program[label.last+1..@
|
|
412
|
+
# binding.pry
|
|
413
|
+
code_segment = @program[label.last+1..@limitation]
|
|
403
414
|
code_segment.each.with_index do |statement, index|
|
|
404
|
-
break if statement.first
|
|
415
|
+
#break if [:rec].include? statement.first.to_sym
|
|
416
|
+
#binding.pry
|
|
405
417
|
partition << statement
|
|
406
418
|
puts (read_internal statement, index).light_yellow if @is_debug
|
|
407
419
|
end
|
|
@@ -411,9 +423,51 @@ class Asmrb
|
|
|
411
423
|
puts "partitioning completed.".light_green
|
|
412
424
|
@partitions if@is_debug
|
|
413
425
|
end
|
|
426
|
+
|
|
427
|
+
def read_internal instruction, index
|
|
428
|
+
" #{index}: #{instruction.first}" +
|
|
429
|
+
" #{instruction.last.join(" ") unless instruction.last.empty?}"
|
|
430
|
+
end
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
x = Asmrb.new do
|
|
434
|
+
fun :play
|
|
435
|
+
arg :toy
|
|
436
|
+
psh :toy
|
|
437
|
+
cal :puts
|
|
438
|
+
|
|
439
|
+
blo :after_print
|
|
440
|
+
psh :times
|
|
441
|
+
jnl :init_timer
|
|
442
|
+
|
|
443
|
+
blo :append
|
|
444
|
+
inv :times, :to_s
|
|
445
|
+
psh "X"
|
|
446
|
+
add
|
|
447
|
+
cal :puts
|
|
448
|
+
|
|
449
|
+
blo :count
|
|
450
|
+
psh :times
|
|
451
|
+
psh 1
|
|
452
|
+
add
|
|
453
|
+
lea :times
|
|
454
|
+
psh :times
|
|
455
|
+
psh 10
|
|
456
|
+
cmp
|
|
457
|
+
jeq :final
|
|
458
|
+
psh "__"
|
|
459
|
+
rec
|
|
460
|
+
|
|
461
|
+
blo :final
|
|
462
|
+
psh :times
|
|
463
|
+
ret
|
|
464
|
+
|
|
465
|
+
blo :init_timer
|
|
466
|
+
psh 0
|
|
467
|
+
lea :times
|
|
468
|
+
jmp :append
|
|
414
469
|
end
|
|
415
470
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
end
|
|
471
|
+
x.is_debug = true
|
|
472
|
+
x.partition
|
|
473
|
+
#x.invoke "I'm The Trung, here we go:"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: asmrb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.2.6.1.
|
|
4
|
+
version: 0.0.2.6.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- The Trung
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-05-
|
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: create a assembly-like toy language in ruby DSL.
|
|
14
14
|
email: deulamco@gmail.com
|