OLD | NEW |
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 "md5.h" | 8 #include "md5.h" |
9 #include "y.tab.h" | 9 #include "y.tab.h" |
10 #include "yerr.h" | 10 #include "yerr.h" |
(...skipping 3790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3801 int | 3801 int |
3802 isdirectiface(Type *t) | 3802 isdirectiface(Type *t) |
3803 { | 3803 { |
3804 // Setting IfacePointerOnly = 1 changes the | 3804 // Setting IfacePointerOnly = 1 changes the |
3805 // interface representation so that the data word | 3805 // interface representation so that the data word |
3806 // in an interface value must always be a pointer. | 3806 // in an interface value must always be a pointer. |
3807 // Setting it to 0 uses the original representation, | 3807 // Setting it to 0 uses the original representation, |
3808 // where the data word can hold a pointer or any | 3808 // where the data word can hold a pointer or any |
3809 // non-pointer value no bigger than a pointer. | 3809 // non-pointer value no bigger than a pointer. |
3810 enum { | 3810 enum { |
3811 » » IfacePointerOnly = 0, | 3811 » » IfacePointerOnly = 1, |
3812 }; | 3812 }; |
3813 | 3813 |
3814 if(IfacePointerOnly) { | 3814 if(IfacePointerOnly) { |
3815 switch(t->etype) { | 3815 switch(t->etype) { |
3816 case TPTR32: | 3816 case TPTR32: |
3817 case TPTR64: | 3817 case TPTR64: |
3818 case TCHAN: | 3818 case TCHAN: |
3819 case TMAP: | 3819 case TMAP: |
3820 case TFUNC: | 3820 case TFUNC: |
3821 case TUNSAFEPTR: | 3821 case TUNSAFEPTR: |
3822 return 1; | 3822 return 1; |
3823 case TARRAY: | 3823 case TARRAY: |
3824 // Array of 1 direct iface type can be direct. | 3824 // Array of 1 direct iface type can be direct. |
3825 return t->bound == 1 && isdirectiface(t->type); | 3825 return t->bound == 1 && isdirectiface(t->type); |
3826 case TSTRUCT: | 3826 case TSTRUCT: |
3827 // Struct with 1 field of direct iface type can be direc
t. | 3827 // Struct with 1 field of direct iface type can be direc
t. |
3828 return t->type != T && t->type->down == T && isdirectifa
ce(t->type->type); | 3828 return t->type != T && t->type->down == T && isdirectifa
ce(t->type->type); |
3829 } | 3829 } |
3830 return 0; | 3830 return 0; |
3831 } | 3831 } |
3832 ········ | 3832 ········ |
3833 dowidth(t); | 3833 dowidth(t); |
3834 return t->width <= widthptr; | 3834 return t->width <= widthptr; |
3835 } | 3835 } |
OLD | NEW |