nudge 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/instructions/bool/bool_and.rb +8 -0
- data/lib/instructions/bool/bool_define.rb +9 -0
- data/lib/instructions/bool/bool_depth.rb +5 -0
- data/lib/instructions/bool/bool_duplicate.rb +7 -0
- data/lib/instructions/bool/bool_equal_q.rb +8 -0
- data/lib/instructions/bool/bool_flush.rb +3 -0
- data/lib/instructions/bool/bool_not.rb +8 -0
- data/lib/instructions/bool/bool_or.rb +8 -0
- data/lib/instructions/bool/bool_pop.rb +3 -0
- data/lib/instructions/bool/bool_random.rb +3 -0
- data/lib/instructions/bool/bool_rotate.rb +11 -0
- data/lib/instructions/bool/bool_shove.rb +14 -0
- data/lib/instructions/bool/bool_swap.rb +3 -0
- data/lib/instructions/bool/bool_xor.rb +8 -0
- data/lib/instructions/bool/bool_yank.rb +12 -0
- data/lib/instructions/bool/bool_yankdup.rb +12 -0
- data/lib/instructions/code/code_atom_q.rb +9 -0
- data/lib/instructions/code/code_backbone_points.rb +17 -0
- data/lib/instructions/code/code_car.rb +15 -0
- data/lib/instructions/code/code_cdr.rb +13 -1
- data/lib/instructions/code/code_concatenate.rb +20 -0
- data/lib/instructions/code/code_cons.rb +22 -1
- data/lib/instructions/code/code_container.rb +21 -2
- data/lib/instructions/code/code_contains_q.rb +11 -0
- data/lib/instructions/code/code_define.rb +9 -0
- data/lib/instructions/code/code_depth.rb +5 -0
- data/lib/instructions/code/code_discrepancy.rb +13 -7
- data/lib/instructions/code/code_do_count.rb +21 -1
- data/lib/instructions/code/code_do_range.rb +44 -3
- data/lib/instructions/code/code_do_times.rb +39 -1
- data/lib/instructions/code/code_duplicate.rb +7 -0
- data/lib/instructions/code/code_equal_q.rb +9 -0
- data/lib/instructions/code/code_execute.rb +7 -0
- data/lib/instructions/code/code_execute_then_pop.rb +9 -0
- data/lib/instructions/code/code_flush.rb +3 -0
- data/lib/instructions/code/code_gsub.rb +11 -3
- data/lib/instructions/code/code_if.rb +8 -0
- data/lib/instructions/code/code_instructions.rb +12 -0
- data/lib/instructions/code/code_list.rb +10 -0
- data/lib/instructions/code/code_member_q.rb +14 -0
- data/lib/instructions/code/code_name_lookup.rb +10 -0
- data/lib/instructions/code/code_noop.rb +3 -0
- data/lib/instructions/code/code_nth.rb +12 -0
- data/lib/instructions/code/code_nth_cdr.rb +14 -2
- data/lib/instructions/code/code_nth_point.rb +15 -0
- data/lib/instructions/code/code_null_q.rb +11 -0
- data/lib/instructions/code/code_parses_q.rb +8 -0
- data/lib/instructions/code/code_points.rb +8 -0
- data/lib/instructions/code/code_pop.rb +3 -0
- data/lib/instructions/code/code_position.rb +11 -0
- data/lib/instructions/code/code_quote.rb +11 -0
- data/lib/instructions/code/code_replace_nth_point.rb +11 -0
- data/lib/instructions/code/code_rotate.rb +11 -0
- data/lib/instructions/code/code_shove.rb +14 -0
- data/lib/instructions/code/code_swap.rb +3 -0
- data/lib/instructions/code/code_yank.rb +12 -0
- data/lib/instructions/code/code_yankdup.rb +12 -0
- data/lib/instructions/conversion/bool_from_float.rb +9 -0
- data/lib/instructions/conversion/bool_from_int.rb +9 -0
- data/lib/instructions/conversion/code_from_bool.rb +9 -1
- data/lib/instructions/conversion/code_from_float.rb +10 -1
- data/lib/instructions/conversion/code_from_int.rb +10 -1
- data/lib/instructions/conversion/code_from_name.rb +10 -1
- data/lib/instructions/conversion/float_from_bool.rb +9 -0
- data/lib/instructions/conversion/float_from_int.rb +9 -0
- data/lib/instructions/conversion/int_from_bool.rb +9 -0
- data/lib/instructions/conversion/int_from_float.rb +9 -0
- data/lib/instructions/exec/exec_define.rb +9 -0
- data/lib/instructions/exec/exec_depth.rb +5 -0
- data/lib/instructions/exec/exec_do_count.rb +22 -0
- data/lib/instructions/exec/exec_do_range.rb +43 -0
- data/lib/instructions/exec/exec_do_times.rb +40 -0
- data/lib/instructions/exec/exec_duplicate.rb +7 -0
- data/lib/instructions/exec/exec_equal_q.rb +9 -0
- data/lib/instructions/exec/exec_flush.rb +5 -0
- data/lib/instructions/exec/exec_if.rb +8 -0
- data/lib/instructions/exec/exec_k.rb +4 -0
- data/lib/instructions/exec/exec_pop.rb +3 -0
- data/lib/instructions/exec/exec_rotate.rb +11 -0
- data/lib/instructions/exec/exec_s.rb +11 -0
- data/lib/instructions/exec/exec_shove.rb +14 -0
- data/lib/instructions/exec/exec_swap.rb +3 -0
- data/lib/instructions/exec/exec_y.rb +18 -0
- data/lib/instructions/exec/exec_yank.rb +12 -0
- data/lib/instructions/exec/exec_yankdup.rb +12 -0
- data/lib/instructions/float/float_abs.rb +8 -0
- data/lib/instructions/float/float_add.rb +8 -0
- data/lib/instructions/float/float_cosine.rb +8 -0
- data/lib/instructions/float/float_define.rb +9 -0
- data/lib/instructions/float/float_depth.rb +5 -0
- data/lib/instructions/float/float_divide.rb +12 -0
- data/lib/instructions/float/float_duplicate.rb +7 -0
- data/lib/instructions/float/float_equal_q.rb +8 -0
- data/lib/instructions/float/float_flush.rb +3 -0
- data/lib/instructions/float/float_greater_than_q.rb +9 -0
- data/lib/instructions/float/float_if.rb +8 -0
- data/lib/instructions/float/float_less_than_q.rb +9 -0
- data/lib/instructions/float/float_max.rb +8 -0
- data/lib/instructions/float/float_min.rb +8 -0
- data/lib/instructions/float/float_modulo.rb +12 -0
- data/lib/instructions/float/float_multiply.rb +8 -0
- data/lib/instructions/float/float_negative.rb +8 -0
- data/lib/instructions/float/float_pop.rb +3 -0
- data/lib/instructions/float/float_power.rb +12 -0
- data/lib/instructions/float/float_random.rb +3 -0
- data/lib/instructions/float/float_rotate.rb +11 -0
- data/lib/instructions/float/float_shove.rb +14 -0
- data/lib/instructions/float/float_sine.rb +8 -0
- data/lib/instructions/float/float_sqrt.rb +10 -0
- data/lib/instructions/float/float_subtract.rb +10 -0
- data/lib/instructions/float/float_swap.rb +3 -0
- data/lib/instructions/float/float_tangent.rb +8 -0
- data/lib/instructions/float/float_yank.rb +12 -0
- data/lib/instructions/float/float_yankdup.rb +12 -0
- data/lib/instructions/int/int_abs.rb +9 -1
- data/lib/instructions/int/int_add.rb +8 -0
- data/lib/instructions/int/int_define.rb +10 -1
- data/lib/instructions/int/int_depth.rb +5 -0
- data/lib/instructions/int/int_divide.rb +12 -0
- data/lib/instructions/int/int_duplicate.rb +7 -0
- data/lib/instructions/int/int_equal_q.rb +8 -0
- data/lib/instructions/int/int_flush.rb +3 -0
- data/lib/instructions/int/int_greater_than_q.rb +9 -0
- data/lib/instructions/int/int_if.rb +8 -0
- data/lib/instructions/int/int_less_than_q.rb +9 -0
- data/lib/instructions/int/int_max.rb +8 -0
- data/lib/instructions/int/int_min.rb +8 -0
- data/lib/instructions/int/int_modulo.rb +12 -0
- data/lib/instructions/int/int_multiply.rb +8 -0
- data/lib/instructions/int/int_negative.rb +8 -0
- data/lib/instructions/int/int_pop.rb +3 -0
- data/lib/instructions/int/int_power.rb +12 -0
- data/lib/instructions/int/int_random.rb +3 -0
- data/lib/instructions/int/int_rotate.rb +11 -0
- data/lib/instructions/int/int_shove.rb +14 -0
- data/lib/instructions/int/int_subtract.rb +10 -0
- data/lib/instructions/int/int_swap.rb +3 -0
- data/lib/instructions/int/int_yank.rb +14 -0
- data/lib/instructions/int/int_yankdup.rb +14 -0
- data/lib/instructions/name/name_depth.rb +5 -0
- data/lib/instructions/name/name_disable_lookup.rb +11 -0
- data/lib/instructions/name/name_duplicate.rb +7 -0
- data/lib/instructions/name/name_equal_q.rb +8 -0
- data/lib/instructions/name/name_flush.rb +3 -0
- data/lib/instructions/name/name_next.rb +7 -0
- data/lib/instructions/name/name_pop.rb +3 -0
- data/lib/instructions/name/name_random_bound.rb +9 -0
- data/lib/instructions/name/name_rotate.rb +11 -0
- data/lib/instructions/name/name_shove.rb +14 -0
- data/lib/instructions/name/name_swap.rb +3 -0
- data/lib/instructions/name/name_unbind.rb +7 -0
- data/lib/instructions/name/name_yank.rb +12 -0
- data/lib/instructions/name/name_yankdup.rb +12 -0
- data/spec/instructions/code/code_nth_cdr_spec.rb +10 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
@@ -1,3 +1,12 @@
|
|
1
|
+
# pops the top item of the +:bool+ stack and the +:name+ stack;
|
2
|
+
# if the name string is not a bound variable (as opposed to a local name),
|
3
|
+
# it binds the name to the +:bool+ ValuePoint
|
4
|
+
#
|
5
|
+
# *needs:* 1 +:bool+, 1 +:name+
|
6
|
+
#
|
7
|
+
# *pushes:* nothing
|
8
|
+
#
|
9
|
+
|
1
10
|
class BoolDefineInstruction < Instruction
|
2
11
|
include DefineInstruction
|
3
12
|
def initialize(context)
|
@@ -1,3 +1,11 @@
|
|
1
|
+
# pops the top 2 items of the +:bool+ stack;
|
2
|
+
# pushes a new ValuePoint onto the +:bool+ stack, with value +true+ if the boolean values are identical
|
3
|
+
#
|
4
|
+
# *needs:* 2 +:bool+
|
5
|
+
#
|
6
|
+
# *pushes:* 1 +:bool+
|
7
|
+
#
|
8
|
+
|
1
9
|
class BoolEqualQInstruction < Instruction
|
2
10
|
|
3
11
|
def preconditions?
|
@@ -1,3 +1,14 @@
|
|
1
|
+
# pops the top 3 items of the +:bool+ stack;
|
2
|
+
# pushes them back in _rotated_ order
|
3
|
+
#
|
4
|
+
# If they were A, B and C (with C originally at the top of the stack)
|
5
|
+
# the result will be B, C, A (with A at the top)
|
6
|
+
#
|
7
|
+
# *needs:* 3 +:bool+
|
8
|
+
#
|
9
|
+
# *pushes:* 3 +:bool+
|
10
|
+
#
|
11
|
+
|
1
12
|
class BoolRotateInstruction < Instruction
|
2
13
|
include RotateInstruction
|
3
14
|
def initialize(context)
|
@@ -1,3 +1,17 @@
|
|
1
|
+
# pops the top items of the +:bool+ and +:int+ stacks;
|
2
|
+
# pushes the +:bool+ down "into" the stack, at a level determined by the +:int+ "destination" value.
|
3
|
+
#
|
4
|
+
# If the destination value is negative or 0, the item stays on top;
|
5
|
+
# if the destination value is greater than or equal to the depth of the stack, the item goes to the bottom;
|
6
|
+
# otherwise, the item is inserted farther from the stack's top as the destination value increases.
|
7
|
+
#
|
8
|
+
# note: the destination depth is calculated after the items have been popped
|
9
|
+
#
|
10
|
+
# *needs:* 1 +:bool+, 1 +:int+
|
11
|
+
#
|
12
|
+
# *pushes:* 1 +:bool+ (sortof)
|
13
|
+
#
|
14
|
+
|
1
15
|
class BoolShoveInstruction < Instruction
|
2
16
|
include ShoveInstruction
|
3
17
|
def initialize(context)
|
@@ -1,3 +1,15 @@
|
|
1
|
+
# pops the top item of the +:int+ stack (the "index");
|
2
|
+
# then repositions an item from down "inside" the +:bool+ stack to its top.
|
3
|
+
#
|
4
|
+
# If the index value is negative or 0, the bottom item on the stack is moved;
|
5
|
+
# if the index value is greater than or equal to the depth of the stack, there is no change;
|
6
|
+
# otherwise, the index value refers to the bottom-to-top order of stack items.
|
7
|
+
#
|
8
|
+
# *needs:* 1 +:int+, 1 +:bool+
|
9
|
+
#
|
10
|
+
# *pushes:* 1 +:bool+ (sortof)
|
11
|
+
#
|
12
|
+
|
1
13
|
class BoolYankInstruction < Instruction
|
2
14
|
include YankInstruction
|
3
15
|
def initialize(context)
|
@@ -1,3 +1,15 @@
|
|
1
|
+
# pops the top item of the +:int+ stack (the "index");
|
2
|
+
# pushes a duplicate of an item from down "inside" the +:bool+ stack to its top.
|
3
|
+
#
|
4
|
+
# If the index value is negative or 0, the bottom item on the stack is copied;
|
5
|
+
# if the index value is greater than or equal to the depth of the stack, the top item is copied;
|
6
|
+
# otherwise, the index value refers to the bottom-to-top order of stack items.
|
7
|
+
#
|
8
|
+
# *needs:* 1 +:int+, 1 +:bool+
|
9
|
+
#
|
10
|
+
# *pushes:* 1 +:bool+ (sortof)
|
11
|
+
#
|
12
|
+
|
1
13
|
class BoolYankdupInstruction < Instruction
|
2
14
|
include YankdupInstruction
|
3
15
|
def initialize(context)
|
@@ -1,3 +1,12 @@
|
|
1
|
+
# pops the top item of the +:code+ stack;
|
2
|
+
# pushes a ValuePoint onto the +:bool+ stack that is +false+ only if the +:code+ item was a CodeBlockPoint,
|
3
|
+
# (that is, a multi-line Nudge program)
|
4
|
+
#
|
5
|
+
# *needs:* 1 +:code+
|
6
|
+
#
|
7
|
+
# *pushes:* 1 +:bool+
|
8
|
+
#
|
9
|
+
|
1
10
|
class CodeAtomQInstruction < Instruction
|
2
11
|
def preconditions?
|
3
12
|
needs :code, 1
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# pops the top item from the +:code+ stack;
|
2
|
+
# pushes an +:int+ with the number of items <i>in the root</i> of the +:code+ value
|
3
|
+
#
|
4
|
+
# note: if the +:code+ value does not parse, or is an atom (doesn't parse into a CodeBlockPoint),
|
5
|
+
# the result is 0; if it is an empty block, it's also 0
|
6
|
+
#
|
7
|
+
# For example:
|
8
|
+
# [1,2,[3,4],5] -> 4 backbone points
|
9
|
+
# [[1,2,3,4,5]] -> 1 backbone point
|
10
|
+
# [] -> 0 backbone points
|
11
|
+
# 1 -> 0 backbone points
|
12
|
+
#
|
13
|
+
# *needs:* 1 +:code+
|
14
|
+
#
|
15
|
+
# *pushes:* 1 +:int+
|
16
|
+
#
|
17
|
+
|
1
18
|
class CodeBackbonePointsInstruction < Instruction
|
2
19
|
|
3
20
|
def preconditions?
|
@@ -1,10 +1,24 @@
|
|
1
|
+
# pops the top item from the +:code+ stack;
|
2
|
+
# implements a equivalent to Lisp's +car+ function, treating Nudge blocks as lists:
|
3
|
+
#
|
4
|
+
# If the +:code+ value has at least two points (meaning it's a block with at least 1 element),
|
5
|
+
# the new code value is the blueprint of the first element of that block; otherwise the "new"
|
6
|
+
# code is the original item's blueprint. A new +:code+ ValuePoint is created with this value and pushed.
|
7
|
+
#
|
8
|
+
# *needs:* 1 +:code+
|
9
|
+
#
|
10
|
+
# *pushes:* 1 +:code+
|
11
|
+
#
|
12
|
+
|
1
13
|
class CodeCarInstruction < Instruction
|
2
14
|
def preconditions?
|
3
15
|
needs :code, 1
|
4
16
|
end
|
17
|
+
|
5
18
|
def setup
|
6
19
|
@arg = @context.pop_value(:code)
|
7
20
|
end
|
21
|
+
|
8
22
|
def derive
|
9
23
|
tree = NudgeProgram.new(@arg)
|
10
24
|
if tree.linked_code.kind_of?(CodeblockPoint) && (tree.points > 2)
|
@@ -14,6 +28,7 @@ class CodeCarInstruction < Instruction
|
|
14
28
|
end
|
15
29
|
@result = ValuePoint.new("code", new_tree.blueprint)
|
16
30
|
end
|
31
|
+
|
17
32
|
def cleanup
|
18
33
|
pushes :code, @result
|
19
34
|
end
|
@@ -1,3 +1,15 @@
|
|
1
|
+
# pops the top item from the +:code+ stack;
|
2
|
+
# implements a equivalent to Lisp's +cdr+ function, treating Nudge blocks as lists:
|
3
|
+
#
|
4
|
+
# If the +:code+ value has at least 2 points (meaning it's a block with at least 1 element),
|
5
|
+
# the new code value is this block with its first element deleted; otherwise, the result is
|
6
|
+
# an empty block.
|
7
|
+
#
|
8
|
+
# *needs:* 1 +:code+
|
9
|
+
#
|
10
|
+
# *pushes:* 1 +:code+
|
11
|
+
#
|
12
|
+
|
1
13
|
class CodeCdrInstruction < Instruction
|
2
14
|
def preconditions?
|
3
15
|
needs :code, 1
|
@@ -7,7 +19,7 @@ class CodeCdrInstruction < Instruction
|
|
7
19
|
end
|
8
20
|
def derive
|
9
21
|
tree = NudgeProgram.new(@arg)
|
10
|
-
if tree.linked_code.kind_of?(CodeblockPoint) && (tree.points >
|
22
|
+
if tree.linked_code.kind_of?(CodeblockPoint) && (tree.points > 1)
|
11
23
|
new_tree = tree.delete_point(2)
|
12
24
|
else
|
13
25
|
new_tree = CodeblockPoint.new([])
|
@@ -1,3 +1,23 @@
|
|
1
|
+
# pops the top 2 items from the +:code+ stack;
|
2
|
+
# pushes a new +:code+ item containing a block obtained by concatenating the other listings
|
3
|
+
#
|
4
|
+
# note: the top stack item (the "attachment") is concatenated _into_ the second popped item (the "receiver")
|
5
|
+
#
|
6
|
+
# If both items are already blocks, the new block is their concatenation;
|
7
|
+
# if the receiver is a block and the attachment isn't, the attachment is appended to the receiver;
|
8
|
+
# if the receiver is not a block, then a _surrounding_ block is constructed that contains both, in order.
|
9
|
+
#
|
10
|
+
# For example:
|
11
|
+
# [a, b] + [1,2,3] -> [a,b,1,2,3]
|
12
|
+
# [a,b] + 1 -> [a,b,1]
|
13
|
+
# a + [1,2,3] -> [a,[1,2,3]]
|
14
|
+
# a + 1 -> [a,1]
|
15
|
+
#
|
16
|
+
# *needs:* 2 +:code+
|
17
|
+
#
|
18
|
+
# *pushes:* 1 +:code+
|
19
|
+
#
|
20
|
+
|
1
21
|
class CodeConcatenateInstruction < Instruction
|
2
22
|
def preconditions?
|
3
23
|
needs :code, 2
|
@@ -1,4 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# pops the top 2 items from the +:code+ stack;
|
2
|
+
# pushes a new +:code+ item containing a block, obtained by +cons+ing the other listings, a la Lisp
|
3
|
+
#
|
4
|
+
# note: order matters, and the top stack item is the second argument, the second stack item is the first
|
5
|
+
#
|
6
|
+
# If the second argument is a block, the result is obtained by inserting the first argument
|
7
|
+
# into that block as the new first element; if the second argument isn't a block, it's first
|
8
|
+
# wrapped in one, and then the first argument is inserted into that block.
|
9
|
+
#
|
10
|
+
# For example:
|
11
|
+
# first_argument + second_argument -> cons result
|
12
|
+
# [a, b] + [1,2,3] -> [[a,b],1,2,3]
|
13
|
+
# [a,b] + 1 -> [[a,b],1]
|
14
|
+
# a + [1,2,3] -> [a,1,2,3]
|
15
|
+
# a + 1 -> [a,1]
|
16
|
+
#
|
17
|
+
# note: there are several differences between this and +code_concatenate+
|
18
|
+
#
|
19
|
+
# *needs:* 2 +:code+
|
20
|
+
#
|
21
|
+
# *pushes:* 1 +:code+
|
22
|
+
#
|
2
23
|
|
3
24
|
class CodeConsInstruction < Instruction
|
4
25
|
def preconditions?
|
@@ -1,14 +1,32 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# pops the top 2 items from the +:code+ stack;
|
2
|
+
# pushes a new +:code+ item containing a block, which is a copy of the first block in the first argument
|
3
|
+
# which contains as a child an exact copy of the second argument
|
4
|
+
#
|
5
|
+
# note: order matters, and the top stack item is the second argument, the second stack item is the first
|
6
|
+
#
|
7
|
+
# For example:
|
8
|
+
# first_argument , second_argument -> code_container result
|
9
|
+
# [a, b] , z -> []
|
10
|
+
# [a,b] , a -> [a,b]
|
11
|
+
# [[a,b],c] , a -> [a,b]
|
12
|
+
# [a,[b,[c,d]]] , b -> [b,[c,d]]
|
13
|
+
# [a,b] , [a,b] -> [a,b]
|
14
|
+
#
|
15
|
+
# *needs:* 2 +:code+
|
16
|
+
#
|
17
|
+
# *pushes:* 1 +:code+
|
18
|
+
#
|
3
19
|
|
4
20
|
class CodeContainerInstruction < Instruction
|
5
21
|
def preconditions?
|
6
22
|
needs :code, 2
|
7
23
|
end
|
24
|
+
|
8
25
|
def setup
|
9
26
|
@searching_in_this = @context.pop_value(:code)
|
10
27
|
@searching_for_this = @context.pop_value(:code)
|
11
28
|
end
|
29
|
+
|
12
30
|
def derive
|
13
31
|
needle = NudgeProgram.new(@searching_for_this).linked_code.blueprint
|
14
32
|
haystack_program = NudgeProgram.new(@searching_in_this)
|
@@ -22,6 +40,7 @@ class CodeContainerInstruction < Instruction
|
|
22
40
|
end
|
23
41
|
@result = ValuePoint.new("code", result_value)
|
24
42
|
end
|
43
|
+
|
25
44
|
def cleanup
|
26
45
|
pushes :code, @result
|
27
46
|
end
|
@@ -1,3 +1,14 @@
|
|
1
|
+
# pops the top 2 item of the +:code+ stack;
|
2
|
+
# pushes a new ValuePoint onto the +:bool+ stack, with value +true+ if the
|
3
|
+
# second argument appears as a sub-block anywhere in the first argument
|
4
|
+
#
|
5
|
+
# note: order matters, and the top stack item is the second argument, the second stack item is the first
|
6
|
+
#
|
7
|
+
# *needs:* 2 +:code+
|
8
|
+
#
|
9
|
+
# *pushes:* 1 +:bool+
|
10
|
+
#
|
11
|
+
|
1
12
|
class CodeContainsQInstruction < Instruction
|
2
13
|
def preconditions?
|
3
14
|
needs :code, 2
|
@@ -1,3 +1,12 @@
|
|
1
|
+
# pops the top item of the +:code+ stack and the +:name+ stack;
|
2
|
+
# if the name string is not a bound variable (as opposed to a local name),
|
3
|
+
# it binds the name to a new ValuePoint the +:code+ value.
|
4
|
+
#
|
5
|
+
# *needs:* 1 +:code+, 1 +:name+
|
6
|
+
#
|
7
|
+
# *pushes:* nothing
|
8
|
+
#
|
9
|
+
|
1
10
|
class CodeDefineInstruction < Instruction
|
2
11
|
def preconditions?
|
3
12
|
needs :code, 1
|
@@ -1,10 +1,16 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
|
1
|
+
# pops the top 2 items of the +:code+ stack;
|
2
|
+
# and compares their values algorithmically to obtain an +:int+ value, which it pushes
|
3
|
+
#
|
4
|
+
# The measure of discrepancy is determined by:
|
5
|
+
# 1. first creating a list of every program point's blueprint, for both +:code+ values
|
6
|
+
# 2. for every item in the _union_ of these sets of blueprints, accumulate the absolute difference in the number of times the blueprint appears in each of the two items' values
|
7
|
+
#
|
8
|
+
# the resulting +:int+ is pushed
|
9
|
+
#
|
10
|
+
# *needs:* 2 +:code+
|
11
|
+
#
|
12
|
+
# *pushes:* 1 +:int+
|
13
|
+
#
|
8
14
|
|
9
15
|
class CodeDiscrepancyInstruction < Instruction
|
10
16
|
def preconditions?
|