equal
deleted
inserted
replaced
301 initialize |
301 initialize |
302 "Invoked when a new instance is created." |
302 "Invoked when a new instance is created." |
303 |
303 |
304 sends := Dictionary new. |
304 sends := Dictionary new. |
305 types := Dictionary new. |
305 types := Dictionary new. |
306 |
306 |
307 "/ super initialize. -- commented since inherited method does nothing |
307 "/ super initialize. -- commented since inherited method does nothing |
308 |
308 |
309 "Modified: / 26-11-2011 / 19:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
309 "Modified: / 26-11-2011 / 19:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
310 "Modified: / 14-07-2017 / 12:57:55 / cg" |
310 ! ! |
311 ! ! |
311 |
312 |
312 !SmalltalkInferencer::Phase1 methodsFor:'private'! |
313 !SmalltalkInferencer::Phase1 methodsFor:'private'! |
313 |
314 |
314 rootsUnderstanding: selectors |
315 rootsUnderstanding: selectors |
437 expression := anObject expression. |
438 expression := anObject expression. |
438 |
439 |
439 self visit: variable. |
440 self visit: variable. |
440 self visit: expression. |
441 self visit: expression. |
441 type := expression inferedType type. |
442 type := expression inferedType type. |
|
443 |
442 type isUnknownType ifFalse:[ |
444 type isUnknownType ifFalse:[ |
443 variable inferedType union: type |
445 variable inferedType union: type. |
|
446 "/ cg: the node may be used as another expr-node; |
|
447 "/ eg. in: foo := bar := 123, |
|
448 "/ the expr of the foo assignment should have type info too. |
|
449 anObject inferedType: type. |
444 ]. |
450 ]. |
445 |
451 |
446 "Created: / 26-11-2011 / 13:53:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
452 "Created: / 26-11-2011 / 13:53:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
447 "Modified: / 18-09-2013 / 02:31:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
453 "Modified: / 18-09-2013 / 02:31:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
454 "Modified: / 14-07-2017 / 13:39:27 / cg" |
448 ! |
455 ! |
449 |
456 |
450 visitBlockNode:anObject |
457 visitBlockNode:anObject |
451 | type | |
458 | type | |
452 |
459 |
462 "Type of a constant is trivially its value class" |
469 "Type of a constant is trivially its value class" |
463 |
470 |
464 | type | |
471 | type | |
465 |
472 |
466 super visitConstantNode: anObject. |
473 super visitConstantNode: anObject. |
467 type := (Type withClass: anObject value class). |
474 |
|
475 type := Type withClass:(anObject value class). |
468 type trustfullness: 100. |
476 type trustfullness: 100. |
469 anObject inferedType: type. |
477 anObject inferedType: type. |
470 |
478 |
471 "Created: / 26-11-2011 / 13:55:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
479 "Created: / 26-11-2011 / 13:55:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
480 "Modified: / 14-07-2017 / 13:33:16 / cg" |
472 ! |
481 ! |
473 |
482 |
474 visitMessageNode:anObject |
483 visitMessageNode:anObject |
475 |
484 |
476 | rec | |
485 | rec | |
500 ] on: Error do:[ |
509 ] on: Error do:[ |
501 "/pass |
510 "/pass |
502 ] |
511 ] |
503 ] |
512 ] |
504 ]. |
513 ]. |
|
514 "/ |
|
515 "/ ( #( new basicNew new: basicNew: ) includes:anObject selector) ifTrue:[ |
|
516 "/ |classOrNil| |
|
517 "/ |
|
518 "/ (classOrNil := Smalltalk classNamed:rec name) notNil ifTrue:[ |
|
519 "/ classOrNil isBehavior ifTrue:[ |
|
520 "/ anObject inferedType:((Type withClass: classOrNil) trustfullness: 99) |
|
521 "/ ]. |
|
522 "/ ]. |
|
523 "/ ]. |
|
524 |
505 ] ifFalse:[ |
525 ] ifFalse:[ |
506 (sends at: rec name ifAbsentPut:[Set new]) add: anObject selector. |
526 (sends at: rec name ifAbsentPut:[Set new]) add: anObject selector. |
507 ]. |
527 ]. |
508 ]. |
528 ]. |
509 |
529 |
510 "Created: / 26-11-2011 / 13:02:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
530 "Created: / 26-11-2011 / 13:02:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
511 "Modified: / 04-10-2013 / 07:56:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
531 "Modified: / 04-10-2013 / 07:56:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
532 "Modified: / 14-07-2017 / 13:18:39 / cg" |
512 ! |
533 ! |
513 |
534 |
514 visitSelfNode:anObject |
535 visitSelfNode:anObject |
515 | type | |
536 | type | |
516 |
537 |
637 (#(#new #basicNew #new: #basicNew:) includes: selector) ifTrue:[ |
658 (#(#new #basicNew #new: #basicNew:) includes: selector) ifTrue:[ |
638 | rec type | |
659 | rec type | |
639 rec := aMessageNode receiver. |
660 rec := aMessageNode receiver. |
640 (rec isSelf and:[class isMetaclass]) ifTrue:[ |
661 (rec isSelf and:[class isMetaclass]) ifTrue:[ |
641 type := Type withClass: class theNonMetaclass. |
662 type := Type withClass: class theNonMetaclass. |
642 type trustfullnessAdd: 50. |
663 type trustfullnessAdd: 99. |
643 aMessageNode inferedType: type. |
664 aMessageNode inferedType: type. |
644 ^self. |
665 ^self. |
645 ]. |
666 ]. |
646 type := aMessageNode receiver inferedType instanceSide. |
667 type := aMessageNode receiver inferedType instanceSide. |
647 aMessageNode inferedType: type. |
668 aMessageNode inferedType: type. |
648 ^self. |
669 ^self. |
649 ]. |
670 ]. |
650 |
671 |
651 "Created: / 05-08-2014 / 14:03:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
672 "Created: / 05-08-2014 / 14:03:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
652 "Modified: / 26-09-2014 / 11:20:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
673 "Modified: / 26-09-2014 / 11:20:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
674 "Modified: / 14-07-2017 / 13:19:27 / cg" |
653 ! |
675 ! |
654 |
676 |
655 visitUnaryNode:anObject |
677 visitUnaryNode:anObject |
656 |
678 |
657 | type sel rec classes javaClass javaNamespace javaVM| |
679 | type sel rec classes javaClass javaNamespace javaVM| |
670 "/ #new / #basicNew: conventionally returns an instance of the class, if receiver is a class. |
692 "/ #new / #basicNew: conventionally returns an instance of the class, if receiver is a class. |
671 (sel == #new or:[sel == #basicNew]) ifTrue:[ |
693 (sel == #new or:[sel == #basicNew]) ifTrue:[ |
672 rec := anObject receiver. |
694 rec := anObject receiver. |
673 (rec isSelf and:[class isMetaclass]) ifTrue:[ |
695 (rec isSelf and:[class isMetaclass]) ifTrue:[ |
674 type := Type withClass: class theNonMetaclass. |
696 type := Type withClass: class theNonMetaclass. |
675 type trustfullnessAdd: 50. |
697 type trustfullnessAdd: 99. |
676 anObject inferedType: type. |
698 anObject inferedType: type. |
677 ^self. |
699 ^self. |
678 ]. |
700 ]. |
679 |
701 |
680 type := anObject receiver inferedType instanceSide. |
702 type := anObject receiver inferedType instanceSide. |
715 ]. |
737 ]. |
716 |
738 |
717 "Created: / 27-11-2011 / 15:49:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
739 "Created: / 27-11-2011 / 15:49:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
718 "Modified: / 08-10-2013 / 11:07:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
740 "Modified: / 08-10-2013 / 11:07:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
719 "Modified (comment): / 05-08-2014 / 13:56:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
741 "Modified (comment): / 05-08-2014 / 13:56:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
720 "Modified: / 22-06-2017 / 06:54:21 / cg" |
742 "Modified: / 14-07-2017 / 13:19:15 / cg" |
721 ! ! |
743 ! ! |
722 |
744 |
723 !SmalltalkInferencer::Phase3 class methodsFor:'documentation'! |
745 !SmalltalkInferencer::Phase3 class methodsFor:'documentation'! |
724 |
746 |
725 documentation |
747 documentation |