LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include <u.h> | 5 #include <u.h> |
6 #include <libc.h> | 6 #include <libc.h> |
7 #include "go.h" | 7 #include "go.h" |
8 #include "../../pkg/runtime/mgc0.h" | 8 #include "../../pkg/runtime/mgc0.h" |
9 | 9 |
10 /* | 10 /* |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // make list of methods for t, | 165 // make list of methods for t, |
166 // generating code if necessary. | 166 // generating code if necessary. |
167 a = nil; | 167 a = nil; |
168 for(f=mt->xmethod; f; f=f->down) { | 168 for(f=mt->xmethod; f; f=f->down) { |
169 if(f->etype != TFIELD) | 169 if(f->etype != TFIELD) |
170 fatal("methods: not field %T", f); | 170 fatal("methods: not field %T", f); |
171 if (f->type->etype != TFUNC || f->type->thistuple == 0) | 171 if (f->type->etype != TFUNC || f->type->thistuple == 0) |
172 fatal("non-method on %T method %S %T\n", mt, f->sym, f); | 172 fatal("non-method on %T method %S %T\n", mt, f->sym, f); |
173 if (!getthisx(f->type)->type) | 173 if (!getthisx(f->type)->type) |
174 fatal("receiver with no type on %T method %S %T\n", mt,
f->sym, f); | 174 fatal("receiver with no type on %T method %S %T\n", mt,
f->sym, f); |
| 175 if(f->nointerface) |
| 176 continue; |
175 | 177 |
176 method = f->sym; | 178 method = f->sym; |
177 if(method == nil) | 179 if(method == nil) |
178 continue; | 180 continue; |
179 | 181 |
180 // get receiver type for this particular method. | 182 // get receiver type for this particular method. |
181 // if pointer receiver but non-pointer t and | 183 // if pointer receiver but non-pointer t and |
182 // this is not an embedded pointer inside a struct, | 184 // this is not an embedded pointer inside a struct, |
183 // method does not apply. | 185 // method does not apply. |
184 this = getthisx(f->type)->type->type; | 186 this = getthisx(f->type)->type->type; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 [TSTRUCT] = KindStruct, | 459 [TSTRUCT] = KindStruct, |
458 [TINTER] = KindInterface, | 460 [TINTER] = KindInterface, |
459 [TCHAN] = KindChan, | 461 [TCHAN] = KindChan, |
460 [TMAP] = KindMap, | 462 [TMAP] = KindMap, |
461 [TARRAY] = KindArray, | 463 [TARRAY] = KindArray, |
462 [TFUNC] = KindFunc, | 464 [TFUNC] = KindFunc, |
463 [TCOMPLEX64] = KindComplex64, | 465 [TCOMPLEX64] = KindComplex64, |
464 [TCOMPLEX128] = KindComplex128, | 466 [TCOMPLEX128] = KindComplex128, |
465 [TUNSAFEPTR] = KindUnsafePointer, | 467 [TUNSAFEPTR] = KindUnsafePointer, |
466 }; | 468 }; |
467 | |
468 static Sym* | |
469 typestruct(Type *t) | |
470 { | |
471 // We use a weak reference to the reflect type | |
472 // to avoid requiring package reflect in every binary. | |
473 // If package reflect is available, the interface{} holding | |
474 // a runtime type will contain a *reflect.commonType. | |
475 // Otherwise it will use a nil type word but still be usable | |
476 // by package runtime (because we always use the memory | |
477 // after the interface value, not the interface value itself). | |
478 USED(t); | |
479 return pkglookup("*reflect.commonType", weaktypepkg); | |
480 } | |
481 | 469 |
482 int | 470 int |
483 haspointers(Type *t) | 471 haspointers(Type *t) |
484 { | 472 { |
485 Type *t1; | 473 Type *t1; |
486 | 474 |
487 switch(t->etype) { | 475 switch(t->etype) { |
488 case TINT: | 476 case TINT: |
489 case TUINT: | 477 case TUINT: |
490 case TINT8: | 478 case TINT8: |
(...skipping 29 matching lines...) Expand all Loading... |
520 default: | 508 default: |
521 return 1; | 509 return 1; |
522 } | 510 } |
523 } | 511 } |
524 | 512 |
525 /* | 513 /* |
526 * commonType | 514 * commonType |
527 * ../../pkg/runtime/type.go:/commonType | 515 * ../../pkg/runtime/type.go:/commonType |
528 */ | 516 */ |
529 static int | 517 static int |
530 dcommontype(Sym *shdr, Sym *s, int ot, Type *t) | 518 dcommontype(Sym *s, int ot, Type *t) |
531 { | 519 { |
532 int i, alg, sizeofAlg; | 520 int i, alg, sizeofAlg; |
533 Sym *sptr, *algsym; | 521 Sym *sptr, *algsym; |
534 static Sym *algarray; | 522 static Sym *algarray; |
535 char *p; | 523 char *p; |
536 ········ | 524 ········ |
537 if(ot != 0) | 525 if(ot != 0) |
538 fatal("dcommontype %d", ot); | 526 fatal("dcommontype %d", ot); |
539 | 527 |
540 sizeofAlg = 4*widthptr; | 528 sizeofAlg = 4*widthptr; |
541 if(algarray == nil) | 529 if(algarray == nil) |
542 algarray = pkglookup("algarray", runtimepkg); | 530 algarray = pkglookup("algarray", runtimepkg); |
543 alg = algtype(t); | 531 alg = algtype(t); |
544 algsym = S; | 532 algsym = S; |
545 if(alg < 0) | 533 if(alg < 0) |
546 algsym = dalgsym(t); | 534 algsym = dalgsym(t); |
547 | 535 |
548 dowidth(t); | 536 dowidth(t); |
549 if(t->sym != nil && !isptr[t->etype]) | 537 if(t->sym != nil && !isptr[t->etype]) |
550 sptr = dtypesym(ptrto(t)); | 538 sptr = dtypesym(ptrto(t)); |
551 else | 539 else |
552 sptr = weaktypesym(ptrto(t)); | 540 sptr = weaktypesym(ptrto(t)); |
553 | |
554 // empty interface pointing at this type. | |
555 // all the references that we emit are *interface{}; | |
556 // they point here. the header (shdr) points at the | |
557 // data (s). | |
558 dsymptr(shdr, 0, typestruct(t), 0); | |
559 dsymptr(shdr, widthptr, s, 0); | |
560 | 541 |
561 // ../../pkg/reflect/type.go:/^type.commonType | 542 // ../../pkg/reflect/type.go:/^type.commonType |
562 // actual type structure | 543 // actual type structure |
563 // type commonType struct { | 544 // type commonType struct { |
564 // size uintptr | 545 // size uintptr |
565 // hash uint32 | 546 // hash uint32 |
566 // _ uint8 | 547 // _ uint8 |
567 // align uint8 | 548 // align uint8 |
568 // fieldAlign uint8 | 549 // fieldAlign uint8 |
569 // kind uint8 | 550 // kind uint8 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 Sym *s; | 600 Sym *s; |
620 | 601 |
621 p = smprint("%-T", t); | 602 p = smprint("%-T", t); |
622 s = pkglookup(p, typepkg); | 603 s = pkglookup(p, typepkg); |
623 //print("typesym: %s -> %+S\n", p, s); | 604 //print("typesym: %s -> %+S\n", p, s); |
624 free(p); | 605 free(p); |
625 return s; | 606 return s; |
626 } | 607 } |
627 | 608 |
628 Sym* | 609 Sym* |
629 typedatasym(Type *t) | 610 tracksym(Type *t) |
630 { | 611 { |
631 char *p; | 612 char *p; |
632 Sym *s; | 613 Sym *s; |
633 | 614 |
634 » p = smprint("%-T", t); | 615 » p = smprint("%-T.%s", t->outer, t->sym->name); |
635 » s = pkglookup(p, typedatapkg); | 616 » s = pkglookup(p, trackpkg); |
636 » //print("typedatasym: %s -> %+S\n", p, s); | 617 » free(p); |
| 618 » return s; |
| 619 } |
| 620 |
| 621 Sym* |
| 622 typelinksym(Type *t) |
| 623 { |
| 624 » char *p; |
| 625 » Sym *s; |
| 626 |
| 627 » // %-uT is what the generated Type's string field says. |
| 628 » // It uses (ambiguous) package names instead of import paths. |
| 629 » // %-T is the complete, unambiguous type name. |
| 630 » // We want the types to end up sorted by string field, |
| 631 » // so use that first in the name, and then add :%-T to |
| 632 » // disambiguate. The names are a little long but they are |
| 633 » // discarded by the linker and do not end up in the symbol |
| 634 » // table of the final binary. |
| 635 » p = smprint("%-uT/%-T", t, t); |
| 636 » s = pkglookup(p, typelinkpkg); |
| 637 » //print("typelinksym: %s -> %+S\n", p, s); |
637 free(p); | 638 free(p); |
638 return s; | 639 return s; |
639 } | 640 } |
640 | 641 |
641 Sym* | 642 Sym* |
642 typesymprefix(char *prefix, Type *t) | 643 typesymprefix(char *prefix, Type *t) |
643 { | 644 { |
644 char *p; | 645 char *p; |
645 Sym *s; | 646 Sym *s; |
646 | 647 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 s = pkglookup(p, weaktypepkg); | 693 s = pkglookup(p, weaktypepkg); |
693 //print("weaktypesym: %s -> %+S\n", p, s); | 694 //print("weaktypesym: %s -> %+S\n", p, s); |
694 free(p); | 695 free(p); |
695 return s; | 696 return s; |
696 } | 697 } |
697 | 698 |
698 static Sym* | 699 static Sym* |
699 dtypesym(Type *t) | 700 dtypesym(Type *t) |
700 { | 701 { |
701 int ot, xt, n, isddd, dupok; | 702 int ot, xt, n, isddd, dupok; |
702 » Sym *s, *s1, *s2, *shdr; | 703 » Sym *s, *s1, *s2, *slink; |
703 Sig *a, *m; | 704 Sig *a, *m; |
704 Type *t1, *tbase, *t2; | 705 Type *t1, *tbase, *t2; |
705 | 706 |
706 // Replace byte, rune aliases with real type. | 707 // Replace byte, rune aliases with real type. |
707 // They've been separate internally to make error messages | 708 // They've been separate internally to make error messages |
708 // better, but we have to merge them in the reflect tables. | 709 // better, but we have to merge them in the reflect tables. |
709 if(t == bytetype || t == runetype) | 710 if(t == bytetype || t == runetype) |
710 t = types[t->etype]; | 711 t = types[t->etype]; |
711 | 712 |
712 if(isideal(t)) | 713 if(isideal(t)) |
713 fatal("dtypesym %T", t); | 714 fatal("dtypesym %T", t); |
714 | 715 |
715 » shdr = typesym(t); | 716 » s = typesym(t); |
716 » if(shdr->flags & SymSiggen) | 717 » if(s->flags & SymSiggen) |
717 » » return shdr; | 718 » » return s; |
718 » shdr->flags |= SymSiggen; | 719 » s->flags |= SymSiggen; |
719 | 720 |
720 // special case (look for runtime below): | 721 // special case (look for runtime below): |
721 // when compiling package runtime, | 722 // when compiling package runtime, |
722 // emit the type structures for int, float, etc. | 723 // emit the type structures for int, float, etc. |
723 tbase = t; | 724 tbase = t; |
724 if(isptr[t->etype] && t->sym == S && t->type->sym != S) | 725 if(isptr[t->etype] && t->sym == S && t->type->sym != S) |
725 tbase = t->type; | 726 tbase = t->type; |
726 dupok = tbase->sym == S; | 727 dupok = tbase->sym == S; |
727 | 728 |
728 if(compiling_runtime && | 729 if(compiling_runtime && |
729 (tbase == types[tbase->etype] || | 730 (tbase == types[tbase->etype] || |
730 tbase == bytetype || | 731 tbase == bytetype || |
731 tbase == runetype || | 732 tbase == runetype || |
732 tbase == errortype)) { // int, float, etc | 733 tbase == errortype)) { // int, float, etc |
733 goto ok; | 734 goto ok; |
734 } | 735 } |
735 | 736 |
736 // named types from other files are defined only by those files | 737 // named types from other files are defined only by those files |
737 if(tbase->sym && !tbase->local) | 738 if(tbase->sym && !tbase->local) |
738 » » return shdr; | 739 » » return s; |
739 if(isforw[tbase->etype]) | 740 if(isforw[tbase->etype]) |
740 » » return shdr; | 741 » » return s; |
741 | 742 |
742 ok: | 743 ok: |
743 s = typedatasym(t); | |
744 ot = 0; | 744 ot = 0; |
745 xt = 0; | 745 xt = 0; |
746 switch(t->etype) { | 746 switch(t->etype) { |
747 default: | 747 default: |
748 » » ot = dcommontype(shdr, s, ot, t); | 748 » » ot = dcommontype(s, ot, t); |
749 xt = ot - 2*widthptr; | 749 xt = ot - 2*widthptr; |
750 break; | 750 break; |
751 | 751 |
752 case TARRAY: | 752 case TARRAY: |
753 if(t->bound >= 0) { | 753 if(t->bound >= 0) { |
754 // ../../pkg/runtime/type.go:/ArrayType | 754 // ../../pkg/runtime/type.go:/ArrayType |
755 s1 = dtypesym(t->type); | 755 s1 = dtypesym(t->type); |
756 t2 = typ(TARRAY); | 756 t2 = typ(TARRAY); |
757 t2->type = t->type; | 757 t2->type = t->type; |
758 t2->bound = -1; // slice | 758 t2->bound = -1; // slice |
759 s2 = dtypesym(t2); | 759 s2 = dtypesym(t2); |
760 » » » ot = dcommontype(shdr, s, ot, t); | 760 » » » ot = dcommontype(s, ot, t); |
761 xt = ot - 2*widthptr; | 761 xt = ot - 2*widthptr; |
762 ot = dsymptr(s, ot, s1, 0); | 762 ot = dsymptr(s, ot, s1, 0); |
763 ot = dsymptr(s, ot, s2, 0); | 763 ot = dsymptr(s, ot, s2, 0); |
764 ot = duintptr(s, ot, t->bound); | 764 ot = duintptr(s, ot, t->bound); |
765 } else { | 765 } else { |
766 // ../../pkg/runtime/type.go:/SliceType | 766 // ../../pkg/runtime/type.go:/SliceType |
767 s1 = dtypesym(t->type); | 767 s1 = dtypesym(t->type); |
768 » » » ot = dcommontype(shdr, s, ot, t); | 768 » » » ot = dcommontype(s, ot, t); |
769 xt = ot - 2*widthptr; | 769 xt = ot - 2*widthptr; |
770 ot = dsymptr(s, ot, s1, 0); | 770 ot = dsymptr(s, ot, s1, 0); |
771 } | 771 } |
772 break; | 772 break; |
773 | 773 |
774 case TCHAN: | 774 case TCHAN: |
775 // ../../pkg/runtime/type.go:/ChanType | 775 // ../../pkg/runtime/type.go:/ChanType |
776 s1 = dtypesym(t->type); | 776 s1 = dtypesym(t->type); |
777 » » ot = dcommontype(shdr, s, ot, t); | 777 » » ot = dcommontype(s, ot, t); |
778 xt = ot - 2*widthptr; | 778 xt = ot - 2*widthptr; |
779 ot = dsymptr(s, ot, s1, 0); | 779 ot = dsymptr(s, ot, s1, 0); |
780 ot = duintptr(s, ot, t->chan); | 780 ot = duintptr(s, ot, t->chan); |
781 break; | 781 break; |
782 | 782 |
783 case TFUNC: | 783 case TFUNC: |
784 for(t1=getthisx(t)->type; t1; t1=t1->down) | 784 for(t1=getthisx(t)->type; t1; t1=t1->down) |
785 dtypesym(t1->type); | 785 dtypesym(t1->type); |
786 isddd = 0; | 786 isddd = 0; |
787 for(t1=getinargx(t)->type; t1; t1=t1->down) { | 787 for(t1=getinargx(t)->type; t1; t1=t1->down) { |
788 isddd = t1->isddd; | 788 isddd = t1->isddd; |
789 dtypesym(t1->type); | 789 dtypesym(t1->type); |
790 } | 790 } |
791 for(t1=getoutargx(t)->type; t1; t1=t1->down) | 791 for(t1=getoutargx(t)->type; t1; t1=t1->down) |
792 dtypesym(t1->type); | 792 dtypesym(t1->type); |
793 | 793 |
794 » » ot = dcommontype(shdr, s, ot, t); | 794 » » ot = dcommontype(s, ot, t); |
795 xt = ot - 2*widthptr; | 795 xt = ot - 2*widthptr; |
796 ot = duint8(s, ot, isddd); | 796 ot = duint8(s, ot, isddd); |
797 | 797 |
798 // two slice headers: in and out. | 798 // two slice headers: in and out. |
799 ot = rnd(ot, widthptr); | 799 ot = rnd(ot, widthptr); |
800 ot = dsymptr(s, ot, s, ot+2*(widthptr+2*widthint)); | 800 ot = dsymptr(s, ot, s, ot+2*(widthptr+2*widthint)); |
801 n = t->thistuple + t->intuple; | 801 n = t->thistuple + t->intuple; |
802 ot = duintxx(s, ot, n, widthint); | 802 ot = duintxx(s, ot, n, widthint); |
803 ot = duintxx(s, ot, n, widthint); | 803 ot = duintxx(s, ot, n, widthint); |
804 ot = dsymptr(s, ot, s, ot+1*(widthptr+2*widthint)+n*widthptr); | 804 ot = dsymptr(s, ot, s, ot+1*(widthptr+2*widthint)+n*widthptr); |
(...skipping 11 matching lines...) Expand all Loading... |
816 | 816 |
817 case TINTER: | 817 case TINTER: |
818 m = imethods(t); | 818 m = imethods(t); |
819 n = 0; | 819 n = 0; |
820 for(a=m; a; a=a->link) { | 820 for(a=m; a; a=a->link) { |
821 dtypesym(a->type); | 821 dtypesym(a->type); |
822 n++; | 822 n++; |
823 } | 823 } |
824 | 824 |
825 // ../../pkg/runtime/type.go:/InterfaceType | 825 // ../../pkg/runtime/type.go:/InterfaceType |
826 » » ot = dcommontype(shdr, s, ot, t); | 826 » » ot = dcommontype(s, ot, t); |
827 xt = ot - 2*widthptr; | 827 xt = ot - 2*widthptr; |
828 ot = dsymptr(s, ot, s, ot+widthptr+2*widthint); | 828 ot = dsymptr(s, ot, s, ot+widthptr+2*widthint); |
829 ot = duintxx(s, ot, n, widthint); | 829 ot = duintxx(s, ot, n, widthint); |
830 ot = duintxx(s, ot, n, widthint); | 830 ot = duintxx(s, ot, n, widthint); |
831 for(a=m; a; a=a->link) { | 831 for(a=m; a; a=a->link) { |
832 // ../../pkg/runtime/type.go:/imethod | 832 // ../../pkg/runtime/type.go:/imethod |
833 ot = dgostringptr(s, ot, a->name); | 833 ot = dgostringptr(s, ot, a->name); |
834 ot = dgopkgpath(s, ot, a->pkg); | 834 ot = dgopkgpath(s, ot, a->pkg); |
835 ot = dsymptr(s, ot, dtypesym(a->type), 0); | 835 ot = dsymptr(s, ot, dtypesym(a->type), 0); |
836 } | 836 } |
837 break; | 837 break; |
838 | 838 |
839 case TMAP: | 839 case TMAP: |
840 // ../../pkg/runtime/type.go:/MapType | 840 // ../../pkg/runtime/type.go:/MapType |
841 s1 = dtypesym(t->down); | 841 s1 = dtypesym(t->down); |
842 s2 = dtypesym(t->type); | 842 s2 = dtypesym(t->type); |
843 » » ot = dcommontype(shdr, s, ot, t); | 843 » » ot = dcommontype(s, ot, t); |
844 xt = ot - 2*widthptr; | 844 xt = ot - 2*widthptr; |
845 ot = dsymptr(s, ot, s1, 0); | 845 ot = dsymptr(s, ot, s1, 0); |
846 ot = dsymptr(s, ot, s2, 0); | 846 ot = dsymptr(s, ot, s2, 0); |
847 break; | 847 break; |
848 | 848 |
849 case TPTR32: | 849 case TPTR32: |
850 case TPTR64: | 850 case TPTR64: |
851 if(t->type->etype == TANY) { | 851 if(t->type->etype == TANY) { |
852 // ../../pkg/runtime/type.go:/UnsafePointerType | 852 // ../../pkg/runtime/type.go:/UnsafePointerType |
853 » » » ot = dcommontype(shdr, s, ot, t); | 853 » » » ot = dcommontype(s, ot, t); |
854 break; | 854 break; |
855 } | 855 } |
856 // ../../pkg/runtime/type.go:/PtrType | 856 // ../../pkg/runtime/type.go:/PtrType |
857 s1 = dtypesym(t->type); | 857 s1 = dtypesym(t->type); |
858 » » ot = dcommontype(shdr, s, ot, t); | 858 » » ot = dcommontype(s, ot, t); |
859 xt = ot - 2*widthptr; | 859 xt = ot - 2*widthptr; |
860 ot = dsymptr(s, ot, s1, 0); | 860 ot = dsymptr(s, ot, s1, 0); |
861 break; | 861 break; |
862 | 862 |
863 case TSTRUCT: | 863 case TSTRUCT: |
864 // ../../pkg/runtime/type.go:/StructType | 864 // ../../pkg/runtime/type.go:/StructType |
865 // for security, only the exported fields. | 865 // for security, only the exported fields. |
866 n = 0; | 866 n = 0; |
867 for(t1=t->type; t1!=T; t1=t1->down) { | 867 for(t1=t->type; t1!=T; t1=t1->down) { |
868 dtypesym(t1->type); | 868 dtypesym(t1->type); |
869 n++; | 869 n++; |
870 } | 870 } |
871 » » ot = dcommontype(shdr, s, ot, t); | 871 » » ot = dcommontype(s, ot, t); |
872 xt = ot - 2*widthptr; | 872 xt = ot - 2*widthptr; |
873 ot = dsymptr(s, ot, s, ot+widthptr+2*widthint); | 873 ot = dsymptr(s, ot, s, ot+widthptr+2*widthint); |
874 ot = duintxx(s, ot, n, widthint); | 874 ot = duintxx(s, ot, n, widthint); |
875 ot = duintxx(s, ot, n, widthint); | 875 ot = duintxx(s, ot, n, widthint); |
876 for(t1=t->type; t1!=T; t1=t1->down) { | 876 for(t1=t->type; t1!=T; t1=t1->down) { |
877 // ../../pkg/runtime/type.go:/structField | 877 // ../../pkg/runtime/type.go:/structField |
878 if(t1->sym && !t1->embedded) { | 878 if(t1->sym && !t1->embedded) { |
879 ot = dgostringptr(s, ot, t1->sym->name); | 879 ot = dgostringptr(s, ot, t1->sym->name); |
880 if(exportname(t1->sym->name)) | 880 if(exportname(t1->sym->name)) |
881 ot = dgostringptr(s, ot, nil); | 881 ot = dgostringptr(s, ot, nil); |
882 else | 882 else |
883 ot = dgopkgpath(s, ot, t1->sym->pkg); | 883 ot = dgopkgpath(s, ot, t1->sym->pkg); |
884 } else { | 884 } else { |
885 ot = dgostringptr(s, ot, nil); | 885 ot = dgostringptr(s, ot, nil); |
886 » » » » ot = dgostringptr(s, ot, nil); | 886 » » » » if(t1->type->sym != S && t1->type->sym->pkg == b
uiltinpkg) |
| 887 » » » » » ot = dgopkgpath(s, ot, localpkg); |
| 888 » » » » else |
| 889 » » » » » ot = dgostringptr(s, ot, nil); |
887 } | 890 } |
888 ot = dsymptr(s, ot, dtypesym(t1->type), 0); | 891 ot = dsymptr(s, ot, dtypesym(t1->type), 0); |
889 ot = dgostrlitptr(s, ot, t1->note); | 892 ot = dgostrlitptr(s, ot, t1->note); |
890 ot = duintptr(s, ot, t1->width); // field offset | 893 ot = duintptr(s, ot, t1->width); // field offset |
891 } | 894 } |
892 break; | 895 break; |
893 } | 896 } |
894 ot = dextratype(s, ot, t, xt); | 897 ot = dextratype(s, ot, t, xt); |
895 ggloblsym(s, ot, dupok, 1); | 898 ggloblsym(s, ot, dupok, 1); |
896 » ggloblsym(shdr, 2*widthptr, dupok, 1); | 899 |
897 » return shdr; | 900 » // generate typelink.foo pointing at s = type.foo. |
| 901 » // The linker will leave a table of all the typelinks for |
| 902 » // types in the binary, so reflect can find them. |
| 903 » // We only need the link for unnamed composites that |
| 904 » // we want be able to find. |
| 905 » if(t->sym == S) { |
| 906 » » switch(t->etype) { |
| 907 » » case TARRAY: |
| 908 » » case TCHAN: |
| 909 » » case TMAP: |
| 910 » » » slink = typelinksym(t); |
| 911 » » » dsymptr(slink, 0, s, 0); |
| 912 » » » ggloblsym(slink, widthptr, dupok, 1); |
| 913 » » } |
| 914 » } |
| 915 |
| 916 » return s; |
898 } | 917 } |
899 | 918 |
900 void | 919 void |
901 dumptypestructs(void) | 920 dumptypestructs(void) |
902 { | 921 { |
903 int i; | 922 int i; |
904 NodeList *l; | 923 NodeList *l; |
905 Node *n; | 924 Node *n; |
906 Type *t; | 925 Type *t; |
907 Pkg *p; | 926 Pkg *p; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 | 964 |
946 // emit type structs for error and func(error) string. | 965 // emit type structs for error and func(error) string. |
947 // The latter is the type of an auto-generated wrapper. | 966 // The latter is the type of an auto-generated wrapper. |
948 dtypesym(ptrto(errortype)); | 967 dtypesym(ptrto(errortype)); |
949 dtypesym(functype(nil, | 968 dtypesym(functype(nil, |
950 list1(nod(ODCLFIELD, N, typenod(errortype))), | 969 list1(nod(ODCLFIELD, N, typenod(errortype))), |
951 list1(nod(ODCLFIELD, N, typenod(types[TSTRING]))))); | 970 list1(nod(ODCLFIELD, N, typenod(types[TSTRING]))))); |
952 | 971 |
953 // add paths for runtime and main, which 6l imports implicitly. | 972 // add paths for runtime and main, which 6l imports implicitly. |
954 dimportpath(runtimepkg); | 973 dimportpath(runtimepkg); |
| 974 if(debug['b']) |
| 975 dimportpath(racepkg); |
955 dimportpath(mkpkg(strlit("main"))); | 976 dimportpath(mkpkg(strlit("main"))); |
956 } | 977 } |
957 } | 978 } |
958 | 979 |
959 static Sym* | 980 static Sym* |
960 dalgsym(Type *t) | 981 dalgsym(Type *t) |
961 { | 982 { |
962 int ot; | 983 int ot; |
963 Sym *s, *hash, *eq; | 984 Sym *s, *hash, *eq; |
964 char buf[100]; | 985 char buf[100]; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 ot = duintptr(s, ot, GC_END); | 1182 ot = duintptr(s, ot, GC_END); |
1162 ggloblsym(s, ot, 1, 1); | 1183 ggloblsym(s, ot, 1, 1); |
1163 | 1184 |
1164 if(t->align > 0) | 1185 if(t->align > 0) |
1165 off = rnd(off, t->align); | 1186 off = rnd(off, t->align); |
1166 if(off != t->width) | 1187 if(off != t->width) |
1167 fatal("dgcsym: off=%lld, size=%lld, type %T", off, t->width, t); | 1188 fatal("dgcsym: off=%lld, size=%lld, type %T", off, t->width, t); |
1168 | 1189 |
1169 return s; | 1190 return s; |
1170 } | 1191 } |
1171 | |
LEFT | RIGHT |