Browse Source

Compiler-* cleanup

Herbert Vojčík 2 years ago
parent
commit
d8c0f3f3c8

+ 1 - 0
local.amd.json

@@ -11,6 +11,7 @@
11 11
     "map": {
12 12
         "*": {
13 13
             "00comment": "These are backward compatibility pointers.",
14
+            "amber_core/Compiler-Exceptions": "amber_core/Compiler-Core",
14 15
             "amber_core/Kernel-ImportExport": "amber_core/Platform-ImportExport"
15 16
         }
16 17
     }

+ 416 - 178
src/Compiler-AST.js

@@ -536,110 +536,6 @@ $globals.Node);
536 536
 
537 537
 $core.addMethod(
538 538
 $core.method({
539
-selector: "nextChild",
540
-protocol: 'accessing',
541
-fn: function (){
542
-var self=this;
543
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
544
-return $core.withContext(function($ctx1) {
545
-//>>excludeEnd("ctx");
546
-var $3,$2,$1;
547
-$3=self._nodes();
548
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
549
-$ctx1.sendIdx["nodes"]=1;
550
-//>>excludeEnd("ctx");
551
-$2=$recv($3)._isEmpty();
552
-if($core.assert($2)){
553
-$1=self;
554
-} else {
555
-$1=$recv($recv(self._nodes())._first())._nextChild();
556
-};
557
-return $1;
558
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
559
-}, function($ctx1) {$ctx1.fill(self,"nextChild",{},$globals.Node)});
560
-//>>excludeEnd("ctx");
561
-},
562
-//>>excludeStart("ide", pragmas.excludeIdeData);
563
-args: [],
564
-source: "nextChild\x0a\x09\x22Answer the next node after aNode.\x0a\x09Recurse into the possible children of the receiver to answer the next node to be evaluated\x22\x0a\x09\x0a\x09^ self nodes isEmpty\x0a\x09\x09ifTrue: [ self ]\x0a\x09\x09ifFalse: [ self nodes first nextChild ]",
565
-referencedClasses: [],
566
-//>>excludeEnd("ide");
567
-messageSends: ["ifTrue:ifFalse:", "isEmpty", "nodes", "nextChild", "first"]
568
-}),
569
-$globals.Node);
570
-
571
-$core.addMethod(
572
-$core.method({
573
-selector: "nextNode",
574
-protocol: 'accessing',
575
-fn: function (){
576
-var self=this;
577
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
578
-return $core.withContext(function($ctx1) {
579
-//>>excludeEnd("ctx");
580
-var $2,$1,$receiver;
581
-$2=self._parent();
582
-if(($receiver = $2) == null || $receiver.isNil){
583
-$1=$2;
584
-} else {
585
-var node;
586
-node=$receiver;
587
-$1=$recv(node)._nextNode_(self);
588
-};
589
-return $1;
590
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
591
-}, function($ctx1) {$ctx1.fill(self,"nextNode",{},$globals.Node)});
592
-//>>excludeEnd("ctx");
593
-},
594
-//>>excludeStart("ide", pragmas.excludeIdeData);
595
-args: [],
596
-source: "nextNode\x0a\x09^ self parent ifNotNil: [ :node |\x0a\x09\x09node nextNode: self ]",
597
-referencedClasses: [],
598
-//>>excludeEnd("ide");
599
-messageSends: ["ifNotNil:", "parent", "nextNode:"]
600
-}),
601
-$globals.Node);
602
-
603
-$core.addMethod(
604
-$core.method({
605
-selector: "nextNode:",
606
-protocol: 'accessing',
607
-fn: function (aNode){
608
-var self=this;
609
-var next;
610
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
611
-return $core.withContext(function($ctx1) {
612
-//>>excludeEnd("ctx");
613
-var $1,$2;
614
-var $early={};
615
-try {
616
-$1=self._nodes();
617
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
618
-$ctx1.sendIdx["nodes"]=1;
619
-//>>excludeEnd("ctx");
620
-next=$recv($1)._at_ifAbsent_($recv($recv(self._nodes())._indexOf_(aNode)).__plus((1)),(function(){
621
-throw $early=[self];
622
-
623
-}));
624
-$2=$recv(next)._nextChild();
625
-return $2;
626
-}
627
-catch(e) {if(e===$early)return e[0]; throw e}
628
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
629
-}, function($ctx1) {$ctx1.fill(self,"nextNode:",{aNode:aNode,next:next},$globals.Node)});
630
-//>>excludeEnd("ctx");
631
-},
632
-//>>excludeStart("ide", pragmas.excludeIdeData);
633
-args: ["aNode"],
634
-source: "nextNode: aNode\x0a\x09\x22Answer the next node after aNode.\x0a\x09Recurse into the possible children of the next node to answer the next node to be evaluated\x22\x0a\x09\x0a\x09| next |\x0a\x09\x0a\x09next := self nodes \x0a\x09\x09at: (self nodes indexOf: aNode) + 1\x0a\x09\x09ifAbsent: [ ^ self ].\x0a\x09\x0a\x09^ next nextChild",
635
-referencedClasses: [],
636
-//>>excludeEnd("ide");
637
-messageSends: ["at:ifAbsent:", "nodes", "+", "indexOf:", "nextChild"]
638
-}),
639
-$globals.Node);
640
-
641
-$core.addMethod(
642
-$core.method({
643 539
 selector: "nodes",
644 540
 protocol: 'accessing',
645 541
 fn: function (){
@@ -1116,24 +1012,6 @@ $globals.Node);
1116 1012
 
1117 1013
 $core.addMethod(
1118 1014
 $core.method({
1119
-selector: "stopOnStepping",
1120
-protocol: 'testing',
1121
-fn: function (){
1122
-var self=this;
1123
-return false;
1124
-
1125
-},
1126
-//>>excludeStart("ide", pragmas.excludeIdeData);
1127
-args: [],
1128
-source: "stopOnStepping\x0a\x09^ false",
1129
-referencedClasses: [],
1130
-//>>excludeEnd("ide");
1131
-messageSends: []
1132
-}),
1133
-$globals.Node);
1134
-
1135
-$core.addMethod(
1136
-$core.method({
1137 1015
 selector: "subtreeNeedsAliasing",
1138 1016
 protocol: 'testing',
1139 1017
 fn: function (){
@@ -1441,42 +1319,6 @@ $globals.BlockNode);
1441 1319
 
1442 1320
 $core.addMethod(
1443 1321
 $core.method({
1444
-selector: "nextChild",
1445
-protocol: 'accessing',
1446
-fn: function (){
1447
-var self=this;
1448
-return self;
1449
-
1450
-},
1451
-//>>excludeStart("ide", pragmas.excludeIdeData);
1452
-args: [],
1453
-source: "nextChild\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
1454
-referencedClasses: [],
1455
-//>>excludeEnd("ide");
1456
-messageSends: []
1457
-}),
1458
-$globals.BlockNode);
1459
-
1460
-$core.addMethod(
1461
-$core.method({
1462
-selector: "nextNode:",
1463
-protocol: 'accessing',
1464
-fn: function (aNode){
1465
-var self=this;
1466
-return self;
1467
-
1468
-},
1469
-//>>excludeStart("ide", pragmas.excludeIdeData);
1470
-args: ["aNode"],
1471
-source: "nextNode: aNode\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
1472
-referencedClasses: [],
1473
-//>>excludeEnd("ide");
1474
-messageSends: []
1475
-}),
1476
-$globals.BlockNode);
1477
-
1478
-$core.addMethod(
1479
-$core.method({
1480 1322
 selector: "parameters",
1481 1323
 protocol: 'accessing',
1482 1324
 fn: function (){
@@ -2813,24 +2655,6 @@ $globals.SendNode);
2813 2655
 
2814 2656
 $core.addMethod(
2815 2657
 $core.method({
2816
-selector: "stopOnStepping",
2817
-protocol: 'testing',
2818
-fn: function (){
2819
-var self=this;
2820
-return true;
2821
-
2822
-},
2823
-//>>excludeStart("ide", pragmas.excludeIdeData);
2824
-args: [],
2825
-source: "stopOnStepping\x0a\x09^ true",
2826
-referencedClasses: [],
2827
-//>>excludeEnd("ide");
2828
-messageSends: []
2829
-}),
2830
-$globals.SendNode);
2831
-
2832
-$core.addMethod(
2833
-$core.method({
2834 2658
 selector: "superSend",
2835 2659
 protocol: 'accessing',
2836 2660
 fn: function (){
@@ -2881,7 +2705,7 @@ $globals.SendNode);
2881 2705
 $core.addMethod(
2882 2706
 $core.method({
2883 2707
 selector: "valueForReceiver:",
2884
-protocol: 'accessing',
2708
+protocol: 'building',
2885 2709
 fn: function (anObject){
2886 2710
 var self=this;
2887 2711
 function $SendNode(){return $globals.SendNode||(typeof SendNode=="undefined"?nil:SendNode)}
@@ -2955,7 +2779,7 @@ $globals.SequenceNode);
2955 2779
 $core.addMethod(
2956 2780
 $core.method({
2957 2781
 selector: "asBlockSequenceNode",
2958
-protocol: 'converting',
2782
+protocol: 'building',
2959 2783
 fn: function (){
2960 2784
 var self=this;
2961 2785
 function $BlockSequenceNode(){return $globals.BlockSequenceNode||(typeof BlockSequenceNode=="undefined"?nil:BlockSequenceNode)}
@@ -3533,6 +3357,420 @@ messageSends: ["value"]
3533 3357
 $globals.VariableNode);
3534 3358
 
3535 3359
 
3360
+
3361
+$core.addClass('NodeVisitor', $globals.Object, [], 'Compiler-AST');
3362
+//>>excludeStart("ide", pragmas.excludeIdeData);
3363
+$globals.NodeVisitor.comment="I am the abstract super class of all AST node visitors.";
3364
+//>>excludeEnd("ide");
3365
+$core.addMethod(
3366
+$core.method({
3367
+selector: "visit:",
3368
+protocol: 'visiting',
3369
+fn: function (aNode){
3370
+var self=this;
3371
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3372
+return $core.withContext(function($ctx1) {
3373
+//>>excludeEnd("ctx");
3374
+var $1;
3375
+$1=$recv(aNode)._accept_(self);
3376
+return $1;
3377
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3378
+}, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},$globals.NodeVisitor)});
3379
+//>>excludeEnd("ctx");
3380
+},
3381
+//>>excludeStart("ide", pragmas.excludeIdeData);
3382
+args: ["aNode"],
3383
+source: "visit: aNode\x0a\x09^ aNode accept: self",
3384
+referencedClasses: [],
3385
+//>>excludeEnd("ide");
3386
+messageSends: ["accept:"]
3387
+}),
3388
+$globals.NodeVisitor);
3389
+
3390
+$core.addMethod(
3391
+$core.method({
3392
+selector: "visitAll:",
3393
+protocol: 'visiting',
3394
+fn: function (aCollection){
3395
+var self=this;
3396
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3397
+return $core.withContext(function($ctx1) {
3398
+//>>excludeEnd("ctx");
3399
+var $1;
3400
+$1=$recv(aCollection)._collect_((function(each){
3401
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3402
+return $core.withContext(function($ctx2) {
3403
+//>>excludeEnd("ctx");
3404
+return self._visit_(each);
3405
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3406
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
3407
+//>>excludeEnd("ctx");
3408
+}));
3409
+return $1;
3410
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3411
+}, function($ctx1) {$ctx1.fill(self,"visitAll:",{aCollection:aCollection},$globals.NodeVisitor)});
3412
+//>>excludeEnd("ctx");
3413
+},
3414
+//>>excludeStart("ide", pragmas.excludeIdeData);
3415
+args: ["aCollection"],
3416
+source: "visitAll: aCollection\x0a\x09^ aCollection collect: [ :each | self visit: each ]",
3417
+referencedClasses: [],
3418
+//>>excludeEnd("ide");
3419
+messageSends: ["collect:", "visit:"]
3420
+}),
3421
+$globals.NodeVisitor);
3422
+
3423
+$core.addMethod(
3424
+$core.method({
3425
+selector: "visitAssignmentNode:",
3426
+protocol: 'visiting',
3427
+fn: function (aNode){
3428
+var self=this;
3429
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3430
+return $core.withContext(function($ctx1) {
3431
+//>>excludeEnd("ctx");
3432
+var $1;
3433
+$1=self._visitNode_(aNode);
3434
+return $1;
3435
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3436
+}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},$globals.NodeVisitor)});
3437
+//>>excludeEnd("ctx");
3438
+},
3439
+//>>excludeStart("ide", pragmas.excludeIdeData);
3440
+args: ["aNode"],
3441
+source: "visitAssignmentNode: aNode\x0a\x09^ self visitNode: aNode",
3442
+referencedClasses: [],
3443
+//>>excludeEnd("ide");
3444
+messageSends: ["visitNode:"]
3445
+}),
3446
+$globals.NodeVisitor);
3447
+
3448
+$core.addMethod(
3449
+$core.method({
3450
+selector: "visitBlockNode:",
3451
+protocol: 'visiting',
3452
+fn: function (aNode){
3453
+var self=this;
3454
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3455
+return $core.withContext(function($ctx1) {
3456
+//>>excludeEnd("ctx");
3457
+var $1;
3458
+$1=self._visitNode_(aNode);
3459
+return $1;
3460
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3461
+}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},$globals.NodeVisitor)});
3462
+//>>excludeEnd("ctx");
3463
+},
3464
+//>>excludeStart("ide", pragmas.excludeIdeData);
3465
+args: ["aNode"],
3466
+source: "visitBlockNode: aNode\x0a\x09^ self visitNode: aNode",
3467
+referencedClasses: [],
3468
+//>>excludeEnd("ide");
3469
+messageSends: ["visitNode:"]
3470
+}),
3471
+$globals.NodeVisitor);
3472
+
3473
+$core.addMethod(
3474
+$core.method({
3475
+selector: "visitBlockSequenceNode:",
3476
+protocol: 'visiting',
3477
+fn: function (aNode){
3478
+var self=this;
3479
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3480
+return $core.withContext(function($ctx1) {
3481
+//>>excludeEnd("ctx");
3482
+var $1;
3483
+$1=self._visitSequenceNode_(aNode);
3484
+return $1;
3485
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3486
+}, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},$globals.NodeVisitor)});
3487
+//>>excludeEnd("ctx");
3488
+},
3489
+//>>excludeStart("ide", pragmas.excludeIdeData);
3490
+args: ["aNode"],
3491
+source: "visitBlockSequenceNode: aNode\x0a\x09^ self visitSequenceNode: aNode",
3492
+referencedClasses: [],
3493
+//>>excludeEnd("ide");
3494
+messageSends: ["visitSequenceNode:"]
3495
+}),
3496
+$globals.NodeVisitor);
3497
+
3498
+$core.addMethod(
3499
+$core.method({
3500
+selector: "visitCascadeNode:",
3501
+protocol: 'visiting',
3502
+fn: function (aNode){
3503
+var self=this;
3504
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3505
+return $core.withContext(function($ctx1) {
3506
+//>>excludeEnd("ctx");
3507
+var $1;
3508
+$1=self._visitNode_(aNode);
3509
+return $1;
3510
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3511
+}, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},$globals.NodeVisitor)});
3512
+//>>excludeEnd("ctx");
3513
+},
3514
+//>>excludeStart("ide", pragmas.excludeIdeData);
3515
+args: ["aNode"],
3516
+source: "visitCascadeNode: aNode\x0a\x09^ self visitNode: aNode",
3517
+referencedClasses: [],
3518
+//>>excludeEnd("ide");
3519
+messageSends: ["visitNode:"]
3520
+}),
3521
+$globals.NodeVisitor);
3522
+
3523
+$core.addMethod(
3524
+$core.method({
3525
+selector: "visitDynamicArrayNode:",
3526
+protocol: 'visiting',
3527
+fn: function (aNode){
3528
+var self=this;
3529
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3530
+return $core.withContext(function($ctx1) {
3531
+//>>excludeEnd("ctx");
3532
+var $1;
3533
+$1=self._visitNode_(aNode);
3534
+return $1;
3535
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3536
+}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode},$globals.NodeVisitor)});
3537
+//>>excludeEnd("ctx");
3538
+},
3539
+//>>excludeStart("ide", pragmas.excludeIdeData);
3540
+args: ["aNode"],
3541
+source: "visitDynamicArrayNode: aNode\x0a\x09^ self visitNode: aNode",
3542
+referencedClasses: [],
3543
+//>>excludeEnd("ide");
3544
+messageSends: ["visitNode:"]
3545
+}),
3546
+$globals.NodeVisitor);
3547
+
3548
+$core.addMethod(
3549
+$core.method({
3550
+selector: "visitDynamicDictionaryNode:",
3551
+protocol: 'visiting',
3552
+fn: function (aNode){
3553
+var self=this;
3554
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3555
+return $core.withContext(function($ctx1) {
3556
+//>>excludeEnd("ctx");
3557
+var $1;
3558
+$1=self._visitNode_(aNode);
3559
+return $1;
3560
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3561
+}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode},$globals.NodeVisitor)});
3562
+//>>excludeEnd("ctx");
3563
+},
3564
+//>>excludeStart("ide", pragmas.excludeIdeData);
3565
+args: ["aNode"],
3566
+source: "visitDynamicDictionaryNode: aNode\x0a\x09^ self visitNode: aNode",
3567
+referencedClasses: [],
3568
+//>>excludeEnd("ide");
3569
+messageSends: ["visitNode:"]
3570
+}),
3571
+$globals.NodeVisitor);
3572
+
3573
+$core.addMethod(
3574
+$core.method({
3575
+selector: "visitJSStatementNode:",
3576
+protocol: 'visiting',
3577
+fn: function (aNode){
3578
+var self=this;
3579
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3580
+return $core.withContext(function($ctx1) {
3581
+//>>excludeEnd("ctx");
3582
+var $1;
3583
+$1=self._visitNode_(aNode);
3584
+return $1;
3585
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3586
+}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},$globals.NodeVisitor)});
3587
+//>>excludeEnd("ctx");
3588
+},
3589
+//>>excludeStart("ide", pragmas.excludeIdeData);
3590
+args: ["aNode"],
3591
+source: "visitJSStatementNode: aNode\x0a\x09^ self visitNode: aNode",
3592
+referencedClasses: [],
3593
+//>>excludeEnd("ide");
3594
+messageSends: ["visitNode:"]
3595
+}),
3596
+$globals.NodeVisitor);
3597
+
3598
+$core.addMethod(
3599
+$core.method({
3600
+selector: "visitMethodNode:",
3601
+protocol: 'visiting',
3602
+fn: function (aNode){
3603
+var self=this;
3604
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3605
+return $core.withContext(function($ctx1) {
3606
+//>>excludeEnd("ctx");
3607
+var $1;
3608
+$1=self._visitNode_(aNode);
3609
+return $1;
3610
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3611
+}, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},$globals.NodeVisitor)});
3612
+//>>excludeEnd("ctx");
3613
+},
3614
+//>>excludeStart("ide", pragmas.excludeIdeData);
3615
+args: ["aNode"],
3616
+source: "visitMethodNode: aNode\x0a\x09^ self visitNode: aNode",
3617
+referencedClasses: [],
3618
+//>>excludeEnd("ide");
3619
+messageSends: ["visitNode:"]
3620
+}),
3621
+$globals.NodeVisitor);
3622
+
3623
+$core.addMethod(
3624
+$core.method({
3625
+selector: "visitNode:",
3626
+protocol: 'visiting',
3627
+fn: function (aNode){
3628
+var self=this;
3629
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3630
+return $core.withContext(function($ctx1) {
3631
+//>>excludeEnd("ctx");
3632
+var $1;
3633
+$1=self._visitAll_($recv(aNode)._nodes());
3634
+return $1;
3635
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3636
+}, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},$globals.NodeVisitor)});
3637
+//>>excludeEnd("ctx");
3638
+},
3639
+//>>excludeStart("ide", pragmas.excludeIdeData);
3640
+args: ["aNode"],
3641
+source: "visitNode: aNode\x0a\x09^ self visitAll: aNode nodes",
3642
+referencedClasses: [],
3643
+//>>excludeEnd("ide");
3644
+messageSends: ["visitAll:", "nodes"]
3645
+}),
3646
+$globals.NodeVisitor);
3647
+
3648
+$core.addMethod(
3649
+$core.method({
3650
+selector: "visitReturnNode:",
3651
+protocol: 'visiting',
3652
+fn: function (aNode){
3653
+var self=this;
3654
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3655
+return $core.withContext(function($ctx1) {
3656
+//>>excludeEnd("ctx");
3657
+var $1;
3658
+$1=self._visitNode_(aNode);
3659
+return $1;
3660
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3661
+}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},$globals.NodeVisitor)});
3662
+//>>excludeEnd("ctx");
3663
+},
3664
+//>>excludeStart("ide", pragmas.excludeIdeData);
3665
+args: ["aNode"],
3666
+source: "visitReturnNode: aNode\x0a\x09^ self visitNode: aNode",
3667
+referencedClasses: [],
3668
+//>>excludeEnd("ide");
3669
+messageSends: ["visitNode:"]
3670
+}),
3671
+$globals.NodeVisitor);
3672
+
3673
+$core.addMethod(
3674
+$core.method({
3675
+selector: "visitSendNode:",
3676
+protocol: 'visiting',
3677
+fn: function (aNode){
3678
+var self=this;
3679
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3680
+return $core.withContext(function($ctx1) {
3681
+//>>excludeEnd("ctx");
3682
+var $1;
3683
+$1=self._visitNode_(aNode);
3684
+return $1;
3685
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3686
+}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.NodeVisitor)});
3687
+//>>excludeEnd("ctx");
3688
+},
3689
+//>>excludeStart("ide", pragmas.excludeIdeData);
3690
+args: ["aNode"],
3691
+source: "visitSendNode: aNode\x0a\x09^ self visitNode: aNode",
3692
+referencedClasses: [],
3693
+//>>excludeEnd("ide");
3694
+messageSends: ["visitNode:"]
3695
+}),
3696
+$globals.NodeVisitor);
3697
+
3698
+$core.addMethod(
3699
+$core.method({
3700
+selector: "visitSequenceNode:",
3701
+protocol: 'visiting',
3702
+fn: function (aNode){
3703
+var self=this;
3704
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3705
+return $core.withContext(function($ctx1) {
3706
+//>>excludeEnd("ctx");
3707
+var $1;
3708
+$1=self._visitNode_(aNode);
3709
+return $1;
3710
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3711
+}, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},$globals.NodeVisitor)});
3712
+//>>excludeEnd("ctx");
3713
+},
3714
+//>>excludeStart("ide", pragmas.excludeIdeData);
3715
+args: ["aNode"],
3716
+source: "visitSequenceNode: aNode\x0a\x09^ self visitNode: aNode",
3717
+referencedClasses: [],
3718
+//>>excludeEnd("ide");
3719
+messageSends: ["visitNode:"]
3720
+}),
3721
+$globals.NodeVisitor);
3722
+
3723
+$core.addMethod(
3724
+$core.method({
3725
+selector: "visitValueNode:",
3726
+protocol: 'visiting',
3727
+fn: function (aNode){
3728
+var self=this;
3729
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3730
+return $core.withContext(function($ctx1) {
3731
+//>>excludeEnd("ctx");
3732
+var $1;
3733
+$1=self._visitNode_(aNode);
3734
+return $1;
3735
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3736
+}, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},$globals.NodeVisitor)});
3737
+//>>excludeEnd("ctx");
3738
+},
3739
+//>>excludeStart("ide", pragmas.excludeIdeData);
3740
+args: ["aNode"],
3741
+source: "visitValueNode: aNode\x0a\x09^ self visitNode: aNode",
3742
+referencedClasses: [],
3743
+//>>excludeEnd("ide");
3744
+messageSends: ["visitNode:"]
3745
+}),
3746
+$globals.NodeVisitor);
3747
+
3748
+$core.addMethod(
3749
+$core.method({
3750
+selector: "visitVariableNode:",
3751
+protocol: 'visiting',
3752
+fn: function (aNode){
3753
+var self=this;
3754
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3755
+return $core.withContext(function($ctx1) {
3756
+//>>excludeEnd("ctx");
3757
+var $1;
3758
+$1=self._visitNode_(aNode);
3759
+return $1;
3760
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3761
+}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},$globals.NodeVisitor)});
3762
+//>>excludeEnd("ctx");
3763
+},
3764
+//>>excludeStart("ide", pragmas.excludeIdeData);
3765
+args: ["aNode"],
3766
+source: "visitVariableNode: aNode\x0a\x09^ self visitNode: aNode",
3767
+referencedClasses: [],
3768
+//>>excludeEnd("ide");
3769
+messageSends: ["visitNode:"]
3770
+}),
3771
+$globals.NodeVisitor);
3772
+
3773
+
3536 3774
 $core.addMethod(
3537 3775
 $core.method({
3538 3776
 selector: "ast",

+ 76 - 49
src/Compiler-AST.st

@@ -48,33 +48,6 @@ navigationNodeAt: aPoint ifAbsent: aBlock
48 48
 		(b positionStart dist: aPoint) ]) first
49 49
 !
50 50
 
51
-nextChild
52
-	"Answer the next node after aNode.
53
-	Recurse into the possible children of the receiver to answer the next node to be evaluated"
54
-	
55
-	^ self nodes isEmpty
56
-		ifTrue: [ self ]
57
-		ifFalse: [ self nodes first nextChild ]
58
-!
59
-
60
-nextNode
61
-	^ self parent ifNotNil: [ :node |
62
-		node nextNode: self ]
63
-!
64
-
65
-nextNode: aNode
66
-	"Answer the next node after aNode.
67
-	Recurse into the possible children of the next node to answer the next node to be evaluated"
68
-	
69
-	| next |
70
-	
71
-	next := self nodes 
72
-		at: (self nodes indexOf: aNode) + 1
73
-		ifAbsent: [ ^ self ].
74
-	
75
-	^ next nextChild
76
-!
77
-
78 51
 nodes
79 52
 	^ nodes ifNil: [ nodes := Array new ]
80 53
 !
@@ -233,10 +206,6 @@ requiresSmalltalkContext
233 206
 		ifNone: [ nil ]) notNil
234 207
 !
235 208
 
236
-stopOnStepping
237
-	^ false
238
-!
239
-
240 209
 subtreeNeedsAliasing
241 210
 	^ (self shouldBeAliased or: [ self shouldBeInlined ]) or: [
242 211
 		self nodes anySatisfy: [ :each | each subtreeNeedsAliasing ] ]
@@ -302,18 +271,6 @@ I represent an block closure node.!
302 271
 
303 272
 !BlockNode methodsFor: 'accessing'!
304 273
 
305
-nextChild
306
-	"Answer the receiver as we want to avoid eager evaluation"
307
-	
308
-	^ self
309
-!
310
-
311
-nextNode: aNode
312
-	"Answer the receiver as we want to avoid eager evaluation"
313
-	
314
-	^ self
315
-!
316
-
317 274
 parameters
318 275
 	^ parameters ifNil: [ parameters := Array new ]
319 276
 !
@@ -612,7 +569,9 @@ superSend
612 569
 
613 570
 superSend: aBoolean
614 571
 	superSend := aBoolean
615
-!
572
+! !
573
+
574
+!SendNode methodsFor: 'building'!
616 575
 
617 576
 valueForReceiver: anObject
618 577
 	^ SendNode new
@@ -656,10 +615,6 @@ shouldBeAliased
656 615
 		self isReferenced and: [
657 616
 			(sends > 1 and: [ self index < sends ])
658 617
 				or: [ self superSend ] ] ])
659
-!
660
-
661
-stopOnStepping
662
-	^ true
663 618
 ! !
664 619
 
665 620
 !SendNode methodsFor: 'visiting'!
@@ -692,7 +647,7 @@ temps: aCollection
692 647
 	temps := aCollection
693 648
 ! !
694 649
 
695
-!SequenceNode methodsFor: 'converting'!
650
+!SequenceNode methodsFor: 'building'!
696 651
 
697 652
 asBlockSequenceNode
698 653
 	^ BlockSequenceNode new
@@ -826,6 +781,78 @@ accept: aVisitor
826 781
 	^ aVisitor visitVariableNode: self
827 782
 ! !
828 783
 
784
+Object subclass: #NodeVisitor
785
+	instanceVariableNames: ''
786
+	package: 'Compiler-AST'!
787
+!NodeVisitor commentStamp!
788
+I am the abstract super class of all AST node visitors.!
789
+
790
+!NodeVisitor methodsFor: 'visiting'!
791
+
792
+visit: aNode
793
+	^ aNode accept: self
794
+!
795
+
796
+visitAll: aCollection
797
+	^ aCollection collect: [ :each | self visit: each ]
798
+!
799
+
800
+visitAssignmentNode: aNode
801
+	^ self visitNode: aNode
802
+!
803
+
804
+visitBlockNode: aNode
805
+	^ self visitNode: aNode
806
+!
807
+
808
+visitBlockSequenceNode: aNode
809
+	^ self visitSequenceNode: aNode
810
+!
811
+
812
+visitCascadeNode: aNode
813
+	^ self visitNode: aNode
814
+!
815
+
816
+visitDynamicArrayNode: aNode
817
+	^ self visitNode: aNode
818
+!
819
+
820
+visitDynamicDictionaryNode: aNode
821
+	^ self visitNode: aNode
822
+!
823
+
824
+visitJSStatementNode: aNode
825
+	^ self visitNode: aNode
826
+!
827
+
828
+visitMethodNode: aNode
829
+	^ self visitNode: aNode
830
+!
831
+
832
+visitNode: aNode
833
+	^ self visitAll: aNode nodes
834
+!
835
+
836
+visitReturnNode: aNode
837
+	^ self visitNode: aNode
838
+!
839
+
840
+visitSendNode: aNode
841
+	^ self visitNode: aNode
842
+!
843
+
844
+visitSequenceNode: aNode
845
+	^ self visitNode: aNode
846
+!
847
+
848
+visitValueNode: aNode
849
+	^ self visitNode: aNode
850
+!
851
+
852
+visitVariableNode: aNode
853
+	^ self visitNode: aNode
854
+! !
855
+
829 856
 !CompiledMethod methodsFor: '*Compiler-AST'!
830 857
 
831 858
 ast

+ 7 - 415
src/Compiler-Core.js

@@ -1,4 +1,4 @@
1
-define("amber_core/Compiler-Core", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Platform-Services", "amber_core/Kernel-Collections"], function($boot){"use strict";
1
+define("amber_core/Compiler-Core", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Platform-Services", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Collections"], function($boot){"use strict";
2 2
 var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
3 3
 $core.addPackage('Compiler-Core');
4 4
 $core.packages["Compiler-Core"].innerEval = function (expr) { return eval(expr); };
@@ -1015,6 +1015,12 @@ messageSends: ["do:", "classes", "recompile:"]
1015 1015
 $globals.Compiler.klass);
1016 1016
 
1017 1017
 
1018
+$core.addClass('CompilerError', $globals.Error, [], 'Compiler-Core');
1019
+//>>excludeStart("ide", pragmas.excludeIdeData);
1020
+$globals.CompilerError.comment="I am the common superclass of all compiling errors.";
1021
+//>>excludeEnd("ide");
1022
+
1023
+
1018 1024
 $core.addClass('DoIt', $globals.Object, [], 'Compiler-Core');
1019 1025
 //>>excludeStart("ide", pragmas.excludeIdeData);
1020 1026
 $globals.DoIt.comment="`DoIt` is the class used to compile and evaluate expressions. See `Compiler >> evaluateExpression:`.";
@@ -1183,420 +1189,6 @@ messageSends: ["evaluate:for:", "new"]
1183 1189
 }),
1184 1190
 $globals.Evaluator.klass);
1185 1191
 
1186
-
1187
-$core.addClass('NodeVisitor', $globals.Object, [], 'Compiler-Core');
1188
-//>>excludeStart("ide", pragmas.excludeIdeData);
1189
-$globals.NodeVisitor.comment="I am the abstract super class of all AST node visitors.";
1190
-//>>excludeEnd("ide");
1191
-$core.addMethod(
1192
-$core.method({
1193
-selector: "visit:",
1194
-protocol: 'visiting',
1195
-fn: function (aNode){
1196
-var self=this;
1197
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1198
-return $core.withContext(function($ctx1) {
1199
-//>>excludeEnd("ctx");
1200
-var $1;
1201
-$1=$recv(aNode)._accept_(self);
1202
-return $1;
1203
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1204
-}, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},$globals.NodeVisitor)});
1205
-//>>excludeEnd("ctx");
1206
-},
1207
-//>>excludeStart("ide", pragmas.excludeIdeData);
1208
-args: ["aNode"],
1209
-source: "visit: aNode\x0a\x09^ aNode accept: self",
1210
-referencedClasses: [],
1211
-//>>excludeEnd("ide");
1212
-messageSends: ["accept:"]
1213
-}),
1214
-$globals.NodeVisitor);
1215
-
1216
-$core.addMethod(
1217
-$core.method({
1218
-selector: "visitAll:",
1219
-protocol: 'visiting',
1220
-fn: function (aCollection){
1221
-var self=this;
1222
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1223
-return $core.withContext(function($ctx1) {
1224
-//>>excludeEnd("ctx");
1225
-var $1;
1226
-$1=$recv(aCollection)._collect_((function(each){
1227
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1228
-return $core.withContext(function($ctx2) {
1229
-//>>excludeEnd("ctx");
1230
-return self._visit_(each);
1231
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1232
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
1233
-//>>excludeEnd("ctx");
1234
-}));
1235
-return $1;
1236
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1237
-}, function($ctx1) {$ctx1.fill(self,"visitAll:",{aCollection:aCollection},$globals.NodeVisitor)});
1238
-//>>excludeEnd("ctx");
1239
-},
1240
-//>>excludeStart("ide", pragmas.excludeIdeData);
1241
-args: ["aCollection"],
1242
-source: "visitAll: aCollection\x0a\x09^ aCollection collect: [ :each | self visit: each ]",
1243
-referencedClasses: [],
1244
-//>>excludeEnd("ide");
1245
-messageSends: ["collect:", "visit:"]
1246
-}),
1247
-$globals.NodeVisitor);
1248
-
1249
-$core.addMethod(
1250
-$core.method({
1251
-selector: "visitAssignmentNode:",
1252
-protocol: 'visiting',
1253
-fn: function (aNode){
1254
-var self=this;
1255
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1256
-return $core.withContext(function($ctx1) {
1257
-//>>excludeEnd("ctx");
1258
-var $1;
1259
-$1=self._visitNode_(aNode);
1260
-return $1;
1261
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1262
-}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},$globals.NodeVisitor)});
1263
-//>>excludeEnd("ctx");
1264
-},
1265
-//>>excludeStart("ide", pragmas.excludeIdeData);
1266
-args: ["aNode"],
1267
-source: "visitAssignmentNode: aNode\x0a\x09^ self visitNode: aNode",
1268
-referencedClasses: [],
1269
-//>>excludeEnd("ide");
1270
-messageSends: ["visitNode:"]
1271
-}),
1272
-$globals.NodeVisitor);
1273
-
1274
-$core.addMethod(
1275
-$core.method({
1276
-selector: "visitBlockNode:",
1277
-protocol: 'visiting',
1278
-fn: function (aNode){
1279
-var self=this;
1280
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1281
-return $core.withContext(function($ctx1) {
1282
-//>>excludeEnd("ctx");
1283
-var $1;
1284
-$1=self._visitNode_(aNode);
1285
-return $1;
1286
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1287
-}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},$globals.NodeVisitor)});
1288
-//>>excludeEnd("ctx");
1289
-},
1290
-//>>excludeStart("ide", pragmas.excludeIdeData);
1291
-args: ["aNode"],
1292
-source: "visitBlockNode: aNode\x0a\x09^ self visitNode: aNode",
1293
-referencedClasses: [],
1294
-//>>excludeEnd("ide");
1295
-messageSends: ["visitNode:"]
1296
-}),
1297
-$globals.NodeVisitor);
1298
-
1299
-$core.addMethod(
1300
-$core.method({
1301
-selector: "visitBlockSequenceNode:",
1302
-protocol: 'visiting',
1303
-fn: function (aNode){
1304
-var self=this;
1305
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1306
-return $core.withContext(function($ctx1) {
1307
-//>>excludeEnd("ctx");
1308
-var $1;
1309
-$1=self._visitSequenceNode_(aNode);
1310
-return $1;
1311
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1312
-}, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},$globals.NodeVisitor)});
1313
-//>>excludeEnd("ctx");
1314
-},
1315
-//>>excludeStart("ide", pragmas.excludeIdeData);
1316
-args: ["aNode"],
1317
-source: "visitBlockSequenceNode: aNode\x0a\x09^ self visitSequenceNode: aNode",
1318
-referencedClasses: [],
1319
-//>>excludeEnd("ide");
1320
-messageSends: ["visitSequenceNode:"]
1321
-}),
1322
-$globals.NodeVisitor);
1323
-
1324
-$core.addMethod(
1325
-$core.method({
1326
-selector: "visitCascadeNode:",
1327
-protocol: 'visiting',
1328
-fn: function (aNode){
1329
-var self=this;
1330
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1331
-return $core.withContext(function($ctx1) {
1332
-//>>excludeEnd("ctx");
1333
-var $1;
1334
-$1=self._visitNode_(aNode);
1335
-return $1;
1336
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1337
-}, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},$globals.NodeVisitor)});
1338
-//>>excludeEnd("ctx");
1339
-},
1340
-//>>excludeStart("ide", pragmas.excludeIdeData);
1341
-args: ["aNode"],
1342
-source: "visitCascadeNode: aNode\x0a\x09^ self visitNode: aNode",
1343
-referencedClasses: [],
1344
-//>>excludeEnd("ide");
1345
-messageSends: ["visitNode:"]
1346
-}),
1347
-$globals.NodeVisitor);
1348
-
1349
-$core.addMethod(
1350
-$core.method({
1351
-selector: "visitDynamicArrayNode:",
1352
-protocol: 'visiting',
1353
-fn: function (aNode){
1354
-var self=this;
1355
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1356
-return $core.withContext(function($ctx1) {
1357
-//>>excludeEnd("ctx");
1358
-var $1;
1359
-$1=self._visitNode_(aNode);
1360
-return $1;
1361
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1362
-}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode},$globals.NodeVisitor)});
1363
-//>>excludeEnd("ctx");
1364
-},
1365
-//>>excludeStart("ide", pragmas.excludeIdeData);
1366
-args: ["aNode"],
1367
-source: "visitDynamicArrayNode: aNode\x0a\x09^ self visitNode: aNode",
1368
-referencedClasses: [],
1369
-//>>excludeEnd("ide");
1370
-messageSends: ["visitNode:"]
1371
-}),
1372
-$globals.NodeVisitor);
1373
-
1374
-$core.addMethod(
1375
-$core.method({
1376
-selector: "visitDynamicDictionaryNode:",
1377
-protocol: 'visiting',
1378
-fn: function (aNode){
1379
-var self=this;
1380
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1381
-return $core.withContext(function($ctx1) {
1382
-//>>excludeEnd("ctx");
1383
-var $1;
1384
-$1=self._visitNode_(aNode);
1385
-return $1;
1386
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1387
-}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode},$globals.NodeVisitor)});
1388
-//>>excludeEnd("ctx");
1389
-},
1390
-//>>excludeStart("ide", pragmas.excludeIdeData);
1391
-args: ["aNode"],
1392
-source: "visitDynamicDictionaryNode: aNode\x0a\x09^ self visitNode: aNode",
1393
-referencedClasses: [],
1394
-//>>excludeEnd("ide");
1395
-messageSends: ["visitNode:"]
1396
-}),
1397
-$globals.NodeVisitor);
1398
-
1399
-$core.addMethod(
1400
-$core.method({
1401
-selector: "visitJSStatementNode:",
1402
-protocol: 'visiting',
1403
-fn: function (aNode){
1404
-var self=this;
1405
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1406
-return $core.withContext(function($ctx1) {
1407
-//>>excludeEnd("ctx");
1408
-var $1;
1409
-$1=self._visitNode_(aNode);
1410
-return $1;
1411
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1412
-}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},$globals.NodeVisitor)});
1413
-//>>excludeEnd("ctx");
1414
-},
1415
-//>>excludeStart("ide", pragmas.excludeIdeData);
1416
-args: ["aNode"],
1417
-source: "visitJSStatementNode: aNode\x0a\x09^ self visitNode: aNode",
1418
-referencedClasses: [],
1419
-//>>excludeEnd("ide");
1420
-messageSends: ["visitNode:"]
1421
-}),
1422
-$globals.NodeVisitor);
1423
-
1424
-$core.addMethod(
1425
-$core.method({
1426
-selector: "visitMethodNode:",
1427
-protocol: 'visiting',
1428
-fn: function (aNode){
1429
-var self=this;
1430
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1431
-return $core.withContext(function($ctx1) {
1432
-//>>excludeEnd("ctx");
1433
-var $1;
1434
-$1=self._visitNode_(aNode);
1435
-return $1;
1436
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1437
-}, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},$globals.NodeVisitor)});
1438
-//>>excludeEnd("ctx");
1439
-},
1440
-//>>excludeStart("ide", pragmas.excludeIdeData);
1441
-args: ["aNode"],
1442
-source: "visitMethodNode: aNode\x0a\x09^ self visitNode: aNode",
1443
-referencedClasses: [],
1444
-//>>excludeEnd("ide");
1445
-messageSends: ["visitNode:"]
1446
-}),
1447
-$globals.NodeVisitor);
1448
-
1449
-$core.addMethod(
1450
-$core.method({
1451
-selector: "visitNode:",
1452
-protocol: 'visiting',
1453
-fn: function (aNode){
1454
-var self=this;
1455
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1456
-return $core.withContext(function($ctx1) {
1457
-//>>excludeEnd("ctx");
1458
-var $1;
1459
-$1=self._visitAll_($recv(aNode)._nodes());
1460
-return $1;
1461
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1462
-}, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},$globals.NodeVisitor)});
1463
-//>>excludeEnd("ctx");
1464
-},
1465
-//>>excludeStart("ide", pragmas.excludeIdeData);
1466
-args: ["aNode"],
1467
-source: "visitNode: aNode\x0a\x09^ self visitAll: aNode nodes",
1468
-referencedClasses: [],
1469
-//>>excludeEnd("ide");
1470
-messageSends: ["visitAll:", "nodes"]
1471
-}),
1472
-$globals.NodeVisitor);
1473
-
1474
-$core.addMethod(
1475
-$core.method({
1476
-selector: "visitReturnNode:",
1477
-protocol: 'visiting',
1478
-fn: function (aNode){
1479
-var self=this;
1480
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1481
-return $core.withContext(function($ctx1) {
1482
-//>>excludeEnd("ctx");
1483
-var $1;
1484
-$1=self._visitNode_(aNode);
1485
-return $1;
1486
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1487
-}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},$globals.NodeVisitor)});
1488
-//>>excludeEnd("ctx");
1489
-},
1490
-//>>excludeStart("ide", pragmas.excludeIdeData);
1491
-args: ["aNode"],
1492
-source: "visitReturnNode: aNode\x0a\x09^ self visitNode: aNode",
1493
-referencedClasses: [],
1494
-//>>excludeEnd("ide");
1495
-messageSends: ["visitNode:"]
1496
-}),
1497
-$globals.NodeVisitor);
1498
-
1499
-$core.addMethod(
1500
-$core.method({
1501
-selector: "visitSendNode:",
1502
-protocol: 'visiting',
1503
-fn: function (aNode){
1504
-var self=this;
1505
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1506
-return $core.withContext(function($ctx1) {
1507
-//>>excludeEnd("ctx");
1508
-var $1;
1509
-$1=self._visitNode_(aNode);
1510
-return $1;
1511
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1512
-}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.NodeVisitor)});
1513
-//>>excludeEnd("ctx");
1514
-},
1515
-//>>excludeStart("ide", pragmas.excludeIdeData);
1516
-args: ["aNode"],
1517
-source: "visitSendNode: aNode\x0a\x09^ self visitNode: aNode",
1518
-referencedClasses: [],
1519
-//>>excludeEnd("ide");
1520
-messageSends: ["visitNode:"]
1521
-}),
1522
-$globals.NodeVisitor);
1523
-
1524
-$core.addMethod(
1525
-$core.method({
1526
-selector: "visitSequenceNode:",
1527
-protocol: 'visiting',
1528
-fn: function (aNode){
1529
-var self=this;
1530
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1531
-return $core.withContext(function($ctx1) {
1532
-//>>excludeEnd("ctx");
1533
-var $1;
1534
-$1=self._visitNode_(aNode);
1535
-return $1;
1536
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1537
-}, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},$globals.NodeVisitor)});
1538
-//>>excludeEnd("ctx");
1539
-},
1540
-//>>excludeStart("ide", pragmas.excludeIdeData);
1541
-args: ["aNode"],
1542
-source: "visitSequenceNode: aNode\x0a\x09^ self visitNode: aNode",
1543
-referencedClasses: [],
1544
-//>>excludeEnd("ide");
1545
-messageSends: ["visitNode:"]
1546
-}),
1547
-$globals.NodeVisitor);
1548
-
1549
-$core.addMethod(
1550
-$core.method({
1551
-selector: "visitValueNode:",
1552
-protocol: 'visiting',
1553
-fn: function (aNode){
1554
-var self=this;
1555
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1556
-return $core.withContext(function($ctx1) {
1557
-//>>excludeEnd("ctx");
1558
-var $1;
1559
-$1=self._visitNode_(aNode);
1560
-return $1;
1561
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1562
-}, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},$globals.NodeVisitor)});
1563
-//>>excludeEnd("ctx");
1564
-},
1565
-//>>excludeStart("ide", pragmas.excludeIdeData);
1566
-args: ["aNode"],
1567
-source: "visitValueNode: aNode\x0a\x09^ self visitNode: aNode",
1568
-referencedClasses: [],
1569
-//>>excludeEnd("ide");
1570
-messageSends: ["visitNode:"]
1571
-}),
1572
-$globals.NodeVisitor);
1573
-
1574
-$core.addMethod(
1575
-$core.method({
1576
-selector: "visitVariableNode:",
1577
-protocol: 'visiting',
1578
-fn: function (aNode){
1579
-var self=this;
1580
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1581
-return $core.withContext(function($ctx1) {
1582
-//>>excludeEnd("ctx");
1583
-var $1;
1584
-$1=self._visitNode_(aNode);
1585
-return $1;
1586
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
1587
-}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},$globals.NodeVisitor)});
1588
-//>>excludeEnd("ctx");
1589
-},
1590
-//>>excludeStart("ide", pragmas.excludeIdeData);
1591
-args: ["aNode"],
1592
-source: "visitVariableNode: aNode\x0a\x09^ self visitNode: aNode",
1593
-referencedClasses: [],
1594
-//>>excludeEnd("ide");
1595
-messageSends: ["visitNode:"]
1596
-}),
1597
-$globals.NodeVisitor);
1598
-
1599
-
1600 1192
 $core.addMethod(
1601 1193
 $core.method({
1602 1194
 selector: "asVariableName",

+ 6 - 72
src/Compiler-Core.st

@@ -246,6 +246,12 @@ recompileAll
246 246
 		self recompile: each ]
247 247
 ! !
248 248
 
249
+Error subclass: #CompilerError
250
+	instanceVariableNames: ''
251
+	package: 'Compiler-Core'!
252
+!CompilerError commentStamp!
253
+I am the common superclass of all compiling errors.!
254
+
249 255
 Object subclass: #DoIt
250 256
 	instanceVariableNames: ''
251 257
 	package: 'Compiler-Core'!
@@ -300,78 +306,6 @@ evaluate: aString for: anObject
300 306
 	^ self new evaluate: aString for: anObject
301 307
 ! !
302 308
 
303
-Object subclass: #NodeVisitor
304
-	instanceVariableNames: ''
305
-	package: 'Compiler-Core'!
306
-!NodeVisitor commentStamp!
307
-I am the abstract super class of all AST node visitors.!
308
-
309
-!NodeVisitor methodsFor: 'visiting'!
310
-
311
-visit: aNode
312
-	^ aNode accept: self
313
-!
314
-
315
-visitAll: aCollection
316
-	^ aCollection collect: [ :each | self visit: each ]
317
-!
318
-
319
-visitAssignmentNode: aNode
320
-	^ self visitNode: aNode
321
-!
322
-
323
-visitBlockNode: aNode
324
-	^ self visitNode: aNode
325
-!
326
-
327
-visitBlockSequenceNode: aNode
328
-	^ self visitSequenceNode: aNode
329
-!
330
-
331
-visitCascadeNode: aNode
332
-	^ self visitNode: aNode
333
-!
334
-
335
-visitDynamicArrayNode: aNode
336
-	^ self visitNode: aNode
337
-!
338
-
339
-visitDynamicDictionaryNode: aNode
340
-	^ self visitNode: aNode
341
-!
342
-
343
-visitJSStatementNode: aNode
344
-	^ self visitNode: aNode
345
-!
346
-
347
-visitMethodNode: aNode
348
-	^ self visitNode: aNode
349
-!
350
-
351
-visitNode: aNode
352
-	^ self visitAll: aNode nodes
353
-!
354
-
355
-visitReturnNode: aNode
356
-	^ self visitNode: aNode
357
-!
358
-
359
-visitSendNode: aNode
360
-	^ self visitNode: aNode
361
-!
362
-
363
-visitSequenceNode: aNode
364
-	^ self visitNode: aNode
365
-!
366
-
367
-visitValueNode: aNode
368
-	^ self visitNode: aNode
369
-!
370
-
371
-visitVariableNode: aNode
372
-	^ self visitNode: aNode
373
-! !
374
-
375 309
 !String methodsFor: '*Compiler-Core'!
376 310
 
377 311
 asVariableName

+ 0 - 300
src/Compiler-Exceptions.js

@@ -1,300 +0,0 @@
1
-define("amber_core/Compiler-Exceptions", ["amber/boot", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Objects"], function($boot){"use strict";
2
-var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
3
-$core.addPackage('Compiler-Exceptions');
4
-$core.packages["Compiler-Exceptions"].innerEval = function (expr) { return eval(expr); };
5
-$core.packages["Compiler-Exceptions"].transport = {"type":"amd","amdNamespace":"amber_core"};
6
-
7
-$core.addClass('CompilerError', $globals.Error, [], 'Compiler-Exceptions');
8
-//>>excludeStart("ide", pragmas.excludeIdeData);
9
-$globals.CompilerError.comment="I am the common superclass of all compiling errors.";
10
-//>>excludeEnd("ide");
11
-
12
-
13
-$core.addClass('ParseError', $globals.CompilerError, [], 'Compiler-Exceptions');
14
-//>>excludeStart("ide", pragmas.excludeIdeData);
15
-$globals.ParseError.comment="Instance of ParseError are signaled on any parsing error.\x0aSee `Smalltalk >> #parse:`";
16
-//>>excludeEnd("ide");
17
-
18
-
19
-$core.addClass('SemanticError', $globals.CompilerError, [], 'Compiler-Exceptions');
20
-//>>excludeStart("ide", pragmas.excludeIdeData);
21
-$globals.SemanticError.comment="I represent an abstract semantic error thrown by the SemanticAnalyzer.\x0aSemantic errors can be unknown variable errors, etc.\x0aSee my subclasses for concrete errors.\x0a\x0aThe IDE should catch instances of Semantic error to deal with them when compiling";
22
-//>>excludeEnd("ide");
23
-
24
-
25
-$core.addClass('InliningError', $globals.SemanticError, [], 'Compiler-Exceptions');
26
-//>>excludeStart("ide", pragmas.excludeIdeData);
27
-$globals.InliningError.comment="Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.";
28
-//>>excludeEnd("ide");
29
-
30
-
31
-$core.addClass('InvalidAssignmentError', $globals.SemanticError, ['variableName'], 'Compiler-Exceptions');
32
-//>>excludeStart("ide", pragmas.excludeIdeData);
33
-$globals.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned.";
34
-//>>excludeEnd("ide");
35
-$core.addMethod(
36
-$core.method({
37
-selector: "messageText",
38
-protocol: 'accessing',
39
-fn: function (){
40
-var self=this;
41
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
42
-return $core.withContext(function($ctx1) {
43
-//>>excludeEnd("ctx");
44
-var $1;
45
-$1=" Invalid assignment to variable: ".__comma(self._variableName());
46
-return $1;
47
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
48
-}, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.InvalidAssignmentError)});
49
-//>>excludeEnd("ctx");
50
-},
51
-//>>excludeStart("ide", pragmas.excludeIdeData);
52
-args: [],
53
-source: "messageText\x0a\x09^ ' Invalid assignment to variable: ', self variableName",
54
-referencedClasses: [],
55
-//>>excludeEnd("ide");
56
-messageSends: [",", "variableName"]
57
-}),
58
-$globals.InvalidAssignmentError);
59
-
60
-$core.addMethod(
61
-$core.method({
62
-selector: "variableName",
63
-protocol: 'accessing',
64
-fn: function (){
65
-var self=this;
66
-var $1;
67
-$1=self["@variableName"];
68
-return $1;
69
-
70
-},
71
-//>>excludeStart("ide", pragmas.excludeIdeData);
72
-args: [],
73
-source: "variableName\x0a\x09^ variableName",
74
-referencedClasses: [],
75
-//>>excludeEnd("ide");
76
-messageSends: []
77
-}),
78
-$globals.InvalidAssignmentError);
79
-
80
-$core.addMethod(
81
-$core.method({
82
-selector: "variableName:",
83
-protocol: 'accessing',
84
-fn: function (aString){
85
-var self=this;
86
-self["@variableName"]=aString;
87
-return self;
88
-
89
-},
90
-//>>excludeStart("ide", pragmas.excludeIdeData);
91
-args: ["aString"],
92
-source: "variableName: aString\x0a\x09variableName := aString",
93
-referencedClasses: [],
94
-//>>excludeEnd("ide");
95
-messageSends: []
96
-}),
97
-$globals.InvalidAssignmentError);
98
-
99
-
100
-
101
-$core.addClass('ShadowingVariableError', $globals.SemanticError, ['variableName'], 'Compiler-Exceptions');
102
-//>>excludeStart("ide", pragmas.excludeIdeData);
103
-$globals.ShadowingVariableError.comment="I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.";
104
-//>>excludeEnd("ide");
105
-$core.addMethod(
106
-$core.method({
107
-selector: "messageText",
108
-protocol: 'accessing',
109
-fn: function (){
110
-var self=this;
111
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
112
-return $core.withContext(function($ctx1) {
113
-//>>excludeEnd("ctx");
114
-var $1;
115
-$1=$recv("Variable shadowing error: ".__comma(self._variableName())).__comma(" is already defined");
116
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
117
-$ctx1.sendIdx[","]=1;
118
-//>>excludeEnd("ctx");
119
-return $1;
120
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
121
-}, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.ShadowingVariableError)});
122
-//>>excludeEnd("ctx");
123
-},
124
-//>>excludeStart("ide", pragmas.excludeIdeData);
125
-args: [],
126
-source: "messageText\x0a\x09^ 'Variable shadowing error: ', self variableName, ' is already defined'",
127
-referencedClasses: [],
128
-//>>excludeEnd("ide");
129
-messageSends: [",", "variableName"]
130
-}),
131
-$globals.ShadowingVariableError);
132
-
133
-$core.addMethod(
134
-$core.method({
135
-selector: "variableName",
136
-protocol: 'accessing',
137
-fn: function (){
138
-var self=this;
139
-var $1;
140
-$1=self["@variableName"];
141
-return $1;
142
-
143
-},
144
-//>>excludeStart("ide", pragmas.excludeIdeData);
145
-args: [],
146
-source: "variableName\x0a\x09^ variableName",
147
-referencedClasses: [],
148
-//>>excludeEnd("ide");
149
-messageSends: []
150
-}),
151
-$globals.ShadowingVariableError);
152
-
153
-$core.addMethod(
154
-$core.method({
155
-selector: "variableName:",
156
-protocol: 'accessing',
157
-fn: function (aString){
158
-var self=this;
159
-self["@variableName"]=aString;
160
-return self;
161
-
162
-},
163
-//>>excludeStart("ide", pragmas.excludeIdeData);
164
-args: ["aString"],
165
-source: "variableName: aString\x0a\x09variableName := aString",
166
-referencedClasses: [],
167
-//>>excludeEnd("ide");
168
-messageSends: []
169
-}),
170
-$globals.ShadowingVariableError);
171
-
172
-
173
-
174
-$core.addClass('UnknownVariableError', $globals.SemanticError, ['variableName'], 'Compiler-Exceptions');
175
-//>>excludeStart("ide", pragmas.excludeIdeData);
176
-$globals.UnknownVariableError.comment="I get signaled when a variable is not defined.\x0aThe default behavior is to allow it, as this is how Amber currently is able to seamlessly send messages to JavaScript objects.";
177
-//>>excludeEnd("ide");
178
-$core.addMethod(
179
-$core.method({
180
-selector: "messageText",
181
-protocol: 'accessing',
182
-fn: function (){
183
-var self=this;
184
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
185
-return $core.withContext(function($ctx1) {
186
-//>>excludeEnd("ctx");
187
-var $1;
188
-$1=$recv("Unknown Variable error: ".__comma(self._variableName())).__comma(" is not defined");
189
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
190
-$ctx1.sendIdx[","]=1;
191
-//>>excludeEnd("ctx");
192
-return $1;
193
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
194
-}, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.UnknownVariableError)});
195
-//>>excludeEnd("ctx");
196
-},
197
-//>>excludeStart("ide", pragmas.excludeIdeData);
198
-args: [],
199
-source: "messageText\x0a\x09^ 'Unknown Variable error: ', self variableName, ' is not defined'",
200
-referencedClasses: [],
201
-//>>excludeEnd("ide");
202
-messageSends: [",", "variableName"]
203
-}),
204
-$globals.UnknownVariableError);
205
-
206
-$core.addMethod(
207
-$core.method({
208
-selector: "variableName",
209
-protocol: 'accessing',
210
-fn: function (){
211
-var self=this;
212
-var $1;
213
-$1=self["@variableName"];
214
-return $1;
215
-
216
-},
217
-//>>excludeStart("ide", pragmas.excludeIdeData);
218
-args: [],
219
-source: "variableName\x0a\x09^ variableName",
220
-referencedClasses: [],
221
-//>>excludeEnd("ide");
222
-messageSends: []
223
-}),
224
-$globals.UnknownVariableError);
225
-
226
-$core.addMethod(
227
-$core.method({
228
-selector: "variableName:",
229
-protocol: 'accessing',
230
-fn: function (aString){
231
-var self=this;
232
-self["@variableName"]=aString;
233
-return self;
234
-
235
-},
236
-//>>excludeStart("ide", pragmas.excludeIdeData);
237
-args: ["aString"],
238
-source: "variableName: aString\x0a\x09variableName := aString",
239
-referencedClasses: [],
240
-//>>excludeEnd("ide");
241
-messageSends: []
242
-}),
243
-$globals.UnknownVariableError);
244
-
245
-
246
-
247
-$core.addClass('RethrowErrorHandler', $globals.Object, [], 'Compiler-Exceptions');
248
-//>>excludeStart("ide", pragmas.excludeIdeData);
249
-$globals.RethrowErrorHandler.comment="This class is used in the commandline version of the compiler.\x0aIt uses the handleError: message of ErrorHandler for printing the stacktrace and throws the error again as JS exception.\x0aAs a result Smalltalk errors are not swallowd by the Amber runtime and compilation can be aborted.";
250
-//>>excludeEnd("ide");
251
-$core.addMethod(
252
-$core.method({
253
-selector: "basicSignal:",
254
-protocol: 'error handling',
255
-fn: function (anError){
256
-var self=this;
257
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
258
-return $core.withContext(function($ctx1) {
259
-//>>excludeEnd("ctx");
260
-throw anError;
261
-return self;
262
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
263
-}, function($ctx1) {$ctx1.fill(self,"basicSignal:",{anError:anError},$globals.RethrowErrorHandler)});
264
-//>>excludeEnd("ctx");
265
-},
266
-//>>excludeStart("ide", pragmas.excludeIdeData);
267
-args: ["anError"],
268
-source: "basicSignal: anError\x0a        <throw anError>",
269
-referencedClasses: [],
270
-//>>excludeEnd("ide");
271
-messageSends: []
272
-}),
273
-$globals.RethrowErrorHandler);
274
-
275
-$core.addMethod(
276
-$core.method({
277
-selector: "handleError:",
278
-protocol: 'error handling',
279
-fn: function (anError){
280
-var self=this;
281
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
282
-return $core.withContext(function($ctx1) {
283
-//>>excludeEnd("ctx");
284
-self._basicSignal_(anError);
285
-return self;
286
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
287
-}, function($ctx1) {$ctx1.fill(self,"handleError:",{anError:anError},$globals.RethrowErrorHandler)});
288
-//>>excludeEnd("ctx");
289
-},
290
-//>>excludeStart("ide", pragmas.excludeIdeData);
291
-args: ["anError"],
292
-source: "handleError: anError\x0a        self basicSignal: anError",
293
-referencedClasses: [],
294
-//>>excludeEnd("ide");
295
-messageSends: ["basicSignal:"]
296
-}),
297
-$globals.RethrowErrorHandler);
298
-
299
-
300
-});

+ 0 - 109
src/Compiler-Exceptions.st

@@ -1,109 +0,0 @@
1
-Smalltalk createPackage: 'Compiler-Exceptions'!
2
-Error subclass: #CompilerError
3
-	instanceVariableNames: ''
4
-	package: 'Compiler-Exceptions'!
5
-!CompilerError commentStamp!
6
-I am the common superclass of all compiling errors.!
7
-
8
-CompilerError subclass: #ParseError
9
-	instanceVariableNames: ''
10
-	package: 'Compiler-Exceptions'!
11
-!ParseError commentStamp!
12
-Instance of ParseError are signaled on any parsing error.
13
-See `Smalltalk >> #parse:`!
14
-
15
-CompilerError subclass: #SemanticError
16
-	instanceVariableNames: ''
17
-	package: 'Compiler-Exceptions'!
18
-!SemanticError commentStamp!
19
-I represent an abstract semantic error thrown by the SemanticAnalyzer.
20
-Semantic errors can be unknown variable errors, etc.
21
-See my subclasses for concrete errors.
22
-
23
-The IDE should catch instances of Semantic error to deal with them when compiling!
24
-
25
-SemanticError subclass: #InliningError
26
-	instanceVariableNames: ''
27
-	package: 'Compiler-Exceptions'!
28
-!InliningError commentStamp!
29
-Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.!
30
-
31
-SemanticError subclass: #InvalidAssignmentError
32
-	instanceVariableNames: 'variableName'
33
-	package: 'Compiler-Exceptions'!
34
-!InvalidAssignmentError commentStamp!
35
-I get signaled when a pseudo variable gets assigned.!
36
-
37
-!InvalidAssignmentError methodsFor: 'accessing'!
38
-
39
-messageText
40
-	^ ' Invalid assignment to variable: ', self variableName
41
-!
42
-
43
-variableName
44
-	^ variableName
45
-!
46
-
47
-variableName: aString
48
-	variableName := aString
49
-! !
50
-
51
-SemanticError subclass: #ShadowingVariableError
52
-	instanceVariableNames: 'variableName'
53
-	package: 'Compiler-Exceptions'!
54
-!ShadowingVariableError commentStamp!
55
-I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.!
56
-
57
-!ShadowingVariableError methodsFor: 'accessing'!
58
-
59
-messageText
60
-	^ 'Variable shadowing error: ', self variableName, ' is already defined'
61
-!
62
-
63
-variableName
64
-	^ variableName
65
-!
66
-
67
-variableName: aString
68
-	variableName := aString
69
-! !
70
-
71
-SemanticError subclass: #UnknownVariableError
72
-	instanceVariableNames: 'variableName'
73
-	package: 'Compiler-Exceptions'!
74
-!UnknownVariableError commentStamp!
75
-I get signaled when a variable is not defined.
76
-The default behavior is to allow it, as this is how Amber currently is able to seamlessly send messages to JavaScript objects.!
77
-
78
-!UnknownVariableError methodsFor: 'accessing'!
79
-
80
-messageText
81
-	^ 'Unknown Variable error: ', self variableName, ' is not defined'
82
-!
83
-
84
-variableName
85
-	^ variableName
86
-!
87
-
88
-variableName: aString
89
-	variableName := aString
90
-! !
91
-
92
-Object subclass: #RethrowErrorHandler
93
-	instanceVariableNames: ''
94
-	package: 'Compiler-Exceptions'!
95
-!RethrowErrorHandler commentStamp!
96
-This class is used in the commandline version of the compiler.
97
-It uses the handleError: message of ErrorHandler for printing the stacktrace and throws the error again as JS exception.
98
-As a result Smalltalk errors are not swallowd by the Amber runtime and compilation can be aborted.!
99
-
100
-!RethrowErrorHandler methodsFor: 'error handling'!
101
-
102
-basicSignal: anError
103
-        <throw anError>
104
-!
105
-
106
-handleError: anError
107
-        self basicSignal: anError
108
-! !
109
-

+ 1 - 1
src/Compiler-IR.js

@@ -1,4 +1,4 @@
1
-define("amber_core/Compiler-IR", ["amber/boot", "amber_core/Compiler-Core", "amber_core/Kernel-Objects", "amber_core/Kernel-Methods"], function($boot){"use strict";
1
+define("amber_core/Compiler-IR", ["amber/boot", "amber_core/Compiler-AST", "amber_core/Kernel-Objects", "amber_core/Kernel-Methods"], function($boot){"use strict";
2 2
 var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
3 3
 $core.addPackage('Compiler-IR');
4 4
 $core.packages["Compiler-IR"].innerEval = function (expr) { return eval(expr); };

+ 7 - 1
src/Compiler-Inlining.js

@@ -1,4 +1,4 @@
1
-define("amber_core/Compiler-Inlining", ["amber/boot", "amber_core/Compiler-IR", "amber_core/Kernel-Objects", "amber_core/Compiler-Core"], function($boot){"use strict";
1
+define("amber_core/Compiler-Inlining", ["amber/boot", "amber_core/Compiler-IR", "amber_core/Kernel-Objects", "amber_core/Compiler-Core", "amber_core/Compiler-Semantic"], function($boot){"use strict";
2 2
 var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
3 3
 $core.addPackage('Compiler-Inlining');
4 4
 $core.packages["Compiler-Inlining"].innerEval = function (expr) { return eval(expr); };
@@ -2615,4 +2615,10 @@ messageSends: ["new"]
2615 2615
 $globals.InliningCodeGenerator);
2616 2616
 
2617 2617
 
2618
+
2619
+$core.addClass('InliningError', $globals.SemanticError, [], 'Compiler-Inlining');
2620
+//>>excludeStart("ide", pragmas.excludeIdeData);
2621
+$globals.InliningError.comment="Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.";
2622
+//>>excludeEnd("ide");
2623
+
2618 2624
 });

+ 6 - 0
src/Compiler-Inlining.st

@@ -632,3 +632,9 @@ irTranslator
632 632
 	^ IRInliningJSTranslator new
633 633
 ! !
634 634
 
635
+SemanticError subclass: #InliningError
636
+	instanceVariableNames: ''
637
+	package: 'Compiler-Inlining'!
638
+!InliningError commentStamp!
639
+Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.!
640
+

+ 141 - 1
src/Compiler-Interpreter.js

@@ -1,4 +1,4 @@
1
-define("amber_core/Compiler-Interpreter", ["amber/boot", "amber_core/Kernel-Methods", "amber_core/Compiler-Semantic", "amber_core/Kernel-Objects", "amber_core/Compiler-Core", "amber_core/Kernel-Exceptions", "amber_core/Compiler-AST"], function($boot){"use strict";
1
+define("amber_core/Compiler-Interpreter", ["amber/boot", "amber_core/Kernel-Methods", "amber_core/Compiler-Semantic", "amber_core/Kernel-Objects", "amber_core/Compiler-AST", "amber_core/Kernel-Exceptions"], function($boot){"use strict";
2 2
 var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
3 3
 $core.addPackage('Compiler-Interpreter');
4 4
 $core.packages["Compiler-Interpreter"].innerEval = function (expr) { return eval(expr); };
@@ -3772,6 +3772,42 @@ $globals.BlockNode);
3772 3772
 
3773 3773
 $core.addMethod(
3774 3774
 $core.method({
3775
+selector: "nextChild",
3776
+protocol: '*Compiler-Interpreter',
3777
+fn: function (){
3778
+var self=this;
3779
+return self;
3780
+
3781
+},
3782
+//>>excludeStart("ide", pragmas.excludeIdeData);
3783
+args: [],
3784
+source: "nextChild\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
3785
+referencedClasses: [],
3786
+//>>excludeEnd("ide");
3787
+messageSends: []
3788
+}),
3789
+$globals.BlockNode);
3790
+
3791
+$core.addMethod(
3792
+$core.method({
3793
+selector: "nextNode:",
3794
+protocol: '*Compiler-Interpreter',
3795
+fn: function (aNode){
3796
+var self=this;
3797
+return self;
3798
+
3799
+},
3800
+//>>excludeStart("ide", pragmas.excludeIdeData);
3801
+args: ["aNode"],
3802
+source: "nextNode: aNode\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
3803
+referencedClasses: [],
3804
+//>>excludeEnd("ide");
3805
+messageSends: []
3806
+}),
3807
+$globals.BlockNode);
3808
+
3809
+$core.addMethod(
3810
+$core.method({
3775 3811
 selector: "isSteppingNode",
3776 3812
 protocol: '*Compiler-Interpreter',
3777 3813
 fn: function (){
@@ -3844,6 +3880,110 @@ $globals.Node);
3844 3880
 
3845 3881
 $core.addMethod(
3846 3882
 $core.method({
3883
+selector: "nextChild",
3884
+protocol: '*Compiler-Interpreter',
3885
+fn: function (){
3886
+var self=this;
3887
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3888
+return $core.withContext(function($ctx1) {
3889
+//>>excludeEnd("ctx");
3890
+var $3,$2,$1;
3891
+$3=self._nodes();
3892
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3893
+$ctx1.sendIdx["nodes"]=1;
3894
+//>>excludeEnd("ctx");
3895
+$2=$recv($3)._isEmpty();
3896
+if($core.assert($2)){
3897
+$1=self;
3898
+} else {
3899
+$1=$recv($recv(self._nodes())._first())._nextChild();
3900
+};
3901
+return $1;
3902
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3903
+}, function($ctx1) {$ctx1.fill(self,"nextChild",{},$globals.Node)});
3904
+//>>excludeEnd("ctx");
3905
+},
3906
+//>>excludeStart("ide", pragmas.excludeIdeData);
3907
+args: [],
3908
+source: "nextChild\x0a\x09\x22Answer the next node after aNode.\x0a\x09Recurse into the possible children of the receiver to answer the next node to be evaluated\x22\x0a\x09\x0a\x09^ self nodes isEmpty\x0a\x09\x09ifTrue: [ self ]\x0a\x09\x09ifFalse: [ self nodes first nextChild ]",
3909
+referencedClasses: [],
3910
+//>>excludeEnd("ide");
3911
+messageSends: ["ifTrue:ifFalse:", "isEmpty", "nodes", "nextChild", "first"]
3912
+}),
3913
+$globals.Node);
3914
+
3915
+$core.addMethod(
3916
+$core.method({
3917
+selector: "nextNode",
3918
+protocol: '*Compiler-Interpreter',
3919
+fn: function (){
3920
+var self=this;
3921
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3922
+return $core.withContext(function($ctx1) {
3923
+//>>excludeEnd("ctx");
3924
+var $2,$1,$receiver;
3925
+$2=self._parent();
3926
+if(($receiver = $2) == null || $receiver.isNil){
3927
+$1=$2;
3928
+} else {
3929
+var node;
3930
+node=$receiver;
3931
+$1=$recv(node)._nextNode_(self);
3932
+};
3933
+return $1;
3934
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3935
+}, function($ctx1) {$ctx1.fill(self,"nextNode",{},$globals.Node)});
3936
+//>>excludeEnd("ctx");
3937
+},
3938
+//>>excludeStart("ide", pragmas.excludeIdeData);
3939
+args: [],
3940
+source: "nextNode\x0a\x09^ self parent ifNotNil: [ :node |\x0a\x09\x09node nextNode: self ]",
3941
+referencedClasses: [],
3942
+//>>excludeEnd("ide");
3943
+messageSends: ["ifNotNil:", "parent", "nextNode:"]
3944
+}),
3945
+$globals.Node);
3946
+
3947
+$core.addMethod(
3948
+$core.method({
3949
+selector: "nextNode:",
3950
+protocol: '*Compiler-Interpreter',
3951
+fn: function (aNode){
3952
+var self=this;
3953
+var next;
3954
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3955
+return $core.withContext(function($ctx1) {
3956
+//>>excludeEnd("ctx");
3957
+var $1,$2;
3958
+var $early={};
3959
+try {
3960
+$1=self._nodes();
3961
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3962
+$ctx1.sendIdx["nodes"]=1;
3963
+//>>excludeEnd("ctx");
3964
+next=$recv($1)._at_ifAbsent_($recv($recv(self._nodes())._indexOf_(aNode)).__plus((1)),(function(){
3965
+throw $early=[self];
3966
+
3967
+}));
3968
+$2=$recv(next)._nextChild();
3969
+return $2;
3970
+}
3971
+catch(e) {if(e===$early)return e[0]; throw e}
3972
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3973
+}, function($ctx1) {$ctx1.fill(self,"nextNode:",{aNode:aNode,next:next},$globals.Node)});
3974
+//>>excludeEnd("ctx");
3975
+},
3976
+//>>excludeStart("ide", pragmas.excludeIdeData);
3977
+args: ["aNode"],
3978
+source: "nextNode: aNode\x0a\x09\x22Answer the next node after aNode.\x0a\x09Recurse into the possible children of the next node to answer the next node to be evaluated\x22\x0a\x09\x0a\x09| next |\x0a\x09\x0a\x09next := self nodes \x0a\x09\x09at: (self nodes indexOf: aNode) + 1\x0a\x09\x09ifAbsent: [ ^ self ].\x0a\x09\x0a\x09^ next nextChild",
3979
+referencedClasses: [],
3980
+//>>excludeEnd("ide");
3981
+messageSends: ["at:ifAbsent:", "nodes", "+", "indexOf:", "nextChild"]
3982
+}),
3983
+$globals.Node);
3984
+
3985
+$core.addMethod(
3986
+$core.method({
3847 3987
 selector: "isSteppingNode",
3848 3988
 protocol: '*Compiler-Interpreter',
3849 3989
 fn: function (){

+ 39 - 0
src/Compiler-Interpreter.st

@@ -941,6 +941,18 @@ isSteppingNode
941 941
 
942 942
 isSteppingNode
943 943
 	^ true
944
+!
945
+
946
+nextChild
947
+	"Answer the receiver as we want to avoid eager evaluation"
948
+	
949
+	^ self
950
+!
951
+
952
+nextNode: aNode
953
+	"Answer the receiver as we want to avoid eager evaluation"
954
+	
955
+	^ self
944 956
 ! !
945 957
 
946 958
 !DynamicArrayNode methodsFor: '*Compiler-Interpreter'!
@@ -965,6 +977,33 @@ isSteppingNode
965 977
 
966 978
 isSteppingNode
967 979
 	^ false
980
+!
981
+
982
+nextChild
983
+	"Answer the next node after aNode.
984
+	Recurse into the possible children of the receiver to answer the next node to be evaluated"
985
+	
986
+	^ self nodes isEmpty
987
+		ifTrue: [ self ]
988
+		ifFalse: [ self nodes first nextChild ]
989
+!
990
+
991
+nextNode
992
+	^ self parent ifNotNil: [ :node |
993
+		node nextNode: self ]
994
+!
995
+
996
+nextNode: aNode
997
+	"Answer the next node after aNode.
998
+	Recurse into the possible children of the next node to answer the next node to be evaluated"
999
+	
1000
+	| next |
1001
+	
1002
+	next := self nodes 
1003
+		at: (self nodes indexOf: aNode) + 1
1004
+		ifAbsent: [ ^ self ].
1005
+	
1006
+	^ next nextChild
968 1007
 ! !
969 1008
 
970 1009
 !SendNode methodsFor: '*Compiler-Interpreter'!

+ 223 - 1
src/Compiler-Semantic.js

@@ -1,4 +1,4 @@
1
-define("amber_core/Compiler-Semantic", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Compiler-Core"], function($boot){"use strict";
1
+define("amber_core/Compiler-Semantic", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Compiler-AST", "amber_core/Compiler-Core"], function($boot){"use strict";
2 2
 var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
3 3
 $core.addPackage('Compiler-Semantic');
4 4
 $core.packages["Compiler-Semantic"].innerEval = function (expr) { return eval(expr); };
@@ -2762,4 +2762,226 @@ messageSends: ["theClass:", "new", "yourself"]
2762 2762
 }),
2763 2763
 $globals.SemanticAnalyzer.klass);
2764 2764
 
2765
+
2766
+$core.addClass('SemanticError', $globals.CompilerError, [], 'Compiler-Semantic');
2767
+//>>excludeStart("ide", pragmas.excludeIdeData);
2768
+$globals.SemanticError.comment="I represent an abstract semantic error thrown by the SemanticAnalyzer.\x0aSemantic errors can be unknown variable errors, etc.\x0aSee my subclasses for concrete errors.\x0a\x0aThe IDE should catch instances of Semantic error to deal with them when compiling";
2769
+//>>excludeEnd("ide");
2770
+
2771
+
2772
+$core.addClass('InvalidAssignmentError', $globals.SemanticError, ['variableName'], 'Compiler-Semantic');
2773
+//>>excludeStart("ide", pragmas.excludeIdeData);
2774
+$globals.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned.";
2775
+//>>excludeEnd("ide");
2776
+$core.addMethod(
2777
+$core.method({
2778
+selector: "messageText",
2779
+protocol: 'accessing',
2780
+fn: function (){
2781
+var self=this;
2782
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
2783
+return $core.withContext(function($ctx1) {
2784
+//>>excludeEnd("ctx");
2785
+var $1;
2786
+$1=" Invalid assignment to variable: ".__comma(self._variableName());
2787
+return $1;
2788
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
2789
+}, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.InvalidAssignmentError)});
2790
+//>>excludeEnd("ctx");
2791
+},
2792
+//>>excludeStart("ide", pragmas.excludeIdeData);
2793
+args: [],
2794
+source: "messageText\x0a\x09^ ' Invalid assignment to variable: ', self variableName",
2795
+referencedClasses: [],
2796
+//>>excludeEnd("ide");
2797
+messageSends: [",", "variableName"]
2798
+}),
2799
+$globals.InvalidAssignmentError);
2800
+
2801
+$core.addMethod(
2802
+$core.method({
2803
+selector: "variableName",
2804
+protocol: 'accessing',
2805
+fn: function (){
2806
+var self=this;
2807
+var $1;
2808
+$1=self["@variableName"];
2809
+return $1;
2810
+
2811
+},
2812
+//>>excludeStart("ide", pragmas.excludeIdeData);
2813
+args: [],
2814
+source: "variableName\x0a\x09^ variableName",
2815
+referencedClasses: [],
2816
+//>>excludeEnd("ide");
2817
+messageSends: []
2818
+}),
2819
+$globals.InvalidAssignmentError);
2820
+
2821
+$core.addMethod(
2822
+$core.method({
2823
+selector: "variableName:",
2824
+protocol: 'accessing',
2825
+fn: function (aString){
2826
+var self=this;
2827
+self["@variableName"]=aString;
2828
+return self;
2829
+
2830
+},
2831
+//>>excludeStart("ide", pragmas.excludeIdeData);
2832
+args: ["aString"],
2833
+source: "variableName: aString\x0a\x09variableName := aString",
2834
+referencedClasses: [],
2835
+//>>excludeEnd("ide");
2836
+messageSends: []
2837
+}),
2838
+$globals.InvalidAssignmentError);
2839
+
2840
+
2841
+
2842
+$core.addClass('ShadowingVariableError', $globals.SemanticError, ['variableName'], 'Compiler-Semantic');
2843
+//>>excludeStart("ide", pragmas.excludeIdeData);
2844
+$globals.ShadowingVariableError.comment="I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.";
2845
+//>>excludeEnd("ide");
2846
+$core.addMethod(
2847
+$core.method({
2848
+selector: "messageText",
2849
+protocol: 'accessing',
2850
+fn: function (){
2851
+var self=this;
2852
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
2853
+return $core.withContext(function($ctx1) {
2854
+//>>excludeEnd("ctx");
2855
+var $1;
2856
+$1=$recv("Variable shadowing error: ".__comma(self._variableName())).__comma(" is already defined");
2857
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
2858
+$ctx1.sendIdx[","]=1;
2859
+//>>excludeEnd("ctx");
2860
+return $1;
2861
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
2862
+}, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.ShadowingVariableError)});
2863
+//>>excludeEnd("ctx");
2864
+},
2865
+//>>excludeStart("ide", pragmas.excludeIdeData);
2866
+args: [],
2867
+source: "messageText\x0a\x09^ 'Variable shadowing error: ', self variableName, ' is already defined'",
2868
+referencedClasses: [],
2869
+//>>excludeEnd("ide");
2870
+messageSends: [",", "variableName"]
2871
+}),
2872
+$globals.ShadowingVariableError);
2873
+
2874
+$core.addMethod(
2875
+$core.method({
2876
+selector: "variableName",
2877
+protocol: 'accessing',
2878
+fn: function (){
2879
+var self=this;
2880
+var $1;
2881
+$1=self["@variableName"];
2882
+return $1;
2883
+
2884
+},
2885
+//>>excludeStart("ide", pragmas.excludeIdeData);
2886
+args: [],
2887
+source: "variableName\x0a\x09^ variableName",
2888
+referencedClasses: [],
2889
+//>>excludeEnd("ide");
2890
+messageSends: []
2891
+}),
2892
+$globals.ShadowingVariableError);
2893
+
2894
+$core.addMethod(
2895
+$core.method({
2896
+selector: "variableName:",
2897
+protocol: 'accessing',
2898
+fn: function (aString){
2899
+var self=this;
2900
+self["@variableName"]=aString;
2901
+return self;
2902
+
2903
+},
2904
+//>>excludeStart("ide", pragmas.excludeIdeData);
2905
+args: ["aString"],
2906
+source: "variableName: aString\x0a\x09variableName := aString",
2907
+referencedClasses: [],
2908
+//>>excludeEnd("ide");
2909
+messageSends: []
2910
+}),
2911
+$globals.ShadowingVariableError);
2912
+
2913
+
2914
+
2915
+$core.addClass('UnknownVariableError', $globals.SemanticError, ['variableName'], 'Compiler-Semantic');
2916
+//>>excludeStart("ide", pragmas.excludeIdeData);
2917
+$globals.UnknownVariableError.comment="I get signaled when a variable is not defined.\x0aThe default behavior is to allow it, as this is how Amber currently is able to seamlessly send messages to JavaScript objects.";
2918
+//>>excludeEnd("ide");
2919
+$core.addMethod(
2920
+$core.method({
2921
+selector: "messageText",
2922
+protocol: 'accessing',
2923
+fn: function (){
2924
+var self=this;
2925
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
2926
+return $core.withContext(function($ctx1) {
2927
+//>>excludeEnd("ctx");
2928
+var $1;
2929
+$1=$recv("Unknown Variable error: ".__comma(self._variableName())).__comma(" is not defined");
2930
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
2931
+$ctx1.sendIdx[","]=1;
2932
+//>>excludeEnd("ctx");
2933
+return $1;
2934
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
2935
+}, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.UnknownVariableError)});
2936
+//>>excludeEnd("ctx");
2937
+},
2938
+//>>excludeStart("ide", pragmas.excludeIdeData);
2939
+args: [],
2940
+source: "messageText\x0a\x09^ 'Unknown Variable error: ', self variableName, ' is not defined'",
2941
+referencedClasses: [],
2942
+//>>excludeEnd("ide");
2943
+messageSends: [",", "variableName"]
2944
+}),
2945
+$globals.UnknownVariableError);
2946
+
2947
+$core.addMethod(
2948
+$core.method({
2949
+selector: "variableName",
2950
+protocol: 'accessing',
2951
+fn: function (){
2952
+var self=this;
2953
+var $1;
2954
+$1=self["@variableName"];
2955
+return $1;
2956
+
2957
+},
2958
+//>>excludeStart("ide", pragmas.excludeIdeData);
2959
+args: [],
2960
+source: "variableName\x0a\x09^ variableName",
2961
+referencedClasses: [],
2962
+//>>excludeEnd("ide");
2963
+messageSends: []
2964
+}),
2965
+$globals.UnknownVariableError);
2966
+
2967
+$core.addMethod(
2968
+$core.method({
2969
+selector: "variableName:",
2970
+protocol: 'accessing',
2971
+fn: function (aString){
2972
+var self=this;
2973
+self["@variableName"]=aString;
2974
+return self;
2975
+
2976
+},
2977
+//>>excludeStart("ide", pragmas.excludeIdeData);
2978
+args: ["aString"],
2979
+source: "variableName: aString\x0a\x09variableName := aString",
2980
+referencedClasses: [],
2981
+//>>excludeEnd("ide");
2982
+messageSends: []
2983
+}),
2984
+$globals.UnknownVariableError);
2985
+
2986
+
2765 2987
 });

+ 71 - 0
src/Compiler-Semantic.st

@@ -638,3 +638,74 @@ on: aClass
638 638
 		yourself
639 639
 ! !
640 640
 
641
+CompilerError subclass: #SemanticError
642
+	instanceVariableNames: ''
643
+	package: 'Compiler-Semantic'!
644
+!SemanticError commentStamp!
645
+I represent an abstract semantic error thrown by the SemanticAnalyzer.
646
+Semantic errors can be unknown variable errors, etc.
647
+See my subclasses for concrete errors.
648
+
649
+The IDE should catch instances of Semantic error to deal with them when compiling!
650
+
651
+SemanticError subclass: #InvalidAssignmentError
652
+	instanceVariableNames: 'variableName'
653
+	package: 'Compiler-Semantic'!
654
+!InvalidAssignmentError commentStamp!
655
+I get signaled when a pseudo variable gets assigned.!
656
+
657
+!InvalidAssignmentError methodsFor: 'accessing'!
658
+
659
+messageText
660
+	^ ' Invalid assignment to variable: ', self variableName
661
+!
662
+
663
+variableName
664
+	^ variableName
665
+!
666
+
667
+variableName: aString
668
+	variableName := aString
669
+! !
670
+
671
+SemanticError subclass: #ShadowingVariableError
672
+	instanceVariableNames: 'variableName'
673
+	package: 'Compiler-Semantic'!
674
+!ShadowingVariableError commentStamp!
675
+I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.!
676
+
677
+!ShadowingVariableError methodsFor: 'accessing'!
678
+
679
+messageText
680
+	^ 'Variable shadowing error: ', self variableName, ' is already defined'
681
+!
682
+
683
+variableName
684
+	^ variableName
685
+!
686
+
687
+variableName: aString
688
+	variableName := aString
689
+! !
690
+
691
+SemanticError subclass: #UnknownVariableError
692
+	instanceVariableNames: 'variableName'
693
+	package: 'Compiler-Semantic'!
694
+!UnknownVariableError commentStamp!
695
+I get signaled when a variable is not defined.
696
+The default behavior is to allow it, as this is how Amber currently is able to seamlessly send messages to JavaScript objects.!
697
+
698
+!UnknownVariableError methodsFor: 'accessing'!
699
+
700
+messageText
701
+	^ 'Unknown Variable error: ', self variableName, ' is not defined'
702
+!
703
+
704
+variableName
705
+	^ variableName
706
+!
707
+
708
+variableName: aString
709
+	variableName := aString
710
+! !
711
+

File diff suppressed because it is too large
+ 61 - 1
src/Kernel-Infrastructure.js


+ 25 - 0
src/Kernel-Infrastructure.st

@@ -596,6 +596,31 @@ initialize
596 596
 	self current observeSystem
597 597
 ! !
598 598
 
599
+Error subclass: #ParseError
600
+	instanceVariableNames: ''
601
+	package: 'Kernel-Infrastructure'!
602
+!ParseError commentStamp!
603
+Instance of ParseError are signaled on any parsing error.
604
+See `Smalltalk >> #parse:`!
605
+
606
+Object subclass: #RethrowErrorHandler
607
+	instanceVariableNames: ''
608
+	package: 'Kernel-Infrastructure'!
609
+!RethrowErrorHandler commentStamp!
610
+This class is used in the commandline version of the compiler.
611
+It uses the handleError: message of ErrorHandler for printing the stacktrace and throws the error again as JS exception.
612
+As a result Smalltalk errors are not swallowd by the Amber runtime and compilation can be aborted.!
613
+
614
+!RethrowErrorHandler methodsFor: 'error handling'!
615
+
616
+basicSignal: anError
617
+        <throw anError>
618
+!
619
+
620
+handleError: anError
621
+        self basicSignal: anError
622
+! !
623
+
599 624
 Object subclass: #Setting
600 625
 	instanceVariableNames: 'key value defaultValue'
601 626
 	package: 'Kernel-Infrastructure'!

+ 0 - 1
support/lang.js

@@ -4,7 +4,6 @@ define([
4 4
 	'./parser',
5 5
 	// --- packages for the Amber reflection begin here ---
6 6
 	'amber_core/Platform-ImportExport',
7
-	'amber_core/Compiler-Exceptions',
8 7
 	'amber_core/Compiler-Core',
9 8
 	'amber_core/Compiler-AST',
10 9
 	'amber_core/Compiler-Semantic',