-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpret.py
More file actions
2150 lines (1360 loc) · 61.3 KB
/
Copy pathinterpret.py
File metadata and controls
2150 lines (1360 loc) · 61.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
import os.path
import stat
from xml.etree import ElementTree
from nis import match
#------------------------------------------------#
# #
# Classes #
# #
#------------------------------------------------#
class CallStack():
def __init__( self ):
self.stack = []
def is_empty( self ):
return len( self.stack ) == 0
def push( self, execute_index ):
self.stack.append( execute_index )
def get_top( self ):
if self.is_empty():
sys.stderr.write("Zasobnik volani je prazdny\n")
exit(56)
return self.stack[ len( self.stack ) - 1 ]
def pop( self ):
self.stack.pop()
class Label:
def __init__( self, name, execute_index ):
self.name = name
self.execute_index = execute_index
class Labels:
def __init__( self ):
self.labels = []
def add_label( self, name, execute_index ):
# Create_new variable indicates wheter method should append new label or not
create_new = True
# Check if label already exists
for label in self.labels:
if label.name == name:
create_new = False
# Check if labels with same name have same execute index
if label.execute_index != execute_index:
sys.stderr.write("Semanticka chyba\n")
exit(52)
# Create new label
if create_new:
label = Label( name, execute_index )
# Append label to list
self.labels.append( label )
def get_execute_index( self, label_argument ):
if label_argument.type != "label":
sys.stderr.write("Semanticka chyba\n")
exit(52)
for label in self.labels:
if label.name == label_argument.value:
return label.execute_index
sys.stderr.write("Skok na neexistujuce navesti\n")
exit(52)
class DataStack:
def __init__( self ):
self.stack = []
def is_empty( self ):
return len( self.stack ) == 0
def push( self, instruction_argument ):
self.stack.append( instruction_argument )
def pop( self ):
if self.is_empty():
sys.stderr.write("Chýbajúca hodnota na datovom zásobníku\n")
exit(56)
self.stack.pop()
def get_top( self ):
return self.stack[ len(self.stack) - 1 ]
class InstructionArgument:
def __init__( self, type, value ):
self.type = type
self.value = value
def is_variable( self ):
return self.type == "var"
def is_constant( self ):
return self.type in ["int","bool","string","nil"]
def get_variable_frame( self ):
if not self.is_variable():
return None
return self.value[0: self.value.find("@")]
def get_variable_name( self ):
if not self.is_variable():
return None
return self.value[self.value.find("@") + 1:]
class Instruction:
def __init__( self, opcode, order ):
self.opcode = opcode
self.order = order
self.arguments = []
def add_argument( self, instruction_argument ):
self.arguments.append( instruction_argument )
# Class represents variable
class Variable:
# Variable has it's name, type and value
def __init__( self, name, type, value ):
self.name = name
self.type = type
self.value = value
# Method for setting variable attributes
def set( self, name, type, value ):
self.name = name
self.type = type
self.value = value
def has_value( self ):
return self.value is not None
# Class represents list of variables
class Frame:
# Frame has list of variables
def __init__( self ):
self.variables = []
# Method for adding variable to the frame
# When variable with the same name already exists in frame,
# method throws error
def add_variable( self, variable_name ):
# Check if variable with same name already exists in the frame
if self.contains_variable( variable_name ):
# Redefinition of variable
sys.stderr.write("Redefinícia premennej")
exit(52)
# Add new variable into frame
self.variables.append( Variable( variable_name, None, None ) )
# Method for finding variable inside frame by variable's name
# Method returns True if variable is found, otherwise it returns False
def contains_variable( self, variable_name ):
# Loop trough all variables
for variable in self.variables:
# If variable names match, return True
if variable.name == variable_name:
return True
# Return False when variablew was not found
return False
# Method for getting variable inside frame by variable's name
# Method return variable object on success, None on failure
def get_variable( self, variable_name ):
# Loop trough all variables
for variable in self.variables:
# If variables name match, return variable
if variable.name == variable_name:
return variable
# Return None on failure
return None
# Destructor of frame
def __del__( self ):
# Delete all variables inside frame
for variable in self.variables:
del variable
# Class for the stack of frames
class FrameStack:
# Frame stack is implemented as list
def __init__( self ):
self.stack = []
# Method for pushing frame into stack
def push( self, frame ):
self.stack.append( frame )
# Method for poping out frame from stack
def pop( self ):
self.stack.pop()
# Method returns boolean that says wheter
# stack is empty or not
def is_empty( self ):
return len( self.stack ) == 0
# Method for getting local frame,
# that should be frame on top of the stack
# If stack is empty, method returns None
def get_local_frame( self ):
# If stack is empty, return None
if self.is_empty():
return None
# If stack is not empty, return top frame from stack
return self.stack[ len( self.stack ) - 1 ]
# Class represents program counter with all the instructions
# and current executt index - position of instruction
# to be execute
class ProgramCounter:
# Program counter contains list of instructions
# and current execute index starting with value 1
def __init__(self):
self.instructions = []
self.execute_index = 1
# Method for adding instruction into program counter
def add_instruction( self, instruction ):
self.instructions.append( instruction )
# Method for changing current execute index
def move_to_instruction( self, execute_index ):
self.execute_index = execute_index
# Method returns True, if program counter contains
# instruction with given order
# Otherwise it returns False
def contains_order( self, order ):
for instruction in self.instructions:
if instruction.order == order:
return True
return False
# Class program contains all info needed
# to interpret a program
class Program:
# Program contains program counter, global frame, temporary frame
# and stack of frames
def __init__( self, input_lines ):
self.program_counter = ProgramCounter()
self.global_frame = Frame()
self.temporary_frame = None
self.frame_stack = FrameStack()
self.data_stack = DataStack()
self.labels = Labels()
self.input_lines = input_lines
self.call_stack = CallStack()
def find_variable_by_argument( self, argument ):
# Get the variable frame and name
variable_frame = argument.get_variable_frame()
variable_name = argument.get_variable_name()
# Decide where the variable should be located
if variable_frame == "GF":
variable = self.global_frame.get_variable( variable_name )
elif variable_frame == "LF":
# Check if local frame exists
if self.frame_stack.is_empty():
sys.stderr.write("Lokálny rámec nie je definovaný\n")
exit(55)
variable = self.frame_stack.get_local_frame().get_variable( variable_name )
elif variable_frame == "TF":
# Check if temporary frame exists
if self.temporary_frame is None:
sys.stderr.write("Dočasný rámec nie je definovaný\n")
exit(55)
variable = self.temporary_frame.get_variable( variable_name )
# Check if variable exists
if variable is None:
sys.stderr.write("Premenná neexistuje\n")
exit(54)
# Return found variable
return variable
def get_variable_by_argument( self, argument ):
# Find the variable
variable = self.find_variable_by_argument( argument )
# Check if variable has value
if variable.value is None:
sys.stderr.write("Chybajúca hodnota v premennej\n")
exit(56)
return variable
# Class interpret is used to execute instructions
class Interpret:
# Help method for getting operand type and value
def get_operand_type_and_value( self, program, operand_argument ):
# Check if operand is variable
if operand_argument.is_variable():
# Get the variable
operand_variable = program.get_variable_by_argument( operand_argument )
# Return operand type and value
return operand_variable.type, operand_variable.value
else:
# Return operand type and value
return operand_argument.type, operand_argument.value
# Help method for getting operand types and values
def get_operand_types_and_values( self, program, operand_arguments ):
# Define lists for operands' types and values
operand_types = []
operand_values = []
# For every operand argument
for operand_argument in operand_arguments:
# Get the operand's type and value
operand_type, operand_value = self.get_operand_type_and_value( program, operand_argument )
# Save the operand's type and value
operand_types.append( operand_type )
operand_values.append( operand_value )
# Return operands's types and values
return operand_types, operand_values
# MOVE
def execute_move_instruction( self, program, instruction ):
# Get the destination argument
dest_argument = instruction.arguments[0]
# Destination argument must be variable type
if not dest_argument.is_variable():
sys.stderr.write("Zlý typ operandov\n")
exit(53)
# Find variable by destination argument
dest_variable = program.find_variable_by_argument( dest_argument )
# Get the source argument
source_argument = instruction.arguments[1]
# If source is a variable
if source_argument.type == "var":
# Get source variable by argument's value
source_variable = program.find_variable_by_argument( source_argument )
# Get source's type and value from variable
source_type = source_variable.type
source_value = source_variable.value
# Verify source variable has value
if not source_variable.has_value():
sys.stderr.write("V premennej chyba hodnota")
exit(56)
else:
# Get source type and value from argument
source_type = source_argument.type
source_value = source_argument.value
# Set source attributes to destination variable
dest_variable.set( dest_variable.name, source_type, source_value )
# If destination variable is now string, translate it into readable form
if dest_variable.type == "string":
dest_variable.value = translate_string_value( dest_variable.value )
# CREATEFRAME
def execute_createframe_instruction( self, program ):
# If there is already a temporary frame
if program.temporary_frame is not None:
del program.temporary_frame
# Create new temporary frame
program.temporary_frame = Frame()
# PUSHFRAME
def execute_pushframe_instruction( self, program ):
# If temporary frame doesn't exist
if program.temporary_frame is None:
sys.stderr.write("Dočasný rámec nie je definovaný\n")
exit(55)
else:
# Push temporary frame into frame stack
program.frame_stack.push( program.temporary_frame )
# Delete temporary frame and undefine it
del program.temporary_frame
program.temporary_frame = None
# POPFRAME
def execute_popframe_instruction( self, program ):
# Check if current local frame exists
if program.frame_stack.is_empty():
sys.stderr.write("Lokálny rámec nie je definovaný\n")
exit(55)
else:
# Delete temporary frame if it exists
if program.temporary_frame is not None:
del program.temporary_frame
# Save the current local frame into temporary frame
program.temporary_frame = program.frame_stack.get_local_frame()
# Pop the current local frame from the frame stack
program.frame_stack.pop()
# DEFVAR
def execute_defvar_instruction( self, program, instruction ):
# Get the argument
argument = instruction.arguments[0]
if not argument.is_variable():
# Operand has bad type
sys.stderr.write("Zly typ operandu\n")
exit(53)
# Get the variable parameters
variable_frame = argument.get_variable_frame()
variable_name = argument.get_variable_name()
if variable_frame == "GF":
# Add variable into the global frame
program.global_frame.add_variable( variable_name )
elif variable_frame == "LF":
# Get the local frame
local_frame = program.frame_stack.get_local_frame()
# Check if there is any local frame
if program.frame_stack.get_local_frame() is None:
# Local frame doesn't exist
sys.stderr.write("Lokálny rámec nie je definovaný\n")
exit(55)
# Add variable into the current local frame
local_frame.add_variable( variable_name )
elif variable_frame == "TF":
# Check if there is any temporary frame
if program.temporary_frame is None:
# Temporary frame doesn't exist
sys.stderr.write("Dočasný rámec nie je definovaný\n")
exit(55)
# Add variable into the temporary frame
program.temporary_frame.add_variable( variable_name )
# CALL
def execute_call_instruction( self, program, instruction ):
# Get label argument
label_argument = instruction.arguments[0]
# Get the execute index from label
execute_index = program.labels.get_execute_index( label_argument )
# Save current execute index to call stack
program.call_stack.push( program.program_counter.execute_index )
# Do the jump
program.program_counter.move_to_instruction( execute_index )
# RETURN
def execute_return_instruction( self, program ):
# Get return execute index
execute_index = program.call_stack.get_top()
program.program_counter.move_to_instruction( execute_index )
# Pop from the call stack
program.call_stack.pop()
# PUSHS
def execute_pushs_instruction( self, program, instruction ):
# Get the argument
argument = instruction.arguments[0]
# If argument is variable
if argument.is_variable():
# Get the variable
variable = program.find_variable_by_argument( argument )
new_argument_type = variable.type
new_argument_value = variable.value
else:
new_argument_type = argument.type
new_argument_value = argument.value
# Create new instruction argument for data stack purposes
new_argument = InstructionArgument( new_argument_type, new_argument_value )
# Push new argument to the data stack
program.data_stack.push( new_argument )
# POPS
def execute_pops_instruction( self, program, instruction ):
# If data stack is empty, throw error
if program.data_stack.is_empty():
sys.stderr.write("Chýbajúca hodnota na datovom zásobníku\n")
exit(56)
# Get the destination argument
dest_argument = instruction.arguments[0]
# Create a temporary instruction that will be
# passed to execute_move_instruction() method
tmp_instruction = Instruction( None, None )
# Fill the temporary instruction
tmp_instruction.add_argument( dest_argument )
tmp_instruction.add_argument( program.data_stack.get_top() )
# Call the execute_move_instruction() method
self.execute_move_instruction( program, tmp_instruction )
# Delete temporary instruction and it's arguments
del tmp_instruction.arguments[1]
del tmp_instruction.arguments[0]
del tmp_instruction
# Pop from data stack
program.data_stack.pop()
# Help method for aritmetic instructions
def get_aritmetic_operands_values( self, program, operand_arguments ):
# Define array for operands' values
operand_values = []
# For every operand argument
for operand_argument in operand_arguments:
# If operand is variable
if operand_argument.is_variable():
# Get the operand's variable
operand_variable = program.get_variable_by_argument( operand_argument )
# Operand must by type of int
if operand_variable.type != "int":
sys.stderr.write("Zly typ operandu\n")
exit(53)
# Get value of the operand's variable
operand_values.append( operand_variable.value )
else:
# First operand must by type of int
if operand_argument.type != "int":
sys.stderr.write("Zly typ operandu\n")
exit(53)
# Get value of the first operand's argument
operand_values.append( operand_argument.value )
return operand_values
# ADD
def execute_add_instruction( self, program, instruction ):
# Get destination argument
dest_argument = instruction.arguments[0]
# Get destination variable
dest_variable = program.find_variable_by_argument( dest_argument )
# Get operands' arguments
operand_arguments = [instruction.arguments[1], instruction.arguments[2]]
# Get operands' values
operand_values = self.get_aritmetic_operands_values( program, operand_arguments )
# Calculate result from operand values
result = int( operand_values[0] ) + int( operand_values[1] )
# Save result to destination variable
dest_variable.set( dest_variable.name, "int", result)
# SUB
def execute_sub_instruction( self, program, instruction ):
# Get destination argument
dest_argument = instruction.arguments[0]
# Get destination variable
dest_variable = program.find_variable_by_argument( dest_argument )
# Get operands' arguments
operand_arguments = [instruction.arguments[1], instruction.arguments[2]]
# Get operands' values
operand_values = self.get_aritmetic_operands_values( program, operand_arguments )
# Calculate result from operand values
result = int( operand_values[0] ) - int( operand_values[1] )
# Save result to destination variable
dest_variable.set( dest_variable.name, "int", result)
# MUL
def execute_mul_instruction( self, program, instruction ):
# Get destination argument
dest_argument = instruction.arguments[0]
# Get destination variable
dest_variable = program.find_variable_by_argument( dest_argument )
# Get operands' arguments
operand_arguments = [instruction.arguments[1], instruction.arguments[2]]
# Get operands' values
operand_values = self.get_aritmetic_operands_values( program, operand_arguments )
# Calculate result from operand values
result = int( operand_values[0] ) * int( operand_values[1] )
# Save result to destination variable
dest_variable.set( dest_variable.name, "int", result)
# IDIV
def execute_idiv_instruction( self, program, instruction ):
# Get destination argument
dest_argument = instruction.arguments[0]
# Get destination variable
dest_variable = program.find_variable_by_argument( dest_argument )
# Get operands' arguments
operand_arguments = [instruction.arguments[1], instruction.arguments[2]]
# Get operands' values
operand_values = self.get_aritmetic_operands_values( program, operand_arguments )
# Check if second operand's value is zero
# Division by zero
if int( operand_values[1] ) == 0:
sys.stderr.write("Delenie nulou\n")
exit(57)
# Calculate result from operand values
result = int( operand_values[0] ) // int( operand_values[1] )
# Save result to destination variable
dest_variable.set( dest_variable.name, "int", result)
# Help method for comparison instructions
def get_comparison_operands_values_and_types( self, program, operand_arguments, eq ):
# Define list for operand values
operand_values = []
# Define list for operand types
operand_types = []
# For every operand argument
for operand_argument in operand_arguments:
# If operand is variable
if operand_argument.is_variable():
# Get the variable
operand_variable = program.get_variable_by_argument( operand_argument )
# Save operand's value and type
operand_values.append( operand_variable.value )
operand_types.append( operand_variable.type )
else:
# Save operand's value and type
operand_values.append( operand_argument.value )
operand_types.append( operand_argument.type )
if eq:
# If one or two operands have type nil
if "nil" not in operand_types:
# Check if operands' types match
if operand_types[0] != operand_types[1]:
# Operand has bad type
sys.stderr.write("Zly typ operandu\n")
exit(53)
# Return operands' values and their types
return operand_values, operand_types
else:
# Check if operands' types match
if operand_types[0] != operand_types[1]:
# Operand has bad type
sys.stderr.write("Zly typ operandu\n")
exit(53)
# Return operands' values and their types
return operand_values, operand_types
# LT
def execute_lt_instruction( self, program, instruction ):
# Get destination argument
dest_argument = instruction.arguments[0]
# Get destination variable
dest_variable = program.find_variable_by_argument( dest_argument )
# Get operands' arguments
operand_arguments = [instruction.arguments[1], instruction.arguments[2]]
# Get operands' values
operand_values, operand_types = self.get_comparison_operands_values_and_types( program, operand_arguments, False )
# Operand cannot be nil
if "nil" in operand_types:
sys.stderr.write("Zly typ operandu\n")
exit(53)
# Get the result of camparison
result = operand_values[0] < operand_values[1]
# Save result of comparison to destination variable
if result:
dest_variable.set( dest_variable.name, "bool", "true" )
else:
dest_variable.set( dest_variable.name, "bool", "false" )
# GT
def execute_gt_instruction( self, program, instruction ):
# Get destination argument
dest_argument = instruction.arguments[0]
# Get destination variable
dest_variable = program.find_variable_by_argument( dest_argument )
# Get operands' arguments
operand_arguments = [instruction.arguments[1], instruction.arguments[2]]
# Get operands' values
operand_values, operand_types = self.get_comparison_operands_values_and_types( program, operand_arguments, False )
# Operand cannot be nil
if "nil" in operand_types:
sys.stderr.write("Zly typ operandu\n")
exit(53)
# Get the result of camparison
result = operand_values[0] > operand_values[1]
# Save result of comparison to destination variable
if result:
dest_variable.set( dest_variable.name, "bool", "true" )
else:
dest_variable.set( dest_variable.name, "bool", "false" )
# EQ
def execute_eq_instruction( self, program, instruction ):
# Get destination argument
dest_argument = instruction.arguments[0]
# Get destination variable
dest_variable = program.find_variable_by_argument( dest_argument )
# Get operands' arguments
operand_arguments = [instruction.arguments[1], instruction.arguments[2]]
# Get operands' values
operand_values, operand_types = self.get_comparison_operands_values_and_types( program, operand_arguments, True )
# If one or two of the operands are nil
if "nil" in operand_types:
# If there is any other operand type
if "int" in operand_types or "string" in operand_types or "bool" in operand_types:
result = False
else:
# If there are only two nil type operands
result = True
else:
# If there is no nil in operands
# Check if operands are same type
if operand_types[0] == operand_types[1]:
# Get the result of camparison
result = operand_values[0] == operand_values[1]
else:
# Operands have bad type
sys.stderr.write("Zly typ operandu\n")
exit(53)
# Save result of comparison to destination variable
if result:
dest_variable.set( dest_variable.name, "bool", "true" )
else:
dest_variable.set( dest_variable.name, "bool", "false" )
# Help method for logical instructions
def get_logical_operands_values( self, program, operand_arguments ):
# Define list for operand values
operand_values = []
# For every operand argument
for operand_argument in operand_arguments:
# Check if operand is variable
if operand_argument.is_variable():
# Get the variable
operand_variable = program.get_variable_by_argument( operand_argument )
# Operand type must be bool
if operand_variable.type != "bool":
# Operand has bad type
sys.stderr.write("Zly typ operandu\n")
exit(53)
operand_values.append( operand_variable.value )
else:
# Operand type must be bool
if operand_argument.type != "bool":
# Operand has bad type
sys.stderr.write("Zly typ operandu\n")
exit(53)
operand_values.append( operand_argument.value )
return operand_values
# AND
def execute_and_instruction( self, program, instruction ):
# Get destination argument
dest_argument = instruction.arguments[0]