1# Do not edit this file - Generated by Perlito6 9.0 2use v5; 3use utf8; 4use strict; 5use warnings; 6no warnings ('redefine', 'once', 'void', 'uninitialized', 'misc', 'recursion'); 7use Perlito6::Perl5::Runtime; 8use Perlito6::Perl5::Prelude; 9our $MATCH = Perlito6::Match->new(); 10{ 11package GLOBAL; 12 sub new { shift; bless { @_ }, "GLOBAL" } 13 14 # use v6 15; 16 { 17 package CompUnit; 18 sub new { shift; bless { @_ }, "CompUnit" } 19 sub eval { 20 my $self = $_[0]; 21 my $env = $_[1]; 22 ((my $env1) = do { 23 (my $List_a = bless [], 'ARRAY'); 24 (my $List_v = bless [], 'ARRAY'); 25 push( @{$List_a}, do { 26 (my $Hash_a = bless {}, 'HASH'); 27 $Hash_a 28} ); 29 ($List_v = ($env)); 30 for my $x ( @{(bless [0 .. ((scalar( @{$List_v} ) - 1))], 'ARRAY')} ) { 31 push( @{$List_a}, $List_v->[$x] ) 32 }; 33 $List_a 34}); 35 for my $stmt ( @{(defined $self->{body} ? $self->{body} : ($self->{body} ||= bless([], 'ARRAY')))} ) { 36 $stmt->eval($env1) 37 } 38 } 39 } 40 41; 42 { 43 package Val::Int; 44 sub new { shift; bless { @_ }, "Val::Int" } 45 sub eval { 46 my $self = $_[0]; 47 my $env = $_[1]; 48 0+($self->{int}) 49 } 50 } 51 52; 53 { 54 package Val::Bit; 55 sub new { shift; bless { @_ }, "Val::Bit" } 56 sub eval { 57 my $self = $_[0]; 58 my $env = $_[1]; 59 $self->{bit} 60 } 61 } 62 63; 64 { 65 package Val::Num; 66 sub new { shift; bless { @_ }, "Val::Num" } 67 sub eval { 68 my $self = $_[0]; 69 my $env = $_[1]; 70 0+($self->{num}) 71 } 72 } 73 74; 75 { 76 package Val::Buf; 77 sub new { shift; bless { @_ }, "Val::Buf" } 78 sub eval { 79 my $self = $_[0]; 80 my $env = $_[1]; 81 $self->{buf} 82 } 83 } 84 85; 86 { 87 package Lit::Block; 88 sub new { shift; bless { @_ }, "Lit::Block" } 89 sub eval { 90 my $self = $_[0]; 91 my $env = $_[1]; 92 ((my $env1) = do { 93 (my $List_a = bless [], 'ARRAY'); 94 (my $List_v = bless [], 'ARRAY'); 95 push( @{$List_a}, do { 96 (my $Hash_a = bless {}, 'HASH'); 97 $Hash_a 98} ); 99 ($List_v = ($env)); 100 for my $x ( @{(bless [0 .. ((scalar( @{$List_v} ) - 1))], 'ARRAY')} ) { 101 push( @{$List_a}, $List_v->[$x] ) 102 }; 103 $List_a 104}); 105 for my $stmt ( @{(defined $self->{stmts} ? $self->{stmts} : ($self->{stmts} ||= bless([], 'ARRAY')))} ) { 106 $stmt->eval($env1) 107 } 108 } 109 } 110 111; 112 { 113 package Lit::Array; 114 sub new { shift; bless { @_ }, "Lit::Array" } 115 sub eval { 116 my $self = $_[0]; 117 my $env = $_[1]; 118 (my $List_a = bless [], 'ARRAY'); 119 for my $v ( @{(defined $self->{array1} ? $self->{array1} : ($self->{array1} ||= bless([], 'ARRAY')))} ) { 120 push( @{$List_a}, $v->eval($env) ) 121 }; 122 return scalar ($List_a) 123 } 124 } 125 126; 127 { 128 package Lit::Hash; 129 sub new { shift; bless { @_ }, "Lit::Hash" } 130 sub eval { 131 my $self = $_[0]; 132 my $env = $_[1]; 133 (my $Hash_h = bless {}, 'HASH'); 134 for my $field ( @{(defined $self->{hash1} ? $self->{hash1} : ($self->{hash1} ||= bless([], 'ARRAY')))} ) { 135 ((my $pair) = $field->arguments()); 136 ($Hash_h->{($pair->[0])->eval($env)} = ($pair->[1])->eval($env)) 137 }; 138 return scalar ($Hash_h) 139 } 140 } 141 142; 143 { 144 package Index; 145 sub new { shift; bless { @_ }, "Index" } 146 sub eval { 147 my $self = $_[0]; 148 my $env = $_[1]; 149 ($self->{obj}->eval($env))->[$self->{index_exp}->eval($env)] 150 } 151 } 152 153; 154 { 155 package Lookup; 156 sub new { shift; bless { @_ }, "Lookup" } 157 sub eval { 158 my $self = $_[0]; 159 my $env = $_[1]; 160 ($self->{obj}->eval($env))->{$self->{index_exp}->eval($env)} 161 } 162 } 163 164; 165 { 166 package Var; 167 sub new { shift; bless { @_ }, "Var" } 168 sub eval { 169 my $self = $_[0]; 170 my $env = $_[1]; 171 ((my $ns) = ''); 172 if ($self->{namespace}) { 173 ($ns = ($self->{namespace} . '::')) 174 } 175 else { 176 if ((((($self->{sigil} eq chr(64))) && (($self->{twigil} eq '*'))) && (($self->{name} eq 'ARGS')))) { 177 return scalar ((\@ARGV)) 178 }; 179 if (($self->{twigil} eq '.')) { 180 warn(('Interpreter TODO: ' . chr(36) . '.' . $self->{name})); 181 return scalar ((chr(36) . 'self->' . chr(123) . $self->{name} . chr(125))) 182 }; 183 if (($self->{name} eq chr(47))) { 184 warn('Interpreter TODO: ' . chr(36) . chr(47)); 185 return scalar (($self->{sigil} . 'MATCH')) 186 } 187 }; 188 ((my $name) = ($self->{sigil} . $ns . $self->{name})); 189 for my $e ( @{(($env))} ) { 190 if (exists($e->{$name})) { 191 return scalar ($e->{$name}) 192 } 193 }; 194 warn(('Interpreter runtime error: variable ' . chr(39)), $name, (chr(39) . ' not found')) 195 }; 196 sub plain_name { 197 my $self = $_[0]; 198 if ($self->{namespace}) { 199 return scalar (($self->{sigil} . $self->{namespace} . '::' . $self->{name})) 200 }; 201 return scalar (($self->{sigil} . $self->{name})) 202 } 203 } 204 205; 206 { 207 package Proto; 208 sub new { shift; bless { @_ }, "Proto" } 209 sub eval { 210 my $self = $_[0]; 211 my $env = $_[1]; 212 "".($self->{name}) 213 } 214 } 215 216; 217 { 218 package Call; 219 sub new { shift; bless { @_ }, "Call" } 220 sub eval { 221 my $self = $_[0]; 222 my $env = $_[1]; 223 warn(('Interpreter TODO: Call')); 224 ((my $invocant) = $self->{invocant}->eval($env)); 225 if (($invocant eq 'self')) { 226 ($invocant = chr(36) . 'self') 227 }; 228 if (($self->{hyper})) { 229 230 }; 231 warn(('Interpreter runtime error: method ' . chr(39)), $self->{method}, ('()' . chr(39) . ' not found')) 232 } 233 } 234 235; 236 { 237 package Apply; 238 sub new { shift; bless { @_ }, "Apply" } 239 sub eval { 240 my $self = $_[0]; 241 my $env = $_[1]; 242 ((my $ns) = ''); 243 if ($self->{namespace}) { 244 ($ns = ($self->{namespace} . '::')) 245 }; 246 ((my $code) = ($ns . $self->{code})); 247 for my $e ( @{(($env))} ) { 248 if (exists($e->{$code})) { 249 return scalar ((($e->{$code})->($env, (defined $self->{arguments} ? $self->{arguments} : ($self->{arguments} ||= bless([], 'ARRAY')))))) 250 } 251 }; 252 warn(('Interpreter runtime error: subroutine ' . chr(39)), $code, ('()' . chr(39) . ' not found')) 253 } 254 } 255 256; 257 { 258 package If; 259 sub new { shift; bless { @_ }, "If" } 260 sub eval { 261 my $self = $_[0]; 262 my $env = $_[1]; 263 ((my $cond) = $self->{cond}); 264 if ($cond->eval($env)) { 265 ((my $env1) = do { 266 (my $List_a = bless [], 'ARRAY'); 267 (my $List_v = bless [], 'ARRAY'); 268 push( @{$List_a}, do { 269 (my $Hash_a = bless {}, 'HASH'); 270 $Hash_a 271} ); 272 ($List_v = ($env)); 273 for my $x ( @{(bless [0 .. ((scalar( @{$List_v} ) - 1))], 'ARRAY')} ) { 274 push( @{$List_a}, $List_v->[$x] ) 275 }; 276 $List_a 277}); 278 for my $stmt ( @{((($self->{body})->stmts()))} ) { 279 $stmt->eval($env1) 280 } 281 } 282 else { 283 ((my $env1) = do { 284 (my $List_a = bless [], 'ARRAY'); 285 (my $List_v = bless [], 'ARRAY'); 286 push( @{$List_a}, do { 287 (my $Hash_a = bless {}, 'HASH'); 288 $Hash_a 289} ); 290 ($List_v = ($env)); 291 for my $x ( @{(bless [0 .. ((scalar( @{$List_v} ) - 1))], 'ARRAY')} ) { 292 push( @{$List_a}, $List_v->[$x] ) 293 }; 294 $List_a 295}); 296 for my $stmt ( @{((($self->{otherwise})->stmts()))} ) { 297 $stmt->eval($env1) 298 } 299 }; 300 return scalar (undef()) 301 } 302 } 303 304; 305 { 306 package For; 307 sub new { shift; bless { @_ }, "For" } 308 sub eval { 309 my $self = $_[0]; 310 my $env = $_[1]; 311 ((my $cond) = $self->{cond}); 312 ((my $topic_name) = (($self->{body})->sig())->plain_name()); 313 ((my $env1) = do { 314 (my $List_a = bless [], 'ARRAY'); 315 (my $List_v = bless [], 'ARRAY'); 316 push( @{$List_a}, do { 317 (my $Hash_a = bless {}, 'HASH'); 318 $Hash_a 319} ); 320 ($List_v = ($env)); 321 for my $x ( @{(bless [0 .. ((scalar( @{$List_v} ) - 1))], 'ARRAY')} ) { 322 push( @{$List_a}, $List_v->[$x] ) 323 }; 324 $List_a 325}); 326 for my $topic ( @{(($cond->eval($env)))} ) { 327 ($env1->[0] = do { 328 (my $Hash_a = bless {}, 'HASH'); 329 ($Hash_a->{$topic_name} = $topic); 330 $Hash_a 331}); 332 for my $stmt ( @{((($self->{body})->stmts()))} ) { 333 $stmt->eval($env1) 334 } 335 }; 336 return scalar (undef()) 337 } 338 } 339 340; 341 { 342 package When; 343 sub new { shift; bless { @_ }, "When" } 344 sub eval { 345 my $self = $_[0]; 346 my $env = $_[1]; 347 die(('TODO - When')) 348 } 349 } 350 351; 352 { 353 package While; 354 sub new { shift; bless { @_ }, "While" } 355 sub eval { 356 my $self = $_[0]; 357 my $env = $_[1]; 358 die(('TODO - While')) 359 } 360 } 361 362; 363 { 364 package Decl; 365 sub new { shift; bless { @_ }, "Decl" } 366 sub eval { 367 my $self = $_[0]; 368 my $env = $_[1]; 369 ((my $decl) = $self->{decl}); 370 ((my $name) = $self->{var}->plain_name()); 371 if (($decl eq 'has')) { 372 warn(('Interpreter TODO: has')) 373 }; 374 if (!((exists(($env->[0])->{$name})))) { 375 (($env->[0])->{$name} = undef()) 376 }; 377 return scalar (undef()) 378 }; 379 sub plain_name { 380 my $self = $_[0]; 381 $self->{var}->plain_name() 382 } 383 } 384 385; 386 { 387 package Method; 388 sub new { shift; bless { @_ }, "Method" } 389 sub eval { 390 my $self = $_[0]; 391 my $env = $_[1]; 392 warn(('Interpreter TODO: Method')); 393 ((my $sig) = $self->{sig}); 394 ((my $invocant) = $sig->invocant()); 395 ((my $pos) = $sig->positional()); 396 ((my $str) = 'my ' . chr(36) . 'List__ ' . chr(61) . ' ' . chr(92) . chr(64) . '_' . chr(59) . ' ') 397 } 398 } 399 400; 401 { 402 package Sub; 403 sub new { shift; bless { @_ }, "Sub" } 404 sub eval { 405 my $self = $_[0]; 406 my $env = $_[1]; 407 (my $List_param_name = bless [], 'ARRAY'); 408 for my $field ( @{(($self->{sig}->positional()))} ) { 409 push( @{$List_param_name}, $field->plain_name() ) 410 }; 411 ((my $sub) = sub { 412 my $env = $_[0]; 413 my $args = $_[1]; 414 (my $Hash_context = bless {}, 'HASH'); 415 ((my $n) = 0); 416 ($Hash_context->{chr(64) . '_'} = $args); 417 for my $name ( @{$List_param_name} ) { 418 ($Hash_context->{$name} = ($args->[$n])->eval($env)); 419 ($n = ($n + 1)) 420 }; 421 ((my $env1) = do { 422 (my $List_a = bless [], 'ARRAY'); 423 (my $List_v = bless [], 'ARRAY'); 424 push( @{$List_a}, $Hash_context ); 425 ($List_v = ($env)); 426 for my $x ( @{(bless [0 .. ((scalar( @{$List_v} ) - 1))], 'ARRAY')} ) { 427 push( @{$List_a}, $List_v->[$x] ) 428 }; 429 $List_a 430}); 431 (my $r); 432 for my $stmt ( @{(defined $self->{block} ? $self->{block} : ($self->{block} ||= bless([], 'ARRAY')))} ) { 433 ($r = $stmt->eval($env1)) 434 }; 435 return scalar ($r) 436}); 437 if ($self->{name}) { 438 (($env->[0])->{$self->{name}} = $sub) 439 }; 440 return scalar ($sub) 441 } 442 } 443 444; 445 { 446 package Do; 447 sub new { shift; bless { @_ }, "Do" } 448 sub eval { 449 my $self = $_[0]; 450 my $env = $_[1]; 451 ((my $env1) = do { 452 (my $List_a = bless [], 'ARRAY'); 453 (my $List_v = bless [], 'ARRAY'); 454 push( @{$List_a}, do { 455 (my $Hash_a = bless {}, 'HASH'); 456 $Hash_a 457} ); 458 ($List_v = ($env)); 459 for my $x ( @{(bless [0 .. ((scalar( @{$List_v} ) - 1))], 'ARRAY')} ) { 460 push( @{$List_a}, $List_v->[$x] ) 461 }; 462 $List_a 463}); 464 for my $stmt ( @{(defined $self->{block} ? $self->{block} : ($self->{block} ||= bless([], 'ARRAY')))} ) { 465 $stmt->eval($env1) 466 } 467 } 468 } 469 470; 471 { 472 package Use; 473 sub new { shift; bless { @_ }, "Use" } 474 sub eval { 475 my $self = $_[0]; 476 my $env = $_[1]; 477 warn(('Interpreter TODO: Use')); 478 ('use ' . $self->{mod}) 479 } 480 } 481 482 483} 484 4851; 486