| 1 | #!/usr/bin/perl -I../lib/ -Ilib | ||||||||||||||||||||||||||||||||||||||||||
| 2 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Assemble and execute code written in the Zero assembler programming language. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Philip R Brenan at appaapps dot com, Appa Apps Ltd Inc., 2023 | ||||||||||||||||||||||||||||||||||||||||||
| 5 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # Pointless adds and subtracts by 0. Perhaps we should flag adds and subtracts by 1 as well so we can have an instruction optimized for these variants. | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Assign needs to know from whence we got the value so we can write a better error message when it is no good | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # Count number of ways an if statement actually goes. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # doubleWrite, not read, rewrite need make-over | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use v5.30; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | package Zero::Emulator; | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our $VERSION = 20230519; # Version | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use warnings FATAL=>qw(all); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Data::Dump qw(dump); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Data::Table::Text qw(:all); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | eval "use Test::More tests=>387" unless caller; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | makeDieConfess; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | our $memoryTechnique; # Undef or the address of a sub that loads the memory handlers into an execution environment. | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my sub maximumInstructionsToExecute {1e6} # Maximum number of subroutines to execute | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maximumInstructionsToExecute: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | sub ExecutionEnvironment(%) # Execution environment for a block of code. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | {my (%options) = @_; # Execution options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ExecutionEnvironment: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | my $exec= genHash("Zero::Emulator", # Execution results | ||||||||||||||||||||||||||||||||||||||||||
| 29 | calls=> [], # Call stack | ||||||||||||||||||||||||||||||||||||||||||
| 30 | block=> $options{code}, # Block of code to be executed | ||||||||||||||||||||||||||||||||||||||||||
| 31 | count=> 0, # Executed instructions count | ||||||||||||||||||||||||||||||||||||||||||
| 32 | counts=> {}, # Executed instructions by name counts | ||||||||||||||||||||||||||||||||||||||||||
| 33 | tally=> 0, # Tally executed instructions in a bin of this name | ||||||||||||||||||||||||||||||||||||||||||
| 34 | tallyCount=> 0, # Executed instructions tally count | ||||||||||||||||||||||||||||||||||||||||||
| 35 | tallyCounts=> {}, # Executed instructions by name tally counts | ||||||||||||||||||||||||||||||||||||||||||
| 36 | tallyTotal=> {}, # Total instructions executed in each tally | ||||||||||||||||||||||||||||||||||||||||||
| 37 | instructionPointer=> 0, # Current instruction | ||||||||||||||||||||||||||||||||||||||||||
| 38 | memory=> [], # Memory contents at the end of execution | ||||||||||||||||||||||||||||||||||||||||||
| 39 | memoryString=> '', # Memory packed into one string | ||||||||||||||||||||||||||||||||||||||||||
| 40 | memoryType=> [], # Memory contents at the end of execution | ||||||||||||||||||||||||||||||||||||||||||
| 41 | rw=> [], # Read / write access to memory | ||||||||||||||||||||||||||||||||||||||||||
| 42 | read=> [], # Records whether a memory address was ever read allowing us to find all the unused locations | ||||||||||||||||||||||||||||||||||||||||||
| 43 | notReadAddresses=> [], # Memory addresses never read | ||||||||||||||||||||||||||||||||||||||||||
| 44 | notExecuted=> [], # Instructions not executed | ||||||||||||||||||||||||||||||||||||||||||
| 45 | out=> '', # The out channel. L<Out> writes an array of items to this followed by a new line. L<out> does the same but without the new line. | ||||||||||||||||||||||||||||||||||||||||||
| 46 | doubleWrite=> {}, # Source of double writes {instruction number} to count - an existing value was overwritten before it was used | ||||||||||||||||||||||||||||||||||||||||||
| 47 | pointlessAssign=> {}, # Location already has the specified value | ||||||||||||||||||||||||||||||||||||||||||
| 48 | suppressOutput=> $options{suppressOutput}, # If true the Out instruction will only write to the execution out array but not to stdout as well. | ||||||||||||||||||||||||||||||||||||||||||
| 49 | stopOnError=> $options{stopOnError}, # Stop on non fatal errors if true | ||||||||||||||||||||||||||||||||||||||||||
| 50 | trace=> $options{trace}, # Trace all statements | ||||||||||||||||||||||||||||||||||||||||||
| 51 | traceLabels=> undef, # Trace changes in execution flow | ||||||||||||||||||||||||||||||||||||||||||
| 52 | printNotRead=> $options{NotRead}, # Memory locations never read | ||||||||||||||||||||||||||||||||||||||||||
| 53 | printDoubleWrite=> $options{doubleWrite}, # Double writes: earlier instruction number to later instruction number | ||||||||||||||||||||||||||||||||||||||||||
| 54 | printPointlessAssign=> $options{pointlessAssign}, # Pointless assigns {instruction number} to count - address already has the specified value | ||||||||||||||||||||||||||||||||||||||||||
| 55 | watch=> [], # Addresses to watch for changes | ||||||||||||||||||||||||||||||||||||||||||
| 56 | widestAreaInArena=> [], # Track highest array access in each arena | ||||||||||||||||||||||||||||||||||||||||||
| 57 | instructionCounts=> {}, # The number of times each actual instruction is executed | ||||||||||||||||||||||||||||||||||||||||||
| 58 | lastAssignArena=> undef, # Last assignment performed - arena | ||||||||||||||||||||||||||||||||||||||||||
| 59 | lastAssignArea=> undef, # Last assignment performed - area | ||||||||||||||||||||||||||||||||||||||||||
| 60 | lastAssignAddress=> undef, # Last assignment performed - address | ||||||||||||||||||||||||||||||||||||||||||
| 61 | lastAssignType=> undef, # Last assignment performed - name of area assigned into | ||||||||||||||||||||||||||||||||||||||||||
| 62 | lastAssignValue=> undef, # Last assignment performed - value | ||||||||||||||||||||||||||||||||||||||||||
| 63 | lastAssignBefore=> undef, # Prior value of memory area before assignment | ||||||||||||||||||||||||||||||||||||||||||
| 64 | freedArrays=> [], # Arrays that have been recently freed and can thus be reused | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | checkArrayNames=> ($options{checkArrayNames} // 1), # Check array names to confirm we are accessing the expected data | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options{"checkArrayNames"} // 1
MC/DC0%0/1
$options{"checkArrayNames"} // 1
$options{"checkArrayNames"}
Truth table50%1/2
A
A= $options{"checkArrayNames"}
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | GetMemoryHeaps=> \&getMemoryHeaps, # Low level memory access - arenas in use | ||||||||||||||||||||||||||||||||||||||||||
| 67 | GetMemoryArea=> \&getMemoryArea, # Low level memory access - area | ||||||||||||||||||||||||||||||||||||||||||
| 68 | GetMemoryLocation=> \&getMemoryLocation, # Low level memory access - location | ||||||||||||||||||||||||||||||||||||||||||
| 69 | AllocMemoryArea=> \&allocMemoryArea, # Low level memory access - allocate new area | ||||||||||||||||||||||||||||||||||||||||||
| 70 | FreeMemoryArea=> \&freeMemoryArea, # Low level memory access - free an area | ||||||||||||||||||||||||||||||||||||||||||
| 71 | ResizeMemoryArea=> \&resizeMemoryArea, # Low level memory access - resize an area | ||||||||||||||||||||||||||||||||||||||||||
| 72 | PushMemoryArea=> \&pushMemoryArea, # Low level memory access - push onto area | ||||||||||||||||||||||||||||||||||||||||||
| 73 | PopMemoryArea=> \&popMemoryArea, # Low level memory access - pop from area | ||||||||||||||||||||||||||||||||||||||||||
| 74 | memoryStringElementWidth=> 0, # Width in bytes of a memory area element | ||||||||||||||||||||||||||||||||||||||||||
| 75 | memoryStringUserElements=> 0, # Maximum number of elements in the user area of a heap arena if such is required by the memory allocation technique in play | ||||||||||||||||||||||||||||||||||||||||||
| 76 | memoryStringSystemElements=> 0, # Maximum number of elements in the system area of a heap arena if such is required by the memory allocation technique in play | ||||||||||||||||||||||||||||||||||||||||||
| 77 | memoryStringTotalElements=> 0, # Maximum number of elements in total in an area in a heap arena if such is required by the memory allocation technique in play | ||||||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | $memoryTechnique->($exec) if $memoryTechnique; # Load memory handlers if a different memory handling system has been requested | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | if (defined(my $n = $options{maximumAreaSize})) # Override the maximum number of elements in an array from the default setting if requested | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | {$exec->memoryStringUserElements = $n; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $exec->memoryStringTotalElements = $n + $exec->memoryStringSystemElements; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | $exec | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | my sub Code(%) # A block of code | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | {my (%options) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Code: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | genHash("Zero::Emulator::Code", # Description of a call stack entry | |||||||||||||||||||||||||||||||||||||||||
| 93 | code=> [], # An array of instructions | ||||||||||||||||||||||||||||||||||||||||||
| 94 | variables=> AreaStructure("Variables"), # Variables in this block of code | ||||||||||||||||||||||||||||||||||||||||||
| 95 | labels=> {}, # Label name to instruction | ||||||||||||||||||||||||||||||||||||||||||
| 96 | labelCounter=> 0, # Label counter used to generate unique labels | ||||||||||||||||||||||||||||||||||||||||||
| 97 | files=> [], # File number to file name | ||||||||||||||||||||||||||||||||||||||||||
| 98 | procedures=> {}, # Procedures defined in this block of code | ||||||||||||||||||||||||||||||||||||||||||
| 99 | arrayNames=> {stackArea=>0, params=>1, return=>2}, # Array names as strings to numbers | ||||||||||||||||||||||||||||||||||||||||||
| 100 | arrayNumbers=> [qw(stackArea params return)], # Array number to name | ||||||||||||||||||||||||||||||||||||||||||
| 101 | %options, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | my sub stackFrame(%) # Describe an entry on the call stack: the return address, the parameter list length, the parameter list address, the line of code from which the call was made, the file number of the file from which the call was made | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | {my (%options) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackFrame: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | genHash("Zero::Emulator::StackFrame", # Description of a stack frame. A stack frame provides the context in which a method runs. | ||||||||||||||||||||||||||||||||||||||||||
| 109 | target=> $options{target}, # The address of the subroutine being called | ||||||||||||||||||||||||||||||||||||||||||
| 110 | instruction=> $options{call}, # The address of the instruction making the call | ||||||||||||||||||||||||||||||||||||||||||
| 111 | stackArea=> $options{stackArea}, # Memory area containing data for this method | ||||||||||||||||||||||||||||||||||||||||||
| 112 | params=> $options{params}, # Memory area containing parameter list | ||||||||||||||||||||||||||||||||||||||||||
| 113 | return=> $options{return}, # Memory area containing returned result | ||||||||||||||||||||||||||||||||||||||||||
| 114 | line=> $options{line}, # The line number from which the call was made | ||||||||||||||||||||||||||||||||||||||||||
| 115 | file=> $options{file}, # The file number from which the call was made - this could be folded into the line number but for reasons best known to themselves people who cannot program very well often scatter projects across several files a practice that is completely pointless in this day of git and so can only lead to chaos and confusion | ||||||||||||||||||||||||||||||||||||||||||
| 116 | variables=> $options{variables}, # Variables local to this stack frame | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | sub Zero::Emulator::Code::instruction($%) #P Create a new instruction. | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | {my ($block, %options) = @_; # Block of code descriptor, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instruction: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my ($package, $fileName, $line) = caller($options{level} // 1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"level"} // 1
MC/DC0%0/1
$options{"level"} // 1
$options{"level"}
Truth table0%0/2
A
A= $options{"level"}
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | my sub stackTrace() # File numbers and line numbers of callers | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | {my @s; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackTrace: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | for my $c(1..99) | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | {my @c = caller($c); | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | last unless @c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | push @s, [$c[1], $c[2]]; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | \@s | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ($options{action} !~ m(\Avariable\Z)i) # Non variable | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | {push $block->code->@*, my $i = genHash("Zero::Emulator::Code::Instruction", # Instruction details | ||||||||||||||||||||||||||||||||||||||||||
| 137 | action=> $options{action }, # Instruction name | ||||||||||||||||||||||||||||||||||||||||||
| 138 | number=> $options{number }, # Instruction sequence number | ||||||||||||||||||||||||||||||||||||||||||
| 139 | source=> $options{source }, # Source memory address | ||||||||||||||||||||||||||||||||||||||||||
| 140 | source2=> $options{source2 }, # Secondary source memory address | ||||||||||||||||||||||||||||||||||||||||||
| 141 | target=> $options{target }, # Target memory address | ||||||||||||||||||||||||||||||||||||||||||
| 142 | jump=> $options{jump }, # Jump target | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # procedure=> $options{procedure}, # Procedure target | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | line=> $line, # Line in source file at which this instruction was encoded | |||||||||||||||||||||||||||||||||||||||||
| 145 | file=> fne $fileName, # Source file in which instruction was encoded | ||||||||||||||||||||||||||||||||||||||||||
| 146 | context=> stackTrace(), # The call context in which this instruction was created | ||||||||||||||||||||||||||||||||||||||||||
| 147 | executed=> 0, # The number of times this instruction was executed | ||||||||||||||||||||||||||||||||||||||||||
| 148 | step=> 0, # The last time (in steps from the start) that this instruction was executed | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return $i; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | sub Zero::Emulator::Code::codeToString($) #P Code as a string. | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | {my ($block) = @_; # Block of code | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
codeToString: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my @T; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my @code = $block->code->@*; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | for my $i(@code) | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | {my $n = $i->number; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $a = $i->action; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $t = $block->referenceToString($i->{target}); | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $s = $block->referenceToString($i->{source}); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $S = $block->referenceToString($i->{source2}); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $T = sprintf "%04d %8s %12s %12s %12s", $n, $a, $t, $s, $S; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | push @T, $T =~ s(\s+\Z) ()sr; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | join "\n", @T, ''; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | sub contextString($$$) #P Stack trace back for this instruction. | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | {my ($exec, $i, $title) = @_; # Execution environment, Instruction, title | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contextString: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my @s = $title; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if (! $exec->suppressOutput) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | {for my $c($i->context->@*) | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | {push @s, sprintf " at %s line %d", $$c[0], $$c[1]; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | join "\n", @s | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | sub Zero::Emulator::Code::Instruction::contextString($) #P Stack trace back for this instruction. | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | {my ($i) = @_; # Instruction | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contextString: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my @s; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | for my $c($i->context->@*) | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | {push @s, sprintf " at %s line %d", $$c[0], $$c[1]; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | @s; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | sub AreaStructure($@) # Describe a data structure mapping a memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | ▶ | {my ($structureName, @names) = @_; # Structure name, fields names | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AreaStructure: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | my $d = genHash("Zero::Emulator::AreaStructure", # Description of a data structure mapping a memory area | |||||||||||||||||||||||||||||||||||||||||
| 197 | structureName=> $structureName, # Name of the structure | ||||||||||||||||||||||||||||||||||||||||||
| 198 | fieldOrder=> [], # Order of the elements in the structure, in effect, giving the offset of each element in the data structure | ||||||||||||||||||||||||||||||||||||||||||
| 199 | fieldNames=> {}, # Maps the names of the fields to their offsets in the structure | ||||||||||||||||||||||||||||||||||||||||||
| 200 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 3 | $d->field($_) for @names; # Add the field descriptions | |||||||||||||||||||||||||||||||||||||||||
| 202 | 3 | $d | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | sub Zero::Emulator::AreaStructure::count($) #P Number of fields in a data structure. | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | {my ($d) = @_; # Area structure | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | scalar $d->fieldOrder->@* | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | sub Zero::Emulator::AreaStructure::name($$) #P Add a field to a data structure. | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 14 | ▶ | {my ($d, $name) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 14 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 14 | ▶ | if (!defined $d->fieldNames->{$name}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 14 | {$d->fieldNames->{$name} = $d->fieldOrder->@*; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 14 | push $d->fieldOrder->@*, $name; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | else | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | {confess "Duplicate name: $name in structure: ".$d->name; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 14 | \($d->fieldNames->{$name}) | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | my sub procedure($%) # Describe a procedure | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | {my ($label, %options) = @_; # Start label of procedure, options describing procedure | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
procedure: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | genHash("Zero::Emulator::Procedure", # Description of a procedure | |||||||||||||||||||||||||||||||||||||||||
| 227 | target=> $label, # Label to call to call this procedure | ||||||||||||||||||||||||||||||||||||||||||
| 228 | variables=> AreaStructure("Procedure"), # Registers local to this procedure | ||||||||||||||||||||||||||||||||||||||||||
| 229 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | sub Zero::Emulator::AreaStructure::registers($) #P Create one or more temporary variables. Need to reuse registers no longer in use. | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | {my ($d, $count) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
registers: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if (!defined($count)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | {my $o = $d->fieldOrder->@*; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | push $d->fieldOrder->@*, undef; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return \$o; # One temporary | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | map {__SUB__->($d)} 1..$count; # Array of temporaries | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | sub Zero::Emulator::AreaStructure::offset($$) #P Offset of a field in a data structure. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | {my ($d, $name) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if (defined(my $n = $d->fieldNames->{$name})){return $n} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | confess "No such name: '$name' in structure: ".$d->structureName; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | sub Zero::Emulator::AreaStructure::address($$) #P Address of a field in a data structure. | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | {my ($d, $name) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
address: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (defined(my $n = $d->fieldNames->{$name})){return \$n} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | confess "No such name: '$name' in structure: ".$d->structureName; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | sub Zero::Emulator::Procedure::registers($) #P Allocate a register within a procedure. | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | {my ($procedure) = @_; # Procedure description | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
registers: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $procedure->variables->registers(); | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | my sub isScalar($) # Check whether an element is a scalar or an array | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | {my ($value) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isScalar: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ! ref $value; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | # Memory is subdivided into arenas that hold items of similar types, sizes, access orders | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | my sub arenaLocal {0} # Variables whose location is fixed at compile time | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arenaLocal: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my sub arenaHeap {1} # Allocations whose location is dynamically allocated as the program runs | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arenaHeap: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | my sub arenaParms {2} # Parameter areas | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arenaParms: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | my sub arenaReturn{3} # Return areas | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arenaReturn: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | sub Zero::Emulator::Code::referenceToString($$) #P Reference as a string. | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | {my ($block, $r) = @_; # Block of code, reference | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
referenceToString: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | return "" unless defined $r; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | ref($r) =~ m(Reference) or confess "Must be a reference, not: ".dump($r); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if ($r->arena == arenaLocal) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | {return "" unless my $a = $r->address; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | return dump $a | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | else | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | {return dump [$r->area, $r->address, $r->name, $r->delta]; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | sub Zero::Emulator::Code::ArrayNameToNumber($$) #P Generate a unique number for this array name. | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | {my ($code, $name) = @_; # Code block, array name | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ArrayNameToNumber: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if (defined(my $n = $code->arrayNames->{$name})) # Name already exists | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | {return $n; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $n = $code->arrayNames->{$name} = $code->arrayNumbers->@*; # Assign a number to this name | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | push $code->arrayNumbers->@*, $name; # Save new name | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $n | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | sub Zero::Emulator::Code::ArrayNumberToName($$) #P Return the array name associated with an array number. | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | {my ($code, $number) = @_; # Code block, array name | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ArrayNumberToName: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | $code->arrayNumbers->[$number] // $number | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$code->arrayNumbers->[$number] // $number
MC/DC0%0/2
$code->arrayNumbers->[$number] // $number
$code->arrayNumbers->[$number]
$number
Truth table0%0/3
A // B
A= $code->arrayNumbers->[$number]B= $number
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | sub Zero::Emulator::Code::Reference($$) # Record a reference to a left or right address. | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | {my ($code, $r) = @_; # Code block, reference | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Reference: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | ref($r) and ref($r) !~ m(\A(array|scalar|ref)\Z)i and confess "Scalar or reference required, not: ".dump($r); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $r and not ref($r) =~ /\A(array|scalar|ref)\Z/iu
MC/DC0%0/2
ref $r and not ref($r) =~ /\A(array|scalar|ref)\Z/iu
ref $r
not ref($r) =~ /\A(array|scalar|ref)\Z/iu
Truth table0%0/3
A and not(B)
A= ref $rB= not ref($r) =~ /\A(array|scalar|ref)\Z/iu
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | my $arena = ref($r) =~ m(\Aarray\Z)i ? arenaHeap : arenaLocal; # Local variables are variables that are not on the heap | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if (ref($r) =~ m(array)i) # Reference represented as [area, address, name, delta] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | {my ($area, $address, $name, $delta) = @$r; # Delta is oddly useful, as illustrated by examples/*Sort, in that it enables us to avoid adding or subtracting one with a separate instruction that does not achieve very much in one clock but that which, is otherwise necessary. | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | defined($area) and !defined($name) and confess "Name required for address specification: in [Area, address, name]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $area and not defined $name
MC/DC0%0/2
defined $area and not defined $name
defined $area
not defined $name
Truth table0%0/3
A and not(B)
A= defined $areaB= not defined $name
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | return genHash("Zero::Emulator::Reference", | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$delta // 0
MC/DC0%0/1
$delta // 0
$delta
Truth table0%0/2
A
A= $delta
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | arena=> $arena, # The memory arena being used. | ||||||||||||||||||||||||||||||||||||||||||
| 320 | area=> $area, | ||||||||||||||||||||||||||||||||||||||||||
| 321 | address=> $address, | ||||||||||||||||||||||||||||||||||||||||||
| 322 | name=> $code->ArrayNameToNumber($name), | ||||||||||||||||||||||||||||||||||||||||||
| 323 | delta=> $delta//0, | ||||||||||||||||||||||||||||||||||||||||||
| 324 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | else # Reference represented as an address | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | {return genHash("Zero::Emulator::Reference", | |||||||||||||||||||||||||||||||||||||||||
| 328 | arena=> $arena, | ||||||||||||||||||||||||||||||||||||||||||
| 329 | area=> undef, | ||||||||||||||||||||||||||||||||||||||||||
| 330 | address=> $r, | ||||||||||||||||||||||||||||||||||||||||||
| 331 | name=> $code->ArrayNameToNumber('stackArea'), | ||||||||||||||||||||||||||||||||||||||||||
| 332 | delta=> 0, | ||||||||||||||||||||||||||||||||||||||||||
| 333 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | sub Zero::Emulator::Procedure::call($) #P Call a procedure. Arguments are supplied by the L<ParamsPut> and L<ParamsGet> commands, return values are supplied by the L<ReturnPut> and L<ReturnGet> commands. | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | {my ($procedure) = @_; # Procedure description | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | Zero::Emulator::Call($procedure->target); | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | sub Zero::Emulator::Code::assemble($%) #P Assemble a block of code to prepare it for execution. This modifies the jump targets and so once assembled we cannot assembled again. | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | {my ($Block, %options) = @_; # Code block, assembly options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assemble: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $code = $Block->code; # The code to be assembled | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $vars = $Block->variables; # The variables referenced by the code | |||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my %labels; # Load labels | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $stackFrame = AreaStructure("Stack"); # The current stack frame we are creating variables in | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | for my $c(keys @$code) # Labels | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | {my $i = $$code[$c]; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $i->number = $c; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | next unless $i->action eq "label"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $labels{$i->source->address} = $c; # Point label to instruction | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | for my $c(keys @$code) # Target jump and call instructions | |||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | {my $i = $$code[$c]; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | next unless $i->action =~ m(\A(j|call))i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | if (my $l = $i->target->address) # Label | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | {if (my $t = $labels{$l}) # Found label | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | {$i->jump = $Block->Reference($t - $c); # Relative jump | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | else | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | {my $a = $i->action; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | confess "No target for $a to label: $l"; | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $Block->labels = {%labels}; # Labels created during assembly | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $Block | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | sub heap($$) #P Return a heap entry. | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | {my ($exec, $area) = @_; # Execution environment, area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
heap: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $exec->GetMemoryArea->($exec, arenaHeap, $area); | |||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | sub areaContent($$) #P Content of an area containing a specified address in memory in the specified execution. | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | {my ($exec, $ref) = @_; # Execution environment, reference to array | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
areaContent: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $array = $exec->right($ref); | |||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $a = $exec->heap($array); | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | $exec->stackTraceAndExit("Invalid area: ".dump($array)) unless defined $a; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | @$a | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | sub areaLength($$) #P Content of an area containing a specified address in memory in the specified execution. | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | {my ($exec, $array) = @_; # Execution environment, reference to array | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
areaLength: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $a = $exec->heap($array); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | $exec->stackTraceAndExit("Invalid area: ".dump($array)) unless defined $a; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | scalar @$a | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | sub currentStackFrame($) #P Address of current stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentStackFrame: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $calls = $exec->calls; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | @$calls > 0 or confess "No current stack frame"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $$calls[-1]->stackArea; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | sub currentParamsGet($) #P Address of current parameters to get from. | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentParamsGet: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $calls = $exec->calls; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | @$calls > 1 or confess "No current parameters to get"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $$calls[-2]->params; | |||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | sub currentParamsPut($) #P Address of current parameters to put to. | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentParamsPut: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $calls = $exec->calls; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | @$calls > 0 or confess "No current parameters to put"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $$calls[-1]->params; | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | sub currentReturnGet($) #P Address of current return to get from. | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentReturnGet: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $calls = $exec->calls; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | @$calls > 0 or confess "No current return to get"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $$calls[-1]->return; | |||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | sub currentReturnPut($) #P Address of current return to put to. | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentReturnPut: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $calls = $exec->calls; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | @$calls > 1 or confess "No current return to put"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $$calls[-2]->return; | |||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | sub dumpMemory($) #P Dump heap memory. | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dumpMemory: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my @m; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $m = $exec->GetMemoryHeaps->($exec); # Memory areas | |||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | for my $area(1..$m) # Each memory area except memory area 0 - which might once have been reserved for some purpose | |||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | {my $h = $exec->heap($area); | |||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | next unless defined $h and @$h; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $h and @$h
MC/DC0%0/2
defined $h and @$h
defined $h
@$h
Truth table0%0/3
A and B
A= defined $hB= @$h
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $l = dump $exec->heap($area); | |||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | $l = substr($l, 0, 100) if length($l) > 100; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $l =~ s(\n) ( )gs; | |||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | push @m, "$area=$l"; | |||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | join "\n", @m, ''; | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | # These methods provide the original unlimited memory mechanism using multidimensional arrays | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | sub getMemoryHeaps($) #P Heaps. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemoryHeaps: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | scalar($exec->memory->[arenaHeap]->@*) | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | sub getMemoryArea($$$) #P Lowest level memory access to an area. | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | {my ($exec, $arena, $area) = @_; # Execution environment, arena, area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemoryArea: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $exec->memory->[$arena][$area] | |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | sub getMemoryLocation($$$$) #P Lowest level memory access to an array: get the address of the indicated location in memory. This method is replaceable to model different memory structures. | ||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | {my ($exec, $arena, $area, $address) = @_; # Execution environment, arena, area, address, expected name of area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemoryLocation: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | \$exec->memory->[$arena][$area][$address]; | |||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | sub allocMemoryArea($$$$) #P Allocate a memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | {my ($exec, $number, $arena, $area) = @_; # Execution environment, name of allocation to bless result, arena to use, area to use | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allocMemoryArea: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | $exec->memory->[$arena][$area] = $number ? bless [], $number : []; # Blessing with 0 is a very bad idea! | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | sub freeMemoryArea($$$) #P Free a memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | {my ($exec, $arena, $area) = @_; # Execution environment, arena to use, area to use | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeMemoryArea: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $exec->memory->[$arena][$area] = []; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | sub resizeMemoryArea($$$) #P Resize an area in the heap. | ||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | {my ($exec, $area, $size) = @_; # Execution environment, area to use, new size | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resizeMemoryArea: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $a = $exec->memory->[arenaHeap][$area]; | |||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $#$a = $size-1; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | sub pushMemoryArea($$$) #P Push a value onto the specified array. | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | {my ($exec, $area, $value) = @_; # Execution environment, arena, array, value to assign | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pushMemoryArea: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | push $exec->memory->[arenaHeap][$area]->@*, $value; # Push | |||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | sub popMemoryArea($$$) #P Pop a value from the specified memory area if possible else confess. | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | {my ($exec, $arena, $area) = @_; # Execution environment, arena, array, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
popMemoryArea: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $a = $exec->memory->[$arena][$area]; | |||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | if (!defined($a) or !$a->@*) # Area does not exists or has zero elements | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $a and @$a
MC/DC0%0/2
defined $a and @$a
defined $a
@$a
Truth table0%0/3
A and B
A= defined $aB= @$a
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | {$exec->stackTraceAndExit("Cannot pop area: $area, in arena: $arena"); | |||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | pop @$a; # Pop | |||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | sub setOriginalMemoryTechnique($) #P Set the handlers for the original memory allocation technique. | ||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setOriginalMemoryTechnique: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $exec->GetMemoryHeaps = \&getMemoryHeaps; # Low level memory access - arena | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $exec->GetMemoryArea = \&getMemoryArea; # Low level memory access - area | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $exec->GetMemoryLocation = \&getMemoryLocation; # Low level memory access - location | |||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $exec->AllocMemoryArea = \&allocMemoryArea; # Low level memory access - allocate new area | |||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $exec->FreeMemoryArea = \&freeMemoryArea; # Low level memory access - free area | |||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $exec->ResizeMemoryArea = \&resizeMemoryArea; # Low level memory access - resize a memory area | |||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $exec->PushMemoryArea = \&pushMemoryArea; # Low level memory access - push onto area | |||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | $exec->PopMemoryArea = \&popMemoryArea; # Low level memory access - pop from area | |||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | # These methods place the heap arena in a vector string. Each area is up to a prespecified width wide. The current length of each such array is held in the first element. | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | sub stringMemoryAreaLength($$$) #P Get the current length of a string memory area n area in. | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | {my ($exec, $arena, $area) = @_; # Execution environment, arena, array, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringMemoryAreaLength: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $o = $area * $t; # Offset of heap area in arena | |||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $l = vec($exec->memoryString, $o, $w * 8); # Zero current length of area so we can push and pop | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | $l > 0 or confess "Area underflow, arena: $arena, area: $area"; # Check we are within the area | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | --$l; # Pop | |||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $O = $o + $s + $l; # Offset of element in area | |||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my $v = vec($exec->memoryString, $O, $w * 8); # Pop element | |||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | vec($exec->memoryString, $o, $w * 8) = $l; # Decrease size of area | |||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $v | |||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | sub stringGetMemoryHeaps($) #P Get number of heaps. | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | {my ($exec) = @_; # Execution environment, arena | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringGetMemoryHeaps: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $a = $w * $t; # Offset of heap area in arena | |||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my $l = length $exec->memoryString; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $n = int($l / $a); # Heap objects must be smaller than a maximum size so that we can calculate their offset in the memory string | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | if ($n * $a < $l) # Last heap might not be full | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | {++$n; | |||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||
| 555 | $n | ||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | sub stringGetMemoryArea($$$$) #P Lowest level memory access to an area. | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | {my ($exec, $arena, $area) = @_; # Execution environment, arena, area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringGetMemoryArea: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | return getMemoryArea($exec, $arena, $area) if $arena != arenaHeap; # Non heap objects continue as normal because the number of local variables and subroutines a human can produce in one lifetime are limited, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $o = $area * $t; # Offset of heap area in arena | |||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $l = vec($exec->memoryString, $o, $w * 8); # Length of area so we can push and pop | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my @o; | |||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | for my $i(0..$l-1) # Check we are within the area | |||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | {push @o, ${$exec->stringGetMemoryLocation($arena, $area, $i)}; | |||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | [@o] | |||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | sub stringGetMemoryLocation($$$$) #P Lowest level memory access to an array: get the address of the indicated location in memory. This method is replaceable to model different memory structures. | ||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | {my ($exec, $arena, $area, $address) = @_; # Execution environment, arena, area, address, expected name of area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringGetMemoryLocation: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if ($arena != arenaHeap) # Non heap objects continue as normal because the number of local variables and subroutines a human can produce in one lifetime are limited, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | {return getMemoryLocation($exec, $arena, $area, $address); | |||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my $o = $area * $t; # Offset into memory of area | |||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | $address < $u or confess "Address $address >= $u"; # Check we are within the area | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my $O = $o + $s + $address; # Offset into memory of element | |||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | if ($address+1 > vec($exec->memoryString, $o, $w * 8)) # Extend length of array if necessary | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | {vec($exec->memoryString, $o, $w * 8) = $address+1; | |||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | \vec($exec->memoryString, $O, $w * 8) # Memory containing one element | |||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | sub stringAllocMemoryArea($$$$) #P Allocate a memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | {my ($exec, $number, $arena, $area) = @_; # Execution environment, name of allocation to bless result, arena to use, area to use | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringAllocMemoryArea: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | return allocMemoryArea($exec, $number, $arena, $area) if $arena != arenaHeap; # Non heap objects continue as normal because the number of local variables and subroutines a human can produce in one lifetime are limited, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | my $o = $area * $t; # Offset of heap area in arena | |||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | vec($exec->memoryString, $o, $w * 8) = 0; # Zero current length of area so we can push and pop | |||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | sub stringFreeMemoryArea($$$) #P Free a memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | {my ($exec, $arena, $area) = @_; # Execution environment, arena to use, area to use | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringFreeMemoryArea: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | return freeMemoryArea($exec, $arena, $area) if $arena != arenaHeap; # Non heap objects continue as normal because the number of local variables and subroutines a human can produce in one lifetime are limited, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $o = $area * $t; # Offset of heap area in arena | |||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | vec($exec->memoryString, $o, $w * 8) = 0; # Zero current length of area so we can push and pop | |||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | sub stringResizeMemoryArea($$$) #P Resize a heap memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | {my ($exec, $area, $size) = @_; # Execution environment, area to resize, new size | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringResizeMemoryArea: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $o = $area * $t; # Offset of heap area in arena | |||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | vec($exec->memoryString, $o, $w * 8) = $size; # Set new size | |||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | sub stringPushMemoryArea($$$) #P Push a value onto the specified array. | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | {my ($exec, $area, $value) = @_; # Execution environment, arena, array, value to assign | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringPushMemoryArea: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my $o = $area * $t; # Offset of heap area in arena | |||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $l = vec($exec->memoryString, $o, $w * 8); # Zero current length of area so we can push and pop | |||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | $l < $u-1 or # Check we are within the area | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | confess "Area overflow, area: $area, " | ||||||||||||||||||||||||||||||||||||||||||
| 650 | ."position: $l, value: $value"; | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my $O = $o + ($s + $l); # Offset of element in area | |||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | vec($exec->memoryString, $O, $w * 8) = $value; # Push element | |||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | vec($exec->memoryString, $o, $w * 8) = $l + 1; # Increase size of area | |||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | sub stringPopMemoryArea($$$) #P Pop a value from the specified memory area if possible else confess. | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | {my ($exec, $arena, $area) = @_; # Execution environment, arena, array, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringPopMemoryArea: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $w = $exec->memoryStringElementWidth; # Width of each element in an an area | |||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $u = $exec->memoryStringUserElements; # User width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my $s = $exec->memoryStringSystemElements; # System width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | my $t = $exec->memoryStringTotalElements; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | my $o = $area * $t; # Offset of heap area in arena | |||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my $l = vec($exec->memoryString, $o, $w * 8); # Zero current length of area so we can push and pop | |||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | $l > 0 or confess "Area underflow, arena: $arena, area: $area"; # Check we are within the area | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | --$l; # Pop | |||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | my $O = $o + $s + $l; # Offset of element in area | |||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $v = vec($exec->memoryString, $O, $w * 8); # Pop element | |||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | vec($exec->memoryString, $o, $w * 8) = $l; # Decrease size of area | |||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | $v | |||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | sub setStringMemoryTechnique($) #P Set the handlers for the string memory allocation technique. | ||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setStringMemoryTechnique: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $exec->GetMemoryHeaps = \&stringGetMemoryHeaps; # Low level memory access - arena | |||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | $exec->GetMemoryArea = \&stringGetMemoryArea; # Low level memory access - area | |||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | $exec->GetMemoryLocation = \&stringGetMemoryLocation; # Low level memory access - location | |||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $exec->AllocMemoryArea = \&stringAllocMemoryArea; # Low level memory access - allocate new area | |||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | $exec->FreeMemoryArea = \&stringFreeMemoryArea; # Low level memory access - free area | |||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | $exec->ResizeMemoryArea = \&stringResizeMemoryArea; # Low level memory access - resize a memory area | |||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | $exec->PushMemoryArea = \&stringPushMemoryArea; # Low level memory access - push onto area | |||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | $exec->PopMemoryArea = \&stringPopMemoryArea; # Low level memory access - pop from area | |||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $exec->memoryStringElementWidth = my $e = 4; # Each element is 32 bits wide | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | $exec->memoryStringUserElements = my $u = 5; # User part of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $exec->memoryStringSystemElements = my $s = 1; # System part of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | $exec->memoryStringTotalElements = $u + $s; # Total width of a heap area | |||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | # End of memory implementation | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | sub getMemory($$$$$) #P Get from memory. | ||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | {my ($exec, $arena, $area, $address, $name) = @_; # Execution environment, arena, area, address, expected name of area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemory: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | @_ == 5 or confess "Five parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $exec->checkArrayName($arena, $area, $name); | |||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my $v = $exec->GetMemoryLocation->($exec, $arena, $area, $address); | |||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | if (!defined($$v)) # Check we are getting a defined value. If undefined values are acceptable use L<getMemoryAddress> and dereference the result. | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | {my $n = $name // 'unknown'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$name // "unknown"
MC/DC0%0/1
$name // "unknown"
$name
Truth table0%0/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $exec->stackTraceAndExit | |||||||||||||||||||||||||||||||||||||||||
| 699 | ("Undefined memory accessed in arena: $arena, at area: $area ($n), address: $address\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | $$v | |||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | sub getMemoryAddress($$$$$) #P Evaluate an address in the current execution environment. | ||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | {my ($exec, $arena, $area, $address, $name) = @_; # Execution environment, arena, area, address, expected name of area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemoryAddress: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | @_ == 5 or confess "Five parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ▶ | $exec->widestAreaInArena->[$arena] = # Track the widest area in each arena | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$exec->widestAreaInArena->[$arena] // 0
MC/DC0%0/1
$exec->widestAreaInArena->[$arena] // 0
$exec->widestAreaInArena->[$arena]
Truth table0%0/2
A
A= $exec->widestAreaInArena->[$arena]
| |||||||||||||||||||||||||||||||||||||||||||
| 708 | max(($exec->widestAreaInArena->[$arena]//0), $address); | ||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | $exec->checkArrayName($arena, $area, $name); # Check area name | |||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $exec->GetMemoryLocation->($exec, $arena, $area, $address); # Read from memory | |||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | sub getMemoryFromAddress($$) #P Get a value from memory at a specified address. | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | {my ($exec, $left) = @_; # Execution environment, left address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemoryFromAddress: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | ref($left) =~ m(Address) or confess "Address needed for second parameter, not: ".ref($left); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | $exec->getMemory($left->arena, $left->area, $left->address, $left->name); | |||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | sub getMemoryAddressFromAddress($) #P Get address of memory location from an address in the current execution environment. | ||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | {my ($exec, $left) = @_; # Execution environment, address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemoryAddressFromAddress: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | ref($left) =~ m(Address) or confess "Address needed for second parameter, not: ".ref($left); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | $exec->getMemoryAddress($left->arena, $left->area, $left->address, $left->name); | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | sub setMemory($$$) #P Set the value of an address at the specified address in memory in the current execution environment. | ||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | {my ($exec, $ref, $value) = @_; # Execution environment, address specification, value | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setMemory: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | my $arena = $ref->arena; | |||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my $area = $ref->area; | |||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my $address = $ref->address; | |||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $exec->lastAssignArena = $arena; | |||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | $exec->lastAssignArea = $area; | |||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | $exec->lastAssignAddress = $address; | |||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $exec->lastAssignType = $exec->getMemoryType($arena, $area); | |||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $exec->lastAssignValue = $value; | |||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $exec->lastAssignBefore = $exec->getMemoryAddressFromAddress($ref)->$*; | |||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my $a = $exec->GetMemoryLocation->($exec, $arena, $area, $address); | |||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $$a = $value; | |||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | sub Address($$$$;$) #P Record a reference to memory. | ||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | {my ($arena, $area, $address, $name, $delta) = @_; # Arena, area, address in area, name of area, delta from specified address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Address: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | my $r = genHash("Zero::Emulator::Address", # Address memory | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$name // "stackArea"
$delta // 0
MC/DC0%0/1
$name // "stackArea"
$name
MC/DC0%0/1
$delta // 0
$delta
Truth table0%0/2
A
A= $name
Truth table0%0/2
A
A= $delta
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | arena=> $arena, # Arena in memory | ||||||||||||||||||||||||||||||||||||||||||
| 748 | area=> $area, # Area in memory, either a number or a reference to a number indicating the level of indirection | ||||||||||||||||||||||||||||||||||||||||||
| 749 | address=> $address, # Address within area, either a number or a reference to a number indicating the level of indirection | ||||||||||||||||||||||||||||||||||||||||||
| 750 | name=> $name // 'stackArea', # Name of area | ||||||||||||||||||||||||||||||||||||||||||
| 751 | delta=> ($delta//0), # Offset from indicated address | ||||||||||||||||||||||||||||||||||||||||||
| 752 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | confess "AAAA" unless defined $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $r | |||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | sub stackTrace($;$) #P Create a stack trace. | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | {my ($exec, $title) = @_; # Execution environment, title | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackTrace: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | my $i = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | my $s = $exec->suppressOutput; # Suppress file and line numbers in dump to facilitate automated testing | |||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | my @t = $exec->contextString($i, $title//"Stack trace:"); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$title // "Stack trace:"
MC/DC0%0/1
$title // "Stack trace:"
$title
Truth table0%0/2
A
A= $title
| |||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | for my $j(reverse keys $exec->calls->@*) | |||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | {my $c = $exec->calls->[$j]; | |||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my $i = $c->instruction; | |||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | push @t, sprintf "%5d %4d %s", $j+1, $i->number+1, $i->action if $s; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | push @t, sprintf "%5d %4d %-16s at %s line %d", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | $j+1, $i->number+1, $i->action, $i->file, $i->line unless $s; | ||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | join "\n", @t, ''; | |||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | sub stackTraceAndExit($$%) #P Create a stack trace and exit from the emulated program. | ||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | {my ($exec, $title, %options) = @_; # Execution environment, title, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackTraceAndExit: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | ▶ | @_ >= 2 or confess "At least two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | my $t = $exec->stackTrace($title); | |||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | $exec->output($t); | |||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | confess $t unless $exec->suppressOutput; # Confess if requested - presumably because this indicates an error in programming and thus nothing can be done about it within the program | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $exec->instructionPointer = undef; # Execution terminates as soon as undefined instruction is encountered | |||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | $t | |||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | 1 | my $allocs = []; # Allocations | |||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | sub allocMemory($$$) #P Create the name of a new memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | {my ($exec, $number, $arena) = @_; # Execution environment, name of allocation, arena to use | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allocMemory: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | $number =~ m(\A\d+\Z) or confess "Array name must be numeric not : $number"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | my $f = $exec->freedArrays->[$arena]; # Reuse recently freed array if possible | |||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | my $a = $f && @$f ? pop @$f : ++$$allocs[$arena]; # Area id to reuse or use for the first time | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$f and @$f
MC/DC0%0/2
$f and @$f
$f
@$f
Truth table0%0/3
A and B
A= $fB= @$f
| |||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | my $n = $exec->block->ArrayNumberToName($number); # Convert array name to number if possible | |||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | $exec->AllocMemoryArea->($exec, $n, $arena, $a); # Create new area | |||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $exec->setMemoryType($arena, $a, $number); # Track name of area | |||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | $a | |||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | sub freeArea($$$$) #P Free a heap memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | {my ($exec, $arena, $area, $number) = @_; # Execution environment, arena, array, name of allocation | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeArea: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | $number =~ m(\A\d+\Z) or confess "Array name must be numeric not : $number"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $exec->checkArrayName($arena, $area, $number); | |||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $exec->FreeMemoryArea->($exec, $arena, $area); | |||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | push $exec->freedArrays->[$arena]->@*, $area; # Save array for reuse | |||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||
| 810 | sub pushArea($$$$) #P Push a value onto the specified heap array. | ||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | {my ($exec, $area, $name, $value) = @_; # Execution environment, array, name of allocation, value to assign | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pushArea: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $exec->checkArrayName(arenaHeap, $area, $name); | |||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | $exec->PushMemoryArea->($exec, $area, $value); | |||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | sub popArea($$$$) # Pop a value from the specified memory area if possible else confess. | ||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | {my ($exec, $arena, $area, $name) = @_; # Execution environment, arena, array, name of allocation, value to assign | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
popArea: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | $exec->checkArrayName($arena, $area, $name); # Check stack name | |||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | $exec->PopMemoryArea->($exec, $arena, $area); | |||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | sub getMemoryType($$$) #P Get the type of an area. | ||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | {my ($exec, $arena, $area) = @_; # Execution environment, arena, area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemoryType: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | $exec->memoryType->[$arena][$area]; | |||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | sub setMemoryType($$$$) #P Set the type of a memory area - a name that can be used to confirm the validity of reads and writes to that array represented by that area. | ||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | {my ($exec, $arena, $area, $name) = @_; # Execution environment, arena, area name, name of allocation | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setMemoryType: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | $exec->memoryType->[$arena][$area] = $name; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | $exec | |||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||
| 836 | sub notRead() #P Record the unused memory locations in the current stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | {my ($exec) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notRead: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my $area = $exec->currentStackFrame; | |||||||||||||||||||||||||||||||||||||||||
| 839 | # my @area = $memory{$area}->@*; # Memory in area | ||||||||||||||||||||||||||||||||||||||||||
| 840 | # my %r; # Location in stack frame=> instruction defining vasriable | ||||||||||||||||||||||||||||||||||||||||||
| 841 | # for my $a(keys @area) | ||||||||||||||||||||||||||||||||||||||||||
| 842 | # {if (my $I = $calls[-1]->variables->instructions->[$a]) | ||||||||||||||||||||||||||||||||||||||||||
| 843 | # {$r{$a} = $I; # Number of instruction creating variable | ||||||||||||||||||||||||||||||||||||||||||
| 844 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 845 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 846 | # | ||||||||||||||||||||||||||||||||||||||||||
| 847 | # if (my $r = $read{$area}) # Locations in this area that have ben read | ||||||||||||||||||||||||||||||||||||||||||
| 848 | # {delete $r{$_} for keys %$r; # Delete locations that have been read from | ||||||||||||||||||||||||||||||||||||||||||
| 849 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 850 | # | ||||||||||||||||||||||||||||||||||||||||||
| 851 | # $notRead{$area} = {%r} if keys %r; # Record not read | ||||||||||||||||||||||||||||||||||||||||||
| 852 | {} | ||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | sub rwWrite($$$$) #P Observe write to memory. | ||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | ▶ | {my ($exec, $arena, $area, $address) = @_; # Execution environment, arena, area, address within area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rwWrite: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my $P = $exec->rw->[$arena][$area][$address]; | |||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | if (defined($P)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | {my $T = $exec->getMemoryType($arena, $area); | |||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | my $M = $exec->getMemoryAddress($arena, $area, $address, $T); | |||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | if ($$M) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | {my $Q = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | my $p = $exec->contextString($P, "Previous write"); | |||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | my $q = $exec->contextString($Q, "Current write"); | |||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | $exec->doubleWrite->{$p}{$q}++; | |||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | $exec->rw->[$arena][$area][$address] = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | sub markAsRead($$$$) #P Mark a memory address as having been read from. | ||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | {my ($exec, $arena, $area, $address) = @_; # Execution environment, arena, area in memory, address within area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
markAsRead: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | delete $exec->rw->[$arena][$area][$address]; # Clear last write operation | |||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | sub rwRead($$$$) #P Observe read from memory. | ||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | {my ($exec, $arena, $area, $address) = @_; # Execution environment, arena, area in memory, address within area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rwRead: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | if (defined(my $a = $exec->rw->[$arena][$area][$address])) # Can only read from locations that actually have something in them | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | {$exec->markAsRead($arena, $area, $address); # Clear last write operation | |||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $exec->read->[$arena][$area][$address]++; # Track reads | |||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | sub stackAreaNameNumber($) # Number of name representing stack area. | ||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackAreaNameNumber: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | $exec->block->ArrayNameToNumber("stackArea"); | |||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | sub left($$) #P Address of a location in memory. | ||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | {my ($exec, $ref) = @_; # Execution environment, reference | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
left: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | ref($ref) =~ m(Reference) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 895 | or confess "Reference required, not: ".dump($ref); | ||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | my $r = $ref->address; | |||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | my $address = $r; | |||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | $address = \$r if isScalar $address; # Interpret constants as direct memory locations | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my $arena = $ref->arena; | |||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my $area = $ref->area; | |||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | my $delta = $ref->delta; | |||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | my $S = $exec->currentStackFrame; # Current stack frame | |||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | my $stackArea = $exec->stackAreaNameNumber; | |||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | my sub invalid($) | ||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | {my ($e) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invalid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | my $i = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $l = $i->line; | |||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | my $f = $i->file; | |||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $exec->stackTraceAndExit( | |||||||||||||||||||||||||||||||||||||||||
| 911 | "Invalid left address," | ||||||||||||||||||||||||||||||||||||||||||
| 912 | ." arena: ".dump($arena) | ||||||||||||||||||||||||||||||||||||||||||
| 913 | ." area: ".dump($area) | ||||||||||||||||||||||||||||||||||||||||||
| 914 | ." address: ".dump($address) | ||||||||||||||||||||||||||||||||||||||||||
| 915 | ." e: ".dump($e) | ||||||||||||||||||||||||||||||||||||||||||
| 916 | , confess=>1) | ||||||||||||||||||||||||||||||||||||||||||
| 917 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | my $M; # Memory address | |||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | ▶ | if (isScalar $$address) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | {$M = $$address + $delta; | |||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||
| 923 | elsif (isScalar $$$address) | ||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | {$M = $exec->getMemory(arenaLocal, $S, $$$address, $stackArea) + $delta; | |||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||
| 926 | else | ||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | {invalid(1) | |||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | ▶ | if ($M < 0) # Disallow negative addresses because they mean something special to Perl | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | {$exec->stackTraceAndExit("Negative address: $M, " | |||||||||||||||||||||||||||||||||||||||||
| 932 | ." for arena: ".dump($arena) | ||||||||||||||||||||||||||||||||||||||||||
| 933 | ." for area: " .dump($area) | ||||||||||||||||||||||||||||||||||||||||||
| 934 | .", address: " .dump($address)); | ||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||
| 936 | elsif (!defined($area)) # Current stack frame | ||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | {my $a = Address(arenaLocal, $S, $M, $ref->name); # Stack frame | |||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | return $a; | |||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||
| 940 | elsif (isScalar($area)) | ||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | {my $a = Address($arena, $area, $M, $ref->name); # Specified constant area | |||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | return $a; | |||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||
| 944 | elsif (isScalar($$area)) | ||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | {my $A = $exec->getMemory(arenaLocal, $S, $$area, $stackArea); | |||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | my $a = Address($arena, $A, $M, $ref->name); # Indirect area | |||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | return $a; | |||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | invalid(2); | |||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||
| 952 | sub right($$) #P Get a constant or a value from memory. | ||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | ▶ | {my ($exec, $ref) = @_; # Location, optional area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
right: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | ▶ | ref($ref) =~ m(Reference) or confess "Reference required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | my $address = $ref->address; | |||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | my $arena = $ref->arena; | |||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | my $area = $ref->area; | |||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | my $stackArea = $exec->currentStackFrame; | |||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | my $name = $ref->name; | |||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | my $delta = $ref->delta; | |||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | my $stackAN = $exec->stackAreaNameNumber; | |||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | my $r; my $e = 0; my $tArena = $arena; my $tArea = $area; my $tAddress = $address; my $tDelta = $delta; | |||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | my sub invalid($) # Invalid address | ||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | {my ($error) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invalid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | my $i = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my $l = $i->line; | |||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | my $f = $i->file; | |||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $exec->stackTraceAndExit( | |||||||||||||||||||||||||||||||||||||||||
| 972 | "Invalid " | ||||||||||||||||||||||||||||||||||||||||||
| 973 | ." error: " .dump($error) | ||||||||||||||||||||||||||||||||||||||||||
| 974 | ." right arena: ".dump($arena) | ||||||||||||||||||||||||||||||||||||||||||
| 975 | ." right area: " .dump($area) | ||||||||||||||||||||||||||||||||||||||||||
| 976 | ." address: " .dump($a) | ||||||||||||||||||||||||||||||||||||||||||
| 977 | ." stack: " .$exec->currentStackFrame | ||||||||||||||||||||||||||||||||||||||||||
| 978 | ." error: " .dump($e) | ||||||||||||||||||||||||||||||||||||||||||
| 979 | ." target Area: ".dump($tArea) | ||||||||||||||||||||||||||||||||||||||||||
| 980 | ." address: " .dump($tAddress) | ||||||||||||||||||||||||||||||||||||||||||
| 981 | ." delta: " .dump($tDelta)); | ||||||||||||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | if (isScalar($address)) # Constant | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 985 | {#rwRead($area//&stackArea, $a) if $a =~ m(\A\-?\d+\Z); | ||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | return $address if defined $address; # Attempting to read a address that has never been set is an error | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | invalid(1); | |||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $m; | |||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | my $memory = $exec->memory; | |||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | if (isScalar($$address)) # Direct | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | {$m = $$address + $delta; | |||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||
| 996 | elsif (isScalar($$$a)) # Indirect | ||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | {$m = $exec->getMemory(arenaLocal, $stackArea, $$$address, $stackAN) + $delta; | |||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||
| 999 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | {invalid(2); | |||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | ▶ | invalid(3) unless defined $m; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | ▶ | if (!defined($area)) # Stack frame | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | {$r = $exec->getMemory(arenaLocal, $stackArea, $m, $stackAN); # Indirect from stack area | |||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | $e = 1; $tArena = arenaLocal; $tArea = $stackArea; $tAddress = $m; | |||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | elsif (isScalar($area)) | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | {$r = $exec->getMemory($arena, $area, $m, $ref->name); # Indirect from stack area | |||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | $e = 2; $tArena = $arena; $tArea = $stackArea; $tAddress = $m; | |||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | elsif (isScalar($$area)) | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | {$e = 3; $tArena = arenaLocal; $tArea = $stackArea; $tAddress = $m; | |||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | if (defined(my $j = $exec->getMemory(arenaLocal, $stackArea, $$area, $stackAN))) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | {$r = $exec->getMemory($arena, $j, $m, $ref->name); # Indirect from stack area | |||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | $e = 4; $tArena = $arena; $tArea = $j; $tAddress = $m; | |||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | {invalid(4); | |||||||||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | ▶ | invalid(5) unless defined $r; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | $r | |||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||
| 1027 | sub jumpOp($$$) #P Jump to the target address if the tested memory area if the condition is matched. | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | ▶ | {my ($exec, $i, $check) = @_; # Execution environment, Instruction, check | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jumpOp: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | ▶ | $exec->instructionPointer = $i->number + $exec->right($i->jump) if &$check; # Check if condition is met | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||
| 1033 | sub assert1($$$) #P Assert true or false. | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | ▶ | {my ($exec, $test, $sub) = @_; # Execution environment, Text of test, subroutine of test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert1: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | my $i = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | my $a = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | ▶ | unless($sub->($a)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | {$exec->stackTraceAndExit("Assert$test $a failed"); | |||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||
| 1043 | sub assert2($$$) #P Assert generically. | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | {my ($exec, $test, $sub) = @_; # Execution environment, Text of test, subroutine of test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert2: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | my $i = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | my ($a, $b) = ($exec->right($i->source), $exec->right($i->source2)); | |||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | ▶ | unless($sub->($a, $b)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | {$exec->stackTraceAndExit("Assert $a $test $b failed"); | |||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | sub assign($$$) #P Assign - check for pointless assignments. | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | ▶ | {my ($exec, $target, $value) = @_; # Execution environment, Target of assign, value to assign | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | ▶ | ref($target) =~ m(Address)i or confess "Not an address: ".dump($target); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | ▶ | !ref($value) or confess "Not a scalar value".dump($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | my $arena = $target->arena; | |||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | my $area = $target->area; | |||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | my $address = $target->address; | |||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | my $name = $target->name; | |||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | $exec->checkArrayName($arena, $area, $name); | |||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | if (!defined($value)) # Check that the assign is not pointless | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | {$exec->stackTraceAndExit | |||||||||||||||||||||||||||||||||||||||||
| 1067 | ("Cannot assign an undefined value to arena: $arena, area: $area($name)," | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | ." address: $address"); | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | {my $currently = $exec->getMemoryAddressFromAddress($target); | |||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | if (defined $$currently) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | ▶ | {if ($$currently == $value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | {$exec->pointlessAssign->{$exec->currentInstruction->number}++; # Record the pointless assign | |||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | ▶ | if ($exec->stopOnError) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | {$exec->stackTraceAndExit("Pointless assign of: $$currently " | |||||||||||||||||||||||||||||||||||||||||
| 1077 | ."to arena: $arena, area: $area($name), at: $address"); | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | ▶ | if (defined $exec->watch->[$area][$address]) # Watch for specified changes | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | ▶ | {my $n = $exec->block->ArrayNumberToName($name) // "unknown"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$exec->block->ArrayNumberToName($name) // "unknown"
MC/DC0%0/1
$exec->block->ArrayNumberToName($name) // "unknown"
$exec->block->ArrayNumberToName($name)
Truth table0%0/2
A
A= $exec->block->ArrayNumberToName($name)
| |||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | my @s = $exec->stackTrace("Change at watched " | |||||||||||||||||||||||||||||||||||||||||
| 1086 | ."arena: $arena, area: $area($n), address: $address"); | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | $s[-1] .= join ' ', "Current value:", $exec->getMemory($arena, $area, $address, $name), | |||||||||||||||||||||||||||||||||||||||||
| 1088 | "New value:", $value; | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | my $s = join "", @s; | |||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | ▶ | say STDERR $s unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | $exec->output("$s\n"); | |||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | $exec->setMemory($target, $value); # Actually do the assign | |||||||||||||||||||||||||||||||||||||||||
| 1095 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||
| 1097 | sub stackAreaNumber($) #P Number for type of stack area array. | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackAreaNumber: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1099 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | $exec->block->ArrayNameToNumber("stackArea") | |||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | sub paramsNumber($) #P Number for type of parameters array. | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paramsNumber: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | $exec->block->ArrayNameToNumber("params") | |||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | sub returnNumber($) #P Number for type of return area array. | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
returnNumber: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | $exec->block->ArrayNameToNumber("return") | |||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | sub allocateSystemAreas($) #P Allocate system areas for a new stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allocateSystemAreas: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | (stackArea=> $exec->allocMemory($exec->stackAreaNameNumber, arenaLocal), | |||||||||||||||||||||||||||||||||||||||||
| 1119 | params=> $exec->allocMemory($exec->paramsNumber, arenaParms), | ||||||||||||||||||||||||||||||||||||||||||
| 1120 | return=> $exec->allocMemory($exec->returnNumber, arenaReturn)); | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||
| 1123 | sub freeSystemAreas($$) #P Free system areas for the specified stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | ▶ | {my ($exec, $c) = @_; # Execution environment, stack frame | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeSystemAreas: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | $exec->notRead; # Record unread memory locations in the current stack frame | |||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | $exec->freeArea(arenaLocal, $c->stackArea, $exec->stackAreaNumber); | |||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | $exec->freeArea(arenaParms, $c->params, $exec->paramsNumber); | |||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | $exec->freeArea(arenaReturn, $c->return, $exec->returnNumber); | |||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||
| 1132 | sub currentInstruction($) #P Locate current instruction. | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentInstruction: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | $exec->calls->[-1]->instruction; | |||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | sub createInitialStackEntry($) #P Create the initial stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createInitialStackEntry: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | my $variables = $exec->block->variables; | |||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | my $nVariables = $variables->fieldOrder->@*; # Number of variables in this stack frame | |||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | ▶ | push $exec->calls->@*, # Variables in initial stack frame | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1144 | stackFrame( | ||||||||||||||||||||||||||||||||||||||||||
| 1145 | $exec->block ? (variables=> $variables) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | $exec->allocateSystemAreas); | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | $exec | |||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||
| 1150 | sub checkArrayName($$$$) #P Check the name of an array. | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | ▶ | {my ($exec, $arena, $area, $number) = @_; # Execution environment, arena, array, array name | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkArrayName: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | ▶ | return 1 unless $exec->checkArrayNames; # Check the names of arrays if requested | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | ▶ | if (!defined($number)) # A name is required | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | {$exec->stackTraceAndExit("Array name required to size array: $area in arena $arena"); | |||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | my $Number = $exec->getMemoryType($arena, $area); # Area has a name | |||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | ▶ | if (!defined($Number)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | {$exec->stackTraceAndExit("No name associated with array: $area in arena $arena"); | |||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | ▶ | if ($number != $Number) # Name does not match supplied name | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | {my $n = $exec->block->ArrayNumberToName($number); | |||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | my $N = $exec->block->ArrayNumberToName($Number); | |||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | $exec->stackTraceAndExit("Wrong name: $n for array with name: $N"); | |||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 1171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||
| 1173 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||
| 1176 | sub locateAreaElement($$$) #P Locate an element in an array. | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | ▶ | {my ($exec, $ref, $op) = @_; # Execution environment, reference naming the array, operation | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locateAreaElement: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | my @a = $exec->areaContent($ref); | |||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | for my $a(keys @a) # Check each element of the array | |||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | {if ($op->($a[$a])) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | {return $a + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||
| 1188 | sub countAreaElement($$$) #P Count the number of elements in array that meet some specification. | ||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | ▶ | {my ($exec, $ref, $op) = @_; # Execution environment, reference naming the array, operation | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
countAreaElement: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | my @a = $exec->areaContent($ref); | |||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | for my $a(keys @a) # Check each element of the array | |||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | ▶ | {if ($op->($a[$a])) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | {++$n; | |||||||||||||||||||||||||||||||||||||||||
| 1196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||
| 1199 | $n | ||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||
| 1202 | sub output($$) #P Write an item to the output channel. Items are separated with one blank each unless the caller has provided formatting with new lines. | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | ▶ | {my ($exec, $item) = @_; # Execution environment, item to write | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | ▶ | if ($exec->out and $exec->out !~ m(\n\Z) and $item !~ m(\A\n)s) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$exec->out and not $exec->out =~ /\n\Z/u and not $item =~ /\A\n/su
$exec->out and not $exec->out =~ /\n\Z/u
MC/DC0%0/3
$exec->out and not $exec->out =~ /\n\Z/u and not $item =~ /\A\n/su
$exec->out
not $exec->out =~ /\n\Z/u
not $item =~ /\A\n/su
Truth table0%0/4
A and not(B) and not(C)
A= $exec->outB= not $exec->out =~ /\n\Z/uC= not $item =~ /\A\n/su
| |||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | {$exec->out .= " $item"; | |||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | {$exec->out .= $item; | |||||||||||||||||||||||||||||||||||||||||
| 1209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||
| 1212 | sub outLines($) #P Turn the output channel into an array of lines. | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
outLines: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | [split /\n/, $exec->out] | |||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||
| 1217 | sub analyzeExecutionResultsLeast($%) #P Analyze execution results for least used code. | ||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionResultsLeast: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | my @c = $exec->block->code->@*; | |||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | my %l; | |||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | for my $i(@c) # Count executions of each instruction | |||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | ▶ | {$l{$i->file}{$i->line} += $i->executed unless $i->action =~ m(\Aassert)i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | my @L; | |||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | for my $f(keys %l) | |||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | {for my $l(keys $l{$f}->%*) | |||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | {push @L, [$l{$f}{$l}, $f, $l]; | |||||||||||||||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | my @l = sort {$$a[0] <=> $$b[0]} # By frequency | |||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | sort {$$a[2] <=> $$b[2]} @L; # By line number | |||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | ▶ | my $N = $options{least}//1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"least"} // 1
MC/DC0%0/1
$options{"least"} // 1
$options{"least"}
Truth table0%0/2
A
A= $options{"least"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | ▶ | $#l = $N if @l > $N; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | map {sprintf "%4d at %s line %4d", $$_[0], $$_[1], $$_[2]} @l; | |||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||
| 1240 | sub analyzeExecutionResultsMost($%) #P Analyze execution results for most used code. | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionResultsMost: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | my @c = $exec->block->code->@*; | |||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | my %m; | |||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | for my $i(@c) # Count executions of each instruction | |||||||||||||||||||||||||||||||||||||||||
| 1246 | {my $t = # Traceback | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | join "\n", map {sprintf " at %s line %4d", $$_[0], $$_[1]} $i->context->@*; | |||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | $m{$t} += $i->executed; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | my @m = reverse sort {$$a[1] <=> $$b[1]} map {[$_, $m{$_}]} keys %m; # Sort a hash into value order | |||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | my $N = $options{most}//1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"most"} // 1
MC/DC0%0/1
$options{"most"} // 1
$options{"most"}
Truth table0%0/2
A
A= $options{"most"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | ▶ | $#m = $N if @m > $N; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | map{sprintf "%4d\n%s", $m[$_][1], $m[$_][0]} keys @m; | |||||||||||||||||||||||||||||||||||||||||
| 1254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||
| 1256 | sub analyzeExecutionNotRead($%) #P Analyze execution results for variables never read. | ||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionNotRead: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | my @t; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | my $n = $exec->notRead; | |||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | for my $areaK(sort keys %$n) | |||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | {my $area = $$n{$areaK}; | |||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | for my $addressK(sort keys %$area) | |||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | {my $address = $$area{$addressK}; | |||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | push @t, $exec->contextString(block->code->[$addressK], | |||||||||||||||||||||||||||||||||||||||||
| 1266 | "Not read from area: $areaK, address: $addressK in context:"); | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | @t; | |||||||||||||||||||||||||||||||||||||||||
| 1270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||
| 1272 | sub analyzeExecutionResultsDoubleWrite($%) #P Analyze execution results - double writes. | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionResultsDoubleWrite: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | my @r; | |||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | my $W = $exec->doubleWrite; | |||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | ▶ | if (keys %$W) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | {for my $p(sort keys %$W) | |||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | {for my $q(keys $$W{$p}->%*) | |||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | {push @r, sprintf "Double write occured %d times. ", $$W{$p}{$q}; | |||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | ▶ | if ($p eq $q) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | {push @r, "First and second write\n$p\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | {push @r, "First write:\n$p\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | push @r, "Second write:\n$q\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1292 | @r | ||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||
| 1295 | sub analyzeExecutionResults($%) #P Analyze execution results. | ||||||||||||||||||||||||||||||||||||||||||
| 1296 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionResults: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | my @r; | |||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | if (1) | |||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | {my @l = $exec->analyzeExecutionResultsLeast(%options); # Least/most executed | |||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | my @m = $exec->analyzeExecutionResultsMost (%options); | |||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | ▶ | if (@l and $options{leastExecuted}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@l and $options{"leastExecuted"}
MC/DC0%0/2
@l and $options{"leastExecuted"}
@l
$options{"leastExecuted"}
Truth table0%0/3
A and B
A= @lB= $options{"leastExecuted"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | {push @r, "Least executed:"; | |||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | push @r, @l; | |||||||||||||||||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | 0 | ▶ | if (@m and $options{mostExecuted}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@m and $options{"mostExecuted"}
MC/DC0%0/2
@m and $options{"mostExecuted"}
@m
$options{"mostExecuted"}
Truth table0%0/3
A and B
A= @mB= $options{"mostExecuted"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | {push @r, "Most executed:"; | |||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | push @r, @m; | |||||||||||||||||||||||||||||||||||||||||
| 1310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | if (my @n = $exec->analyzeExecutionNotRead(%options)) # Variables not read | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | {my $n = @n; | |||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | ▶ | @n = () unless $options{notRead}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | push @r, @n; | |||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | push @r, sprintf "# %8d variables not read", $n; | |||||||||||||||||||||||||||||||||||||||||
| 1318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | ▶ | if (my @d = $exec->analyzeExecutionResultsDoubleWrite(%options)) # Analyze execution results - double writes | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | {my $d = @d; | |||||||||||||||||||||||||||||||||||||||||
| 1322 | 0 | ▶ | @d = () unless $options{doubleWrite}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | push @r, @d; | |||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | push @r, sprintf "# %8d double writes", $d/2; | |||||||||||||||||||||||||||||||||||||||||
| 1325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | push @r, sprintf "# %8d instructions executed", $exec->count; | |||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | join "\n", @r; | |||||||||||||||||||||||||||||||||||||||||
| 1329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||
| 1331 | sub Zero::Emulator::Code::execute($%) #P Execute a block of code. | ||||||||||||||||||||||||||||||||||||||||||
| 1332 | 1 | ▶ | {my ($block, %options) = @_; # Block of code, execution options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=10 SCAR=46.5
| |||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||
| 1334 | 1 | ▶ | $block->assemble if $block; # Assemble unless we just want the instructions | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||
| 1336 | 1 | my $exec = ExecutionEnvironment(code=>$block, %options); # Create the execution environment | |||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||
| 1338 | my %instructions = # Instruction definitions | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | (add=> sub # Add the two source operands and store the result in the target | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | my $a = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | my $b = $exec->right($i->source2); | |||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | $exec->assign($t, $a + $b); | |||||||||||||||||||||||||||||||||||||||||
| 1345 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||
| 1347 | subtract=> sub # Subtract the second source operand from the first and store the result in the target | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | my $a = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | my $b = $exec->right($i->source2); | |||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | $exec->assign($t, $a - $b); | |||||||||||||||||||||||||||||||||||||||||
| 1353 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||
| 1355 | assert=> sub # Assert | ||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | $exec->stackTraceAndExit("Assert failed"); | |||||||||||||||||||||||||||||||||||||||||
| 1358 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||
| 1360 | assertEq=> sub # Assert equals | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | 0 | ▶ | {$exec->assert2("==", sub {my ($a, $b) = @_; $a == $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | }, | |||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | assertNe=> sub # Assert not equals | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | ▶ | {$exec->assert2("!=", sub {my ($a, $b) = @_; $a != $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | }, | |||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||
| 1368 | assertLt=> sub # Assert less than | ||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | ▶ | {$exec->assert2("< ", sub {my ($a, $b) = @_; $a < $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | }, | |||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||
| 1372 | assertLe=> sub # Assert less than or equal | ||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | ▶ | {$exec->assert2("<=", sub {my ($a, $b) = @_; $a <= $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | }, | |||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||
| 1376 | assertGt=> sub # Assert greater than | ||||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | ▶ | {$exec->assert2("> ", sub {my ($a, $b) = @_; $a > $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | }, | |||||||||||||||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||||||||||||||||
| 1380 | assertGe=> sub # Assert greater | ||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | ▶ | {$exec->assert2(">=", sub {my ($a, $b) = @_; $a >= $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | }, | |||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||
| 1384 | assertFalse=> sub # Assert false | ||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | ▶ | {$exec->assert1("False", sub {my ($a) = @_; $a == 0}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | }, | |||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||
| 1388 | assertTrue=> sub # Assert true | ||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | ▶ | {$exec->assert1("True", sub {my ($a) = @_; $a != 0}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | }, | |||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||
| 1392 | array=> sub # Create a new memory area and write its number into the address named by the target operand | ||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | my $s = $exec->right($i->source); # The reason for this allocation | |||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | my $a = $exec->allocMemory($s, arenaHeap); # Allocate | |||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | my $t = $exec->left($i->target); # Target in which to save array number | |||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | $exec->assign($t, $a); # Save array number in target# | |||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | $a | |||||||||||||||||||||||||||||||||||||||||
| 1399 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||
| 1401 | free=> sub # Free the memory area named by the source operand | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | my $area = $exec->right($i->target); # Area | |||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | my $name = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | $exec->freeArea(arenaHeap, $area, $name); # Free the area | |||||||||||||||||||||||||||||||||||||||||
| 1406 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | |||||||||||||||||||||||||||||||||||||||||||
| 1408 | arraySize=> sub # Get the size of the specified area | ||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | my $size = $exec->left ($i->target); # Location to store size in | |||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | my $area = $exec->right($i->source); # Location of area | |||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | my $name = $i->source2; # Name of area | |||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | $exec->checkArrayName(arenaHeap, $area, $name); # Check that the supplied array name matches what is actually in memory | |||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | $exec->assign($size, $exec->areaLength($area)) # Size of area | |||||||||||||||||||||||||||||||||||||||||
| 1417 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||
| 1419 | arrayIndex=> sub # Place the 1 based index of the second source operand in the array referenced by the first source operand in the target location | ||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1421 | 0 | my $x = $exec->left ($i->target); # Location to store index in | |||||||||||||||||||||||||||||||||||||||||
| 1422 | 0 | my $e = $exec->right($i->source2); # Location of element | |||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | ▶ | $exec->assign($x, $exec->locateAreaElement($i->source, sub{$_[0] == $e})) # Index of element | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1425 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||
| 1427 | arrayCountGreater=> sub # Count the number of elements in the array specified by the first source operand that are greater than the element supplied by the second source operand and place the result in the target location | ||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | my $x = $exec->left ($i->target); # Location to store index in | |||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | my $e = $exec->right($i->source2); # Location of element | |||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | ▶ | $exec->assign($x, $exec->countAreaElement($i->source, sub{$_[0] > $e})) # Index of element | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1433 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||||||||||||
| 1435 | arrayCountLess=> sub # Count the number of elements in the array specified by the first source operand that are less than the element supplied by the second source operand and place the result in the target location | ||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | my $x = $exec->left ($i->target); # Location to store index in | |||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | my $e = $exec->right($i->source2); # Location of element | |||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | ▶ | $exec->assign($x, $exec->countAreaElement($i->source, sub{$_[0] < $e})) # Index of element | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1441 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||
| 1443 | resize=> sub # Resize an array | ||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | my $size = $exec->right($i->source); # New size | |||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | my $name = $exec->right($i->source2); # Array name | |||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | my $area = $exec->right($i->target); # Array to resize | |||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | $exec->checkArrayName(arenaHeap, $area, $name); | |||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | $exec->ResizeMemoryArea->($exec, $area, $size); | |||||||||||||||||||||||||||||||||||||||||
| 1450 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||
| 1452 | call=> sub # Call a subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 1453 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | my $t = $i->jump->address; # Subroutine to call | |||||||||||||||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | ▶ | if (isScalar($t)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1457 | 0 | {$exec->instructionPointer = $i->number + $t; # Relative call if we know where the subroutine is relative to the call instruction | |||||||||||||||||||||||||||||||||||||||||
| 1458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1460 | 0 | {$exec->instructionPointer = $t; # Absolute call | |||||||||||||||||||||||||||||||||||||||||
| 1461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | 0 | push $exec->calls->@*, | |||||||||||||||||||||||||||||||||||||||||
| 1463 | stackFrame(target=>$block->code->[$exec->instructionPointer], # Create a new call stack entry | ||||||||||||||||||||||||||||||||||||||||||
| 1464 | instruction=>$i, #variables=>$i->procedure->variables, | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | $exec->allocateSystemAreas()); | ||||||||||||||||||||||||||||||||||||||||||
| 1466 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||
| 1468 | return=> sub # Return from a subroutine call via the call stack | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | ▶ | $exec->calls or $exec->stackTraceAndExit("The call stack is empty so I do not know where to return to"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | $exec->freeSystemAreas(pop $exec->calls->@* ); | |||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | ▶ | if ($exec->calls) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | {my $c = $exec->calls->[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 1474 | 0 | $exec->instructionPointer = $c->instruction->number+1; | |||||||||||||||||||||||||||||||||||||||||
| 1475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | {$exec->instructionPointer = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1479 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||
| 1481 | confess=> sub # Print the current call stack and stop | ||||||||||||||||||||||||||||||||||||||||||
| 1482 | 0 | ▶ | {$exec->stackTraceAndExit("Confess at:", confess=>1); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1483 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||
| 1485 | trace=> sub # Start/stop/change tracing status from a program. A trace writes out which instructions have been executed and how they affected memory | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | ▶ | my $s = $exec->right($i->source) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1488 | 0 | $exec->trace = $s; | |||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | my $m = "Trace: $s"; | |||||||||||||||||||||||||||||||||||||||||
| 1490 | 0 | ▶ | say STDERR $m unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1491 | 0 | $exec->output("$m\n"); | |||||||||||||||||||||||||||||||||||||||||
| 1492 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||
| 1494 | traceLabels=> sub # Start trace points | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | ▶ | my $s = $exec->right($i->source) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1497 | 0 | $exec->traceLabels = $s; | |||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | my $m = "TraceLabels: $s"; | |||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | ▶ | say STDERR $m unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1500 | 0 | $exec->output("$m\n"); | |||||||||||||||||||||||||||||||||||||||||
| 1501 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||
| 1503 | dump=> sub # Dump memory | ||||||||||||||||||||||||||||||||||||||||||
| 1504 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1505 | 0 | my @m= $exec->dumpMemory; | |||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | push @m, $exec->stackTrace; | |||||||||||||||||||||||||||||||||||||||||
| 1507 | 0 | my $m = join '', @m; | |||||||||||||||||||||||||||||||||||||||||
| 1508 | 0 | ▶ | say STDERR $m unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | $exec->output($m); | |||||||||||||||||||||||||||||||||||||||||
| 1510 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||
| 1512 | arrayDump=> sub # Dump array in memory | ||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1514 | 0 | my $a = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1515 | 0 | my $m = dump($exec->GetMemoryArea->($exec, arenaHeap, $a)) =~ s(\n) ()gsr; | |||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | ▶ | say STDERR $m unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | $exec->output("$m\n"); | |||||||||||||||||||||||||||||||||||||||||
| 1518 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||||||||||||||||
| 1520 | dec=> sub # Decrement locations in memory. The first address is incremented by 1, the next by two, etc. | ||||||||||||||||||||||||||||||||||||||||||
| 1521 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1522 | 0 | my $T = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1523 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1524 | 0 | ▶ | $exec->setMemory($t, defined($t) ? $T-1 : -1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1525 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||||||||||||
| 1527 | inc=> sub # Increment locations in memory. The first address is incremented by 1, the next by two, etc. | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1529 | 0 | my $T = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1530 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | ▶ | $exec->setMemory($t, defined($t) ? $T+1 : 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1532 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||
| 1534 | jmp=> sub # Jump to the target address | ||||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | my $n = $i->number; | |||||||||||||||||||||||||||||||||||||||||
| 1537 | #my $r = $exec->right($i->target); | ||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | my $r = $exec->right($i->jump); | |||||||||||||||||||||||||||||||||||||||||
| 1539 | 0 | $exec->instructionPointer = $n + $r; | |||||||||||||||||||||||||||||||||||||||||
| 1540 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1541 | # Conditional jumps | ||||||||||||||||||||||||||||||||||||||||||
| 1542 | 0 | ▶ | jEq=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) == $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | ▶ | jNe=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) != $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | ▶ | jLe=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) <= $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1545 | 0 | ▶ | jLt=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) < $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | ▶ | jGe=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) >= $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1547 | 0 | ▶ | jGt=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) > $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | ▶ | jFalse=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) == 0})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | ▶ | jTrue=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) != 0})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||
| 1551 | label=> sub # Label - no operation | ||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | ▶ | {my ($i) = @_; # Instruction | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | ▶ | return unless $exec->traceLabels; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | my $s = $exec->stackTrace("Label"); | |||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | ▶ | say STDERR $s unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1556 | 0 | $exec->output($s); | |||||||||||||||||||||||||||||||||||||||||
| 1557 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||
| 1559 | clear=> sub # Clear the first bytes of an area as specified by the target operand | ||||||||||||||||||||||||||||||||||||||||||
| 1560 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1561 | 0 | my $t = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1562 | 0 | my $N = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1563 | 0 | my $n = $exec->right($i->source2); | |||||||||||||||||||||||||||||||||||||||||
| 1564 | 0 | for my $a(0..$N-1) | |||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | {my $p = Address(arenaHeap, $t, $a, $N); | |||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | $exec->assign($p, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||||||||||||||||
| 1570 | loadAddress=> sub # Load the address component of a reference | ||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | my $s = $exec->left($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1574 | 0 | $exec->assign($t, $s->address); | |||||||||||||||||||||||||||||||||||||||||
| 1575 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||
| 1577 | loadArea=> sub # Load the area component of an address | ||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1579 | 0 | my $s = $exec->left($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1580 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1581 | 0 | $exec->assign($t, $s->area); | |||||||||||||||||||||||||||||||||||||||||
| 1582 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||
| 1584 | mov=> sub # Move data moves data from one part of memory to another - "set", by contrast, sets variables from constant values | ||||||||||||||||||||||||||||||||||||||||||
| 1585 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1586 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1588 | 0 | $exec->assign($t, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1589 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||
| 1591 | moveLong=> sub # Copy the number of elements specified by the second source operand from the location specified by the first source operand to the target operand | ||||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | my $s = $exec->left ($i->source); # Source | |||||||||||||||||||||||||||||||||||||||||
| 1594 | 0 | my $l = $exec->right($i->source2); # Length | |||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | my $t = $exec->left($i->target); # Target | |||||||||||||||||||||||||||||||||||||||||
| 1596 | 0 | for my $j(0..$l-1) | |||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | {my $S = Address($s->arena, $s->area, $s->address+$j, $s->name, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | my $T = Address($t->arena, $t->area, $t->address+$j, $t->name, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | my $v = $exec->getMemoryFromAddress($S); | |||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | $exec->assign($T, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1602 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||
| 1604 | not=> sub # Not in place | ||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1608 | 0 | $exec->assign($t, !$s); | |||||||||||||||||||||||||||||||||||||||||
| 1609 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||
| 1611 | paramsGet=> sub # Get a parameter from the previous parameter block - this means that we must always have two entries on the call stack - one representing the caller of the program, the second representing the current context of the program | ||||||||||||||||||||||||||||||||||||||||||
| 1612 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | my $S = Address(arenaParms, $exec->currentParamsGet, $s, $exec->paramsNumber); | |||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | my $v = $exec->getMemoryFromAddress($S); | |||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | $exec->assign($t, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1618 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1619 | |||||||||||||||||||||||||||||||||||||||||||
| 1620 | paramsPut=> sub # Place a parameter in the current parameter block | ||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | my $t = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | my $T = Address(arenaParms, $exec->currentParamsPut, $t, $exec->paramsNumber); | |||||||||||||||||||||||||||||||||||||||||
| 1625 | 0 | $exec->assign($T, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1626 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||
| 1628 | random=> sub # Random number in the specified range | ||||||||||||||||||||||||||||||||||||||||||
| 1629 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1630 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1631 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1632 | 0 | $exec->assign($t, int rand($s)); | |||||||||||||||||||||||||||||||||||||||||
| 1633 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||
| 1635 | randomSeed=> sub # Random number seed | ||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1637 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1638 | 0 | srand $s; | |||||||||||||||||||||||||||||||||||||||||
| 1639 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||
| 1641 | returnGet=> sub # Get a returned value | ||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1643 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1644 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | my $S = Address(arenaReturn, $exec->currentReturnGet, $s, $exec->returnNumber); | |||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | my $v = $exec->getMemoryFromAddress($S); | |||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | $exec->assign($t, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1648 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||||||||||||||||
| 1650 | returnPut=> sub # Place a value to be returned | ||||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1652 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | my $t = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | my $T = Address(arenaReturn, $exec->currentReturnPut, $t, $exec->returnNumber); | |||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | $exec->assign($T, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1656 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||||||||||||||||
| 1658 | nop=> sub # No operation | ||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | {my ($i) = @_; # Instruction | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1660 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1661 | |||||||||||||||||||||||||||||||||||||||||||
| 1662 | out=> sub # Write source as output to an array of words | ||||||||||||||||||||||||||||||||||||||||||
| 1663 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | ▶ | if (ref($i->source) =~ m(array)i) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | {my @t = map {$exec->right($_)} $i->source->@*; | |||||||||||||||||||||||||||||||||||||||||
| 1666 | 0 | my $t = join ' ', @t; | |||||||||||||||||||||||||||||||||||||||||
| 1667 | 0 | ▶ | say STDERR $t unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | $exec->output("$t\n"); | |||||||||||||||||||||||||||||||||||||||||
| 1669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1670 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | {my $t = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | ▶ | say STDERR $t unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1673 | 0 | $exec->output("$t\n"); | |||||||||||||||||||||||||||||||||||||||||
| 1674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1675 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||
| 1677 | pop=> sub # Pop a value from the specified memory area if possible else confess | ||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | my $S = $i->source2; | |||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1682 | 0 | my $v = $exec->popArea(arenaHeap, $s, $S); | |||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | $exec->assign($t, $v); # Pop from memory area into indicated memory address | |||||||||||||||||||||||||||||||||||||||||
| 1684 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1685 | |||||||||||||||||||||||||||||||||||||||||||
| 1686 | push=> sub # Push a value onto the specified memory area | ||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | my $S = $i->source2; | |||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | my $t = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | $exec->pushArea($t, $S, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1692 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1693 | |||||||||||||||||||||||||||||||||||||||||||
| 1694 | shiftLeft=> sub # Shift left within an element | ||||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1696 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | my $v = $exec->getMemoryFromAddress($t) << $s; | |||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | $exec->assign($t, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1700 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1701 | |||||||||||||||||||||||||||||||||||||||||||
| 1702 | shiftRight=> sub # Shift right within an element | ||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1706 | 0 | my $v = $exec->getMemoryFromAddress($t) >> $s; | |||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | $exec->assign($t, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1708 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||
| 1710 | shiftUp=> sub # Shift an element up in a memory area | ||||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1712 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1713 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | my $L = $exec->areaLength($t->area); # Length of target array | |||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | my $l = $t->address; | |||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | for my $j(reverse $l..$L) | |||||||||||||||||||||||||||||||||||||||||
| 1717 | 0 | {my $S = Address($t->arena, $t->area, $j-1, $t->name, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1718 | 0 | my $T = Address($t->arena, $t->area, $j, $t->name, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1719 | 0 | my $v = $exec->getMemoryFromAddress($S); | |||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | $exec->assign($T, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | 0 | $exec->assign($t, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1723 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||||||||||||||||
| 1725 | shiftDown=> sub # Shift an element down in a memory area | ||||||||||||||||||||||||||||||||||||||||||
| 1726 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1727 | 0 | my $s = $exec->left($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1729 | 0 | my $L = $exec->areaLength($s->area); # Length of source array | |||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | my $l = $s->address; | |||||||||||||||||||||||||||||||||||||||||
| 1731 | 0 | my $v = $exec->getMemoryFromAddress($s); | |||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | for my $j($l..$L-2) # Each element in specified range | |||||||||||||||||||||||||||||||||||||||||
| 1733 | 0 | {my $S = Address($s->arena, $s->area, $j+1, $s->name, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1734 | 0 | my $T = Address($s->arena, $s->area, $j, $s->name, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1735 | 0 | my $v = $exec->getMemoryFromAddress($S); | |||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | $exec->assign($T, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1737 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | $exec->popArea(arenaHeap, $s->area, $s->name); | |||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | my $T = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | $exec->assign($T, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1741 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||
| 1743 | tally=> sub # Tally instruction usage | ||||||||||||||||||||||||||||||||||||||||||
| 1744 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1745 | 0 | my $t = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1746 | 0 | $exec->tally = $t; | |||||||||||||||||||||||||||||||||||||||||
| 1747 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||||||||||||||||
| 1749 | watch=> sub # Watch a memory location for changes | ||||||||||||||||||||||||||||||||||||||||||
| 1750 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1751 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1752 | 0 | $exec->watch->[$t->area][$t->address]++; | |||||||||||||||||||||||||||||||||||||||||
| 1753 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1754 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 1755 | 1 | ▶ | return {%instructions} unless $block; # Return a list of the instructions | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||||||||||||
| 1757 | 0 | $allocs = []; # Reset all allocations | |||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | $exec->createInitialStackEntry; # Variables in initial stack frame | |||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||
| 1760 | my $mi = $options{maximumInstructionsToExecute} // # Prevent run away executions | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | 0 | ▶ | maximumInstructionsToExecute; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$options{"maximumInstructionsToExecute"} // maximumInstructionsToExecute()
MC/DC0%0/2
$options{"maximumInstructionsToExecute"} // maximumInstructionsToExecute()
$options{"maximumInstructionsToExecute"}
maximumInstructionsToExecute()
Truth table0%0/3
A // B
A= $options{"maximumInstructionsToExecute"}B= maximumInstructionsToExecute()
| |||||||||||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||||||||||
| 1763 | 0 | for my $step(1..$mi) # Execute each instruction in the code until we hit an undefined instruction. Track various statistics to assist in debugging and code improvement. | |||||||||||||||||||||||||||||||||||||||||
| 1764 | 0 | ▶ | {last unless defined($exec->instructionPointer); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1765 | 0 | my $instruction = $exec->block->code->[$exec->instructionPointer++]; # Current instruction | |||||||||||||||||||||||||||||||||||||||||
| 1766 | 0 | ▶ | last unless $instruction; # Current instruction is undefined so we must have reached the end of the program | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | $exec->calls->[-1]->instruction = $instruction; # Make this instruction the current instruction | |||||||||||||||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||||||||||||||||
| 1770 | 0 | ▶ | if (my $a = $instruction->action) # Action | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1771 | {$exec->stackTraceAndExit(qq(No implementation for instruction: "$a")) # Check that there is come code implementing the action for this instruction | ||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | ▶ | unless my $implementation = $instructions{$a}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | $exec->tallyInstructionCounts($instruction); # Tally instruction counts | |||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | $exec->resetLastAssign; # Trace assignments | |||||||||||||||||||||||||||||||||||||||||
| 1776 | 0 | $instruction->step = $step; # Execution step number facilitates debugging | |||||||||||||||||||||||||||||||||||||||||
| 1777 | |||||||||||||||||||||||||||||||||||||||||||
| 1778 | 0 | $implementation->($instruction); # Execute instruction | |||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||
| 1780 | #say STDERR "AAAA", unpack "h*", $exec->memoryString if $a =~ m(mov); # Print memory | ||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | $exec->instructionCounts->{$instruction->number}++; # Execution count by actual instruction | |||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||
| 1783 | 0 | ++$instruction->executed; | |||||||||||||||||||||||||||||||||||||||||
| 1784 | |||||||||||||||||||||||||||||||||||||||||||
| 1785 | 0 | $exec->traceMemory($instruction); # Trace changes to memory | |||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1787 | 0 | ▶ | if ($step >= maximumInstructionsToExecute) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1788 | 0 | {confess "Out of instructions after $step"; | |||||||||||||||||||||||||||||||||||||||||
| 1789 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1791 | |||||||||||||||||||||||||||||||||||||||||||
| 1792 | 0 | $exec->freeSystemAreas($exec->calls->[0]); # Free first stack frame | |||||||||||||||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||||||||||||||||
| 1794 | 0 | $exec->completionStatistics; | |||||||||||||||||||||||||||||||||||||||||
| 1795 | |||||||||||||||||||||||||||||||||||||||||||
| 1796 | 0 | $exec | |||||||||||||||||||||||||||||||||||||||||
| 1797 | } # Execution results | ||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||
| 1799 | sub completionStatistics($) #P Produce various statistics summarizing the execution of the program. | ||||||||||||||||||||||||||||||||||||||||||
| 1800 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
completionStatistics: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | my $code = $exec->block->code; # Instructions in code block | |||||||||||||||||||||||||||||||||||||||||
| 1802 | 0 | my @n; | |||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | for my $i(@$code) # Each instruction | |||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | ▶ | {push @n, $i unless $i->executed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1805 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | $exec->notExecuted = [@n]; | |||||||||||||||||||||||||||||||||||||||||
| 1807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||
| 1809 | sub tallyInstructionCounts($$) #P Tally instruction counts. | ||||||||||||||||||||||||||||||||||||||||||
| 1810 | 0 | ▶ | {my ($exec, $instruction) = @_; # Execution environment, instruction being executed | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tallyInstructionCounts: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1811 | 0 | my $a = $instruction->action; | |||||||||||||||||||||||||||||||||||||||||
| 1812 | 0 | ▶ | if ($a !~ m(\A(assert.*|label|tally|trace(Points?)?)\Z)) # Omit instructions that are not tally-able | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1813 | 0 | ▶ | {if (my $t = $exec->tally) # Tally instruction counts | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1814 | 0 | {$exec->tallyCount++; | |||||||||||||||||||||||||||||||||||||||||
| 1815 | 0 | $exec->tallyTotal->{$t}++; | |||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | $exec->tallyCounts->{$t}{$a}++; | |||||||||||||||||||||||||||||||||||||||||
| 1817 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1818 | 0 | $exec->counts->{$a}++; $exec->count++; # Execution instruction counts | |||||||||||||||||||||||||||||||||||||||||
| 1819 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1820 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||||||||||||||||
| 1822 | sub resetLastAssign($) #P Reset the last assign trace fields ready for this instruction. | ||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resetLastAssign: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | $exec->lastAssignArena = $exec->lastAssignArea = | |||||||||||||||||||||||||||||||||||||||||
| 1825 | $exec->lastAssignAddress = $exec->lastAssignValue = undef; | ||||||||||||||||||||||||||||||||||||||||||
| 1826 | } # Execution results | ||||||||||||||||||||||||||||||||||||||||||
| 1827 | |||||||||||||||||||||||||||||||||||||||||||
| 1828 | sub traceMemory($$) #P Trace memory. | ||||||||||||||||||||||||||||||||||||||||||
| 1829 | 0 | ▶ | {my ($exec, $instruction) = @_; # Execution environment, current instruction | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
traceMemory: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1830 | 0 | ▶ | return unless $exec->trace; # Trace changes to memory if requested | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | my $e = $exec->instructionCounts->{$instruction->number}; # Execution count for this instruction | |||||||||||||||||||||||||||||||||||||||||
| 1832 | 0 | my $f = $exec->formatTrace; | |||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | my $s = $exec->suppressOutput; | |||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | my $a = $instruction->action; | |||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | my $n = $instruction->number; | |||||||||||||||||||||||||||||||||||||||||
| 1836 | 0 | my $F = $instruction->file; | |||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | my $L = $instruction->line; | |||||||||||||||||||||||||||||||||||||||||
| 1838 | 0 | my $S = $instruction->step; | |||||||||||||||||||||||||||||||||||||||||
| 1839 | 0 | my $m = sprintf "%5d %4d %4d %12s", $S, $n, $e, $a; | |||||||||||||||||||||||||||||||||||||||||
| 1840 | 0 | ▶ | $m .= sprintf " %20s", $f if $f; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1841 | 0 | ▶ | $m .= sprintf " at %s line %d", $F, $L unless $s; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1842 | 0 | ▶ | say STDERR $m unless $s; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1843 | 0 | $exec->output("$m\n"); | |||||||||||||||||||||||||||||||||||||||||
| 1844 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||||||||||||||||
| 1846 | sub formatTrace($) #P Describe last memory assignment. | ||||||||||||||||||||||||||||||||||||||||||
| 1847 | 0 | ▶ | {my ($exec) = @_; # Execution | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
formatTrace: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1848 | 0 | ▶ | return "" unless defined(my $arena = $exec->lastAssignArena); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1849 | 0 | ▶ | return "" unless defined(my $area = $exec->lastAssignArea); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1850 | 0 | ▶ | return "" unless defined(my $addr = $exec->lastAssignAddress); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1851 | 0 | ▶ | return "" unless defined(my $type = $exec->block->ArrayNumberToName($exec->lastAssignType)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1852 | 0 | ▶ | return "" unless defined(my $value = $exec->lastAssignValue); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1853 | 0 | my $B = $exec->lastAssignBefore; | |||||||||||||||||||||||||||||||||||||||||
| 1854 | 0 | ▶ | my $b = defined($B) ? " was $B" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1855 | 0 | sprintf "[%d, %d, %s] = %d$b", $area, $addr, $type, $value; | |||||||||||||||||||||||||||||||||||||||||
| 1856 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||||||||||||||||
| 1858 | #D1 Instruction Set # The instruction set used by the Zero assembler programming language. | ||||||||||||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||||||||||||
| 1860 | 1 | my $assembly; # The current assembly | |||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||
| 1862 | sub Assembly() #P Start some assembly code. | ||||||||||||||||||||||||||||||||||||||||||
| 1863 | 0 | ▶ | {$assembly = Code; # The current assembly | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Assembly: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1864 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||||||||||||||||
| 1866 | my sub label() # Next unique label | ||||||||||||||||||||||||||||||||||||||||||
| 1867 | 0 | ▶ | {++$assembly->labelCounter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1868 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||
| 1870 | my sub setLabel(;$) # Set and return a label | ||||||||||||||||||||||||||||||||||||||||||
| 1871 | 0 | ▶ | {my ($l) = @_; # Optional preset label | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setLabel: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1872 | 0 | ▶ | $l //= label; # Create label if none supplied | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$l //= label
MC/DC0%0/2
$l //= label
$l
label
Truth table0%0/3
A //= B
A= $lB= label
| |||||||||||||||||||||||||||||||||||||||||||
| 1873 | 0 | Label($l); # Set label | |||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | $l # Return (new) label | |||||||||||||||||||||||||||||||||||||||||
| 1875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1876 | |||||||||||||||||||||||||||||||||||||||||||
| 1877 | my sub xSource($) # Record a source argument | ||||||||||||||||||||||||||||||||||||||||||
| 1878 | 0 | ▶ | {my ($s) = @_; # Source expression | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xSource: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1879 | 0 | (q(source), $assembly->Reference($s)) | |||||||||||||||||||||||||||||||||||||||||
| 1880 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||
| 1882 | my sub xSource2($) # Record a source argument | ||||||||||||||||||||||||||||||||||||||||||
| 1883 | 0 | ▶ | {my ($s) = @_; # Source expression | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xSource2: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1884 | 0 | (q(source2), $assembly->Reference($s)) | |||||||||||||||||||||||||||||||||||||||||
| 1885 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1886 | |||||||||||||||||||||||||||||||||||||||||||
| 1887 | my sub xTarget($) # Record a target argument | ||||||||||||||||||||||||||||||||||||||||||
| 1888 | 0 | ▶ | {my ($t) = @_; # Target expression | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xTarget: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1889 | 0 | (q(target), $assembly->Reference($t)) | |||||||||||||||||||||||||||||||||||||||||
| 1890 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||||||||||||||||
| 1892 | sub Inc($); | ||||||||||||||||||||||||||||||||||||||||||
| 1893 | sub Jge($$$); | ||||||||||||||||||||||||||||||||||||||||||
| 1894 | sub Jlt($$$); | ||||||||||||||||||||||||||||||||||||||||||
| 1895 | sub Jmp($); | ||||||||||||||||||||||||||||||||||||||||||
| 1896 | sub Mov($;$); | ||||||||||||||||||||||||||||||||||||||||||
| 1897 | sub Subtract($$;$); | ||||||||||||||||||||||||||||||||||||||||||
| 1898 | |||||||||||||||||||||||||||||||||||||||||||
| 1899 | sub Add($$;$) #i Add the source locations together and store the result in the target area. | ||||||||||||||||||||||||||||||||||||||||||
| 1900 | 0 | ▶ | {my ($target, $s1, $s2) = @_ == 2 ? (&Var(), @_) : @_; # Target address, source one, source two | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Add: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1901 | 0 | $assembly->instruction(action=>"add", xTarget($target), | |||||||||||||||||||||||||||||||||||||||||
| 1902 | xSource($s1), xSource2($s2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1903 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 1904 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||
| 1906 | sub Array($) #i Create a new memory area and write its number into the address named by the target operand. | ||||||||||||||||||||||||||||||||||||||||||
| 1907 | 0 | ▶ | {my ($source) = @_; # Name of allocation | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Array: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1908 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1909 | 0 | my $n = $assembly->ArrayNameToNumber($source); | |||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | $assembly->instruction(action=>"array", xTarget($t), xSource($n)); # Encode array name as a number | |||||||||||||||||||||||||||||||||||||||||
| 1911 | 0 | $t; | |||||||||||||||||||||||||||||||||||||||||
| 1912 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1913 | |||||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | ▶ | sub ArrayCountLess($$;$) { #i Count the number of elements in the array specified by the first source operand that are less than the element supplied by the second source operand and place the result in the target location. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ArrayCountLess: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | ▶ | if (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1916 | 0 | {my ($area, $element) = @_; # Area, element to find | |||||||||||||||||||||||||||||||||||||||||
| 1917 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1918 | 0 | $assembly->instruction(action=>"arrayCountLess", | |||||||||||||||||||||||||||||||||||||||||
| 1919 | xTarget($t), xSource($area), xSource2($element)); | ||||||||||||||||||||||||||||||||||||||||||
| 1920 | 0 | $t | |||||||||||||||||||||||||||||||||||||||||
| 1921 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1922 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1923 | 0 | {my ($target, $area, $element) = @_; # Target, area, element to find | |||||||||||||||||||||||||||||||||||||||||
| 1924 | 0 | $assembly->instruction(action=>"arrayCountLess", | |||||||||||||||||||||||||||||||||||||||||
| 1925 | xTarget($target), xSource($area), xSource2($element)); | ||||||||||||||||||||||||||||||||||||||||||
| 1926 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1927 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1928 | |||||||||||||||||||||||||||||||||||||||||||
| 1929 | 0 | ▶ | sub ArrayCountGreater($$;$) { #i Count the number of elements in the array specified by the first source operand that are greater than the element supplied by the second source operand and place the result in the target location. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ArrayCountGreater: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1930 | 0 | ▶ | if (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1931 | 0 | {my ($area, $element) = @_; # Area, element to find | |||||||||||||||||||||||||||||||||||||||||
| 1932 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1933 | 0 | $assembly->instruction(action=>"arrayCountGreater", | |||||||||||||||||||||||||||||||||||||||||
| 1934 | xTarget($t), xSource($area), xSource2($element)); | ||||||||||||||||||||||||||||||||||||||||||
| 1935 | 0 | $t | |||||||||||||||||||||||||||||||||||||||||
| 1936 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1937 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1938 | 0 | {my ($target, $area, $element) = @_; # Target, area, element to find | |||||||||||||||||||||||||||||||||||||||||
| 1939 | 0 | $assembly->instruction(action=>"arrayCountGreater", | |||||||||||||||||||||||||||||||||||||||||
| 1940 | xTarget($target), xSource($area), xSource2($element)); | ||||||||||||||||||||||||||||||||||||||||||
| 1941 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1942 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||
| 1944 | sub ArrayDump($) #i Dump an array. | ||||||||||||||||||||||||||||||||||||||||||
| 1945 | 0 | ▶ | {my ($target) = @_; # Array to dump, title of dump | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ArrayDump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1946 | 0 | $assembly->instruction(action=>"arrayDump", xTarget($target)); | |||||||||||||||||||||||||||||||||||||||||
| 1947 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1948 | |||||||||||||||||||||||||||||||||||||||||||
| 1949 | 0 | ▶ | sub ArrayIndex($$;$) { #i Find the 1 based index of the second source operand in the array referenced by the first source operand if it is present in the array else 0 into the target location. The business of returning -1 would have led to the confusion of "try catch" and we certainly do not want that. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ArrayIndex: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1950 | 0 | ▶ | if (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1951 | 0 | {my ($area, $element) = @_; # Area, element to find | |||||||||||||||||||||||||||||||||||||||||
| 1952 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1953 | 0 | $assembly->instruction(action=>"arrayIndex", | |||||||||||||||||||||||||||||||||||||||||
| 1954 | xTarget($t), xSource($area), xSource2($element)); | ||||||||||||||||||||||||||||||||||||||||||
| 1955 | 0 | $t | |||||||||||||||||||||||||||||||||||||||||
| 1956 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1957 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1958 | 0 | {my ($target, $area, $element) = @_; # Target, area, element to find | |||||||||||||||||||||||||||||||||||||||||
| 1959 | 0 | $assembly->instruction(action=>"arrayIndex", | |||||||||||||||||||||||||||||||||||||||||
| 1960 | xTarget($target), xSource($area), xSource2($element)); | ||||||||||||||||||||||||||||||||||||||||||
| 1961 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1962 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||||||||||||||||
| 1964 | sub ArraySize($$) #i The current size of an array. | ||||||||||||||||||||||||||||||||||||||||||
| 1965 | 0 | ▶ | {my ($area, $name) = @_; # Location of area, name of area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ArraySize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1966 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1967 | 0 | $assembly->instruction(action=>"arraySize", # Target - location to place the size in, source - address of the area, source2 - the name of the area which cannot be taken from the area of the first source operand because that area name is the name of the area that contains the location of the area we wish to work on. | |||||||||||||||||||||||||||||||||||||||||
| 1968 | xTarget($t), xSource($area), source2=>$assembly->ArrayNameToNumber($name)); | ||||||||||||||||||||||||||||||||||||||||||
| 1969 | 0 | $t | |||||||||||||||||||||||||||||||||||||||||
| 1970 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1971 | sub Assert1($$) #P Assert operation. | ||||||||||||||||||||||||||||||||||||||||||
| 1972 | 0 | ▶ | {my ($op, $a) = @_; # Operation, Source operand | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Assert1: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1973 | 0 | $assembly->instruction(action=>"assert$op", xSource($a), level=>2); | |||||||||||||||||||||||||||||||||||||||||
| 1974 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||||||||||||
| 1976 | sub Assert2($$$) #P Assert operation. | ||||||||||||||||||||||||||||||||||||||||||
| 1977 | 0 | ▶ | {my ($op, $a, $b) = @_; # Operation, First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Assert2: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1978 | 0 | $assembly->instruction(action=>"assert$op", | |||||||||||||||||||||||||||||||||||||||||
| 1979 | xSource($a), xSource2($b), level=>2); | ||||||||||||||||||||||||||||||||||||||||||
| 1980 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||||||||||||||||
| 1982 | sub Assert(%) #i Assert regardless. | ||||||||||||||||||||||||||||||||||||||||||
| 1983 | 0 | ▶ | {my (%options) = @_; # Options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Assert: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1984 | 0 | $assembly->instruction(action=>"assert"); | |||||||||||||||||||||||||||||||||||||||||
| 1985 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||
| 1987 | sub AssertEq($$%) #i Assert two memory locations are equal. | ||||||||||||||||||||||||||||||||||||||||||
| 1988 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertEq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1989 | 0 | Assert2("Eq", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1990 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1991 | |||||||||||||||||||||||||||||||||||||||||||
| 1992 | sub AssertFalse($%) #i Assert false. | ||||||||||||||||||||||||||||||||||||||||||
| 1993 | 0 | ▶ | {my ($a, %options) = @_; # Source operand | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertFalse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1994 | 0 | Assert1("False", $a); | |||||||||||||||||||||||||||||||||||||||||
| 1995 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1996 | |||||||||||||||||||||||||||||||||||||||||||
| 1997 | sub AssertGe($$%) #i Assert are greater than or equal. | ||||||||||||||||||||||||||||||||||||||||||
| 1998 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertGe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1999 | 0 | Assert2("Ge", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 2000 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2001 | |||||||||||||||||||||||||||||||||||||||||||
| 2002 | sub AssertGt($$%) #i Assert two memory locations are greater than. | ||||||||||||||||||||||||||||||||||||||||||
| 2003 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertGt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2004 | 0 | Assert2("Gt", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 2005 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2006 | |||||||||||||||||||||||||||||||||||||||||||
| 2007 | sub AssertLe($$%) #i Assert two memory locations are less than or equal. | ||||||||||||||||||||||||||||||||||||||||||
| 2008 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertLe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2009 | 0 | Assert2("Le", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 2010 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2011 | |||||||||||||||||||||||||||||||||||||||||||
| 2012 | sub AssertLt($$%) #i Assert two memory locations are less than. | ||||||||||||||||||||||||||||||||||||||||||
| 2013 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertLt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2014 | 0 | Assert2("Lt", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 2015 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||||||||||||||||
| 2017 | sub AssertNe($$%) #i Assert two memory locations are not equal. | ||||||||||||||||||||||||||||||||||||||||||
| 2018 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertNe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2019 | 0 | Assert2("Ne", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 2020 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||||||||||||||||
| 2022 | sub AssertTrue($%) #i Assert true. | ||||||||||||||||||||||||||||||||||||||||||
| 2023 | 0 | ▶ | {my ($a, %options) = @_; # Source operand | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertTrue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2024 | 0 | Assert1("True", $a); | |||||||||||||||||||||||||||||||||||||||||
| 2025 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||||||||||||||||
| 2027 | sub Bad(&) #i A bad ending. | ||||||||||||||||||||||||||||||||||||||||||
| 2028 | 0 | ▶ | {my ($bad) = @_; # What to do on a bad ending | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Bad: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2029 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2030 | 0 | (bad=> $bad) | |||||||||||||||||||||||||||||||||||||||||
| 2031 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2032 | |||||||||||||||||||||||||||||||||||||||||||
| 2033 | sub Block(&%) #i Block of code that can either be restarted or come to a good or a bad ending. | ||||||||||||||||||||||||||||||||||||||||||
| 2034 | 0 | ▶ | {my ($block, %options) = @_; # Block, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Block: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2035 | 0 | my ($Start, $Good, $Bad, $End) = (label, label, label, label); | |||||||||||||||||||||||||||||||||||||||||
| 2036 | |||||||||||||||||||||||||||||||||||||||||||
| 2037 | 0 | my $g = $options{good}; | |||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | my $b = $options{bad}; | |||||||||||||||||||||||||||||||||||||||||
| 2039 | |||||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | setLabel($Start); # Start | |||||||||||||||||||||||||||||||||||||||||
| 2041 | |||||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | &$block($Start, $Good, $Bad, $End); # Code of block | |||||||||||||||||||||||||||||||||||||||||
| 2043 | |||||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | ▶ | if ($g) # Good | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2045 | 0 | {Jmp $End; | |||||||||||||||||||||||||||||||||||||||||
| 2046 | 0 | setLabel($Good); | |||||||||||||||||||||||||||||||||||||||||
| 2047 | 0 | &$g($Start, $Good, $Bad, $End); | |||||||||||||||||||||||||||||||||||||||||
| 2048 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2049 | |||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | ▶ | if ($b) # Bad | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2051 | 0 | {Jmp $End; | |||||||||||||||||||||||||||||||||||||||||
| 2052 | 0 | setLabel($Bad); | |||||||||||||||||||||||||||||||||||||||||
| 2053 | 0 | &$b($Start, $Good, $Bad, $End); | |||||||||||||||||||||||||||||||||||||||||
| 2054 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2055 | 0 | ▶ | setLabel($Good) unless $g; # Default positions for Good and Bad if not specified | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2056 | 0 | ▶ | setLabel($Bad) unless $b; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2057 | 0 | setLabel($End); # End | |||||||||||||||||||||||||||||||||||||||||
| 2058 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2059 | |||||||||||||||||||||||||||||||||||||||||||
| 2060 | sub Call($) #i Call the subroutine at the target address. | ||||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | ▶ | {my ($p) = @_; # Procedure description. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Call: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2062 | 0 | $assembly->instruction(action=>"call", xTarget($p->target)); | |||||||||||||||||||||||||||||||||||||||||
| 2063 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2064 | |||||||||||||||||||||||||||||||||||||||||||
| 2065 | sub Clear($$$) #i Clear the first bytes of an area. The area is specified by the first element of the address, the number of locations to clear is specified by the second element of the target address. | ||||||||||||||||||||||||||||||||||||||||||
| 2066 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target address to clear, number of bytes to clear, name of target | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Clear: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2067 | 0 | $assembly->instruction(action=>"clear", xTarget($target), | |||||||||||||||||||||||||||||||||||||||||
| 2068 | xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2069 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2070 | |||||||||||||||||||||||||||||||||||||||||||
| 2071 | sub Confess() #i Confess with a stack trace showing the location both in the emulated code and in the code that produced the emulated code. | ||||||||||||||||||||||||||||||||||||||||||
| 2072 | 0 | ▶ | {$assembly->instruction(action=>"confess"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Confess: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2073 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2074 | |||||||||||||||||||||||||||||||||||||||||||
| 2075 | sub Dec($) #i Decrement the target. | ||||||||||||||||||||||||||||||||||||||||||
| 2076 | 0 | ▶ | {my ($target) = @_; # Target address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Dec: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2077 | 0 | $assembly->instruction(action=>"dec", xTarget($target)) | |||||||||||||||||||||||||||||||||||||||||
| 2078 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2079 | |||||||||||||||||||||||||||||||||||||||||||
| 2080 | sub Dump() #i Dump all the arrays currently in memory. | ||||||||||||||||||||||||||||||||||||||||||
| 2081 | 0 | ▶ | {$assembly->instruction(action=>"dump"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2082 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||||||||||||||||
| 2084 | sub Else(&) #i Else block. | ||||||||||||||||||||||||||||||||||||||||||
| 2085 | 0 | ▶ | {my ($e) = @_; # Else block subroutine | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Else: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2086 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2087 | 0 | (else=> $e) | |||||||||||||||||||||||||||||||||||||||||
| 2088 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2089 | |||||||||||||||||||||||||||||||||||||||||||
| 2090 | sub Execute(%) #i Execute the current assembly. | ||||||||||||||||||||||||||||||||||||||||||
| 2091 | 0 | ▶ | {my (%options) = @_; # Options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Execute: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2092 | 0 | $assembly->execute(%options); # Execute the code in the current assembly | |||||||||||||||||||||||||||||||||||||||||
| 2093 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2094 | |||||||||||||||||||||||||||||||||||||||||||
| 2095 | sub For(&$%) #i For loop 0..range-1 or in reverse. | ||||||||||||||||||||||||||||||||||||||||||
| 2096 | 0 | ▶ | {my ($block, $range, %options) = @_; # Block, limit, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
For: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2097 | 0 | ▶ | if (!exists $options{reverse}) # Ascending order | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2098 | 0 | {my $s = 0; my $e = $range; # Start, end | |||||||||||||||||||||||||||||||||||||||||
| 2099 | 0 | ▶ | ($s, $e) = @$range if ref($e) =~ m(ARRAY); # Start, end as a reference | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2100 | |||||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | my ($Start, $Check, $Next, $End) = (label, label, label, label); | |||||||||||||||||||||||||||||||||||||||||
| 2102 | |||||||||||||||||||||||||||||||||||||||||||
| 2103 | 0 | setLabel($Start); # Start | |||||||||||||||||||||||||||||||||||||||||
| 2104 | 0 | my $i = Mov $s; | |||||||||||||||||||||||||||||||||||||||||
| 2105 | 0 | setLabel($Check); # Check | |||||||||||||||||||||||||||||||||||||||||
| 2106 | 0 | Jge $End, $i, $e; | |||||||||||||||||||||||||||||||||||||||||
| 2107 | 0 | &$block($i, $Check, $Next, $End); # Block | |||||||||||||||||||||||||||||||||||||||||
| 2108 | 0 | setLabel($Next); | |||||||||||||||||||||||||||||||||||||||||
| 2109 | 0 | Inc $i; # Next | |||||||||||||||||||||||||||||||||||||||||
| 2110 | 0 | Jmp $Check; | |||||||||||||||||||||||||||||||||||||||||
| 2111 | 0 | setLabel($End); # End | |||||||||||||||||||||||||||||||||||||||||
| 2112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2113 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2114 | 0 | {my $s = $range; my $e = 0; # Start, end | |||||||||||||||||||||||||||||||||||||||||
| 2115 | 0 | ▶ | ($e, $s) = @$range if ref($s) =~ m(ARRAY); # End, start as a reference | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2116 | |||||||||||||||||||||||||||||||||||||||||||
| 2117 | 0 | my ($Start, $Check, $Next, $End) = (label, label, label, label); | |||||||||||||||||||||||||||||||||||||||||
| 2118 | |||||||||||||||||||||||||||||||||||||||||||
| 2119 | 0 | setLabel($Start); # Start | |||||||||||||||||||||||||||||||||||||||||
| 2120 | 0 | my $i = Subtract $s, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2121 | 0 | Subtract $i, $s; | |||||||||||||||||||||||||||||||||||||||||
| 2122 | 0 | setLabel($Check); # Check | |||||||||||||||||||||||||||||||||||||||||
| 2123 | 0 | Jlt $End, $i, $e; | |||||||||||||||||||||||||||||||||||||||||
| 2124 | 0 | &$block($i, $Check, $Next, $End); # Block | |||||||||||||||||||||||||||||||||||||||||
| 2125 | 0 | setLabel($Next); | |||||||||||||||||||||||||||||||||||||||||
| 2126 | 0 | Dec $i; # Next | |||||||||||||||||||||||||||||||||||||||||
| 2127 | 0 | Jmp $Check; | |||||||||||||||||||||||||||||||||||||||||
| 2128 | 0 | setLabel($End); # End | |||||||||||||||||||||||||||||||||||||||||
| 2129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2131 | |||||||||||||||||||||||||||||||||||||||||||
| 2132 | sub ForArray(&$$%) #i For loop to process each element of the named area. | ||||||||||||||||||||||||||||||||||||||||||
| 2133 | 0 | ▶ | {my ($block, $area, $name, %options) = @_; # Block of code, area, area name, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ForArray: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2134 | 0 | my $e = ArraySize $area, $name; # End | |||||||||||||||||||||||||||||||||||||||||
| 2135 | 0 | my $s = 0; # Start | |||||||||||||||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||||||||||||||||
| 2137 | 0 | my ($Start, $Check, $Next, $End) = (label, label, label, label); | |||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||
| 2139 | 0 | setLabel($Start); # Start | |||||||||||||||||||||||||||||||||||||||||
| 2140 | 0 | my $i = Mov $s; | |||||||||||||||||||||||||||||||||||||||||
| 2141 | 0 | setLabel($Check); # Check | |||||||||||||||||||||||||||||||||||||||||
| 2142 | 0 | Jge $End, $i, $e; | |||||||||||||||||||||||||||||||||||||||||
| 2143 | 0 | my $a = Mov [$area, \$i, $name]; | |||||||||||||||||||||||||||||||||||||||||
| 2144 | 0 | &$block($i, $a, $Check, $Next, $End); # Block | |||||||||||||||||||||||||||||||||||||||||
| 2145 | 0 | setLabel($Next); | |||||||||||||||||||||||||||||||||||||||||
| 2146 | 0 | Inc $i; # Next | |||||||||||||||||||||||||||||||||||||||||
| 2147 | 0 | Jmp $Check; | |||||||||||||||||||||||||||||||||||||||||
| 2148 | 0 | setLabel($End); # End | |||||||||||||||||||||||||||||||||||||||||
| 2149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||
| 2151 | sub Free($$) #i Free the memory area named by the target operand after confirming that it has the name specified on the source operand. | ||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | ▶ | {my ($target, $source) = @_; # Target area yielding the id of the area to be freed, source area yielding the name of the area to be freed | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Free: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2153 | 0 | my $n = $assembly->ArrayNameToNumber($source); | |||||||||||||||||||||||||||||||||||||||||
| 2154 | 0 | $assembly->instruction(action=>"free", xTarget($target), xSource($n)); | |||||||||||||||||||||||||||||||||||||||||
| 2155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2156 | |||||||||||||||||||||||||||||||||||||||||||
| 2157 | sub Good(&) #i A good ending. | ||||||||||||||||||||||||||||||||||||||||||
| 2158 | 0 | ▶ | {my ($good) = @_; # What to do on a good ending | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Good: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2159 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2160 | 0 | (good=> $good) | |||||||||||||||||||||||||||||||||||||||||
| 2161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2162 | |||||||||||||||||||||||||||||||||||||||||||
| 2163 | sub Ifx($$$%) #P Execute then or else clause depending on whether two memory locations are equal. | ||||||||||||||||||||||||||||||||||||||||||
| 2164 | 0 | ▶ | {my ($cmp, $a, $b, %options) = @_; # Comparison, first memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Ifx: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2165 | 0 | ▶ | confess "Then required" unless $options{then}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2166 | 0 | ▶ | if ($options{else}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2167 | 0 | {my $else = label; | |||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | my $end = label; | |||||||||||||||||||||||||||||||||||||||||
| 2169 | 0 | &$cmp($else, $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 2170 | 0 | &{$options{then}}; | |||||||||||||||||||||||||||||||||||||||||
| 2171 | 0 | Jmp $end; | |||||||||||||||||||||||||||||||||||||||||
| 2172 | 0 | setLabel($else); | |||||||||||||||||||||||||||||||||||||||||
| 2173 | 0 | &{$options{else}}; | |||||||||||||||||||||||||||||||||||||||||
| 2174 | 0 | setLabel($end); | |||||||||||||||||||||||||||||||||||||||||
| 2175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2176 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2177 | 0 | {my $end = label; | |||||||||||||||||||||||||||||||||||||||||
| 2178 | 0 | &$cmp($end, $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 2179 | 0 | &{$options{then}}; | |||||||||||||||||||||||||||||||||||||||||
| 2180 | 0 | setLabel($end); | |||||||||||||||||||||||||||||||||||||||||
| 2181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2183 | |||||||||||||||||||||||||||||||||||||||||||
| 2184 | sub IfEq($$%) #i Execute then or else clause depending on whether two memory locations are equal. | ||||||||||||||||||||||||||||||||||||||||||
| 2185 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfEq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2186 | 0 | Ifx(\&Jne, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||||||||||
| 2189 | sub IfFalse($%) #i Execute then clause if the specified memory address is zero thus representing false. | ||||||||||||||||||||||||||||||||||||||||||
| 2190 | 0 | ▶ | {my ($a, %options) = @_; # Memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfFalse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2191 | 0 | Ifx(\&Jne, $a, 0, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2193 | |||||||||||||||||||||||||||||||||||||||||||
| 2194 | sub IfGe($$%) #i Execute then or else clause depending on whether two memory locations are greater than or equal. | ||||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfGe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2196 | 0 | Ifx(\&Jlt, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2198 | |||||||||||||||||||||||||||||||||||||||||||
| 2199 | sub IfGt($$%) #i Execute then or else clause depending on whether two memory locations are greater than. | ||||||||||||||||||||||||||||||||||||||||||
| 2200 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfGt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2201 | 0 | Ifx(\&Jle, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||||||||||
| 2204 | sub IfNe($$%) #i Execute then or else clause depending on whether two memory locations are not equal. | ||||||||||||||||||||||||||||||||||||||||||
| 2205 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfNe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2206 | 0 | Ifx(\&Jeq, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2208 | |||||||||||||||||||||||||||||||||||||||||||
| 2209 | sub IfLe($$%) #i Execute then or else clause depending on whether two memory locations are less than or equal. | ||||||||||||||||||||||||||||||||||||||||||
| 2210 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfLe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2211 | 0 | Ifx(\&Jgt, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2213 | |||||||||||||||||||||||||||||||||||||||||||
| 2214 | sub IfLt($$%) #i Execute then or else clause depending on whether two memory locations are less than. | ||||||||||||||||||||||||||||||||||||||||||
| 2215 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfLt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2216 | 0 | Ifx(\&Jge, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2218 | |||||||||||||||||||||||||||||||||||||||||||
| 2219 | sub IfTrue($%) #i Execute then clause if the specified memory address is not zero thus representing true. | ||||||||||||||||||||||||||||||||||||||||||
| 2220 | 0 | ▶ | {my ($a, %options) = @_; # Memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfTrue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2221 | 0 | Ifx(\&Jeq, $a, 0, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2223 | |||||||||||||||||||||||||||||||||||||||||||
| 2224 | sub Inc($) #i Increment the target. | ||||||||||||||||||||||||||||||||||||||||||
| 2225 | 0 | ▶ | {my ($target) = @_; # Target address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Inc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2226 | 0 | $assembly->instruction(action=>"inc", xTarget($target)) | |||||||||||||||||||||||||||||||||||||||||
| 2227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2228 | |||||||||||||||||||||||||||||||||||||||||||
| 2229 | sub Jeq($$$) #i Jump to a target label if the first source field is equal to the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 2230 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jeq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2231 | 0 | $assembly->instruction(action=>"jEq", | |||||||||||||||||||||||||||||||||||||||||
| 2232 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2234 | |||||||||||||||||||||||||||||||||||||||||||
| 2235 | sub JFalse($$) #i Jump to a target label if the first source field is equal to zero. | ||||||||||||||||||||||||||||||||||||||||||
| 2236 | 0 | ▶ | {my ($target, $source) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
JFalse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2237 | 0 | $assembly->instruction(action=>"jFalse", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||
| 2240 | sub Jge($$$) #i Jump to a target label if the first source field is greater than or equal to the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 2241 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jge: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2242 | 0 | $assembly->instruction(action=>"jGe", | |||||||||||||||||||||||||||||||||||||||||
| 2243 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2245 | |||||||||||||||||||||||||||||||||||||||||||
| 2246 | sub Jgt($$$) #i Jump to a target label if the first source field is greater than the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 2247 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jgt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2248 | 0 | $assembly->instruction(action=>"jGt", | |||||||||||||||||||||||||||||||||||||||||
| 2249 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||||||||||||||||
| 2252 | sub Jle($$$) #i Jump to a target label if the first source field is less than or equal to the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 2253 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jle: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2254 | 0 | $assembly->instruction(action=>"jLe", | |||||||||||||||||||||||||||||||||||||||||
| 2255 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2257 | |||||||||||||||||||||||||||||||||||||||||||
| 2258 | sub Jlt($$$) #i Jump to a target label if the first source field is less than the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 2259 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jlt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2260 | 0 | $assembly->instruction(action=>"jLt", | |||||||||||||||||||||||||||||||||||||||||
| 2261 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||||||||||||||||
| 2264 | sub Jmp($) #i Jump to a label. | ||||||||||||||||||||||||||||||||||||||||||
| 2265 | 0 | ▶ | {my ($target) = @_; # Target address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jmp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2266 | 0 | $assembly->instruction(action=>"jmp", xTarget($target)); | |||||||||||||||||||||||||||||||||||||||||
| 2267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2268 | |||||||||||||||||||||||||||||||||||||||||||
| 2269 | sub Jne($$$) #i Jump to a target label if the first source field is not equal to the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 2270 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jne: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2271 | 0 | $assembly->instruction(action=>"jNe", | |||||||||||||||||||||||||||||||||||||||||
| 2272 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2274 | |||||||||||||||||||||||||||||||||||||||||||
| 2275 | sub JTrue($$) #i Jump to a target label if the first source field is not equal to zero. | ||||||||||||||||||||||||||||||||||||||||||
| 2276 | 0 | ▶ | {my ($target, $source) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
JTrue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2277 | 0 | $assembly->instruction(action=>"jTrue", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2279 | |||||||||||||||||||||||||||||||||||||||||||
| 2280 | sub Label($) #P Create a label. | ||||||||||||||||||||||||||||||||||||||||||
| 2281 | 0 | ▶ | {my ($source) = @_; # Name of label | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Label: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2282 | 0 | $assembly->instruction(action=>"label", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2284 | |||||||||||||||||||||||||||||||||||||||||||
| 2285 | 0 | ▶ | sub LoadAddress($;$) { #i Load the address component of an address. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
LoadAddress: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2286 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2287 | 0 | {my ($source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 2288 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2289 | 0 | $assembly->instruction(action=>"loadAddress", xTarget($t), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2290 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 2291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2292 | elsif (@ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 2293 | 0 | {my ($target, $source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 2294 | 0 | $assembly->instruction(action=>"loadAddress", | |||||||||||||||||||||||||||||||||||||||||
| 2295 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2297 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2298 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 2299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2301 | |||||||||||||||||||||||||||||||||||||||||||
| 2302 | 0 | ▶ | sub LoadArea($;$) { #i Load the area component of an address. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
LoadArea: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2303 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2304 | 0 | {my ($source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 2305 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2306 | 0 | $assembly->instruction(action=>"loadArea", | |||||||||||||||||||||||||||||||||||||||||
| 2307 | xTarget($t), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2308 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 2309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2310 | elsif (@ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 2311 | 0 | {my ($target, $source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 2312 | 0 | $assembly->instruction(action=>"loadArea", | |||||||||||||||||||||||||||||||||||||||||
| 2313 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2315 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2316 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 2317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2319 | |||||||||||||||||||||||||||||||||||||||||||
| 2320 | 0 | ▶ | sub Mov($;$) { #i Copy a constant or memory address to the target address. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Mov: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2321 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2322 | 0 | {my ($source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 2323 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2324 | 0 | $assembly->instruction(action=>"mov", xTarget($t), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2325 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 2326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2327 | elsif (@ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 2328 | 0 | {my ($target, $source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 2329 | 0 | $assembly->instruction(action=>"mov", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2331 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2332 | 0 | {confess "One or two parameters required for mov"; | |||||||||||||||||||||||||||||||||||||||||
| 2333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2335 | |||||||||||||||||||||||||||||||||||||||||||
| 2336 | sub MoveLong($$$) #i Copy the number of elements specified by the second source operand from the location specified by the first source operand to the target operand. | ||||||||||||||||||||||||||||||||||||||||||
| 2337 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target of move, source of move, length of move | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MoveLong: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2338 | 0 | $assembly->instruction(action=>"moveLong", xTarget($target), | |||||||||||||||||||||||||||||||||||||||||
| 2339 | xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2341 | |||||||||||||||||||||||||||||||||||||||||||
| 2342 | 0 | ▶ | sub Not($) { #i Move and not. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Not: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2343 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2344 | 0 | {my ($source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 2345 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2346 | 0 | $assembly->instruction(action=>"not", xTarget($t), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2347 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 2348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2349 | elsif (@ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 2350 | 0 | {my ($target, $source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 2351 | 0 | $assembly->instruction(action=>"not", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2353 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2354 | 0 | {confess "One or two parameters required for not"; | |||||||||||||||||||||||||||||||||||||||||
| 2355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2357 | |||||||||||||||||||||||||||||||||||||||||||
| 2358 | sub Nop() #i Do nothing (but do it well!). | ||||||||||||||||||||||||||||||||||||||||||
| 2359 | 0 | ▶ | {$assembly->instruction(action=>"nop"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Nop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2361 | |||||||||||||||||||||||||||||||||||||||||||
| 2362 | sub Out(@) #i Write memory location contents to out. | ||||||||||||||||||||||||||||||||||||||||||
| 2363 | 0 | ▶ | {my (@source) = @_; # Either a scalar constant or memory address to output | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Out: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2364 | 0 | ▶ | if (@source > 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2365 | 0 | {my @a = map {$assembly->Reference($_)} @source; | |||||||||||||||||||||||||||||||||||||||||
| 2366 | 0 | $assembly->instruction(action=>"out", source=>[@a]); | |||||||||||||||||||||||||||||||||||||||||
| 2367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2368 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2369 | 0 | {$assembly->instruction(action=>"out", xSource($source[0])); | |||||||||||||||||||||||||||||||||||||||||
| 2370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2372 | |||||||||||||||||||||||||||||||||||||||||||
| 2373 | 0 | ▶ | sub ParamsGet($;$) { #i Get a word from the parameters in the previous frame and store it in the current frame. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParamsGet: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2374 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2375 | 0 | {my ($source) = @_; # Memory address to place parameter in, parameter number | |||||||||||||||||||||||||||||||||||||||||
| 2376 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2377 | 0 | $assembly->instruction(action=>"paramsGet", xTarget($p), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2378 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 2379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2380 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 2381 | 0 | {my ($target, $source) = @_; # Memory address to place parameter in, parameter number | |||||||||||||||||||||||||||||||||||||||||
| 2382 | 0 | $assembly->instruction(action=>"paramsGet", | |||||||||||||||||||||||||||||||||||||||||
| 2383 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2385 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2386 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 2387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2389 | |||||||||||||||||||||||||||||||||||||||||||
| 2390 | sub ParamsPut($$) #i Put a word into the parameters list to make it visible in a called procedure. | ||||||||||||||||||||||||||||||||||||||||||
| 2391 | 0 | ▶ | {my ($target, $source) = @_; # Parameter number, address to fetch parameter from | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParamsPut: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2392 | 0 | $assembly->instruction(action=>"paramsPut", | |||||||||||||||||||||||||||||||||||||||||
| 2393 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2395 | |||||||||||||||||||||||||||||||||||||||||||
| 2396 | 0 | ▶ | sub Pop(;$$) { #i Pop the memory area specified by the source operand into the memory address specified by the target operand. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Pop: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2397 | 0 | ▶ | if (@_ == 2) # Pop indicated area into a local variable | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2398 | 0 | {my ($source, $source2) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 2399 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2400 | 0 | my $n = $assembly->ArrayNameToNumber($source2); | |||||||||||||||||||||||||||||||||||||||||
| 2401 | 0 | $assembly->instruction(action=>"pop", xTarget($p), xSource($source), source2=>$n); | |||||||||||||||||||||||||||||||||||||||||
| 2402 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 2403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2404 | elsif (@_ == 3) | ||||||||||||||||||||||||||||||||||||||||||
| 2405 | 0 | {my ($target, $source, $source2) = @_; # Pop indicated area into target address | |||||||||||||||||||||||||||||||||||||||||
| 2406 | 0 | my $n = $assembly->ArrayNameToNumber($source2); | |||||||||||||||||||||||||||||||||||||||||
| 2407 | 0 | $assembly->instruction(action=>"pop", xTarget($target), xSource($source), source2=>$n); | |||||||||||||||||||||||||||||||||||||||||
| 2408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2409 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2410 | 0 | {confess "Two or three parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 2411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||||||||||||||||
| 2414 | sub Procedure($$) #i Define a procedure. | ||||||||||||||||||||||||||||||||||||||||||
| 2415 | 0 | ▶ | {my ($name, $source) = @_; # Name of procedure, source code as a subroutine | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Procedure: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2416 | 0 | ▶ | if ($name and my $n = $assembly->procedures->{$name}) # Reuse existing named procedure | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and my $n = $assembly->procedures->{$name}
MC/DC0%0/2
$name and my $n = $assembly->procedures->{$name}
$name
my $n = $assembly->procedures->{$name}
Truth table0%0/3
A and B
A= $nameB= my $n = $assembly->procedures->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 2417 | 0 | {return $n; | |||||||||||||||||||||||||||||||||||||||||
| 2418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2419 | |||||||||||||||||||||||||||||||||||||||||||
| 2420 | 0 | Jmp(my $end = label); # Jump over the code of the procedure body | |||||||||||||||||||||||||||||||||||||||||
| 2421 | 0 | my $start = setLabel; | |||||||||||||||||||||||||||||||||||||||||
| 2422 | 0 | my $p = procedure($start); # Procedure description | |||||||||||||||||||||||||||||||||||||||||
| 2423 | 0 | my $save_registers = $assembly->variables; | |||||||||||||||||||||||||||||||||||||||||
| 2424 | 0 | $assembly->variables = $p->variables; | |||||||||||||||||||||||||||||||||||||||||
| 2425 | 0 | &$source($p); # Code of procedure called with start label as a parameter | |||||||||||||||||||||||||||||||||||||||||
| 2426 | 0 | &Return; | |||||||||||||||||||||||||||||||||||||||||
| 2427 | 0 | $assembly->variables = $save_registers; | |||||||||||||||||||||||||||||||||||||||||
| 2428 | |||||||||||||||||||||||||||||||||||||||||||
| 2429 | 0 | setLabel $end; | |||||||||||||||||||||||||||||||||||||||||
| 2430 | 0 | $assembly->procedures->{$name} = $p; # Return the start of the procedure | |||||||||||||||||||||||||||||||||||||||||
| 2431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2432 | |||||||||||||||||||||||||||||||||||||||||||
| 2433 | sub Push($$$) #i Push the value in the current stack frame specified by the source operand onto the memory area identified by the target operand. | ||||||||||||||||||||||||||||||||||||||||||
| 2434 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Memory area to push to, memory containing value to push | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Push: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2435 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2436 | 0 | my $n = $assembly->ArrayNameToNumber($source2); | |||||||||||||||||||||||||||||||||||||||||
| 2437 | 0 | $assembly->instruction(action=>"push", xTarget($target), xSource($source), source2=>$n); | |||||||||||||||||||||||||||||||||||||||||
| 2438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||||||||||||||||
| 2440 | sub Resize($$$) #i Resize the target area to the source size. | ||||||||||||||||||||||||||||||||||||||||||
| 2441 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target array, new size, array name | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Resize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2442 | 0 | $assembly->instruction(action=>"resize", xTarget($target), | |||||||||||||||||||||||||||||||||||||||||
| 2443 | xSource($source), xSource2($assembly->ArrayNameToNumber($source2))); | ||||||||||||||||||||||||||||||||||||||||||
| 2444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2445 | |||||||||||||||||||||||||||||||||||||||||||
| 2446 | 0 | ▶ | sub Random($;$) { #i Create a random number in a specified range. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Random: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2447 | 0 | ▶ | if (@_ == 1) # Create a variable | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2448 | 0 | {my ($source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 2449 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2450 | 0 | $assembly->instruction(action=>"random", xTarget($p), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2451 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 2452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2453 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 2454 | 0 | {my ($target, $source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 2455 | 0 | $assembly->instruction(action=>"random", | |||||||||||||||||||||||||||||||||||||||||
| 2456 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2458 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2459 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 2460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2462 | |||||||||||||||||||||||||||||||||||||||||||
| 2463 | sub RandomSeed($) #i Seed the random number generator. | ||||||||||||||||||||||||||||||||||||||||||
| 2464 | 0 | ▶ | {my ($seed) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RandomSeed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2465 | 0 | $assembly->instruction(action=>"randomSeed", xSource($seed)); | |||||||||||||||||||||||||||||||||||||||||
| 2466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2467 | |||||||||||||||||||||||||||||||||||||||||||
| 2468 | sub Return() #i Return from a procedure via the call stack. | ||||||||||||||||||||||||||||||||||||||||||
| 2469 | 0 | ▶ | {$assembly->instruction(action=>"return"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Return: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2471 | |||||||||||||||||||||||||||||||||||||||||||
| 2472 | 0 | ▶ | sub ReturnGet($;$) { #i Get a word from the return area and save it. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ReturnGet: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2473 | 0 | ▶ | if (@_ == 1) # Create a variable | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2474 | 0 | {my ($source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 2475 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2476 | 0 | $assembly->instruction(action=>"returnGet", xTarget($p), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2477 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 2478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2479 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 2480 | 0 | {my ($target, $source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 2481 | 0 | $assembly->instruction(action=>"returnGet", | |||||||||||||||||||||||||||||||||||||||||
| 2482 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2484 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2485 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 2486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2488 | |||||||||||||||||||||||||||||||||||||||||||
| 2489 | sub ReturnPut($$) #i Put a word into the return area. | ||||||||||||||||||||||||||||||||||||||||||
| 2490 | 0 | ▶ | {my ($target, $source) = @_; # Offset in return area to write to, memory address whose contents are to be placed in the return area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ReturnPut: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2491 | 0 | $assembly->instruction(action=>"returnPut", | |||||||||||||||||||||||||||||||||||||||||
| 2492 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2494 | |||||||||||||||||||||||||||||||||||||||||||
| 2495 | 0 | ▶ | sub ShiftDown($;$) { #i Shift an element down one in an area. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ShiftDown: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2496 | 0 | ▶ | if (@_ == 1) # Create a variable | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2497 | 0 | {my ($source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 2498 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 2499 | 0 | $assembly->instruction(action=>"shiftDown", xTarget($p), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2500 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 2501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2502 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 2503 | 0 | {my ($target, $source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 2504 | 0 | $assembly->instruction(action=>"shiftDown", | |||||||||||||||||||||||||||||||||||||||||
| 2505 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2506 | 0 | confess "Needs work"; | |||||||||||||||||||||||||||||||||||||||||
| 2507 | 0 | return $target; | |||||||||||||||||||||||||||||||||||||||||
| 2508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2509 | else | ||||||||||||||||||||||||||||||||||||||||||
| 2510 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 2511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2513 | |||||||||||||||||||||||||||||||||||||||||||
| 2514 | 0 | ▶ | sub ShiftLeft($;$) { #i Shift left within an element. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ShiftLeft: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2515 | 0 | my ($target, $source) = @_; # Target to shift, amount to shift | |||||||||||||||||||||||||||||||||||||||||
| 2516 | 0 | $assembly->instruction(action=>"shiftLeft", | |||||||||||||||||||||||||||||||||||||||||
| 2517 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2518 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 2519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2520 | |||||||||||||||||||||||||||||||||||||||||||
| 2521 | 0 | ▶ | sub ShiftRight($;$) { #i Shift right with an element. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ShiftRight: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2522 | 0 | my ($target, $source) = @_; # Target to shift, amount to shift | |||||||||||||||||||||||||||||||||||||||||
| 2523 | 0 | $assembly->instruction(action=>"shiftRight", | |||||||||||||||||||||||||||||||||||||||||
| 2524 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2525 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 2526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2527 | |||||||||||||||||||||||||||||||||||||||||||
| 2528 | sub ShiftUp($;$) #i Shift an element up one in an area. | ||||||||||||||||||||||||||||||||||||||||||
| 2529 | 0 | ▶ | {my ($target, $source) = @_; # Target to shift, amount to shift | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ShiftUp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2530 | 0 | $assembly->instruction(action=>"shiftUp", | |||||||||||||||||||||||||||||||||||||||||
| 2531 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 2532 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 2533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2534 | |||||||||||||||||||||||||||||||||||||||||||
| 2535 | sub Start($) #i Start the current assembly using the specified version of the Zero language. At the moment only version 1 works. | ||||||||||||||||||||||||||||||||||||||||||
| 2536 | 0 | ▶ | {my ($version) = @_; # Version desired - at the moment only 1 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Start: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2537 | 0 | ▶ | $version == 1 or confess "Version 1 is currently the only version available"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2538 | 0 | Assembly(); | |||||||||||||||||||||||||||||||||||||||||
| 2539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2540 | |||||||||||||||||||||||||||||||||||||||||||
| 2541 | sub Subtract($$;$) #i Subtract the second source operand value from the first source operand value and store the result in the target area. | ||||||||||||||||||||||||||||||||||||||||||
| 2542 | 0 | ▶ | {my ($target, $s1, $s2) = @_ == 2 ? (&Var(), @_) : @_; # Target address, source one, source two | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Subtract: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2543 | 0 | $assembly->instruction(action=>"subtract", xTarget($target), | |||||||||||||||||||||||||||||||||||||||||
| 2544 | xSource($s1), xSource2($s2)); | ||||||||||||||||||||||||||||||||||||||||||
| 2545 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 2546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2547 | |||||||||||||||||||||||||||||||||||||||||||
| 2548 | sub Tally($) #i Counts instructions when enabled. | ||||||||||||||||||||||||||||||||||||||||||
| 2549 | 0 | ▶ | {my ($source) = @_; # Tally instructions when true | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Tally: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2550 | 0 | $assembly->instruction(action=>"tally", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2552 | |||||||||||||||||||||||||||||||||||||||||||
| 2553 | sub Then(&) #i Then block. | ||||||||||||||||||||||||||||||||||||||||||
| 2554 | 0 | ▶ | {my ($t) = @_; # Then block subroutine | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Then: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2555 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2556 | 0 | (then=> $t) | |||||||||||||||||||||||||||||||||||||||||
| 2557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2558 | |||||||||||||||||||||||||||||||||||||||||||
| 2559 | sub Trace($) #i Start or stop tracing. Tracing prints each instruction executed and its effect on memory. | ||||||||||||||||||||||||||||||||||||||||||
| 2560 | 0 | ▶ | {my ($source) = @_; # Trace setting | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Trace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2561 | 0 | $assembly->instruction(action=>"trace", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2563 | |||||||||||||||||||||||||||||||||||||||||||
| 2564 | sub TraceLabels($) #i Enable or disable label tracing. If tracing is enabled a stack trace is printed for each label instruction executed showing the call stack at the time the instruction was generated as well as the current stack frames. | ||||||||||||||||||||||||||||||||||||||||||
| 2565 | 0 | ▶ | {my ($source) = @_; # Trace points if true | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TraceLabels: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2566 | 0 | $assembly->instruction(action=>"traceLabels", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 2567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2568 | |||||||||||||||||||||||||||||||||||||||||||
| 2569 | sub Var(;$) #i Create a variable initialized to the specified value. | ||||||||||||||||||||||||||||||||||||||||||
| 2570 | 0 | ▶ | {my ($value) = @_; # Value | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Var: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2571 | 0 | ▶ | return Mov $value if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2572 | 0 | $assembly->variables->registers | |||||||||||||||||||||||||||||||||||||||||
| 2573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2574 | |||||||||||||||||||||||||||||||||||||||||||
| 2575 | sub Watch($) #i Watches for changes to the specified memory location. | ||||||||||||||||||||||||||||||||||||||||||
| 2576 | 0 | ▶ | {my ($target) = @_; # Memory address to watch | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Watch: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2577 | 0 | $assembly->instruction(action=>"watch", xTarget($target)); | |||||||||||||||||||||||||||||||||||||||||
| 2578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2579 | |||||||||||||||||||||||||||||||||||||||||||
| 2580 | #D1 Instruction Set Architecture # Map the instruction set into a machine architecture. | ||||||||||||||||||||||||||||||||||||||||||
| 2581 | |||||||||||||||||||||||||||||||||||||||||||
| 2582 | 1 | my $instructions = Zero::Emulator::Code::execute(undef); | |||||||||||||||||||||||||||||||||||||||||
| 2583 | 1 | my @instructions = sort keys %$instructions; | |||||||||||||||||||||||||||||||||||||||||
| 2584 | 1 | my %instructions = map {$instructions[$_]=>$_} keys @instructions; | |||||||||||||||||||||||||||||||||||||||||
| 2585 | |||||||||||||||||||||||||||||||||||||||||||
| 2586 | sub instructionList() #P Create a list of instructions. | ||||||||||||||||||||||||||||||||||||||||||
| 2587 | 0 | ▶ | {my @i = grep {m(\s+#i)} readFile $0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instructionList: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2588 | 0 | my @j; # Description of instruction | |||||||||||||||||||||||||||||||||||||||||
| 2589 | 0 | for my $i(@i) | |||||||||||||||||||||||||||||||||||||||||
| 2590 | 0 | {my @parse = split /[ (){}]+/, $i, 5; | |||||||||||||||||||||||||||||||||||||||||
| 2591 | 0 | my $name = $parse[1]; | |||||||||||||||||||||||||||||||||||||||||
| 2592 | 0 | my $sig = $parse[2]; | |||||||||||||||||||||||||||||||||||||||||
| 2593 | 0 | my $comment = $i =~ s(\A.*?#i\s*) ()r; | |||||||||||||||||||||||||||||||||||||||||
| 2594 | 0 | push @j, [$name, $sig, $comment]; | |||||||||||||||||||||||||||||||||||||||||
| 2595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2596 | 0 | [sort {$$a[0] cmp $$b[0]} @j] | |||||||||||||||||||||||||||||||||||||||||
| 2597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2598 | |||||||||||||||||||||||||||||||||||||||||||
| 2599 | sub instructionListExport() #P Create an export statement. | ||||||||||||||||||||||||||||||||||||||||||
| 2600 | 0 | ▶ | {my $i = instructionList; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instructionListExport: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2601 | 0 | say STDERR '@EXPORT_OK = qw(', (join ' ', map {$$_[0]} @$i), ");\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2602 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2603 | #instructionListExport; exit; | ||||||||||||||||||||||||||||||||||||||||||
| 2604 | |||||||||||||||||||||||||||||||||||||||||||
| 2605 | sub instructionListReadMe() #P List instructions for inclusion in read me. | ||||||||||||||||||||||||||||||||||||||||||
| 2606 | 0 | ▶ | {my $i = instructionList; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instructionListReadMe: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2607 | 0 | my $s = ''; | |||||||||||||||||||||||||||||||||||||||||
| 2608 | 0 | for my $i(@$i) | |||||||||||||||||||||||||||||||||||||||||
| 2609 | 0 | {my ($name, $sig, $comment) = @$i; | |||||||||||||||||||||||||||||||||||||||||
| 2610 | 0 | $s .= sprintf("**%10s** %s\n", $name, $comment); | |||||||||||||||||||||||||||||||||||||||||
| 2611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2612 | $s | ||||||||||||||||||||||||||||||||||||||||||
| 2613 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 2614 | |||||||||||||||||||||||||||||||||||||||||||
| 2615 | sub instructionListMapping() #P Map instructions to small integers. | ||||||||||||||||||||||||||||||||||||||||||
| 2616 | 0 | ▶ | {my $i = instructionList; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instructionListMapping: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2617 | 0 | my @n = map {$$_[0]} @$i; # Description of instruction | |||||||||||||||||||||||||||||||||||||||||
| 2618 | 0 | my $n = join ' ', @n; | |||||||||||||||||||||||||||||||||||||||||
| 2619 | 0 | say STDERR <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2620 | my \@instructions = qw($n); | ||||||||||||||||||||||||||||||||||||||||||
| 2621 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2623 | #instructionListMapping(); exit; | ||||||||||||||||||||||||||||||||||||||||||
| 2624 | |||||||||||||||||||||||||||||||||||||||||||
| 2625 | sub refDepth($) #P The depth of a reference. | ||||||||||||||||||||||||||||||||||||||||||
| 2626 | 0 | ▶ | {my ($ref) = @_; # Reference to pack | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refDepth: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2627 | 0 | ▶ | return 0 if isScalar($ref); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2628 | 0 | ▶ | return 1 if isScalar($$ref); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2629 | 0 | ▶ | return 2 if isScalar($$$ref); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2630 | 0 | confess "Reference too deep".dump($ref); | |||||||||||||||||||||||||||||||||||||||||
| 2631 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2632 | |||||||||||||||||||||||||||||||||||||||||||
| 2633 | sub refValue($) #P The value of a reference after dereferencing. | ||||||||||||||||||||||||||||||||||||||||||
| 2634 | 0 | ▶ | {my ($ref) = @_; # Reference to pack | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refValue: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2635 | 0 | ▶ | return $ref if isScalar($ref); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2636 | 0 | ▶ | return $$ref if isScalar($$ref); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2637 | 0 | ▶ | return $$$ref if isScalar($$$ref); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2638 | 0 | confess "Reference too deep".dump($ref); | |||||||||||||||||||||||||||||||||||||||||
| 2639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2640 | |||||||||||||||||||||||||||||||||||||||||||
| 2641 | sub rerefValue($$) #P Re-reference a value. | ||||||||||||||||||||||||||||||||||||||||||
| 2642 | 0 | ▶ | {my ($value, $depth) = @_; # Value to reference, depth of reference | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rerefValue: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2643 | 0 | ▶ | return $value if $depth == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2644 | 0 | ▶ | return \$value if $depth == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2645 | 0 | ▶ | return \\$value if $depth == 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2646 | 0 | confess "Rereference depth of $depth is too deep"; | |||||||||||||||||||||||||||||||||||||||||
| 2647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2648 | |||||||||||||||||||||||||||||||||||||||||||
| 2649 | sub Zero::Emulator::Code::packRef($$$) #P Pack a reference into 8 bytes. | ||||||||||||||||||||||||||||||||||||||||||
| 2650 | 0 | ▶ | {my ($code, $instruction, $ref) = @_; # Code block being packed, instruction being packed, reference being packed | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
packRef: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 2651 | |||||||||||||||||||||||||||||||||||||||||||
| 2652 | 0 | ▶ | if (!defined($ref) or ref($ref) =~ m(array)i && !@$ref) # Unused reference | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not defined $ref or ref($ref) =~ /array/iu and not @$ref
ref($ref) =~ /array/iu and not @$ref
MC/DC0%0/3
not defined $ref or ref($ref) =~ /array/iu and not @$ref
not defined $ref
ref($ref) =~ /array/iu
not @$ref
Truth table0%0/4
not(A) or B and not(C)
A= not defined $refB= ref($ref) =~ /array/iuC= not @$ref
| |||||||||||||||||||||||||||||||||||||||||||
| 2653 | 0 | {my $a = ''; | |||||||||||||||||||||||||||||||||||||||||
| 2654 | 0 | vec($a, 0, 32) = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2655 | 0 | vec($a, 1, 32) = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2656 | 0 | vec($a, 7, 8) = 2**7 - 1; | |||||||||||||||||||||||||||||||||||||||||
| 2657 | 0 | return $a; | |||||||||||||||||||||||||||||||||||||||||
| 2658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2659 | |||||||||||||||||||||||||||||||||||||||||||
| 2660 | 0 | my @a = (arenaLocal, 0, $ref, 0); # Local variable or constant | |||||||||||||||||||||||||||||||||||||||||
| 2661 | 0 | ▶ | @a = @$ref{qw(arena area address delta name)} if ref($ref) =~ m(Reference)i; # Heap reference | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2662 | |||||||||||||||||||||||||||||||||||||||||||
| 2663 | 0 | ▶ | $_ //= 0 for @a; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_ //= 0
MC/DC0%0/1
$_ //= 0
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 2664 | 0 | my ($arena, $area, $address, $delta, $name) = @a; | |||||||||||||||||||||||||||||||||||||||||
| 2665 | |||||||||||||||||||||||||||||||||||||||||||
| 2666 | 0 | my $dArea = dump $area; | |||||||||||||||||||||||||||||||||||||||||
| 2667 | 0 | my $dAddress = dump $address; | |||||||||||||||||||||||||||||||||||||||||
| 2668 | 0 | my $dArena = dump $arena; | |||||||||||||||||||||||||||||||||||||||||
| 2669 | 0 | my $dDelta = dump $delta; | |||||||||||||||||||||||||||||||||||||||||
| 2670 | |||||||||||||||||||||||||||||||||||||||||||
| 2671 | 0 | my $b = "too big, should be less than:"; | |||||||||||||||||||||||||||||||||||||||||
| 2672 | |||||||||||||||||||||||||||||||||||||||||||
| 2673 | 0 | my $bArea = "$b 2**16"; | |||||||||||||||||||||||||||||||||||||||||
| 2674 | 0 | my $bAddress = "$b 2**32"; | |||||||||||||||||||||||||||||||||||||||||
| 2675 | 0 | my $bArena = "$b 2**2"; | |||||||||||||||||||||||||||||||||||||||||
| 2676 | 0 | my $bDelta = "$b 2**7"; | |||||||||||||||||||||||||||||||||||||||||
| 2677 | |||||||||||||||||||||||||||||||||||||||||||
| 2678 | |||||||||||||||||||||||||||||||||||||||||||
| 2679 | 0 | my @m; | |||||||||||||||||||||||||||||||||||||||||
| 2680 | 0 | ▶ | push @m, "Area: $dArea $bArea" if refValue($area) >= 2**16; # 2 + 16 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2681 | 0 | ▶ | push @m, "Address: $dAddress $bAddress" if refValue($address) >= 2**32; # 2 + 32 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2682 | 0 | ▶ | push @m, "Arena: $dArena $bArea" if $arena >= 2**2; # 2 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2683 | 0 | ▶ | push @m, "Delta: $dDelta $bDelta" if abs($delta) > 2**7; # 8 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2684 | |||||||||||||||||||||||||||||||||||||||||||
| 2685 | 0 | ▶ | if (@m) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2686 | 0 | {my $i = dump $instruction; | |||||||||||||||||||||||||||||||||||||||||
| 2687 | 0 | my $r = dump $ref; | |||||||||||||||||||||||||||||||||||||||||
| 2688 | 0 | my $c = join "\n", $instruction->contextString, ''; | |||||||||||||||||||||||||||||||||||||||||
| 2689 | 0 | my ($m) = @m; | |||||||||||||||||||||||||||||||||||||||||
| 2690 | 0 | confess <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2691 | Unable to pack reference: $r | ||||||||||||||||||||||||||||||||||||||||||
| 2692 | $m | ||||||||||||||||||||||||||||||||||||||||||
| 2693 | $i | ||||||||||||||||||||||||||||||||||||||||||
| 2694 | $c | ||||||||||||||||||||||||||||||||||||||||||
| 2695 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2696 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2697 | |||||||||||||||||||||||||||||||||||||||||||
| 2698 | 0 | my $a = ''; | |||||||||||||||||||||||||||||||||||||||||
| 2699 | 0 | vec($a, 0, 32) = refValue $address; | |||||||||||||||||||||||||||||||||||||||||
| 2700 | 0 | vec($a, 2, 16) = refValue $area; | |||||||||||||||||||||||||||||||||||||||||
| 2701 | 0 | vec($a, 24, 2) = refDepth $address; | |||||||||||||||||||||||||||||||||||||||||
| 2702 | 0 | vec($a, 25, 2) = refDepth $area; | |||||||||||||||||||||||||||||||||||||||||
| 2703 | 0 | vec($a, 26, 2) = $arena; | |||||||||||||||||||||||||||||||||||||||||
| 2704 | 0 | vec($a, 27, 2) = $arena; | |||||||||||||||||||||||||||||||||||||||||
| 2705 | 0 | vec($a, 7, 8) = 2**7 + $delta - 1; | |||||||||||||||||||||||||||||||||||||||||
| 2706 | 0 | $a | |||||||||||||||||||||||||||||||||||||||||
| 2707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2708 | |||||||||||||||||||||||||||||||||||||||||||
| 2709 | sub Zero::Emulator::Code::unpackRef($$) #P Unpack a reference. | ||||||||||||||||||||||||||||||||||||||||||
| 2710 | 0 | ▶ | {my ($code, $a) = @_; # Code block being packed, instruction being packed, reference being packed | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpackRef: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2711 | |||||||||||||||||||||||||||||||||||||||||||
| 2712 | 0 | my $vAddress = vec($a, 0, 32); | |||||||||||||||||||||||||||||||||||||||||
| 2713 | 0 | my $vArea = vec($a, 2, 16); | |||||||||||||||||||||||||||||||||||||||||
| 2714 | 0 | my $rAddress = vec($a, 24, 2); | |||||||||||||||||||||||||||||||||||||||||
| 2715 | 0 | my $rArea = vec($a, 25, 2); | |||||||||||||||||||||||||||||||||||||||||
| 2716 | 0 | my $arena = vec($a, 26, 2); | |||||||||||||||||||||||||||||||||||||||||
| 2717 | 0 | my $delta = vec($a, 7, 8) - (2**7 - 1); | |||||||||||||||||||||||||||||||||||||||||
| 2718 | |||||||||||||||||||||||||||||||||||||||||||
| 2719 | 0 | my $area = rerefValue($vArea, $rArea); | |||||||||||||||||||||||||||||||||||||||||
| 2720 | 0 | my $address = rerefValue($vAddress, $rAddress); | |||||||||||||||||||||||||||||||||||||||||
| 2721 | 0 | ▶ | $code->Reference([$arena != arenaHeap ? undef : $area, $address, 0, $delta]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2722 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2723 | |||||||||||||||||||||||||||||||||||||||||||
| 2724 | sub Zero::Emulator::Code::packInstruction($$) #P Pack an instruction. | ||||||||||||||||||||||||||||||||||||||||||
| 2725 | 0 | ▶ | {my ($code, $i) = @_; # Code being packed, instruction to pack | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
packInstruction: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2726 | 0 | my $a = ''; | |||||||||||||||||||||||||||||||||||||||||
| 2727 | 0 | vec($a, 0, 32) = $instructions{$i->action}; | |||||||||||||||||||||||||||||||||||||||||
| 2728 | 0 | vec($a, 1, 32) = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2729 | 0 | $a .= $code->packRef($i, $i->target); | |||||||||||||||||||||||||||||||||||||||||
| 2730 | 0 | $a .= $code->packRef($i, $i->source); | |||||||||||||||||||||||||||||||||||||||||
| 2731 | 0 | $a .= $code->packRef($i, $i->source2); | |||||||||||||||||||||||||||||||||||||||||
| 2732 | 0 | $a | |||||||||||||||||||||||||||||||||||||||||
| 2733 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2734 | |||||||||||||||||||||||||||||||||||||||||||
| 2735 | sub unpackInstruction($) #P Unpack an instruction. | ||||||||||||||||||||||||||||||||||||||||||
| 2736 | 0 | ▶ | {my ($I) = @_; # Instruction numbers, instruction to pack | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpackInstruction: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2737 | |||||||||||||||||||||||||||||||||||||||||||
| 2738 | 0 | my $i = vec($I, 0, 32); | |||||||||||||||||||||||||||||||||||||||||
| 2739 | 0 | my $n = $instructions[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 2740 | 0 | ▶ | confess "Invalid instruction number: $i" unless defined $n; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2741 | 0 | $n | |||||||||||||||||||||||||||||||||||||||||
| 2742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2743 | |||||||||||||||||||||||||||||||||||||||||||
| 2744 | sub GenerateMachineCode(%) # Generate a string of machine code from the current block of code. | ||||||||||||||||||||||||||||||||||||||||||
| 2745 | 0 | ▶ | {my (%options) = @_; # Generation options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GenerateMachineCode: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2746 | |||||||||||||||||||||||||||||||||||||||||||
| 2747 | 0 | my $code = $assembly->code; | |||||||||||||||||||||||||||||||||||||||||
| 2748 | 0 | my $pack = ''; | |||||||||||||||||||||||||||||||||||||||||
| 2749 | 0 | for my $i(@$code) | |||||||||||||||||||||||||||||||||||||||||
| 2750 | 0 | {$pack .= $assembly->packInstruction($i); | |||||||||||||||||||||||||||||||||||||||||
| 2751 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2752 | $pack | ||||||||||||||||||||||||||||||||||||||||||
| 2753 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 2754 | |||||||||||||||||||||||||||||||||||||||||||
| 2755 | sub disAssemble($) # Disassemble machine code. | ||||||||||||||||||||||||||||||||||||||||||
| 2756 | 0 | ▶ | {my ($mc) = @_; # Machine code string | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disAssemble: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2757 | |||||||||||||||||||||||||||||||||||||||||||
| 2758 | 0 | my $C = Code; | |||||||||||||||||||||||||||||||||||||||||
| 2759 | |||||||||||||||||||||||||||||||||||||||||||
| 2760 | 0 | my $n = length($mc) / 32; # The instructions are formatted into 32 byte blocks | |||||||||||||||||||||||||||||||||||||||||
| 2761 | 0 | for my $i(1..$n) | |||||||||||||||||||||||||||||||||||||||||
| 2762 | 0 | {my $c = substr($mc, ($i-1)*32, 32); | |||||||||||||||||||||||||||||||||||||||||
| 2763 | 0 | my $i = $C->instruction | |||||||||||||||||||||||||||||||||||||||||
| 2764 | (action=> unpackInstruction(substr($c, 0, 8)), | ||||||||||||||||||||||||||||||||||||||||||
| 2765 | target=> $C->unpackRef (substr($c, 8, 8)), | ||||||||||||||||||||||||||||||||||||||||||
| 2766 | source=> $C->unpackRef (substr($c, 16, 8)), | ||||||||||||||||||||||||||||||||||||||||||
| 2767 | source2=> $C->unpackRef (substr($c, 24, 8))); | ||||||||||||||||||||||||||||||||||||||||||
| 2768 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2769 | $C | ||||||||||||||||||||||||||||||||||||||||||
| 2770 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 2771 | |||||||||||||||||||||||||||||||||||||||||||
| 2772 | sub disAssembleMinusContext($) #P Disassemble and remove context information from disassembly to make testing easier. | ||||||||||||||||||||||||||||||||||||||||||
| 2773 | 0 | ▶ | {my ($D) = @_; # Machine code string | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disAssembleMinusContext: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2774 | |||||||||||||||||||||||||||||||||||||||||||
| 2775 | 0 | my $d = disAssemble $D; | |||||||||||||||||||||||||||||||||||||||||
| 2776 | |||||||||||||||||||||||||||||||||||||||||||
| 2777 | 0 | for my $c($d->code->@*) # Remove context fields | |||||||||||||||||||||||||||||||||||||||||
| 2778 | 0 | {delete @$c{qw(context executed file line number)}; | |||||||||||||||||||||||||||||||||||||||||
| 2779 | 0 | delete $$c{$_}{name} for qw(target source source2); | |||||||||||||||||||||||||||||||||||||||||
| 2780 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2781 | |||||||||||||||||||||||||||||||||||||||||||
| 2782 | 0 | delete @$d{qw(assembled files labelCounter labels procedures variables)}; | |||||||||||||||||||||||||||||||||||||||||
| 2783 | |||||||||||||||||||||||||||||||||||||||||||
| 2784 | 0 | $d | |||||||||||||||||||||||||||||||||||||||||
| 2785 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2786 | |||||||||||||||||||||||||||||||||||||||||||
| 2787 | sub GenerateMachineCodeDisAssembleExecute(%) #i Round trip: generate machine code and write it onto a string, disassemble the generated machine code string and recreate a block of code from it, then execute the reconstituted code to prove that it works as well as the original code. | ||||||||||||||||||||||||||||||||||||||||||
| 2788 | 0 | ▶ | {my (%options) = @_; # Options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GenerateMachineCodeDisAssembleExecute: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2789 | 0 | my $m = GenerateMachineCode; | |||||||||||||||||||||||||||||||||||||||||
| 2790 | 0 | my $M = disAssemble $m; | |||||||||||||||||||||||||||||||||||||||||
| 2791 | 0 | $M->execute(checkArrayNames=>0, %options); | |||||||||||||||||||||||||||||||||||||||||
| 2792 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2793 | |||||||||||||||||||||||||||||||||||||||||||
| 2794 | #D0 | ||||||||||||||||||||||||||||||||||||||||||
| 2795 | |||||||||||||||||||||||||||||||||||||||||||
| 2796 | 1 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2797 | 1 | ▶ | use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2798 | |||||||||||||||||||||||||||||||||||||||||||
| 2799 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 2800 | 1 | @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||
| 2801 | 1 | @EXPORT_OK = qw(GenerateMachineCodeDisAssembleExecute Add Array ArrayCountGreater ArrayCountLess ArrayDump ArrayIndex ArraySize Assert AssertEq AssertFalse AssertGe AssertGt AssertLe AssertLt AssertNe AssertTrue Bad Block Call Clear Confess Dec Dump Else Execute For ForArray Free Good IfEq IfFalse IfGe IfGt IfLe IfLt IfNe IfTrue Inc JFalse JTrue Jeq Jge Jgt Jle Jlt Jmp Jne LoadAddress LoadArea Mov MoveLong Nop Not Out ParamsGet ParamsPut Pop Procedure Push Random RandomSeed Resize Return ReturnGet ReturnPut ShiftDown ShiftLeft ShiftRight ShiftUp Start Subtract Tally Then Trace TraceLabels Var Watch); | |||||||||||||||||||||||||||||||||||||||||
| 2802 | 1 | %EXPORT_TAGS = (all=>[@EXPORT, @EXPORT_OK]); | |||||||||||||||||||||||||||||||||||||||||
| 2803 | |||||||||||||||||||||||||||||||||||||||||||
| 2804 | 1 | ▶ | return 1 if caller; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2805 | |||||||||||||||||||||||||||||||||||||||||||
| 2806 | # Tests | ||||||||||||||||||||||||||||||||||||||||||
| 2807 | |||||||||||||||||||||||||||||||||||||||||||
| 2808 | #Test::More->builder->output("/dev/null"); # Reduce number of confirmation messages during testing | ||||||||||||||||||||||||||||||||||||||||||
| 2809 | |||||||||||||||||||||||||||||||||||||||||||
| 2810 | 0 | my $debug = -e q(/home/phil/); # Assume debugging if testing locally | |||||||||||||||||||||||||||||||||||||||||
| 2811 | sub is_deeply; | ||||||||||||||||||||||||||||||||||||||||||
| 2812 | sub ok($;$); | ||||||||||||||||||||||||||||||||||||||||||
| 2813 | 0 | ▶ | sub x {exit if $debug} # Stop if debugging. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
x: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2814 | 0 | Test::More->builder->output("/dev/null"); # Reduce number of confirmation messages during testing | |||||||||||||||||||||||||||||||||||||||||
| 2815 | |||||||||||||||||||||||||||||||||||||||||||
| 2816 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 2817 | |||||||||||||||||||||||||||||||||||||||||||
| 2818 | Tests are run using different combinations of execution engine and memory | ||||||||||||||||||||||||||||||||||||||||||
| 2819 | manager to prove that different implementations produce the same results. | ||||||||||||||||||||||||||||||||||||||||||
| 2820 | |||||||||||||||||||||||||||||||||||||||||||
| 2821 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2822 | |||||||||||||||||||||||||||||||||||||||||||
| 2823 | 0 | for my $testSet(1..4) { # Select various combinations of execution engine and memory handler | |||||||||||||||||||||||||||||||||||||||||
| 2824 | 0 | say STDOUT "TestSet: $testSet"; | |||||||||||||||||||||||||||||||||||||||||
| 2825 | 0 | ▶ | my $ee = $testSet % 2 ? \&Execute : # Assemble and execute | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2826 | \&GenerateMachineCodeDisAssembleExecute; # Generate machine code, load code and execute | ||||||||||||||||||||||||||||||||||||||||||
| 2827 | |||||||||||||||||||||||||||||||||||||||||||
| 2828 | 0 | ▶ | $memoryTechnique = $testSet <= 2 ? undef : \&setStringMemoryTechnique; # Set memory allocation technique | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2829 | |||||||||||||||||||||||||||||||||||||||||||
| 2830 | 0 | ▶ | eval {goto latest if $debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2831 | |||||||||||||||||||||||||||||||||||||||||||
| 2832 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2833 | 0 | if (1) ##Out ##Start ##Execute | |||||||||||||||||||||||||||||||||||||||||
| 2834 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2835 | 0 | Out "Hello", "World"; | |||||||||||||||||||||||||||||||||||||||||
| 2836 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2837 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2838 | Hello World | ||||||||||||||||||||||||||||||||||||||||||
| 2839 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2841 | |||||||||||||||||||||||||||||||||||||||||||
| 2842 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2843 | 0 | if (1) ##Var | |||||||||||||||||||||||||||||||||||||||||
| 2844 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2845 | 0 | my $a = Var 22; | |||||||||||||||||||||||||||||||||||||||||
| 2846 | 0 | AssertEq $a, 22; | |||||||||||||||||||||||||||||||||||||||||
| 2847 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2848 | 0 | is_deeply $e->out, ""; | |||||||||||||||||||||||||||||||||||||||||
| 2849 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2850 | |||||||||||||||||||||||||||||||||||||||||||
| 2851 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2852 | 0 | if (1) ##Nop | |||||||||||||||||||||||||||||||||||||||||
| 2853 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2854 | 0 | Nop; | |||||||||||||||||||||||||||||||||||||||||
| 2855 | 0 | my $e = &$ee; | |||||||||||||||||||||||||||||||||||||||||
| 2856 | 0 | is_deeply $e->out, ""; | |||||||||||||||||||||||||||||||||||||||||
| 2857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2858 | |||||||||||||||||||||||||||||||||||||||||||
| 2859 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2860 | 0 | if (1) ##Mov | |||||||||||||||||||||||||||||||||||||||||
| 2861 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2862 | 0 | my $a = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 2863 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2864 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2865 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2866 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 2867 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2868 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2869 | |||||||||||||||||||||||||||||||||||||||||||
| 2870 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2871 | 0 | if (1) | |||||||||||||||||||||||||||||||||||||||||
| 2872 | 0 | {Start 1; ##Mov | |||||||||||||||||||||||||||||||||||||||||
| 2873 | 0 | my $a = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2874 | 0 | my $b = Mov $$a; | |||||||||||||||||||||||||||||||||||||||||
| 2875 | 0 | my $c = Mov \$b; | |||||||||||||||||||||||||||||||||||||||||
| 2876 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 2877 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2878 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2879 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 2880 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2881 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2882 | |||||||||||||||||||||||||||||||||||||||||||
| 2883 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2884 | 0 | if (1) ##Add | |||||||||||||||||||||||||||||||||||||||||
| 2885 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2886 | 0 | my $a = Add 3, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2887 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2888 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2889 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2890 | 5 | ||||||||||||||||||||||||||||||||||||||||||
| 2891 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2893 | |||||||||||||||||||||||||||||||||||||||||||
| 2894 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2895 | 0 | if (1) ##Subtract | |||||||||||||||||||||||||||||||||||||||||
| 2896 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2897 | 0 | my $a = Subtract 4, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2898 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2899 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2900 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2901 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 2902 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2904 | |||||||||||||||||||||||||||||||||||||||||||
| 2905 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2906 | 0 | if (1) ##Dec | |||||||||||||||||||||||||||||||||||||||||
| 2907 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2908 | 0 | my $a = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2909 | 0 | Dec $a; | |||||||||||||||||||||||||||||||||||||||||
| 2910 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2911 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2912 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2913 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 2914 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2915 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2916 | |||||||||||||||||||||||||||||||||||||||||||
| 2917 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2918 | 0 | if (1) ##Inc | |||||||||||||||||||||||||||||||||||||||||
| 2919 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2920 | 0 | my $a = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2921 | 0 | Inc $a; | |||||||||||||||||||||||||||||||||||||||||
| 2922 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2923 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2924 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2925 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 2926 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2927 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2928 | |||||||||||||||||||||||||||||||||||||||||||
| 2929 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2930 | 0 | if (1) ##Not | |||||||||||||||||||||||||||||||||||||||||
| 2931 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2932 | 0 | my $a = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2933 | 0 | my $b = Not $a; | |||||||||||||||||||||||||||||||||||||||||
| 2934 | 0 | my $c = Not $b; | |||||||||||||||||||||||||||||||||||||||||
| 2935 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2936 | 0 | Out $b; | |||||||||||||||||||||||||||||||||||||||||
| 2937 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 2938 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2939 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2940 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 2941 | |||||||||||||||||||||||||||||||||||||||||||
| 2942 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2943 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2944 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2945 | |||||||||||||||||||||||||||||||||||||||||||
| 2946 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2947 | 0 | if (1) ##ShiftLeft | |||||||||||||||||||||||||||||||||||||||||
| 2948 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2949 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2950 | 0 | ShiftLeft $a, $a; | |||||||||||||||||||||||||||||||||||||||||
| 2951 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2952 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2953 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2954 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 2955 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2956 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2957 | |||||||||||||||||||||||||||||||||||||||||||
| 2958 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2959 | 0 | if (1) ##ShiftRight | |||||||||||||||||||||||||||||||||||||||||
| 2960 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2961 | 0 | my $a = Mov 4; | |||||||||||||||||||||||||||||||||||||||||
| 2962 | 0 | ShiftRight $a, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2963 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2964 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2965 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2966 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 2967 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2968 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2969 | |||||||||||||||||||||||||||||||||||||||||||
| 2970 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2971 | 0 | if (1) ##Jmp | |||||||||||||||||||||||||||||||||||||||||
| 2972 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2973 | 0 | Jmp (my $a = label); | |||||||||||||||||||||||||||||||||||||||||
| 2974 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 2975 | 0 | Jmp (my $b = label); | |||||||||||||||||||||||||||||||||||||||||
| 2976 | 0 | setLabel($a); | |||||||||||||||||||||||||||||||||||||||||
| 2977 | 0 | Out 2; | |||||||||||||||||||||||||||||||||||||||||
| 2978 | 0 | setLabel($b); | |||||||||||||||||||||||||||||||||||||||||
| 2979 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2980 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2981 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 2982 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2983 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2984 | |||||||||||||||||||||||||||||||||||||||||||
| 2985 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2986 | 0 | if (1) ##JLt ##Label | |||||||||||||||||||||||||||||||||||||||||
| 2987 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2988 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2989 | 0 | Jlt ((my $a = label), \0, 2); | |||||||||||||||||||||||||||||||||||||||||
| 2990 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 2991 | 0 | Jmp (my $b = label); | |||||||||||||||||||||||||||||||||||||||||
| 2992 | 0 | setLabel($a); | |||||||||||||||||||||||||||||||||||||||||
| 2993 | 0 | Out 2; | |||||||||||||||||||||||||||||||||||||||||
| 2994 | 0 | setLabel($b); | |||||||||||||||||||||||||||||||||||||||||
| 2995 | |||||||||||||||||||||||||||||||||||||||||||
| 2996 | 0 | Jgt ((my $c = label), \0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 2997 | 0 | Out 3; | |||||||||||||||||||||||||||||||||||||||||
| 2998 | 0 | Jmp (my $d = label); | |||||||||||||||||||||||||||||||||||||||||
| 2999 | 0 | setLabel($c); | |||||||||||||||||||||||||||||||||||||||||
| 3000 | 0 | Out 4; | |||||||||||||||||||||||||||||||||||||||||
| 3001 | 0 | setLabel($d); | |||||||||||||||||||||||||||||||||||||||||
| 3002 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3003 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3004 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3005 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3006 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3007 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3008 | |||||||||||||||||||||||||||||||||||||||||||
| 3009 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3010 | 0 | if (1) ##Label | |||||||||||||||||||||||||||||||||||||||||
| 3011 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3012 | 0 | Mov 0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 3013 | 0 | my $a = setLabel; | |||||||||||||||||||||||||||||||||||||||||
| 3014 | 0 | Out \0; | |||||||||||||||||||||||||||||||||||||||||
| 3015 | 0 | Inc \0; | |||||||||||||||||||||||||||||||||||||||||
| 3016 | 0 | Jlt $a, \0, 10; | |||||||||||||||||||||||||||||||||||||||||
| 3017 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3018 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3019 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 3020 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3021 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3022 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3023 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3024 | 5 | ||||||||||||||||||||||||||||||||||||||||||
| 3025 | 6 | ||||||||||||||||||||||||||||||||||||||||||
| 3026 | 7 | ||||||||||||||||||||||||||||||||||||||||||
| 3027 | 8 | ||||||||||||||||||||||||||||||||||||||||||
| 3028 | 9 | ||||||||||||||||||||||||||||||||||||||||||
| 3029 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3030 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3031 | |||||||||||||||||||||||||||||||||||||||||||
| 3032 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3033 | 0 | if (1) ##Mov | |||||||||||||||||||||||||||||||||||||||||
| 3034 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3035 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3036 | 0 | Mov [$a, 1, "aaa"], 11; | |||||||||||||||||||||||||||||||||||||||||
| 3037 | 0 | Mov 1, [$a, \1, "aaa"]; | |||||||||||||||||||||||||||||||||||||||||
| 3038 | 0 | Out \1; | |||||||||||||||||||||||||||||||||||||||||
| 3039 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3040 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3041 | 11 | ||||||||||||||||||||||||||||||||||||||||||
| 3042 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3043 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3044 | |||||||||||||||||||||||||||||||||||||||||||
| 3045 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3046 | 0 | if (1) ##Call ##Return | |||||||||||||||||||||||||||||||||||||||||
| 3047 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3048 | my $w = Procedure 'write', sub | ||||||||||||||||||||||||||||||||||||||||||
| 3049 | 0 | ▶ | {Out 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3050 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 3051 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3052 | 0 | Call $w; | |||||||||||||||||||||||||||||||||||||||||
| 3053 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3054 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3055 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3056 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3057 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3058 | |||||||||||||||||||||||||||||||||||||||||||
| 3059 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3060 | 0 | if (1) ##Call | |||||||||||||||||||||||||||||||||||||||||
| 3061 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3062 | my $w = Procedure 'write', sub | ||||||||||||||||||||||||||||||||||||||||||
| 3063 | 0 | ▶ | {my $a = ParamsGet 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3064 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 3065 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 3066 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3067 | 0 | ParamsPut 0, 999; | |||||||||||||||||||||||||||||||||||||||||
| 3068 | 0 | Call $w; | |||||||||||||||||||||||||||||||||||||||||
| 3069 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3070 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3071 | 999 | ||||||||||||||||||||||||||||||||||||||||||
| 3072 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3073 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3074 | |||||||||||||||||||||||||||||||||||||||||||
| 3075 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3076 | 0 | if (1) ##Call ##ReturnPut ##ReturnGet | |||||||||||||||||||||||||||||||||||||||||
| 3077 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3078 | my $w = Procedure 'write', sub | ||||||||||||||||||||||||||||||||||||||||||
| 3079 | 0 | ▶ | {ReturnPut 0, 999; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3080 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 3081 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3082 | 0 | Call $w; | |||||||||||||||||||||||||||||||||||||||||
| 3083 | 0 | ReturnGet \0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 3084 | 0 | Out \0; | |||||||||||||||||||||||||||||||||||||||||
| 3085 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3086 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3087 | 999 | ||||||||||||||||||||||||||||||||||||||||||
| 3088 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3089 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3090 | |||||||||||||||||||||||||||||||||||||||||||
| 3091 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3092 | 0 | if (1) ##Procedure | |||||||||||||||||||||||||||||||||||||||||
| 3093 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3094 | my $add = Procedure 'add2', sub | ||||||||||||||||||||||||||||||||||||||||||
| 3095 | 0 | ▶ | {my $a = ParamsGet 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3096 | 0 | my $b = Add $a, 2; | |||||||||||||||||||||||||||||||||||||||||
| 3097 | 0 | ReturnPut 0, $b; | |||||||||||||||||||||||||||||||||||||||||
| 3098 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 3099 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3100 | 0 | ParamsPut 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 3101 | 0 | Call $add; | |||||||||||||||||||||||||||||||||||||||||
| 3102 | 0 | my $c = ReturnGet 0; | |||||||||||||||||||||||||||||||||||||||||
| 3103 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 3104 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3105 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3106 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3107 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3109 | |||||||||||||||||||||||||||||||||||||||||||
| 3110 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3111 | 0 | if (1) ##Confess | |||||||||||||||||||||||||||||||||||||||||
| 3112 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3113 | my $c = Procedure 'confess', sub | ||||||||||||||||||||||||||||||||||||||||||
| 3114 | 0 | ▶ | {Confess; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3115 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3116 | 0 | Call $c; | |||||||||||||||||||||||||||||||||||||||||
| 3117 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3118 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3119 | Confess at: | ||||||||||||||||||||||||||||||||||||||||||
| 3120 | 2 3 confess | ||||||||||||||||||||||||||||||||||||||||||
| 3121 | 1 6 call | ||||||||||||||||||||||||||||||||||||||||||
| 3122 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3124 | |||||||||||||||||||||||||||||||||||||||||||
| 3125 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3126 | 0 | if (1) ##Push ##Pop | |||||||||||||||||||||||||||||||||||||||||
| 3127 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3128 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3129 | 0 | Push $a, 1, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3130 | 0 | Push $a, 2, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3131 | 0 | my $c = Pop $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3132 | 0 | my $d = Pop $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3133 | |||||||||||||||||||||||||||||||||||||||||||
| 3134 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 3135 | 0 | Out $d; | |||||||||||||||||||||||||||||||||||||||||
| 3136 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3137 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3138 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3139 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3140 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3141 | 0 | is_deeply $e->heap(1), []; | |||||||||||||||||||||||||||||||||||||||||
| 3142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3143 | |||||||||||||||||||||||||||||||||||||||||||
| 3144 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3145 | 0 | if (1) ##Push | |||||||||||||||||||||||||||||||||||||||||
| 3146 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3147 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3148 | 0 | Push $a, 1, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3149 | 0 | Push $a, 2, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3150 | 0 | Push $a, 3, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3151 | 0 | my $b = Array "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 3152 | 0 | Push $b, 11, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 3153 | 0 | Push $b, 22, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 3154 | 0 | Push $b, 33, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 3155 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3156 | 0 | is_deeply $e->GetMemoryHeaps->($e), 3; | |||||||||||||||||||||||||||||||||||||||||
| 3157 | 0 | is_deeply $e->heap(1), [1, 2, 3]; | |||||||||||||||||||||||||||||||||||||||||
| 3158 | 0 | is_deeply $e->heap(2), [11, 22, 33]; | |||||||||||||||||||||||||||||||||||||||||
| 3159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3160 | |||||||||||||||||||||||||||||||||||||||||||
| 3161 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3162 | 0 | if (1) ##Alloc ##Mov | |||||||||||||||||||||||||||||||||||||||||
| 3163 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3164 | 0 | my $a = Array "alloc"; | |||||||||||||||||||||||||||||||||||||||||
| 3165 | 0 | my $b = Mov 99; | |||||||||||||||||||||||||||||||||||||||||
| 3166 | 0 | my $c = Mov $a; | |||||||||||||||||||||||||||||||||||||||||
| 3167 | 0 | Mov [$a, 0, 'alloc'], $b; | |||||||||||||||||||||||||||||||||||||||||
| 3168 | 0 | Mov [$c, 1, 'alloc'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 3169 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3170 | 0 | is_deeply $e->heap(1), [99, 2]; | |||||||||||||||||||||||||||||||||||||||||
| 3171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3172 | |||||||||||||||||||||||||||||||||||||||||||
| 3173 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3174 | 0 | if (1) ##Free | |||||||||||||||||||||||||||||||||||||||||
| 3175 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3176 | 0 | my $a = Array "node"; | |||||||||||||||||||||||||||||||||||||||||
| 3177 | 0 | Free $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3178 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3179 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3180 | Wrong name: aaa for array with name: node | ||||||||||||||||||||||||||||||||||||||||||
| 3181 | 1 2 free | ||||||||||||||||||||||||||||||||||||||||||
| 3182 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3184 | |||||||||||||||||||||||||||||||||||||||||||
| 3185 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3186 | 0 | if (1) ##Free ##Dump | |||||||||||||||||||||||||||||||||||||||||
| 3187 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3188 | 0 | my $a = Array "node"; | |||||||||||||||||||||||||||||||||||||||||
| 3189 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 3190 | 0 | Mov [$a, 1, 'node'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3191 | 0 | Mov [$a, 2, 'node'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 3192 | 0 | Mov 1, [$a, \1, 'node']; | |||||||||||||||||||||||||||||||||||||||||
| 3193 | 0 | Dump; | |||||||||||||||||||||||||||||||||||||||||
| 3194 | 0 | Free $a, "node"; | |||||||||||||||||||||||||||||||||||||||||
| 3195 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3196 | 0 | ▶ | is_deeply $e->out, <<END if $testSet <= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 3197 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3198 | 1=bless([undef, 1, 2], "node") | ||||||||||||||||||||||||||||||||||||||||||
| 3199 | Stack trace: | ||||||||||||||||||||||||||||||||||||||||||
| 3200 | 1 6 dump | ||||||||||||||||||||||||||||||||||||||||||
| 3201 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3202 | 0 | ▶ | is_deeply $e->out, <<END if $testSet > 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 3203 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3204 | 1=[0, 1, 2] | ||||||||||||||||||||||||||||||||||||||||||
| 3205 | Stack trace: | ||||||||||||||||||||||||||||||||||||||||||
| 3206 | 1 6 dump | ||||||||||||||||||||||||||||||||||||||||||
| 3207 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3209 | |||||||||||||||||||||||||||||||||||||||||||
| 3210 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3211 | 0 | if (1) # Layout | |||||||||||||||||||||||||||||||||||||||||
| 3212 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3213 | 0 | my $a = Mov 'A'; | |||||||||||||||||||||||||||||||||||||||||
| 3214 | 0 | my $b = Mov 'B'; | |||||||||||||||||||||||||||||||||||||||||
| 3215 | 0 | my $c = Mov 'C'; | |||||||||||||||||||||||||||||||||||||||||
| 3216 | 0 | Out $c, $b, $a; | |||||||||||||||||||||||||||||||||||||||||
| 3217 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3218 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3219 | C B A | ||||||||||||||||||||||||||||||||||||||||||
| 3220 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3222 | |||||||||||||||||||||||||||||||||||||||||||
| 3223 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3224 | 0 | if (1) ##IfEq ##IfNe ##IfLt ##IfLe ##IfGt ##IfGe | |||||||||||||||||||||||||||||||||||||||||
| 3225 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3226 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 3227 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 3228 | 0 | ▶ | IfEq $a, $a, Then {Out "Eq"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3229 | 0 | ▶ | IfNe $a, $a, Then {Out "Ne"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3230 | 0 | ▶ | IfLe $a, $a, Then {Out "Le"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3231 | 0 | ▶ | IfLt $a, $a, Then {Out "Lt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3232 | 0 | ▶ | IfGe $a, $a, Then {Out "Ge"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3233 | 0 | ▶ | IfGt $a, $a, Then {Out "Gt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3234 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3235 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3236 | Eq | ||||||||||||||||||||||||||||||||||||||||||
| 3237 | Le | ||||||||||||||||||||||||||||||||||||||||||
| 3238 | Ge | ||||||||||||||||||||||||||||||||||||||||||
| 3239 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3241 | |||||||||||||||||||||||||||||||||||||||||||
| 3242 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3243 | 0 | if (1) ##IfEq ##IfNe ##IfLt ##IfLe ##IfGt ##IfGe | |||||||||||||||||||||||||||||||||||||||||
| 3244 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3245 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 3246 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 3247 | 0 | ▶ | IfEq $a, $b, Then {Out "Eq"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3248 | 0 | ▶ | IfNe $a, $b, Then {Out "Ne"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3249 | 0 | ▶ | IfLe $a, $b, Then {Out "Le"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3250 | 0 | ▶ | IfLt $a, $b, Then {Out "Lt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3251 | 0 | ▶ | IfGe $a, $b, Then {Out "Ge"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3252 | 0 | ▶ | IfGt $a, $b, Then {Out "Gt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3253 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3254 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3255 | Ne | ||||||||||||||||||||||||||||||||||||||||||
| 3256 | Le | ||||||||||||||||||||||||||||||||||||||||||
| 3257 | Lt | ||||||||||||||||||||||||||||||||||||||||||
| 3258 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3260 | |||||||||||||||||||||||||||||||||||||||||||
| 3261 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3262 | 0 | if (1) ##IfEq ##IfNe ##IfLt ##IfLe ##IfGt ##IfGe | |||||||||||||||||||||||||||||||||||||||||
| 3263 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3264 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 3265 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 3266 | 0 | ▶ | IfEq $b, $a, Then {Out "Eq"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3267 | 0 | ▶ | IfNe $b, $a, Then {Out "Ne"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3268 | 0 | ▶ | IfLe $b, $a, Then {Out "Le"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3269 | 0 | ▶ | IfLt $b, $a, Then {Out "Lt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3270 | 0 | ▶ | IfGe $b, $a, Then {Out "Ge"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3271 | 0 | ▶ | IfGt $b, $a, Then {Out "Gt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3272 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3273 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3274 | Ne | ||||||||||||||||||||||||||||||||||||||||||
| 3275 | Ge | ||||||||||||||||||||||||||||||||||||||||||
| 3276 | Gt | ||||||||||||||||||||||||||||||||||||||||||
| 3277 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3279 | |||||||||||||||||||||||||||||||||||||||||||
| 3280 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3281 | 0 | if (1) ##IfTrue | |||||||||||||||||||||||||||||||||||||||||
| 3282 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3283 | IfTrue 1, | ||||||||||||||||||||||||||||||||||||||||||
| 3284 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 3285 | 0 | ▶ | {Out 1 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3286 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 3287 | Else | ||||||||||||||||||||||||||||||||||||||||||
| 3288 | 0 | ▶ | {Out 0 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3289 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3290 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3291 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3292 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3293 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3295 | |||||||||||||||||||||||||||||||||||||||||||
| 3296 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3297 | 0 | if (1) ##IfFalse ##Then ##Else | |||||||||||||||||||||||||||||||||||||||||
| 3298 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3299 | IfFalse 1, | ||||||||||||||||||||||||||||||||||||||||||
| 3300 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 3301 | 0 | ▶ | {Out 1 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3302 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 3303 | Else | ||||||||||||||||||||||||||||||||||||||||||
| 3304 | 0 | ▶ | {Out 0 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3305 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3306 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3307 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3308 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 3309 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3311 | |||||||||||||||||||||||||||||||||||||||||||
| 3312 | |||||||||||||||||||||||||||||||||||||||||||
| 3313 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3314 | 0 | if (1) ##For | |||||||||||||||||||||||||||||||||||||||||
| 3315 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3316 | For | ||||||||||||||||||||||||||||||||||||||||||
| 3317 | 0 | ▶ | {my ($i) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3318 | 0 | Out $i; | |||||||||||||||||||||||||||||||||||||||||
| 3319 | 0 | } 10; | |||||||||||||||||||||||||||||||||||||||||
| 3320 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3321 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3322 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 3323 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3324 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3325 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3326 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3327 | 5 | ||||||||||||||||||||||||||||||||||||||||||
| 3328 | 6 | ||||||||||||||||||||||||||||||||||||||||||
| 3329 | 7 | ||||||||||||||||||||||||||||||||||||||||||
| 3330 | 8 | ||||||||||||||||||||||||||||||||||||||||||
| 3331 | 9 | ||||||||||||||||||||||||||||||||||||||||||
| 3332 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3334 | |||||||||||||||||||||||||||||||||||||||||||
| 3335 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3336 | 0 | if (1) ##For | |||||||||||||||||||||||||||||||||||||||||
| 3337 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3338 | For | ||||||||||||||||||||||||||||||||||||||||||
| 3339 | 0 | ▶ | {my ($i) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3340 | 0 | Out $i; | |||||||||||||||||||||||||||||||||||||||||
| 3341 | 0 | } 10, reverse=>1; | |||||||||||||||||||||||||||||||||||||||||
| 3342 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3343 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3344 | 9 | ||||||||||||||||||||||||||||||||||||||||||
| 3345 | 8 | ||||||||||||||||||||||||||||||||||||||||||
| 3346 | 7 | ||||||||||||||||||||||||||||||||||||||||||
| 3347 | 6 | ||||||||||||||||||||||||||||||||||||||||||
| 3348 | 5 | ||||||||||||||||||||||||||||||||||||||||||
| 3349 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3350 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3351 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3352 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3353 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 3354 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3356 | |||||||||||||||||||||||||||||||||||||||||||
| 3357 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3358 | 0 | if (1) ##For | |||||||||||||||||||||||||||||||||||||||||
| 3359 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3360 | For | ||||||||||||||||||||||||||||||||||||||||||
| 3361 | 0 | ▶ | {my ($i) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3362 | 0 | Out $i; | |||||||||||||||||||||||||||||||||||||||||
| 3363 | 0 | } [2, 10]; | |||||||||||||||||||||||||||||||||||||||||
| 3364 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3365 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3366 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3367 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3368 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3369 | 5 | ||||||||||||||||||||||||||||||||||||||||||
| 3370 | 6 | ||||||||||||||||||||||||||||||||||||||||||
| 3371 | 7 | ||||||||||||||||||||||||||||||||||||||||||
| 3372 | 8 | ||||||||||||||||||||||||||||||||||||||||||
| 3373 | 9 | ||||||||||||||||||||||||||||||||||||||||||
| 3374 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3376 | |||||||||||||||||||||||||||||||||||||||||||
| 3377 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3378 | 0 | if (1) ##Assert | |||||||||||||||||||||||||||||||||||||||||
| 3379 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3380 | 0 | Assert; | |||||||||||||||||||||||||||||||||||||||||
| 3381 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3382 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3383 | Assert failed | ||||||||||||||||||||||||||||||||||||||||||
| 3384 | 1 1 assert | ||||||||||||||||||||||||||||||||||||||||||
| 3385 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3387 | |||||||||||||||||||||||||||||||||||||||||||
| 3388 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3389 | 0 | if (1) ##AssertEq | |||||||||||||||||||||||||||||||||||||||||
| 3390 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3391 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3392 | 0 | AssertEq \0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 3393 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3394 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3395 | Assert 1 == 2 failed | ||||||||||||||||||||||||||||||||||||||||||
| 3396 | 1 2 assertEq | ||||||||||||||||||||||||||||||||||||||||||
| 3397 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3399 | |||||||||||||||||||||||||||||||||||||||||||
| 3400 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3401 | 0 | if (1) ##AssertNe | |||||||||||||||||||||||||||||||||||||||||
| 3402 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3403 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3404 | 0 | AssertNe \0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3405 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3406 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3407 | Assert 1 != 1 failed | ||||||||||||||||||||||||||||||||||||||||||
| 3408 | 1 2 assertNe | ||||||||||||||||||||||||||||||||||||||||||
| 3409 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3411 | |||||||||||||||||||||||||||||||||||||||||||
| 3412 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3413 | 0 | if (1) ##AssertLt | |||||||||||||||||||||||||||||||||||||||||
| 3414 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3415 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3416 | 0 | AssertLt \0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 3417 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3418 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3419 | Assert 1 < 0 failed | ||||||||||||||||||||||||||||||||||||||||||
| 3420 | 1 2 assertLt | ||||||||||||||||||||||||||||||||||||||||||
| 3421 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3423 | |||||||||||||||||||||||||||||||||||||||||||
| 3424 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3425 | 0 | if (1) ##AssertLe | |||||||||||||||||||||||||||||||||||||||||
| 3426 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3427 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3428 | 0 | AssertLe \0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 3429 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3430 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3431 | Assert 1 <= 0 failed | ||||||||||||||||||||||||||||||||||||||||||
| 3432 | 1 2 assertLe | ||||||||||||||||||||||||||||||||||||||||||
| 3433 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3435 | |||||||||||||||||||||||||||||||||||||||||||
| 3436 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3437 | 0 | if (1) ##AssertGt | |||||||||||||||||||||||||||||||||||||||||
| 3438 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3439 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3440 | 0 | AssertGt \0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 3441 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3442 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3443 | Assert 1 > 2 failed | ||||||||||||||||||||||||||||||||||||||||||
| 3444 | 1 2 assertGt | ||||||||||||||||||||||||||||||||||||||||||
| 3445 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3447 | |||||||||||||||||||||||||||||||||||||||||||
| 3448 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3449 | 0 | if (1) ##AssertGe | |||||||||||||||||||||||||||||||||||||||||
| 3450 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3451 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3452 | 0 | AssertGe \0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 3453 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3454 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3455 | Assert 1 >= 2 failed | ||||||||||||||||||||||||||||||||||||||||||
| 3456 | 1 2 assertGe | ||||||||||||||||||||||||||||||||||||||||||
| 3457 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3459 | |||||||||||||||||||||||||||||||||||||||||||
| 3460 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3461 | 0 | if (1) ##AssertTrue | |||||||||||||||||||||||||||||||||||||||||
| 3462 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3463 | 0 | AssertFalse 0; | |||||||||||||||||||||||||||||||||||||||||
| 3464 | 0 | AssertTrue 0; | |||||||||||||||||||||||||||||||||||||||||
| 3465 | 0 | my $e = &$ee(suppressOutput=>1, trace=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3466 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3467 | 1 0 1 assertFalse | ||||||||||||||||||||||||||||||||||||||||||
| 3468 | AssertTrue 0 failed | ||||||||||||||||||||||||||||||||||||||||||
| 3469 | 1 2 assertTrue | ||||||||||||||||||||||||||||||||||||||||||
| 3470 | 2 1 1 assertTrue | ||||||||||||||||||||||||||||||||||||||||||
| 3471 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3473 | |||||||||||||||||||||||||||||||||||||||||||
| 3474 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3475 | 0 | if (1) ##AssertFalse | |||||||||||||||||||||||||||||||||||||||||
| 3476 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3477 | 0 | AssertTrue 1; | |||||||||||||||||||||||||||||||||||||||||
| 3478 | 0 | AssertFalse 1; | |||||||||||||||||||||||||||||||||||||||||
| 3479 | 0 | my $e = &$ee(suppressOutput=>1, trace=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3480 | |||||||||||||||||||||||||||||||||||||||||||
| 3481 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3482 | 1 0 1 assertTrue | ||||||||||||||||||||||||||||||||||||||||||
| 3483 | AssertFalse 1 failed | ||||||||||||||||||||||||||||||||||||||||||
| 3484 | 1 2 assertFalse | ||||||||||||||||||||||||||||||||||||||||||
| 3485 | 2 1 1 assertFalse | ||||||||||||||||||||||||||||||||||||||||||
| 3486 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3488 | |||||||||||||||||||||||||||||||||||||||||||
| 3489 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3490 | 0 | if (1) # Temporary variable | |||||||||||||||||||||||||||||||||||||||||
| 3491 | 0 | {my $s = Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3492 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 3493 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 3494 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 3495 | 0 | Out $b; | |||||||||||||||||||||||||||||||||||||||||
| 3496 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3497 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3498 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3499 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3500 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3502 | |||||||||||||||||||||||||||||||||||||||||||
| 3503 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3504 | 0 | if (1) ##Alloc ##Mov ##Call | |||||||||||||||||||||||||||||||||||||||||
| 3505 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3506 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3507 | 0 | Dump; | |||||||||||||||||||||||||||||||||||||||||
| 3508 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3509 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3510 | Stack trace: | ||||||||||||||||||||||||||||||||||||||||||
| 3511 | 1 2 dump | ||||||||||||||||||||||||||||||||||||||||||
| 3512 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3514 | |||||||||||||||||||||||||||||||||||||||||||
| 3515 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3516 | 0 | if (1) ##Alloc ##Mov ##Call ##ParamsPut ##ParamsGet | |||||||||||||||||||||||||||||||||||||||||
| 3517 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3518 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3519 | 0 | my $i = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 3520 | 0 | my $v = Mov 11; | |||||||||||||||||||||||||||||||||||||||||
| 3521 | 0 | ParamsPut 0, $a; | |||||||||||||||||||||||||||||||||||||||||
| 3522 | 0 | ParamsPut 1, $i; | |||||||||||||||||||||||||||||||||||||||||
| 3523 | 0 | ParamsPut 2, $v; | |||||||||||||||||||||||||||||||||||||||||
| 3524 | my $set = Procedure 'set', sub | ||||||||||||||||||||||||||||||||||||||||||
| 3525 | 0 | ▶ | {my $a = ParamsGet 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3526 | 0 | my $i = ParamsGet 1; | |||||||||||||||||||||||||||||||||||||||||
| 3527 | 0 | my $v = ParamsGet 2; | |||||||||||||||||||||||||||||||||||||||||
| 3528 | 0 | Mov [$a, \$i, 'aaa'], $v; | |||||||||||||||||||||||||||||||||||||||||
| 3529 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 3530 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3531 | 0 | Call $set; | |||||||||||||||||||||||||||||||||||||||||
| 3532 | 0 | my $V = Mov [$a, \$i, 'aaa']; | |||||||||||||||||||||||||||||||||||||||||
| 3533 | 0 | AssertEq $v, $V; | |||||||||||||||||||||||||||||||||||||||||
| 3534 | 0 | Out [$a, \$i, 'aaa']; | |||||||||||||||||||||||||||||||||||||||||
| 3535 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3536 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3537 | 11 | ||||||||||||||||||||||||||||||||||||||||||
| 3538 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3540 | |||||||||||||||||||||||||||||||||||||||||||
| 3541 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3542 | 0 | if (1) ##Alloc ##Clear | |||||||||||||||||||||||||||||||||||||||||
| 3543 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3544 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3545 | 0 | Clear $a, 10, 'aaa'; | |||||||||||||||||||||||||||||||||||||||||
| 3546 | 0 | my $e = &$ee(suppressOutput=>1, maximumAreaSize=>10); | |||||||||||||||||||||||||||||||||||||||||
| 3547 | 0 | is_deeply $e->heap(1), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |||||||||||||||||||||||||||||||||||||||||
| 3548 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3549 | |||||||||||||||||||||||||||||||||||||||||||
| 3550 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3551 | 0 | if (1) ##Block ##Good ##Bad | |||||||||||||||||||||||||||||||||||||||||
| 3552 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3553 | Block | ||||||||||||||||||||||||||||||||||||||||||
| 3554 | 0 | ▶ | {my ($start, $good, $bad, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3555 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 3556 | 0 | Jmp $good; | |||||||||||||||||||||||||||||||||||||||||
| 3557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3558 | Good | ||||||||||||||||||||||||||||||||||||||||||
| 3559 | 0 | ▶ | {Out 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3560 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 3561 | Bad | ||||||||||||||||||||||||||||||||||||||||||
| 3562 | 0 | ▶ | {Out 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3563 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3564 | 0 | Out 4; | |||||||||||||||||||||||||||||||||||||||||
| 3565 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3566 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3567 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3568 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3569 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3570 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3572 | |||||||||||||||||||||||||||||||||||||||||||
| 3573 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3574 | 0 | if (1) ##Block | |||||||||||||||||||||||||||||||||||||||||
| 3575 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3576 | Block | ||||||||||||||||||||||||||||||||||||||||||
| 3577 | 0 | ▶ | {my ($start, $good, $bad, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3578 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 3579 | 0 | Jmp $bad; | |||||||||||||||||||||||||||||||||||||||||
| 3580 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3581 | Good | ||||||||||||||||||||||||||||||||||||||||||
| 3582 | 0 | ▶ | {Out 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3583 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 3584 | Bad | ||||||||||||||||||||||||||||||||||||||||||
| 3585 | 0 | ▶ | {Out 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3586 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3587 | 0 | Out 4; | |||||||||||||||||||||||||||||||||||||||||
| 3588 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3589 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3590 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3591 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3592 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3593 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3595 | |||||||||||||||||||||||||||||||||||||||||||
| 3596 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3597 | 0 | if (1) ##Procedure | |||||||||||||||||||||||||||||||||||||||||
| 3598 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3599 | 0 | for my $i(1..10) | |||||||||||||||||||||||||||||||||||||||||
| 3600 | 0 | {Out $i; | |||||||||||||||||||||||||||||||||||||||||
| 3601 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 3602 | IfTrue 0, | ||||||||||||||||||||||||||||||||||||||||||
| 3603 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 3604 | 0 | ▶ | {Out 99; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3605 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3606 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3607 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3608 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3609 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3610 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3611 | 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3612 | 5 | ||||||||||||||||||||||||||||||||||||||||||
| 3613 | 6 | ||||||||||||||||||||||||||||||||||||||||||
| 3614 | 7 | ||||||||||||||||||||||||||||||||||||||||||
| 3615 | 8 | ||||||||||||||||||||||||||||||||||||||||||
| 3616 | 9 | ||||||||||||||||||||||||||||||||||||||||||
| 3617 | 10 | ||||||||||||||||||||||||||||||||||||||||||
| 3618 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3619 | 0 | is_deeply $e->outLines, [1..10]; | |||||||||||||||||||||||||||||||||||||||||
| 3620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3621 | |||||||||||||||||||||||||||||||||||||||||||
| 3622 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3623 | 0 | if (0) # Double write - needs rewrite of double write detection | |||||||||||||||||||||||||||||||||||||||||
| 3624 | {Start 1; | ||||||||||||||||||||||||||||||||||||||||||
| 3625 | Mov 1, 1; | ||||||||||||||||||||||||||||||||||||||||||
| 3626 | Mov 2, 1; | ||||||||||||||||||||||||||||||||||||||||||
| 3627 | Mov 3, 1; | ||||||||||||||||||||||||||||||||||||||||||
| 3628 | Mov 3, 1; | ||||||||||||||||||||||||||||||||||||||||||
| 3629 | Mov 1, 1; | ||||||||||||||||||||||||||||||||||||||||||
| 3630 | my $e = &$ee(suppressOutput=>0); | ||||||||||||||||||||||||||||||||||||||||||
| 3631 | ok keys($e->doubleWrite->%*) == 2; # In area 0, variable 1 was first written by instruction 0 then again by instruction 1 once. | ||||||||||||||||||||||||||||||||||||||||||
| 3632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3633 | |||||||||||||||||||||||||||||||||||||||||||
| 3634 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3635 | 0 | if (1) # Pointless assign | |||||||||||||||||||||||||||||||||||||||||
| 3636 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3637 | 0 | Add 2, 1, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3638 | 0 | Add 2, \2, 0; | |||||||||||||||||||||||||||||||||||||||||
| 3639 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3640 | 0 | is_deeply $e->pointlessAssign, { 1=> 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 3641 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3642 | |||||||||||||||||||||||||||||||||||||||||||
| 3643 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3644 | 0 | if (0) # Not read | |||||||||||||||||||||||||||||||||||||||||
| 3645 | {Start 1; | ||||||||||||||||||||||||||||||||||||||||||
| 3646 | my $a = Mov 1; | ||||||||||||||||||||||||||||||||||||||||||
| 3647 | my $b = Mov $a; | ||||||||||||||||||||||||||||||||||||||||||
| 3648 | my $e = &$ee(suppressOutput=>1); | ||||||||||||||||||||||||||||||||||||||||||
| 3649 | ok $e->notRead->{0}{1} == 1; # Area 0 == stack, variable 1 == $b generated by instruction 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3651 | |||||||||||||||||||||||||||||||||||||||||||
| 3652 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3653 | 0 | if (1) ##Alloc ##Mov ##Call | |||||||||||||||||||||||||||||||||||||||||
| 3654 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3655 | my $set = Procedure 'set', sub | ||||||||||||||||||||||||||||||||||||||||||
| 3656 | 0 | ▶ | {my $a = ParamsGet 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3657 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 3658 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3659 | 0 | ParamsPut 0, 1; Call $set; | |||||||||||||||||||||||||||||||||||||||||
| 3660 | 0 | ParamsPut 0, 2; Call $set; | |||||||||||||||||||||||||||||||||||||||||
| 3661 | 0 | ParamsPut 0, 3; Call $set; | |||||||||||||||||||||||||||||||||||||||||
| 3662 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3663 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3664 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3665 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3666 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3667 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3668 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3669 | |||||||||||||||||||||||||||||||||||||||||||
| 3670 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3671 | 0 | if (1) # Invalid address | |||||||||||||||||||||||||||||||||||||||||
| 3672 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3673 | 0 | Mov 1, \0; | |||||||||||||||||||||||||||||||||||||||||
| 3674 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3675 | 0 | ok $e->out =~ m"Cannot assign an undefined value"; | |||||||||||||||||||||||||||||||||||||||||
| 3676 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3677 | |||||||||||||||||||||||||||||||||||||||||||
| 3678 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3679 | 0 | if (1) ##LoadArea ##LoadAddress | |||||||||||||||||||||||||||||||||||||||||
| 3680 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3681 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 3682 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 3683 | 0 | my $c = Mov 5; | |||||||||||||||||||||||||||||||||||||||||
| 3684 | 0 | my $d = LoadAddress $c; | |||||||||||||||||||||||||||||||||||||||||
| 3685 | 0 | my $f = LoadArea [$a, \0, 'array']; | |||||||||||||||||||||||||||||||||||||||||
| 3686 | |||||||||||||||||||||||||||||||||||||||||||
| 3687 | 0 | Out $d; | |||||||||||||||||||||||||||||||||||||||||
| 3688 | 0 | Out $f; | |||||||||||||||||||||||||||||||||||||||||
| 3689 | |||||||||||||||||||||||||||||||||||||||||||
| 3690 | 0 | Mov [$a, \$b, 'array'], 22; | |||||||||||||||||||||||||||||||||||||||||
| 3691 | 0 | Mov [$a, \$c, 'array'], 33; | |||||||||||||||||||||||||||||||||||||||||
| 3692 | 0 | Mov [$f, \$d, 'array'], 44; | |||||||||||||||||||||||||||||||||||||||||
| 3693 | |||||||||||||||||||||||||||||||||||||||||||
| 3694 | 0 | my $e = &$ee(suppressOutput=>1, maximumAreaSize=>6); | |||||||||||||||||||||||||||||||||||||||||
| 3695 | |||||||||||||||||||||||||||||||||||||||||||
| 3696 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3697 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3698 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3699 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3700 | |||||||||||||||||||||||||||||||||||||||||||
| 3701 | 0 | ▶ | is_deeply $e->heap(1), [undef, undef, 44, undef, undef, 33] if $testSet <= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 3702 | 0 | ▶ | is_deeply $e->heap(1), [0, 0, 44, 0, 0, 33] if $testSet > 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 3703 | 0 | is_deeply $e->widestAreaInArena, [4,5]; | |||||||||||||||||||||||||||||||||||||||||
| 3704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3705 | |||||||||||||||||||||||||||||||||||||||||||
| 3706 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3707 | 0 | if (1) ##ShiftUp | |||||||||||||||||||||||||||||||||||||||||
| 3708 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3709 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 3710 | |||||||||||||||||||||||||||||||||||||||||||
| 3711 | 0 | Mov [$a, 0, 'array'], 0; | |||||||||||||||||||||||||||||||||||||||||
| 3712 | 0 | Mov [$a, 1, 'array'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3713 | 0 | Mov [$a, 2, 'array'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 3714 | 0 | ShiftUp [$a, 0, 'array'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 3715 | |||||||||||||||||||||||||||||||||||||||||||
| 3716 | 0 | my $e = &$ee(suppressOutput=>0); | |||||||||||||||||||||||||||||||||||||||||
| 3717 | 0 | is_deeply $e->heap(1), [99, 0, 1, 2]; | |||||||||||||||||||||||||||||||||||||||||
| 3718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3719 | |||||||||||||||||||||||||||||||||||||||||||
| 3720 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3721 | 0 | if (1) ##ShiftUp | |||||||||||||||||||||||||||||||||||||||||
| 3722 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3723 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 3724 | |||||||||||||||||||||||||||||||||||||||||||
| 3725 | 0 | Mov [$a, 0, 'array'], 0; | |||||||||||||||||||||||||||||||||||||||||
| 3726 | 0 | Mov [$a, 1, 'array'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3727 | 0 | Mov [$a, 2, 'array'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 3728 | 0 | ShiftUp [$a, 1, 'array'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 3729 | |||||||||||||||||||||||||||||||||||||||||||
| 3730 | 0 | my $e = &$ee(suppressOutput=>0); | |||||||||||||||||||||||||||||||||||||||||
| 3731 | 0 | is_deeply $e->heap(1), [0, 99, 1, 2]; | |||||||||||||||||||||||||||||||||||||||||
| 3732 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3733 | |||||||||||||||||||||||||||||||||||||||||||
| 3734 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3735 | 0 | if (1) ##ShiftUp | |||||||||||||||||||||||||||||||||||||||||
| 3736 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3737 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 3738 | |||||||||||||||||||||||||||||||||||||||||||
| 3739 | 0 | Mov [$a, 0, 'array'], 0; | |||||||||||||||||||||||||||||||||||||||||
| 3740 | 0 | Mov [$a, 1, 'array'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3741 | 0 | Mov [$a, 2, 'array'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 3742 | 0 | ShiftUp [$a, 2, 'array'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 3743 | |||||||||||||||||||||||||||||||||||||||||||
| 3744 | 0 | my $e = &$ee(suppressOutput=>0); | |||||||||||||||||||||||||||||||||||||||||
| 3745 | 0 | is_deeply $e->heap(1), [0, 1, 99, 2]; | |||||||||||||||||||||||||||||||||||||||||
| 3746 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3747 | |||||||||||||||||||||||||||||||||||||||||||
| 3748 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3749 | 0 | if (1) ##ShiftUp | |||||||||||||||||||||||||||||||||||||||||
| 3750 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3751 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 3752 | |||||||||||||||||||||||||||||||||||||||||||
| 3753 | 0 | Mov [$a, 0, 'array'], 0; | |||||||||||||||||||||||||||||||||||||||||
| 3754 | 0 | Mov [$a, 1, 'array'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3755 | 0 | Mov [$a, 2, 'array'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 3756 | 0 | ShiftUp [$a, 3, 'array'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 3757 | |||||||||||||||||||||||||||||||||||||||||||
| 3758 | 0 | my $e = &$ee(suppressOutput=>0); | |||||||||||||||||||||||||||||||||||||||||
| 3759 | 0 | is_deeply $e->heap(1), [0, 1, 2, 99]; | |||||||||||||||||||||||||||||||||||||||||
| 3760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3761 | |||||||||||||||||||||||||||||||||||||||||||
| 3762 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3763 | 0 | if (1) ##ShiftUp | |||||||||||||||||||||||||||||||||||||||||
| 3764 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3765 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 3766 | |||||||||||||||||||||||||||||||||||||||||||
| 3767 | 0 | Mov [$a, $_-1, 'array'], 10*$_ for 1..7; | |||||||||||||||||||||||||||||||||||||||||
| 3768 | 0 | ShiftUp [$a, 2, 'array'], 26; | |||||||||||||||||||||||||||||||||||||||||
| 3769 | |||||||||||||||||||||||||||||||||||||||||||
| 3770 | 0 | my $e = &$ee(suppressOutput=>1, maximumAreaSize=>8); | |||||||||||||||||||||||||||||||||||||||||
| 3771 | 0 | is_deeply $e->heap(1), bless([10, 20, 26, 30, 40, 50, 60, 70], "array"); | |||||||||||||||||||||||||||||||||||||||||
| 3772 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3773 | |||||||||||||||||||||||||||||||||||||||||||
| 3774 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3775 | 0 | if (1) ##ShiftDown | |||||||||||||||||||||||||||||||||||||||||
| 3776 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3777 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 3778 | 0 | Mov [$a, 0, 'array'], 0; | |||||||||||||||||||||||||||||||||||||||||
| 3779 | 0 | Mov [$a, 1, 'array'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 3780 | 0 | Mov [$a, 2, 'array'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 3781 | |||||||||||||||||||||||||||||||||||||||||||
| 3782 | 0 | my $b = ShiftDown [$a, \1, 'array']; | |||||||||||||||||||||||||||||||||||||||||
| 3783 | 0 | Out $b; | |||||||||||||||||||||||||||||||||||||||||
| 3784 | |||||||||||||||||||||||||||||||||||||||||||
| 3785 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3786 | 0 | is_deeply $e->heap(1), [0, 2]; | |||||||||||||||||||||||||||||||||||||||||
| 3787 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3788 | 99 | ||||||||||||||||||||||||||||||||||||||||||
| 3789 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3791 | |||||||||||||||||||||||||||||||||||||||||||
| 3792 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3793 | 0 | if (1) ##Alloc ##Mov ##Jeq ##Jne ##Jle ##Jlt ##Jge ##Jgt | |||||||||||||||||||||||||||||||||||||||||
| 3794 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3795 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3796 | 0 | my $b = Array "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 3797 | 0 | Mov [$a, 0, 'aaa'], $b; | |||||||||||||||||||||||||||||||||||||||||
| 3798 | 0 | Mov [$b, 0, 'bbb'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 3799 | |||||||||||||||||||||||||||||||||||||||||||
| 3800 | For | ||||||||||||||||||||||||||||||||||||||||||
| 3801 | 0 | ▶ | {my ($i, $check, $next, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3802 | 0 | my $c = Mov [$a, \0, 'aaa']; | |||||||||||||||||||||||||||||||||||||||||
| 3803 | 0 | my $d = Mov [$c, \0, 'bbb']; | |||||||||||||||||||||||||||||||||||||||||
| 3804 | 0 | Jeq $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 3805 | 0 | Jne $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 3806 | 0 | Jle $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 3807 | 0 | Jlt $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 3808 | 0 | Jge $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 3809 | 0 | Jgt $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 3810 | 0 | } 3; | |||||||||||||||||||||||||||||||||||||||||
| 3811 | |||||||||||||||||||||||||||||||||||||||||||
| 3812 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3813 | |||||||||||||||||||||||||||||||||||||||||||
| 3814 | 0 | is_deeply $e->analyzeExecutionResults(doubleWrite=>3), "# 24 instructions executed"; | |||||||||||||||||||||||||||||||||||||||||
| 3815 | 0 | is_deeply $e->heap(1), [2]; | |||||||||||||||||||||||||||||||||||||||||
| 3816 | 0 | is_deeply $e->heap(2), [99]; | |||||||||||||||||||||||||||||||||||||||||
| 3817 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3818 | |||||||||||||||||||||||||||||||||||||||||||
| 3819 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3820 | 0 | if (1) ##JTrue ##JFalse | |||||||||||||||||||||||||||||||||||||||||
| 3821 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3822 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 3823 | Block | ||||||||||||||||||||||||||||||||||||||||||
| 3824 | 0 | ▶ | {my ($start, $good, $bad, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3825 | 0 | JTrue $end, $a; | |||||||||||||||||||||||||||||||||||||||||
| 3826 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 3827 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3828 | Block | ||||||||||||||||||||||||||||||||||||||||||
| 3829 | 0 | ▶ | {my ($start, $good, $bad, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3830 | 0 | JFalse $end, $a; | |||||||||||||||||||||||||||||||||||||||||
| 3831 | 0 | Out 2; | |||||||||||||||||||||||||||||||||||||||||
| 3832 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3833 | 0 | Mov $a, 0; | |||||||||||||||||||||||||||||||||||||||||
| 3834 | Block | ||||||||||||||||||||||||||||||||||||||||||
| 3835 | 0 | ▶ | {my ($start, $good, $bad, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3836 | 0 | JTrue $end, $a; | |||||||||||||||||||||||||||||||||||||||||
| 3837 | 0 | Out 3; | |||||||||||||||||||||||||||||||||||||||||
| 3838 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3839 | Block | ||||||||||||||||||||||||||||||||||||||||||
| 3840 | 0 | ▶ | {my ($start, $good, $bad, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3841 | 0 | JFalse $end, $a; | |||||||||||||||||||||||||||||||||||||||||
| 3842 | 0 | Out 4; | |||||||||||||||||||||||||||||||||||||||||
| 3843 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3844 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3845 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3846 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 3847 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3848 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3849 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3850 | |||||||||||||||||||||||||||||||||||||||||||
| 3851 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3852 | 0 | if (1) ##Alloc ##Mov | |||||||||||||||||||||||||||||||||||||||||
| 3853 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3854 | 0 | my $a = Array 'aaa'; | |||||||||||||||||||||||||||||||||||||||||
| 3855 | 0 | my $b = Mov 2; # Location to move to in a | |||||||||||||||||||||||||||||||||||||||||
| 3856 | |||||||||||||||||||||||||||||||||||||||||||
| 3857 | For | ||||||||||||||||||||||||||||||||||||||||||
| 3858 | 0 | ▶ | {my ($i, $check, $next, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3859 | 0 | Mov [$a, \$b, 'aaa'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3860 | 0 | Jeq $next, [$a, \$b, 'aaa'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3861 | 0 | } 3; | |||||||||||||||||||||||||||||||||||||||||
| 3862 | |||||||||||||||||||||||||||||||||||||||||||
| 3863 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3864 | |||||||||||||||||||||||||||||||||||||||||||
| 3865 | 0 | is_deeply $e->analyzeExecutionResults(doubleWrite=>3), "# 19 instructions executed"; | |||||||||||||||||||||||||||||||||||||||||
| 3866 | 0 | ▶ | is_deeply $e->heap(1), [undef, undef, 1] if $testSet <= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 3867 | 0 | ▶ | is_deeply $e->heap(1), [0, 0, 1] if $testSet > 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 3868 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3869 | |||||||||||||||||||||||||||||||||||||||||||
| 3870 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3871 | 0 | if (1) ##Alloc | |||||||||||||||||||||||||||||||||||||||||
| 3872 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3873 | |||||||||||||||||||||||||||||||||||||||||||
| 3874 | For # Allocate and free several times to demonstrate area reuse | ||||||||||||||||||||||||||||||||||||||||||
| 3875 | 0 | ▶ | {my ($i) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3876 | 0 | my $a = Array 'aaaa'; | |||||||||||||||||||||||||||||||||||||||||
| 3877 | 0 | Mov [$a, 0, 'aaaa'], $i; | |||||||||||||||||||||||||||||||||||||||||
| 3878 | 0 | Free $a, 'aaaa'; | |||||||||||||||||||||||||||||||||||||||||
| 3879 | 0 | Dump; | |||||||||||||||||||||||||||||||||||||||||
| 3880 | 0 | } 3; | |||||||||||||||||||||||||||||||||||||||||
| 3881 | |||||||||||||||||||||||||||||||||||||||||||
| 3882 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3883 | |||||||||||||||||||||||||||||||||||||||||||
| 3884 | 0 | is_deeply $e->counts, # Several allocations and frees | |||||||||||||||||||||||||||||||||||||||||
| 3885 | {array=>3, dump=>3, free=>3, inc=>3, jGe=>4, jmp=>3, mov=>4 | ||||||||||||||||||||||||||||||||||||||||||
| 3886 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 3887 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3888 | Stack trace: | ||||||||||||||||||||||||||||||||||||||||||
| 3889 | 1 8 dump | ||||||||||||||||||||||||||||||||||||||||||
| 3890 | Stack trace: | ||||||||||||||||||||||||||||||||||||||||||
| 3891 | 1 8 dump | ||||||||||||||||||||||||||||||||||||||||||
| 3892 | Stack trace: | ||||||||||||||||||||||||||||||||||||||||||
| 3893 | 1 8 dump | ||||||||||||||||||||||||||||||||||||||||||
| 3894 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3895 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3896 | |||||||||||||||||||||||||||||||||||||||||||
| 3897 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3898 | 0 | if (1) ##Resize | |||||||||||||||||||||||||||||||||||||||||
| 3899 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3900 | 0 | my $a = Array 'aaa'; | |||||||||||||||||||||||||||||||||||||||||
| 3901 | 0 | Mov [$a, 0, 'aaa'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3902 | 0 | Mov [$a, 1, 'aaa'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 3903 | 0 | Mov [$a, 2, 'aaa'], 3; | |||||||||||||||||||||||||||||||||||||||||
| 3904 | 0 | Resize $a, 2, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3905 | 0 | ArrayDump $a; | |||||||||||||||||||||||||||||||||||||||||
| 3906 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3907 | |||||||||||||||||||||||||||||||||||||||||||
| 3908 | 0 | is_deeply $e->heap(1), [1, 2]; | |||||||||||||||||||||||||||||||||||||||||
| 3909 | 0 | is_deeply eval($e->out), [1,2]; | |||||||||||||||||||||||||||||||||||||||||
| 3910 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3911 | |||||||||||||||||||||||||||||||||||||||||||
| 3912 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3913 | 0 | if (1) ##Trace ##Then ##Else | |||||||||||||||||||||||||||||||||||||||||
| 3914 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3915 | 0 | Trace 1; | |||||||||||||||||||||||||||||||||||||||||
| 3916 | IfEq 1, 2, | ||||||||||||||||||||||||||||||||||||||||||
| 3917 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 3918 | 0 | ▶ | {Mov 1, 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3919 | 0 | Mov 2, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3920 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 3921 | Else | ||||||||||||||||||||||||||||||||||||||||||
| 3922 | 0 | ▶ | {Mov 3, 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3923 | 0 | Mov 4, 4; | |||||||||||||||||||||||||||||||||||||||||
| 3924 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3925 | IfEq 2, 2, | ||||||||||||||||||||||||||||||||||||||||||
| 3926 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 3927 | 0 | ▶ | {Mov 1, 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3928 | 0 | Mov 2, 1; | |||||||||||||||||||||||||||||||||||||||||
| 3929 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 3930 | Else | ||||||||||||||||||||||||||||||||||||||||||
| 3931 | 0 | ▶ | {Mov 3, 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 3932 | 0 | Mov 4, 4; | |||||||||||||||||||||||||||||||||||||||||
| 3933 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 3934 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3935 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3936 | Trace: 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3937 | 1 0 1 trace | ||||||||||||||||||||||||||||||||||||||||||
| 3938 | 2 1 1 jNe | ||||||||||||||||||||||||||||||||||||||||||
| 3939 | 3 5 1 label | ||||||||||||||||||||||||||||||||||||||||||
| 3940 | 4 6 1 mov [1, 3, stackArea] = 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3941 | 5 7 1 mov [1, 4, stackArea] = 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3942 | 6 8 1 label | ||||||||||||||||||||||||||||||||||||||||||
| 3943 | 7 9 1 jNe | ||||||||||||||||||||||||||||||||||||||||||
| 3944 | 8 10 1 mov [1, 1, stackArea] = 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3945 | 9 11 1 mov [1, 2, stackArea] = 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3946 | 10 12 1 jmp | ||||||||||||||||||||||||||||||||||||||||||
| 3947 | 11 16 1 label | ||||||||||||||||||||||||||||||||||||||||||
| 3948 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3949 | 0 | my $E = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3950 | 0 | is_deeply $E->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3951 | Trace: 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3952 | 1 0 1 trace | ||||||||||||||||||||||||||||||||||||||||||
| 3953 | 2 1 1 jNe | ||||||||||||||||||||||||||||||||||||||||||
| 3954 | 3 5 1 label | ||||||||||||||||||||||||||||||||||||||||||
| 3955 | 4 6 1 mov [1, 3, stackArea] = 3 | ||||||||||||||||||||||||||||||||||||||||||
| 3956 | 5 7 1 mov [1, 4, stackArea] = 4 | ||||||||||||||||||||||||||||||||||||||||||
| 3957 | 6 8 1 label | ||||||||||||||||||||||||||||||||||||||||||
| 3958 | 7 9 1 jNe | ||||||||||||||||||||||||||||||||||||||||||
| 3959 | 8 10 1 mov [1, 1, stackArea] = 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3960 | 9 11 1 mov [1, 2, stackArea] = 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3961 | 10 12 1 jmp | ||||||||||||||||||||||||||||||||||||||||||
| 3962 | 11 16 1 label | ||||||||||||||||||||||||||||||||||||||||||
| 3963 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3964 | |||||||||||||||||||||||||||||||||||||||||||
| 3965 | 0 | is_deeply scalar($e->notExecuted->@*), 6; | |||||||||||||||||||||||||||||||||||||||||
| 3966 | 0 | is_deeply scalar($E->notExecuted->@*), 6; | |||||||||||||||||||||||||||||||||||||||||
| 3967 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3968 | |||||||||||||||||||||||||||||||||||||||||||
| 3969 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3970 | 0 | if (1) ##Watch | |||||||||||||||||||||||||||||||||||||||||
| 3971 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3972 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 3973 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 3974 | 0 | my $c = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 3975 | 0 | Watch $b; | |||||||||||||||||||||||||||||||||||||||||
| 3976 | 0 | Mov $a, 4; | |||||||||||||||||||||||||||||||||||||||||
| 3977 | 0 | Mov $b, 5; | |||||||||||||||||||||||||||||||||||||||||
| 3978 | 0 | Mov $c, 6; | |||||||||||||||||||||||||||||||||||||||||
| 3979 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 3980 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 3981 | Change at watched arena: 0, area: 1(stackArea), address: 1 | ||||||||||||||||||||||||||||||||||||||||||
| 3982 | 1 6 mov | ||||||||||||||||||||||||||||||||||||||||||
| 3983 | Current value: 2 New value: 5 | ||||||||||||||||||||||||||||||||||||||||||
| 3984 | END | ||||||||||||||||||||||||||||||||||||||||||
| 3985 | } | ||||||||||||||||||||||||||||||||||||||||||
| 3986 | |||||||||||||||||||||||||||||||||||||||||||
| 3987 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 3988 | 0 | if (1) ##ArraySize ##ForArray ##Array ##Nop | |||||||||||||||||||||||||||||||||||||||||
| 3989 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 3990 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3991 | 0 | Mov [$a, 0, "aaa"], 1; | |||||||||||||||||||||||||||||||||||||||||
| 3992 | 0 | Mov [$a, 1, "aaa"], 22; | |||||||||||||||||||||||||||||||||||||||||
| 3993 | 0 | Mov [$a, 2, "aaa"], 333; | |||||||||||||||||||||||||||||||||||||||||
| 3994 | |||||||||||||||||||||||||||||||||||||||||||
| 3995 | 0 | my $n = ArraySize $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 3996 | 0 | Out "Array size:", $n; | |||||||||||||||||||||||||||||||||||||||||
| 3997 | 0 | ArrayDump $a; | |||||||||||||||||||||||||||||||||||||||||
| 3998 | |||||||||||||||||||||||||||||||||||||||||||
| 3999 | ForArray | ||||||||||||||||||||||||||||||||||||||||||
| 4000 | 0 | ▶ | {my ($i, $e, $check, $next, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 4001 | 0 | Out $i; Out $e; | |||||||||||||||||||||||||||||||||||||||||
| 4002 | 0 | } $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4003 | |||||||||||||||||||||||||||||||||||||||||||
| 4004 | 0 | Nop; | |||||||||||||||||||||||||||||||||||||||||
| 4005 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 4006 | |||||||||||||||||||||||||||||||||||||||||||
| 4007 | 0 | is_deeply $e->heap(1), [1, 22, 333]; | |||||||||||||||||||||||||||||||||||||||||
| 4008 | 0 | ▶ | is_deeply $e->out, <<END if $testSet <= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 4009 | Array size: 3 | ||||||||||||||||||||||||||||||||||||||||||
| 4010 | bless([1, 22, 333], "aaa") | ||||||||||||||||||||||||||||||||||||||||||
| 4011 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 4012 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4013 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4014 | 22 | ||||||||||||||||||||||||||||||||||||||||||
| 4015 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 4016 | 333 | ||||||||||||||||||||||||||||||||||||||||||
| 4017 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4018 | 0 | ▶ | is_deeply $e->out, <<END if $testSet > 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 4019 | Array size: 3 | ||||||||||||||||||||||||||||||||||||||||||
| 4020 | [1, 22, 333] | ||||||||||||||||||||||||||||||||||||||||||
| 4021 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 4022 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4023 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4024 | 22 | ||||||||||||||||||||||||||||||||||||||||||
| 4025 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 4026 | 333 | ||||||||||||||||||||||||||||||||||||||||||
| 4027 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4028 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4029 | |||||||||||||||||||||||||||||||||||||||||||
| 4030 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4031 | 0 | if (1) # Small array | |||||||||||||||||||||||||||||||||||||||||
| 4032 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4033 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 4034 | 0 | my @a = qw(6 8 4 2 1 3 5 7); | |||||||||||||||||||||||||||||||||||||||||
| 4035 | 0 | Push $a, $_, "array" for @a; # Load array | |||||||||||||||||||||||||||||||||||||||||
| 4036 | 0 | ArrayDump $a; | |||||||||||||||||||||||||||||||||||||||||
| 4037 | 0 | my $e = &$ee(suppressOutput=>1, maximumAreaSize=>9); | |||||||||||||||||||||||||||||||||||||||||
| 4038 | 0 | is_deeply $e->heap(1), [6, 8, 4, 2, 1, 3, 5, 7]; | |||||||||||||||||||||||||||||||||||||||||
| 4039 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4040 | |||||||||||||||||||||||||||||||||||||||||||
| 4041 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4042 | 0 | if (1) ##ArrayDump ##Mov | |||||||||||||||||||||||||||||||||||||||||
| 4043 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4044 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4045 | 0 | Mov [$a, 0, "aaa"], 1; | |||||||||||||||||||||||||||||||||||||||||
| 4046 | 0 | Mov [$a, 1, "aaa"], 22; | |||||||||||||||||||||||||||||||||||||||||
| 4047 | 0 | Mov [$a, 2, "aaa"], 333; | |||||||||||||||||||||||||||||||||||||||||
| 4048 | 0 | ArrayDump $a; | |||||||||||||||||||||||||||||||||||||||||
| 4049 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 4050 | |||||||||||||||||||||||||||||||||||||||||||
| 4051 | 0 | is_deeply eval($e->out), [1, 22, 333]; | |||||||||||||||||||||||||||||||||||||||||
| 4052 | |||||||||||||||||||||||||||||||||||||||||||
| 4053 | #say STDERR $e->block->codeToString; | ||||||||||||||||||||||||||||||||||||||||||
| 4054 | 0 | ▶ | is_deeply $e->block->codeToString, <<'END' if $testSet == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 4055 | 0000 array \0 3 | ||||||||||||||||||||||||||||||||||||||||||
| 4056 | 0001 mov [\0, 0, 3, 0] 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4057 | 0002 mov [\0, 1, 3, 0] 22 | ||||||||||||||||||||||||||||||||||||||||||
| 4058 | 0003 mov [\0, 2, 3, 0] 333 | ||||||||||||||||||||||||||||||||||||||||||
| 4059 | 0004 arrayDump \0 | ||||||||||||||||||||||||||||||||||||||||||
| 4060 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4061 | |||||||||||||||||||||||||||||||||||||||||||
| 4062 | 0 | ▶ | is_deeply $e->block->codeToString, <<'END' if $testSet == 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 4063 | 0000 array [undef, \0, 3, 0] [undef, 3, 3, 0] [undef, 0, 3, 0] | ||||||||||||||||||||||||||||||||||||||||||
| 4064 | 0001 mov [\0, 0, 3, 0] [undef, 1, 3, 0] [undef, 0, 3, 0] | ||||||||||||||||||||||||||||||||||||||||||
| 4065 | 0002 mov [\0, 1, 3, 0] [undef, 22, 3, 0] [undef, 0, 3, 0] | ||||||||||||||||||||||||||||||||||||||||||
| 4066 | 0003 mov [\0, 2, 3, 0] [undef, 333, 3, 0] [undef, 0, 3, 0] | ||||||||||||||||||||||||||||||||||||||||||
| 4067 | 0004 arrayDump [undef, \0, 3, 0] [undef, 0, 3, 0] [undef, 0, 3, 0] | ||||||||||||||||||||||||||||||||||||||||||
| 4068 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4069 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4070 | |||||||||||||||||||||||||||||||||||||||||||
| 4071 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4072 | 0 | if (1) ##MoveLong | |||||||||||||||||||||||||||||||||||||||||
| 4073 | 0 | {my $N = 10; | |||||||||||||||||||||||||||||||||||||||||
| 4074 | 0 | Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4075 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4076 | 0 | my $b = Array "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 4077 | For | ||||||||||||||||||||||||||||||||||||||||||
| 4078 | 0 | ▶ | {my ($i, $Check, $Next, $End) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 4079 | 0 | Mov [$a, \$i, "aaa"], $i; | |||||||||||||||||||||||||||||||||||||||||
| 4080 | 0 | my $j = Add $i, 100; | |||||||||||||||||||||||||||||||||||||||||
| 4081 | 0 | Mov [$b, \$i, "bbb"], $j; | |||||||||||||||||||||||||||||||||||||||||
| 4082 | 0 | } $N; | |||||||||||||||||||||||||||||||||||||||||
| 4083 | |||||||||||||||||||||||||||||||||||||||||||
| 4084 | 0 | MoveLong [$b, \2, 'bbb'], [$a, \4, 'aaa'], 3; | |||||||||||||||||||||||||||||||||||||||||
| 4085 | |||||||||||||||||||||||||||||||||||||||||||
| 4086 | 0 | my $e = &$ee(suppressOutput=>1, maximumAreaSize=>11); | |||||||||||||||||||||||||||||||||||||||||
| 4087 | 0 | is_deeply $e->heap(1), [0 .. 9]; | |||||||||||||||||||||||||||||||||||||||||
| 4088 | 0 | is_deeply $e->heap(2), [100, 101, 4, 5, 6, 105 .. 109]; | |||||||||||||||||||||||||||||||||||||||||
| 4089 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4090 | |||||||||||||||||||||||||||||||||||||||||||
| 4091 | # 0 1 2 | ||||||||||||||||||||||||||||||||||||||||||
| 4092 | # 10 20 30 | ||||||||||||||||||||||||||||||||||||||||||
| 4093 | # 5=0 15=1 25=2 35=3 | ||||||||||||||||||||||||||||||||||||||||||
| 4094 | |||||||||||||||||||||||||||||||||||||||||||
| 4095 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4096 | 0 | if (1) ##ArrayIndex ##ArrayCountLess ##ArrayCountGreater | |||||||||||||||||||||||||||||||||||||||||
| 4097 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4098 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4099 | 0 | Mov [$a, 0, "aaa"], 10; | |||||||||||||||||||||||||||||||||||||||||
| 4100 | 0 | Mov [$a, 1, "aaa"], 20; | |||||||||||||||||||||||||||||||||||||||||
| 4101 | 0 | Mov [$a, 2, "aaa"], 30; | |||||||||||||||||||||||||||||||||||||||||
| 4102 | |||||||||||||||||||||||||||||||||||||||||||
| 4103 | 0 | Out ArrayIndex ($a, 30), ArrayIndex ($a, 20), ArrayIndex ($a, 10), ArrayIndex ($a, 15); | |||||||||||||||||||||||||||||||||||||||||
| 4104 | 0 | Out ArrayCountLess ($a, 35), ArrayCountLess ($a, 25), ArrayCountLess ($a, 15), ArrayCountLess ($a, 5); | |||||||||||||||||||||||||||||||||||||||||
| 4105 | 0 | Out ArrayCountGreater($a, 35), ArrayCountGreater($a, 25), ArrayCountGreater($a, 15), ArrayCountGreater($a, 5); | |||||||||||||||||||||||||||||||||||||||||
| 4106 | |||||||||||||||||||||||||||||||||||||||||||
| 4107 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 4108 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 4109 | 3 2 1 0 | ||||||||||||||||||||||||||||||||||||||||||
| 4110 | 3 2 1 0 | ||||||||||||||||||||||||||||||||||||||||||
| 4111 | 0 1 2 3 | ||||||||||||||||||||||||||||||||||||||||||
| 4112 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4114 | |||||||||||||||||||||||||||||||||||||||||||
| 4115 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4116 | 0 | if (1) ##Tally ##For | |||||||||||||||||||||||||||||||||||||||||
| 4117 | 0 | {my $N = 5; | |||||||||||||||||||||||||||||||||||||||||
| 4118 | 0 | Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4119 | For | ||||||||||||||||||||||||||||||||||||||||||
| 4120 | 0 | ▶ | {Tally 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 4121 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 4122 | 0 | Tally 2; | |||||||||||||||||||||||||||||||||||||||||
| 4123 | 0 | Inc $a; | |||||||||||||||||||||||||||||||||||||||||
| 4124 | 0 | Tally 0; | |||||||||||||||||||||||||||||||||||||||||
| 4125 | 0 | } $N; | |||||||||||||||||||||||||||||||||||||||||
| 4126 | 0 | my $e = Execute; | |||||||||||||||||||||||||||||||||||||||||
| 4127 | |||||||||||||||||||||||||||||||||||||||||||
| 4128 | 0 | is_deeply $e->tallyCount, 2 * $N; | |||||||||||||||||||||||||||||||||||||||||
| 4129 | 0 | is_deeply $e->tallyCounts, { 1 => {mov => $N}, 2 => {inc => $N}}; | |||||||||||||||||||||||||||||||||||||||||
| 4130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4131 | |||||||||||||||||||||||||||||||||||||||||||
| 4132 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4133 | 0 | if (1) ##TraceLabels | |||||||||||||||||||||||||||||||||||||||||
| 4134 | 0 | {my $N = 5; | |||||||||||||||||||||||||||||||||||||||||
| 4135 | 0 | Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4136 | 0 | TraceLabels 1; | |||||||||||||||||||||||||||||||||||||||||
| 4137 | For | ||||||||||||||||||||||||||||||||||||||||||
| 4138 | 0 | ▶ | {my $a = Mov 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 4139 | 0 | Inc $a; | |||||||||||||||||||||||||||||||||||||||||
| 4140 | 0 | } $N; | |||||||||||||||||||||||||||||||||||||||||
| 4141 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 4142 | |||||||||||||||||||||||||||||||||||||||||||
| 4143 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 4144 | TraceLabels: 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4145 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4146 | 1 2 label | ||||||||||||||||||||||||||||||||||||||||||
| 4147 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4148 | 1 4 label | ||||||||||||||||||||||||||||||||||||||||||
| 4149 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4150 | 1 8 label | ||||||||||||||||||||||||||||||||||||||||||
| 4151 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4152 | 1 4 label | ||||||||||||||||||||||||||||||||||||||||||
| 4153 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4154 | 1 8 label | ||||||||||||||||||||||||||||||||||||||||||
| 4155 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4156 | 1 4 label | ||||||||||||||||||||||||||||||||||||||||||
| 4157 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4158 | 1 8 label | ||||||||||||||||||||||||||||||||||||||||||
| 4159 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4160 | 1 4 label | ||||||||||||||||||||||||||||||||||||||||||
| 4161 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4162 | 1 8 label | ||||||||||||||||||||||||||||||||||||||||||
| 4163 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4164 | 1 4 label | ||||||||||||||||||||||||||||||||||||||||||
| 4165 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4166 | 1 8 label | ||||||||||||||||||||||||||||||||||||||||||
| 4167 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4168 | 1 4 label | ||||||||||||||||||||||||||||||||||||||||||
| 4169 | Label | ||||||||||||||||||||||||||||||||||||||||||
| 4170 | 1 11 label | ||||||||||||||||||||||||||||||||||||||||||
| 4171 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4173 | |||||||||||||||||||||||||||||||||||||||||||
| 4174 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4175 | 0 | if (1) ##Random ##RandomSeed | |||||||||||||||||||||||||||||||||||||||||
| 4176 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4177 | 0 | RandomSeed 1; | |||||||||||||||||||||||||||||||||||||||||
| 4178 | 0 | my $a = Random 10; | |||||||||||||||||||||||||||||||||||||||||
| 4179 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 4180 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 4181 | 0 | ok $e->out =~ m(\A\d\Z); | |||||||||||||||||||||||||||||||||||||||||
| 4182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4183 | |||||||||||||||||||||||||||||||||||||||||||
| 4184 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4185 | 0 | if (1) # Local variable | |||||||||||||||||||||||||||||||||||||||||
| 4186 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4187 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 4188 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 4189 | 0 | my $e = &$ee(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 4190 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 4191 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4192 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4195 | |||||||||||||||||||||||||||||||||||||||||||
| 4196 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4197 | 0 | if (1) ##GenerateMachineCode ##GenerateMachineCodeDisAssembleExecute ##disAssemble | |||||||||||||||||||||||||||||||||||||||||
| 4198 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4199 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 4200 | 0 | my $g = GenerateMachineCode; | |||||||||||||||||||||||||||||||||||||||||
| 4201 | 0 | is_deeply dump($g), 'pack("H*","0000002300000000000000000000017f000000010000007f000000000000007f")'; | |||||||||||||||||||||||||||||||||||||||||
| 4202 | |||||||||||||||||||||||||||||||||||||||||||
| 4203 | 0 | my $d = disAssemble $g; | |||||||||||||||||||||||||||||||||||||||||
| 4204 | 0 | $d->assemble; | |||||||||||||||||||||||||||||||||||||||||
| 4205 | 0 | is_deeply $d->codeToString, <<'END'; | |||||||||||||||||||||||||||||||||||||||||
| 4206 | 0000 mov [undef, \0, 3, 0] [undef, 1, 3, 0] [undef, 0, 3, 0] | ||||||||||||||||||||||||||||||||||||||||||
| 4207 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4208 | 0 | my $e = GenerateMachineCodeDisAssembleExecute; | |||||||||||||||||||||||||||||||||||||||||
| 4209 | 0 | is_deeply $e->block->codeToString, <<'END'; | |||||||||||||||||||||||||||||||||||||||||
| 4210 | 0000 mov [undef, \0, 3, 0] [undef, 1, 3, 0] [undef, 0, 3, 0] | ||||||||||||||||||||||||||||||||||||||||||
| 4211 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4213 | |||||||||||||||||||||||||||||||||||||||||||
| 4214 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 4215 | 0 | if (1) # String memory | |||||||||||||||||||||||||||||||||||||||||
| 4216 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 4217 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4218 | 0 | Push $a, 1, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4219 | 0 | Push $a, 2, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4220 | 0 | Push $a, 3, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4221 | 0 | my $b = Array "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 4222 | 0 | Push $b, 11, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 4223 | 0 | Push $b, 22, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 4224 | 0 | Push $b, 33, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 4225 | 0 | my $b3 = Pop $b, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 4226 | 0 | my $b2 = Pop $b, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 4227 | 0 | my $b1 = Pop $b, "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 4228 | 0 | my $a3 = Pop $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4229 | 0 | my $a2 = Pop $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4230 | 0 | my $a1 = Pop $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 4231 | |||||||||||||||||||||||||||||||||||||||||||
| 4232 | 0 | Out $a1; | |||||||||||||||||||||||||||||||||||||||||
| 4233 | 0 | Out $a2; | |||||||||||||||||||||||||||||||||||||||||
| 4234 | 0 | Out $a3; | |||||||||||||||||||||||||||||||||||||||||
| 4235 | 0 | Out $b1; | |||||||||||||||||||||||||||||||||||||||||
| 4236 | 0 | Out $b2; | |||||||||||||||||||||||||||||||||||||||||
| 4237 | 0 | Out $b3; | |||||||||||||||||||||||||||||||||||||||||
| 4238 | |||||||||||||||||||||||||||||||||||||||||||
| 4239 | 0 | $memoryTechnique = \&setStringMemoryTechnique; | |||||||||||||||||||||||||||||||||||||||||
| 4240 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 4241 | # say STDERR $e->out; | ||||||||||||||||||||||||||||||||||||||||||
| 4242 | 0 | is_deeply $e->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 4243 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4244 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 4245 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 4246 | 11 | ||||||||||||||||||||||||||||||||||||||||||
| 4247 | 22 | ||||||||||||||||||||||||||||||||||||||||||
| 4248 | 33 | ||||||||||||||||||||||||||||||||||||||||||
| 4249 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4250 | |||||||||||||||||||||||||||||||||||||||||||
| 4251 | 0 | my $E = GenerateMachineCodeDisAssembleExecute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 4252 | 0 | is_deeply $E->out, <<END; | |||||||||||||||||||||||||||||||||||||||||
| 4253 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 4254 | 2 | ||||||||||||||||||||||||||||||||||||||||||
| 4255 | 3 | ||||||||||||||||||||||||||||||||||||||||||
| 4256 | 11 | ||||||||||||||||||||||||||||||||||||||||||
| 4257 | 22 | ||||||||||||||||||||||||||||||||||||||||||
| 4258 | 33 | ||||||||||||||||||||||||||||||||||||||||||
| 4259 | END | ||||||||||||||||||||||||||||||||||||||||||
| 4260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 4261 | |||||||||||||||||||||||||||||||||||||||||||
| 4262 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 4263 | (\A.{80})\s+(#.*\Z) \1\2 | ||||||||||||||||||||||||||||||||||||||||||
| 4264 | say STDERR ' is_deeply $e->out, <<END;', "\n", $e->out, "END"; exit; | ||||||||||||||||||||||||||||||||||||||||||
| 4265 | =cut | ||||||||||||||||||||||||||||||||||||||||||