LEFT | RIGHT |
(no file at all) | |
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 #define TUP(x,y) (((x)<<16)|(y)) | 8 #define TUP(x,y) (((x)<<16)|(y)) |
9 | 9 |
10 static Val tocplx(Val); | 10 static Val tocplx(Val); |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 fatal("defaultlit"); | 1045 fatal("defaultlit"); |
1046 } | 1046 } |
1047 // n is ideal, so left and right must both be ideal. | 1047 // n is ideal, so left and right must both be ideal. |
1048 // n has not been computed as a constant value, | 1048 // n has not been computed as a constant value, |
1049 // so either left or right must not be constant. | 1049 // so either left or right must not be constant. |
1050 // The only 'ideal' non-constant expressions are shifts. Ugh. | 1050 // The only 'ideal' non-constant expressions are shifts. Ugh. |
1051 // If one of these is a shift and the other is not, use that typ
e. | 1051 // If one of these is a shift and the other is not, use that typ
e. |
1052 // When compiling x := 1<<i + 3.14, this means we try to push | 1052 // When compiling x := 1<<i + 3.14, this means we try to push |
1053 // the float64 down into the 1<<i, producing the correct error | 1053 // the float64 down into the 1<<i, producing the correct error |
1054 // (cannot shift float64). | 1054 // (cannot shift float64). |
| 1055 // |
| 1056 // If t is an interface type, we want the default type for the |
| 1057 // value, so just do as if no type was given. |
| 1058 if(t && t->etype == TINTER) |
| 1059 t = T; |
1055 if(t == T && (n->right->op == OLSH || n->right->op == ORSH)) { | 1060 if(t == T && (n->right->op == OLSH || n->right->op == ORSH)) { |
1056 defaultlit(&n->left, T); | 1061 defaultlit(&n->left, T); |
1057 defaultlit(&n->right, n->left->type); | 1062 defaultlit(&n->right, n->left->type); |
1058 } else if(t == T && (n->left->op == OLSH || n->left->op == ORSH)
) { | 1063 } else if(t == T && (n->left->op == OLSH || n->left->op == ORSH)
) { |
1059 defaultlit(&n->right, T); | 1064 defaultlit(&n->right, T); |
1060 defaultlit(&n->left, n->right->type); | 1065 defaultlit(&n->left, n->right->type); |
1061 } else if(iscmp[n->op]) { | 1066 } else if(iscmp[n->op]) { |
1062 defaultlit2(&n->left, &n->right, 1); | 1067 defaultlit2(&n->left, &n->right, 1); |
1063 } else { | 1068 } else { |
1064 defaultlit(&n->left, t); | 1069 defaultlit(&n->left, t); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 mpmulfltflt(&ad, &rv->imag); // ad | 1414 mpmulfltflt(&ad, &rv->imag); // ad |
1410 | 1415 |
1411 mpmovefltflt(&v->real, &ac); | 1416 mpmovefltflt(&v->real, &ac); |
1412 mpaddfltflt(&v->real, &bd); // ac+bd | 1417 mpaddfltflt(&v->real, &bd); // ac+bd |
1413 mpdivfltflt(&v->real, &cc_plus_dd); // (ac+bd)/(cc+dd) | 1418 mpdivfltflt(&v->real, &cc_plus_dd); // (ac+bd)/(cc+dd) |
1414 | 1419 |
1415 mpmovefltflt(&v->imag, &bc); | 1420 mpmovefltflt(&v->imag, &bc); |
1416 mpsubfltflt(&v->imag, &ad); // bc-ad | 1421 mpsubfltflt(&v->imag, &ad); // bc-ad |
1417 mpdivfltflt(&v->imag, &cc_plus_dd); // (bc+ad)/(cc+dd) | 1422 mpdivfltflt(&v->imag, &cc_plus_dd); // (bc+ad)/(cc+dd) |
1418 } | 1423 } |
LEFT | RIGHT |