mirror of
https://github.com/golang/go
synced 2024-11-12 07:40:23 -07:00
- added missing file
R=r OCL=13681 CL=13681
This commit is contained in:
parent
6dd92ea6cb
commit
9fb9e82fa3
114
usr/gri/gosrc/verifier.go
Normal file
114
usr/gri/gosrc/verifier.go
Normal file
@ -0,0 +1,114 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user