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
f21e731c
Commit
f21e731c
authored
Oct 02, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added printn and panicn
prints that insert spaces and new line R=r OCL=16370 CL=16370
parent
0216273c
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
351 additions
and
287 deletions
+351
-287
src/cmd/gc/go.h
src/cmd/gc/go.h
+2
-2
src/cmd/gc/go.y
src/cmd/gc/go.y
+11
-1
src/cmd/gc/lex.c
src/cmd/gc/lex.c
+2
-0
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+2
-0
src/cmd/gc/sys.go
src/cmd/gc/sys.go
+4
-0
src/cmd/gc/sysimport.c
src/cmd/gc/sysimport.c
+286
-276
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+32
-8
src/runtime/print.c
src/runtime/print.c
+12
-0
No files found.
src/cmd/gc/go.h
View file @
f21e731c
...
...
@@ -269,7 +269,7 @@ enum
ORETURN
,
OFOR
,
OIF
,
OSWITCH
,
OAS
,
OASOP
,
OCASE
,
OXCASE
,
OFALL
,
OXFALL
,
OGOTO
,
OPROC
,
ONEW
,
OEMPTY
,
OSELECT
,
OLEN
,
OCAP
,
OPANIC
,
OP
RINT
,
OTYPEOF
,
OLEN
,
OCAP
,
OPANIC
,
OP
ANICN
,
OPRINT
,
OPRINTN
,
OTYPEOF
,
OOROR
,
OANDAND
,
...
...
@@ -695,7 +695,7 @@ Node* ascompatee(int, Node**, Node**);
Node
*
ascompatet
(
int
,
Node
**
,
Type
**
,
int
);
Node
*
ascompatte
(
int
,
Type
**
,
Node
**
,
int
);
int
ascompat
(
Type
*
,
Type
*
);
Node
*
prcompat
(
Node
*
);
Node
*
prcompat
(
Node
*
,
int
);
Node
*
nodpanic
(
int32
);
Node
*
newcompat
(
Node
*
);
Node
*
stringop
(
Node
*
,
int
);
...
...
src/cmd/gc/go.y
View file @
f21e731c
...
...
@@ -18,7 +18,7 @@
%
token
<
sym
>
LPACKAGE
LIMPORT
LEXPORT
%
token
<
sym
>
LMAP
LCHAN
LINTERFACE
LFUNC
LSTRUCT
%
token
<
sym
>
LCOLAS
LFALL
LRETURN
%
token
<
sym
>
LNEW
LLEN
LCAP
LTYPEOF
LPANIC
LP
RINT
%
token
<
sym
>
LNEW
LLEN
LCAP
LTYPEOF
LPANIC
LP
ANICN
LPRINT
LPRINTN
%
token
<
sym
>
LVAR
LTYPE
LCONST
LCONVERT
LSELECT
%
token
<
sym
>
LFOR
LIF
LELSE
LSWITCH
LCASE
LDEFAULT
%
token
<
sym
>
LBREAK
LCONTINUE
LGO
LGOTO
LRANGE
...
...
@@ -361,10 +361,18 @@ noninc_stmt:
{
$$
=
nod
(
OPRINT
,
$
3
,
N
);
}
|
LPRINTN
'('
oexpr_list
')'
{
$$
=
nod
(
OPRINTN
,
$
3
,
N
);
}
|
LPANIC
'('
oexpr_list
')'
{
$$
=
nod
(
OPANIC
,
$
3
,
N
);
}
|
LPANICN
'('
oexpr_list
')'
{
$$
=
nod
(
OPANICN
,
$
3
,
N
);
}
inc_stmt
:
expr
LINC
...
...
@@ -896,7 +904,9 @@ keyword:
|
LLEN
|
LCAP
|
LPANIC
|
LPANICN
|
LPRINT
|
LPRINTN
|
LNEW
|
LBASETYPE
|
LTYPEOF
...
...
src/cmd/gc/lex.c
View file @
f21e731c
...
...
@@ -998,7 +998,9 @@ static struct
"nil"
,
LNIL
,
Txxx
,
"package"
,
LPACKAGE
,
Txxx
,
"panic"
,
LPANIC
,
Txxx
,
"panicn"
,
LPANICN
,
Txxx
,
"print"
,
LPRINT
,
Txxx
,
"printn"
,
LPRINTN
,
Txxx
,
"range"
,
LRANGE
,
Txxx
,
"return"
,
LRETURN
,
Txxx
,
"select"
,
LSELECT
,
Txxx
,
...
...
src/cmd/gc/subr.c
View file @
f21e731c
...
...
@@ -693,7 +693,9 @@ opnames[] =
[
OFALL
]
=
"FALL"
,
[
OXFALL
]
=
"XFALL"
,
[
OPANIC
]
=
"PANIC"
,
[
OPANICN
]
=
"PANICN"
,
[
OPRINT
]
=
"PRINT"
,
[
OPRINTN
]
=
"PRINTN"
,
[
OXXX
]
=
"XXX"
,
};
...
...
src/cmd/gc/sys.go
View file @
f21e731c
...
...
@@ -17,6 +17,8 @@ func printint(int64);
func
printstring
(
string
);
func
printpointer
(
*
any
);
func
printinter
(
any
);
func
printnl
();
func
printsp
();
func
catstring
(
string
,
string
)
string
;
func
cmpstring
(
string
,
string
)
int32
;
...
...
@@ -92,6 +94,8 @@ export
printstring
printpointer
printinter
printnl
printsp
// op string
catstring
...
...
src/cmd/gc/sysimport.c
View file @
f21e731c
This diff is collapsed.
Click to expand it.
src/cmd/gc/walk.c
View file @
f21e731c
...
...
@@ -124,7 +124,9 @@ loop:
case
OSEND
:
case
ORECV
:
case
OPRINT
:
case
OPRINTN
:
case
OPANIC
:
case
OPANICN
:
case
OFOR
:
case
OIF
:
case
OSWITCH
:
...
...
@@ -203,14 +205,28 @@ loop:
if
(
top
!=
Etop
)
goto
nottop
;
walktype
(
n
->
left
,
Erv
);
indir
(
n
,
prcompat
(
n
->
left
));
indir
(
n
,
prcompat
(
n
->
left
,
0
));
goto
ret
;
case
OPRINTN
:
if
(
top
!=
Etop
)
goto
nottop
;
walktype
(
n
->
left
,
Erv
);
indir
(
n
,
prcompat
(
n
->
left
,
1
));
goto
ret
;
case
OPANIC
:
if
(
top
!=
Etop
)
goto
nottop
;
walktype
(
n
->
left
,
Erv
);
indir
(
n
,
list
(
prcompat
(
n
->
left
),
nodpanic
(
n
->
lineno
)));
indir
(
n
,
list
(
prcompat
(
n
->
left
,
0
),
nodpanic
(
n
->
lineno
)));
goto
ret
;
case
OPANICN
:
if
(
top
!=
Etop
)
goto
nottop
;
walktype
(
n
->
left
,
Erv
);
indir
(
n
,
list
(
prcompat
(
n
->
left
,
1
),
nodpanic
(
n
->
lineno
)));
goto
ret
;
case
OLITERAL
:
...
...
@@ -1598,23 +1614,33 @@ ascompat(Type *t1, Type *t2)
}
Node
*
prcompat
(
Node
*
n
)
prcompat
(
Node
*
n
,
int
fmt
)
{
Node
*
l
,
*
r
;
Node
*
on
;
Type
*
t
;
Iter
save
;
int
w
;
int
w
,
notfirst
;
r
=
N
;
l
=
listfirst
(
&
save
,
&
n
);
notfirst
=
0
;
loop:
if
(
l
==
N
)
{
if
(
fmt
)
{
on
=
syslook
(
"printnl"
,
0
);
r
=
list
(
r
,
nod
(
OCALL
,
on
,
N
));
}
walktype
(
r
,
Etop
);
return
r
;
}
if
(
notfirst
)
{
on
=
syslook
(
"printsp"
,
0
);
r
=
list
(
r
,
nod
(
OCALL
,
on
,
N
));
}
w
=
whatis
(
l
);
switch
(
w
)
{
default:
...
...
@@ -1663,12 +1689,10 @@ loop:
l
->
type
=
t
;
}
if
(
r
==
N
)
r
=
nod
(
OCALL
,
on
,
l
);
else
r
=
list
(
r
,
nod
(
OCALL
,
on
,
l
));
r
=
list
(
r
,
nod
(
OCALL
,
on
,
l
));
out:
notfirst
=
fmt
;
l
=
listnext
(
&
save
);
goto
loop
;
}
...
...
src/runtime/print.c
View file @
f21e731c
...
...
@@ -166,3 +166,15 @@ sys·printstring(string v)
if
(
v
!=
nil
)
sys
·
write
(
1
,
v
->
str
,
v
->
len
);
}
void
sys
·
printsp
(
void
)
{
sys
·
write
(
1
,
" "
,
1
);
}
void
sys
·
printnl
(
void
)
{
sys
·
write
(
1
,
"
\n
"
,
1
);
}
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