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
9fb9e82f
Commit
9fb9e82f
authored
Jul 31, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added missing file
R=r OCL=13681 CL=13681
parent
6dd92ea6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
114 additions
and
0 deletions
+114
-0
verifier.go
usr/gri/gosrc/verifier.go
+114
-0
No files found.
usr/gri/gosrc/verifier.go
0 → 100644
View file @
9fb9e82f
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Verifies compiler-internal data structures.
package
Verifier
import
Utils
"utils"
import
Scanner
"scanner"
import
Globals
"globals"
import
Object
"object"
import
Type
"type"
import
Universe
"universe"
import
Import
"import"
import
AST
"ast"
func
Error
(
msg
string
)
{
panic
"internal compiler error: "
,
msg
,
"
\n
"
;
}
func
VerifyObject
(
obj
*
Globals
.
Object
,
pnolev
int
);
func
VerifyType
(
typ
*
Globals
.
Type
)
{
if
typ
==
nil
{
return
;
// see Globals.NewObject
}
if
typ
.
obj
!=
nil
{
VerifyObject
(
typ
.
obj
,
0
);
}
switch
typ
.
form
{
case
Type
.
UNDEF
:
// for now - remove eventually
break
;
case
Type
.
NIL
:
break
;
case
Type
.
BOOL
:
break
;
case
Type
.
UINT
:
break
;
case
Type
.
INT
:
break
;
case
Type
.
FLOAT
:
break
;
case
Type
.
STRING
:
break
;
case
Type
.
ANY
:
break
;
case
Type
.
ARRAY
:
break
;
case
Type
.
STRUCT
:
break
;
case
Type
.
INTERFACE
:
break
;
case
Type
.
MAP
:
break
;
case
Type
.
CHANNEL
:
break
;
case
Type
.
FUNCTION
:
break
;
case
Type
.
POINTER
:
break
;
case
Type
.
REFERENCE
:
break
;
default
:
Error
(
"illegal type form "
+
Type
.
FormStr
(
typ
.
form
));
}
}
func
VerifyObject
(
obj
*
Globals
.
Object
,
pnolev
int
)
{
VerifyType
(
obj
.
typ
);
switch
obj
.
kind
{
case
Object
.
CONST
:
break
;
case
Object
.
TYPE
:
break
;
case
Object
.
VAR
:
break
;
case
Object
.
FUNC
:
break
;
case
Object
.
PACKAGE
:
break
;
case
Object
.
LABEL
:
break
;
default
:
Error
(
"illegal object kind "
+
Object
.
KindStr
(
obj
.
kind
));
}
}
func
VerifyScope
(
scope
*
Globals
.
Scope
)
{
for
p
:=
scope
.
entries
.
first
;
p
!=
nil
;
p
=
p
.
next
{
VerifyObject
(
p
.
obj
,
0
);
}
}
func
VerifyPackage
(
pkg
*
Globals
.
Package
,
pno
int
)
{
VerifyObject
(
pkg
.
obj
,
0
);
}
export
Verify
func
Verify
(
comp
*
Globals
.
Compilation
)
{
for
i
:=
0
;
i
<
comp
.
npkgs
;
i
++
{
VerifyPackage
(
comp
.
pkgs
[
i
],
i
);
}
}
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