Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
bb02e481
Commit
bb02e481
authored
Mar 12, 2009
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added bitclear operators &^ and &^=
R=r OCL=26152 CL=26152
parent
767845b6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
4 deletions
+72
-4
const.c
src/cmd/gc/const.c
+3
-0
go.h
src/cmd/gc/go.h
+2
-1
go.y
src/cmd/gc/go.y
+6
-2
lex.c
src/cmd/gc/lex.c
+9
-0
mparith2.c
src/cmd/gc/mparith2.c
+34
-0
subr.c
src/cmd/gc/subr.c
+1
-0
walk.c
src/cmd/gc/walk.c
+17
-1
No files found.
src/cmd/gc/const.c
View file @
bb02e481
...
...
@@ -314,6 +314,9 @@ evconst(Node *n)
case
TUP
(
OAND
,
Wlitint
):
mpandfixfix
(
xval
,
nr
->
val
.
u
.
xval
);
break
;
case
TUP
(
OANDNOT
,
Wlitint
):
mpandnotfixfix
(
xval
,
nr
->
val
.
u
.
xval
);
break
;
case
TUP
(
OXOR
,
Wlitint
):
mpxorfixfix
(
xval
,
nr
->
val
.
u
.
xval
);
break
;
...
...
src/cmd/gc/go.h
View file @
bb02e481
...
...
@@ -314,7 +314,7 @@ enum
OANDAND
,
OEQ
,
ONE
,
OLT
,
OLE
,
OGE
,
OGT
,
OADD
,
OSUB
,
OOR
,
OXOR
,
OMUL
,
ODIV
,
OMOD
,
OLSH
,
ORSH
,
OAND
,
OMUL
,
ODIV
,
OMOD
,
OLSH
,
ORSH
,
OAND
,
OANDNOT
,
OINC
,
ODEC
,
// placeholders - not used
OFUNC
,
OLABEL
,
...
...
@@ -610,6 +610,7 @@ void mpdivmodfixfix(Mpint *q, Mpint *r, Mpint *n, Mpint *d);
void
mpdivfract
(
Mpint
*
a
,
Mpint
*
b
);
void
mpnegfix
(
Mpint
*
a
);
void
mpandfixfix
(
Mpint
*
a
,
Mpint
*
b
);
void
mpnotandfixfix
(
Mpint
*
a
,
Mpint
*
b
);
void
mplshfixfix
(
Mpint
*
a
,
Mpint
*
b
);
void
mporfixfix
(
Mpint
*
a
,
Mpint
*
b
);
void
mprshfixfix
(
Mpint
*
a
,
Mpint
*
b
);
...
...
src/cmd/gc/go.y
View file @
bb02e481
...
...
@@ -25,7 +25,7 @@
%
token
<
sym
>
LNIL
LTRUE
LFALSE
LIOTA
%
token
LOROR
LANDAND
LEQ
LNE
LLE
LLT
LGE
LGT
%
token
LLSH
LRSH
LINC
LDEC
LCOMM
%
token
LLSH
LRSH
LINC
LDEC
LCOMM
LANDNOT
%
token
LIGNORE
/*
...
...
@@ -87,7 +87,7 @@
%
left
LCOMM
%
left
LEQ
LNE
LLE
LGE
LLT
LGT
%
left
'+'
'-'
'|'
'^'
%
left
'*'
'/'
'%'
'&'
LLSH
LRSH
%
left
'*'
'/'
'%'
'&'
LLSH
LRSH
LANDNOT
/*
*
resolve
{
vs
condition
in
favor
of
condition
...
...
@@ -766,6 +766,10 @@ expr:
{
$$
=
nod
(
OAND
,
$
1
,
$
3
);
}
|
expr
LANDNOT
expr
{
$$
=
nod
(
OANDNOT
,
$
1
,
$
3
);
}
|
expr
LLSH
expr
{
$$
=
nod
(
OLSH
,
$
1
,
$
3
);
...
...
src/cmd/gc/lex.c
View file @
bb02e481
...
...
@@ -654,6 +654,15 @@ l0:
c
=
LANDAND
;
goto
lx
;
}
if
(
c1
==
'^'
)
{
c
=
LANDNOT
;
c1
=
getc
();
if
(
c1
==
'='
)
{
c
=
OANDNOT
;
goto
asop
;
}
break
;
}
if
(
c1
==
'='
)
{
c
=
OAND
;
goto
asop
;
...
...
src/cmd/gc/mparith2.c
View file @
bb02e481
...
...
@@ -406,6 +406,40 @@ mpandfixfix(Mpint *a, Mpint *b)
}
}
void
mpandnotfixfix
(
Mpint
*
a
,
Mpint
*
b
)
{
int
i
;
long
x
,
*
a1
,
*
b1
;
if
(
a
->
ovf
||
b
->
ovf
)
{
warn
(
"ovf in mpandnotfixfix"
);
mpmovecfix
(
a
,
0
);
a
->
ovf
=
1
;
return
;
}
if
(
a
->
neg
)
{
a
->
neg
=
0
;
mpneg
(
a
);
}
if
(
b
->
neg
)
mpneg
(
b
);
a1
=
&
a
->
a
[
0
];
b1
=
&
b
->
a
[
0
];
for
(
i
=
0
;
i
<
Mpprec
;
i
++
)
{
x
=
*
a1
&
~*
b1
++
;
*
a1
++
=
x
;
}
if
(
b
->
neg
)
mpneg
(
b
);
if
(
x
&
Mpsign
)
{
a
->
neg
=
1
;
mpneg
(
a
);
}
}
void
mpxorfixfix
(
Mpint
*
a
,
Mpint
*
b
)
{
...
...
src/cmd/gc/subr.c
View file @
bb02e481
...
...
@@ -643,6 +643,7 @@ opnames[] =
[
OADDR
]
=
"ADDR"
,
[
OADD
]
=
"ADD"
,
[
OANDAND
]
=
"ANDAND"
,
[
OANDNOT
]
=
"ANDNOT"
,
[
OAND
]
=
"AND"
,
[
OARRAY
]
=
"ARRAY"
,
[
OASOP
]
=
"ASOP"
,
...
...
src/cmd/gc/walk.c
View file @
bb02e481
...
...
@@ -667,6 +667,7 @@ loop:
case
OMOD
:
case
OAND
:
case
OANDNOT
:
case
OOR
:
case
OXOR
:
case
OANDAND
:
...
...
@@ -700,6 +701,20 @@ loop:
goto
badt
;
switch
(
n
->
op
)
{
case
OANDNOT
:
n
->
op
=
OAND
;
n
->
right
=
nod
(
OCOM
,
n
->
right
,
N
);
n
->
right
->
type
=
n
->
right
->
left
->
type
;
break
;
case
OASOP
:
if
(
n
->
etype
==
OANDNOT
)
{
n
->
etype
=
OAND
;
n
->
right
=
nod
(
OCOM
,
n
->
right
,
N
);
n
->
right
->
type
=
n
->
right
->
left
->
type
;
break
;
}
case
OEQ
:
case
ONE
:
case
OLT
:
...
...
@@ -707,11 +722,11 @@ loop:
case
OGE
:
case
OGT
:
case
OADD
:
case
OASOP
:
if
(
istype
(
n
->
left
->
type
,
TSTRING
))
{
indir
(
n
,
stringop
(
n
,
top
));
goto
ret
;
}
break
;
}
break
;
...
...
@@ -1070,6 +1085,7 @@ loop:
case
OLSH
:
case
ORSH
:
case
OAND
:
case
OANDNOT
:
case
OOR
:
case
OXOR
:
case
OMOD
:
...
...
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