Class: CodeMemberQInstruction
Instance Attribute Summary
Attributes inherited from Instruction
#context
Instance Method Summary
collapse
Methods inherited from Instruction
all_instructions, #go, inherited, #initialize, #needs, #pushes, to_nudgecode
Constructor Details
This class inherits a constructor from Instruction
Instance Method Details
#cleanup ⇒ Object
37
38
39
|
# File 'lib/instructions/code/code_member_q.rb', line 37
def cleanup
pushes :bool, @result
end
|
#derive ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/instructions/code/code_member_q.rb', line 23
def derive
looking_for_this = NudgeProgram.new(@arg1)
tree = NudgeProgram.new(@arg2)
if tree.parses? && looking_for_this.parses?
if tree.linked_code.kind_of?(CodeblockPoint)
found = tree[1].contents.any? {|branch| branch.blueprint == looking_for_this.blueprint}
else
found = (tree.blueprint == looking_for_this.blueprint)
end
else
found = false
end
@result = ValuePoint.new("bool", found)
end
|
#preconditions? ⇒ Boolean
16
17
18
|
# File 'lib/instructions/code/code_member_q.rb', line 16
def preconditions?
needs :code, 2
end
|
#setup ⇒ Object
19
20
21
22
|
# File 'lib/instructions/code/code_member_q.rb', line 19
def setup
@arg2 = @context.pop_value(:code)
@arg1 = @context.pop_value(:code)
end
|