Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
126d475a
Commit
126d475a
authored
Feb 18, 2012
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: drop ideal bool
R=golang-dev, ken2 CC=golang-dev
https://golang.org/cl/5674098
parent
ad17a9c0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
13 additions
and
19 deletions
+13
-19
src/cmd/gc/const.c
src/cmd/gc/const.c
+3
-4
src/cmd/gc/export.c
src/cmd/gc/export.c
+1
-1
src/cmd/gc/fmt.c
src/cmd/gc/fmt.c
+2
-2
src/cmd/gc/go.h
src/cmd/gc/go.h
+0
-1
src/cmd/gc/lex.c
src/cmd/gc/lex.c
+2
-3
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+2
-2
test/fixedbugs/bug285.go
test/fixedbugs/bug285.go
+0
-1
test/named.go
test/named.go
+1
-3
test/named1.go
test/named1.go
+2
-2
No files found.
src/cmd/gc/const.c
View file @
126d475a
...
@@ -586,7 +586,7 @@ evconst(Node *n)
...
@@ -586,7 +586,7 @@ evconst(Node *n)
n
->
diag
=
1
;
n
->
diag
=
1
;
}
}
return
;
return
;
case
TUP
(
OADD
,
CTINT
):
case
TUP
(
OADD
,
CTINT
):
case
TUP
(
OADD
,
CTRUNE
):
case
TUP
(
OADD
,
CTRUNE
):
mpaddfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
,
0
);
mpaddfixfix
(
v
.
u
.
xval
,
rv
.
u
.
xval
,
0
);
...
@@ -660,7 +660,6 @@ evconst(Node *n)
...
@@ -660,7 +660,6 @@ evconst(Node *n)
}
}
mpdivfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
);
mpdivfltflt
(
v
.
u
.
fval
,
rv
.
u
.
fval
);
break
;
break
;
case
TUP
(
OADD
,
CTCPLX
):
case
TUP
(
OADD
,
CTCPLX
):
mpaddfltflt
(
&
v
.
u
.
cval
->
real
,
&
rv
.
u
.
cval
->
real
);
mpaddfltflt
(
&
v
.
u
.
cval
->
real
,
&
rv
.
u
.
cval
->
real
);
mpaddfltflt
(
&
v
.
u
.
cval
->
imag
,
&
rv
.
u
.
cval
->
imag
);
mpaddfltflt
(
&
v
.
u
.
cval
->
imag
,
&
rv
.
u
.
cval
->
imag
);
...
@@ -936,7 +935,7 @@ nodlit(Val v)
...
@@ -936,7 +935,7 @@ nodlit(Val v)
n
->
type
=
idealstring
;
n
->
type
=
idealstring
;
break
;
break
;
case
CTBOOL
:
case
CTBOOL
:
n
->
type
=
idealbool
;
n
->
type
=
types
[
TBOOL
]
;
break
;
break
;
case
CTINT
:
case
CTINT
:
case
CTRUNE
:
case
CTRUNE
:
...
@@ -1025,7 +1024,7 @@ defaultlit(Node **np, Type *t)
...
@@ -1025,7 +1024,7 @@ defaultlit(Node **np, Type *t)
defaultlit
(
&
n
->
left
,
t
);
defaultlit
(
&
n
->
left
,
t
);
defaultlit
(
&
n
->
right
,
t
);
defaultlit
(
&
n
->
right
,
t
);
}
}
if
(
n
->
type
==
idealbool
||
n
->
type
==
idealstring
)
if
(
n
->
type
==
types
[
TBOOL
]
||
n
->
type
==
idealstring
)
n
->
type
=
types
[
n
->
type
->
etype
];
n
->
type
=
types
[
n
->
type
->
etype
];
else
else
n
->
type
=
n
->
left
->
type
;
n
->
type
=
n
->
left
->
type
;
...
...
src/cmd/gc/export.c
View file @
126d475a
...
@@ -122,7 +122,7 @@ reexportdep(Node *n)
...
@@ -122,7 +122,7 @@ reexportdep(Node *n)
case
OLITERAL
:
case
OLITERAL
:
t
=
n
->
type
;
t
=
n
->
type
;
if
(
t
!=
types
[
n
->
type
->
etype
]
&&
t
!=
ideal
bool
&&
t
!=
ideal
string
)
{
if
(
t
!=
types
[
n
->
type
->
etype
]
&&
t
!=
idealstring
)
{
if
(
isptr
[
t
->
etype
])
if
(
isptr
[
t
->
etype
])
t
=
t
->
type
;
t
=
t
->
type
;
if
(
t
&&
t
->
sym
&&
t
->
sym
->
def
&&
t
->
sym
->
pkg
!=
localpkg
&&
t
->
sym
->
pkg
!=
builtinpkg
)
{
if
(
t
&&
t
->
sym
&&
t
->
sym
->
def
&&
t
->
sym
->
pkg
!=
localpkg
&&
t
->
sym
->
pkg
!=
builtinpkg
)
{
...
...
src/cmd/gc/fmt.c
View file @
126d475a
...
@@ -602,7 +602,7 @@ typefmt(Fmt *fp, Type *t)
...
@@ -602,7 +602,7 @@ typefmt(Fmt *fp, Type *t)
}
}
if
(
t
->
etype
<
nelem
(
basicnames
)
&&
basicnames
[
t
->
etype
]
!=
nil
)
{
if
(
t
->
etype
<
nelem
(
basicnames
)
&&
basicnames
[
t
->
etype
]
!=
nil
)
{
if
(
fmtmode
==
FErr
&&
(
t
==
idealbool
||
t
==
idealstring
)
)
if
(
fmtmode
==
FErr
&&
t
==
idealstring
)
fmtstrcpy
(
fp
,
"ideal "
);
fmtstrcpy
(
fp
,
"ideal "
);
return
fmtstrcpy
(
fp
,
basicnames
[
t
->
etype
]);
return
fmtstrcpy
(
fp
,
basicnames
[
t
->
etype
]);
}
}
...
@@ -1086,7 +1086,7 @@ exprfmt(Fmt *f, Node *n, int prec)
...
@@ -1086,7 +1086,7 @@ exprfmt(Fmt *f, Node *n, int prec)
return
fmtprint
(
f
,
"%S"
,
n
->
sym
);
return
fmtprint
(
f
,
"%S"
,
n
->
sym
);
if
(
n
->
val
.
ctype
==
CTNIL
)
if
(
n
->
val
.
ctype
==
CTNIL
)
n
=
n
->
orig
;
// if this node was a nil decorated with at type, print the original naked nil
n
=
n
->
orig
;
// if this node was a nil decorated with at type, print the original naked nil
if
(
n
->
type
!=
types
[
n
->
type
->
etype
]
&&
n
->
type
!=
ideal
bool
&&
n
->
type
!=
ideal
string
)
{
if
(
n
->
type
!=
types
[
n
->
type
->
etype
]
&&
n
->
type
!=
idealstring
)
{
// Need parens when type begins with what might
// Need parens when type begins with what might
// be misinterpreted as a unary operator: * or <-.
// be misinterpreted as a unary operator: * or <-.
if
(
isptr
[
n
->
type
->
etype
]
||
(
n
->
type
->
etype
==
TCHAN
&&
n
->
type
->
chan
==
Crecv
))
if
(
isptr
[
n
->
type
->
etype
]
||
(
n
->
type
->
etype
==
TCHAN
&&
n
->
type
->
chan
==
Crecv
))
...
...
src/cmd/gc/go.h
View file @
126d475a
...
@@ -775,7 +775,6 @@ EXTERN Idir* idirs;
...
@@ -775,7 +775,6 @@ EXTERN Idir* idirs;
EXTERN
Type
*
types
[
NTYPE
];
EXTERN
Type
*
types
[
NTYPE
];
EXTERN
Type
*
idealstring
;
EXTERN
Type
*
idealstring
;
EXTERN
Type
*
idealbool
;
EXTERN
Type
*
bytetype
;
EXTERN
Type
*
bytetype
;
EXTERN
Type
*
runetype
;
EXTERN
Type
*
runetype
;
EXTERN
Type
*
errortype
;
EXTERN
Type
*
errortype
;
...
...
src/cmd/gc/lex.c
View file @
126d475a
...
@@ -1824,17 +1824,16 @@ lexinit(void)
...
@@ -1824,17 +1824,16 @@ lexinit(void)
// this is the ideal form
// this is the ideal form
// (the type of x in const x = "hello").
// (the type of x in const x = "hello").
idealstring
=
typ
(
TSTRING
);
idealstring
=
typ
(
TSTRING
);
idealbool
=
typ
(
TBOOL
);
s
=
pkglookup
(
"true"
,
builtinpkg
);
s
=
pkglookup
(
"true"
,
builtinpkg
);
s
->
def
=
nodbool
(
1
);
s
->
def
=
nodbool
(
1
);
s
->
def
->
sym
=
lookup
(
"true"
);
s
->
def
->
sym
=
lookup
(
"true"
);
s
->
def
->
type
=
idealbool
;
s
->
def
->
type
=
types
[
TBOOL
]
;
s
=
pkglookup
(
"false"
,
builtinpkg
);
s
=
pkglookup
(
"false"
,
builtinpkg
);
s
->
def
=
nodbool
(
0
);
s
->
def
=
nodbool
(
0
);
s
->
def
->
sym
=
lookup
(
"false"
);
s
->
def
->
sym
=
lookup
(
"false"
);
s
->
def
->
type
=
idealbool
;
s
->
def
->
type
=
types
[
TBOOL
]
;
s
=
lookup
(
"_"
);
s
=
lookup
(
"_"
);
s
->
block
=
-
100
;
s
->
block
=
-
100
;
...
...
src/cmd/gc/subr.c
View file @
126d475a
...
@@ -768,7 +768,7 @@ nodbool(int b)
...
@@ -768,7 +768,7 @@ nodbool(int b)
c
=
nodintconst
(
0
);
c
=
nodintconst
(
0
);
c
->
val
.
ctype
=
CTBOOL
;
c
->
val
.
ctype
=
CTBOOL
;
c
->
val
.
u
.
bval
=
b
;
c
->
val
.
u
.
bval
=
b
;
c
->
type
=
idealbool
;
c
->
type
=
types
[
TBOOL
]
;
return
c
;
return
c
;
}
}
...
@@ -929,7 +929,7 @@ isideal(Type *t)
...
@@ -929,7 +929,7 @@ isideal(Type *t)
{
{
if
(
t
==
T
)
if
(
t
==
T
)
return
0
;
return
0
;
if
(
t
==
idealstring
||
t
==
idealbool
)
if
(
t
==
idealstring
)
return
1
;
return
1
;
switch
(
t
->
etype
)
{
switch
(
t
->
etype
)
{
case
TNIL
:
case
TNIL
:
...
...
test/fixedbugs/bug285.go
View file @
126d475a
...
@@ -20,7 +20,6 @@ func main() {
...
@@ -20,7 +20,6 @@ func main() {
type
B
bool
type
B
bool
b
:=
B
(
false
)
b
:=
B
(
false
)
mb
:=
make
(
map
[
B
]
int
)
mb
:=
make
(
map
[
B
]
int
)
mb
[
false
]
=
42
// this should work: false is assignment compatible with B
mb
[
b
]
=
42
mb
[
b
]
=
42
type
Z
int
type
Z
int
...
...
test/named.go
View file @
126d475a
...
@@ -31,7 +31,6 @@ func asString(String) {}
...
@@ -31,7 +31,6 @@ func asString(String) {}
func
(
Map
)
M
()
{}
func
(
Map
)
M
()
{}
// These functions check at run time that the default type
// These functions check at run time that the default type
// (in the absence of any implicit conversion hints)
// (in the absence of any implicit conversion hints)
// is the given type.
// is the given type.
...
@@ -47,7 +46,7 @@ func isString(x interface{}) { _ = x.(String) }
...
@@ -47,7 +46,7 @@ func isString(x interface{}) { _ = x.(String) }
func
main
()
{
func
main
()
{
var
(
var
(
a
Array
a
Array
b
Bool
=
true
b
Bool
=
Bool
(
true
)
c
Chan
=
make
(
Chan
)
c
Chan
=
make
(
Chan
)
f
Float
=
1
f
Float
=
1
i
Int
=
1
i
Int
=
1
...
@@ -67,7 +66,6 @@ func main() {
...
@@ -67,7 +66,6 @@ func main() {
isBool
(
b
)
isBool
(
b
)
asBool
(
!
b
)
asBool
(
!
b
)
isBool
(
!
b
)
isBool
(
!
b
)
asBool
(
true
)
asBool
(
*&
b
)
asBool
(
*&
b
)
isBool
(
*&
b
)
isBool
(
*&
b
)
asBool
(
Bool
(
true
))
asBool
(
Bool
(
true
))
...
...
test/named1.go
View file @
126d475a
...
@@ -26,7 +26,7 @@ type String string
...
@@ -26,7 +26,7 @@ type String string
func
main
()
{
func
main
()
{
var
(
var
(
b
Bool
=
true
b
Bool
=
Bool
(
true
)
i
,
j
int
i
,
j
int
c
=
make
(
chan
int
)
c
=
make
(
chan
int
)
m
=
make
(
Map
)
m
=
make
(
Map
)
...
@@ -34,7 +34,7 @@ func main() {
...
@@ -34,7 +34,7 @@ func main() {
asBool
(
b
)
asBool
(
b
)
asBool
(
!
b
)
asBool
(
!
b
)
asBool
(
true
)
asBool
(
true
)
// ERROR "cannot use.*type bool.*as type Bool"
asBool
(
*&
b
)
asBool
(
*&
b
)
asBool
(
Bool
(
true
))
asBool
(
Bool
(
true
))
asBool
(
1
!=
2
)
// ERROR "cannot use.*type bool.*as type Bool"
asBool
(
1
!=
2
)
// ERROR "cannot use.*type bool.*as type Bool"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment