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 | 8 |
9 /* | 9 /* |
10 * runtime interface and reflection data structures | 10 * runtime interface and reflection data structures |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 ot = duint8(s, ot, algtype(t)); | 586 ot = duint8(s, ot, algtype(t)); |
587 ot = duint8(s, ot, t->align); // align | 587 ot = duint8(s, ot, t->align); // align |
588 ot = duint8(s, ot, t->align); // fieldAlign | 588 ot = duint8(s, ot, t->align); // fieldAlign |
589 i = kinds[t->etype]; | 589 i = kinds[t->etype]; |
590 if(t->etype == TARRAY && t->bound < 0) | 590 if(t->etype == TARRAY && t->bound < 0) |
591 i = KindSlice; | 591 i = KindSlice; |
592 if(!haspointers(t)) | 592 if(!haspointers(t)) |
593 i |= KindNoPointers; | 593 i |= KindNoPointers; |
594 ot = duint8(s, ot, i); // kind | 594 ot = duint8(s, ot, i); // kind |
595 p = smprint("%-uT", t); | 595 p = smprint("%-uT", t); |
596 //» print("dcommontype %s\n", p); | 596 » //print("dcommontype: %s\n", p); |
597 ot = dgostringptr(s, ot, p); // string | 597 ot = dgostringptr(s, ot, p); // string |
598 free(p); | 598 free(p); |
599 ········ | 599 ········ |
600 // skip pointer to extraType, | 600 // skip pointer to extraType, |
601 // which follows the rest of this type structure. | 601 // which follows the rest of this type structure. |
602 // caller will fill in if needed. | 602 // caller will fill in if needed. |
603 // otherwise linker will assume 0. | 603 // otherwise linker will assume 0. |
604 ot += widthptr; | 604 ot += widthptr; |
605 | 605 |
606 ot = dsymptr(s, ot, sptr, 0); // ptrto type | 606 ot = dsymptr(s, ot, sptr, 0); // ptrto type |
607 return ot; | 607 return ot; |
608 } | 608 } |
609 | 609 |
610 Sym* | 610 Sym* |
611 typesym(Type *t) | 611 typesym(Type *t) |
612 { | 612 { |
613 char *p; | 613 char *p; |
614 Sym *s; | 614 Sym *s; |
615 | 615 |
616 p = smprint("%-T", t); | 616 p = smprint("%-T", t); |
617 s = pkglookup(p, typepkg); | 617 s = pkglookup(p, typepkg); |
618 //» print("typesym %s -> %+S\n", p, s); | 618 » //print("typesym: %s -> %+S\n", p, s); |
619 free(p); | 619 free(p); |
620 return s; | 620 return s; |
621 } | 621 } |
622 | 622 |
623 Node* | 623 Node* |
624 typename(Type *t) | 624 typename(Type *t) |
625 { | 625 { |
626 Sym *s; | 626 Sym *s; |
627 Node *n; | 627 Node *n; |
628 | 628 |
(...skipping 28 matching lines...) Expand all Loading... |
657 static Pkg *weak; | 657 static Pkg *weak; |
658 ········ | 658 ········ |
659 if(weak == nil) { | 659 if(weak == nil) { |
660 weak = mkpkg(strlit("weak.type")); | 660 weak = mkpkg(strlit("weak.type")); |
661 weak->name = "weak.type"; | 661 weak->name = "weak.type"; |
662 weak->prefix = "weak.type"; // not weak%2etype | 662 weak->prefix = "weak.type"; // not weak%2etype |
663 } | 663 } |
664 ········ | 664 ········ |
665 p = smprint("%-T", t); | 665 p = smprint("%-T", t); |
666 s = pkglookup(p, weak); | 666 s = pkglookup(p, weak); |
667 //» print("weaktypesym %s -> %+S\n", p, s); | 667 » //print("weaktypesym: %s -> %+S\n", p, s); |
668 free(p); | 668 free(p); |
669 return s; | 669 return s; |
670 } | 670 } |
671 | 671 |
672 static Sym* | 672 static Sym* |
673 dtypesym(Type *t) | 673 dtypesym(Type *t) |
674 { | 674 { |
675 int ot, xt, n, isddd, dupok; | 675 int ot, xt, n, isddd, dupok; |
676 Sym *s, *s1, *s2; | 676 Sym *s, *s1, *s2; |
677 Sig *a, *m; | 677 Sig *a, *m; |
678 Type *t1, *tbase, *t2; | 678 Type *t1, *tbase, *t2; |
679 | 679 |
680 if(isideal(t)) | 680 if(isideal(t)) |
681 fatal("dtypesym %T", t); | 681 fatal("dtypesym %T", t); |
682 | 682 |
683 s = typesym(t); | 683 s = typesym(t); |
684 if(s->flags & SymSiggen) | 684 if(s->flags & SymSiggen) |
685 return s; | 685 return s; |
686 s->flags |= SymSiggen; | 686 s->flags |= SymSiggen; |
687 | 687 |
688 // special case (look for runtime below): | 688 // special case (look for runtime below): |
689 // when compiling package runtime, | 689 // when compiling package runtime, |
690 // emit the type structures for int, float, etc. | 690 // emit the type structures for int, float, etc. |
691 tbase = t; | 691 tbase = t; |
692 if(isptr[t->etype] && t->sym == S && t->type->sym != S) | 692 if(isptr[t->etype] && t->sym == S && t->type->sym != S) |
693 tbase = t->type; | 693 tbase = t->type; |
694 dupok = tbase->sym == S; | 694 dupok = tbase->sym == S; |
695 | 695 |
696 » if(compiling_runtime && tbase == types[tbase->etype])» // int, float, e
tc | 696 » if(compiling_runtime && (tbase == types[tbase->etype] || tbase == bytety
pe || tbase == runetype))» // int, float, etc |
697 goto ok; | 697 goto ok; |
698 | 698 |
699 // named types from other files are defined only by those files | 699 // named types from other files are defined only by those files |
700 if(tbase->sym && !tbase->local) | 700 if(tbase->sym && !tbase->local) |
701 return s; | 701 return s; |
702 if(isforw[tbase->etype]) | 702 if(isforw[tbase->etype]) |
703 return s; | 703 return s; |
704 | 704 |
705 ok: | 705 ok: |
706 ot = 0; | 706 ot = 0; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 for(i=1; i<=TBOOL; i++) | 902 for(i=1; i<=TBOOL; i++) |
903 dtypesym(ptrto(types[i])); | 903 dtypesym(ptrto(types[i])); |
904 dtypesym(ptrto(types[TSTRING])); | 904 dtypesym(ptrto(types[TSTRING])); |
905 dtypesym(ptrto(types[TUNSAFEPTR])); | 905 dtypesym(ptrto(types[TUNSAFEPTR])); |
906 ················ | 906 ················ |
907 // add paths for runtime and main, which 6l imports implicitly. | 907 // add paths for runtime and main, which 6l imports implicitly. |
908 dimportpath(runtimepkg); | 908 dimportpath(runtimepkg); |
909 dimportpath(mkpkg(strlit("main"))); | 909 dimportpath(mkpkg(strlit("main"))); |
910 } | 910 } |
911 } | 911 } |
LEFT | RIGHT |