import Object "object"
import Type "type"
import Universe "universe"
-import Package "package"
import Scanner "scanner"
import Parser "parser"
import Export "export"
type Compilation struct {
src_name string;
pkg *Globals.Object;
- imports [256] *Package.Package; // TODO need open arrays
+ imports [256] *Globals.Package; // TODO need open arrays
nimports int;
}
-func (C *Compilation) Lookup(file_name string) *Package.Package {
+func (C *Compilation) Lookup(file_name string) *Globals.Package {
for i := 0; i < C.nimports; i++ {
pkg := C.imports[i];
if pkg.file_name == file_name {
}
-func (C *Compilation) Insert(pkg *Package.Package) {
+func (C *Compilation) Insert(pkg *Globals.Package) {
if C.Lookup(pkg.file_name) != nil {
panic "package already inserted";
}
}
-func (C *Compilation) InsertImport(pkg *Package.Package) *Package.Package {
+func (C *Compilation) InsertImport(pkg *Globals.Package) *Globals.Package {
p := C.Lookup(pkg.file_name);
if (p == nil) {
// no primary package found
print "parsing ", src_name, "\n";
P.ParseProgram();
+ //comp.Export();
}
import Globals "globals"
import Object "object"
import Type "type"
-import Package "package"
//import Compilation "compilation"
func (E *Exporter) WriteType(typ *Globals.Type);
func (E *Exporter) WriteObject(obj *Globals.Object);
-func (E *Exporter) WritePackage(pkg *Package.Package) ;
+func (E *Exporter) WritePackage(pkg *Globals.Package) ;
func (E *Exporter) WriteByte(x byte) {
}
-func (E *Exporter) WritePackage(pkg *Package.Package) {
+func (E *Exporter) WritePackage(pkg *Globals.Package) {
if pkg.ref >= 0 {
E.WritePackageTag(-pkg.ref); // package already exported
return;
E.type_ref = Universe.types.len();
*/
- var pkg *Package.Package = nil; // comp.packages[0];
+ var pkg *Globals.Package = nil; // comp.packages[0];
E.WritePackage(pkg);
for p := pkg.scope.entries.first; p != nil; p = p.next {
if p.obj.mark {
// The following types should really be in their respective files
-// object.go, type.go, and scope.go but they refer to each other
-// and we don't know how to handle forward-declared pointers across
-// packages yet.
+// (object.go, type.go, scope.go, package.go) but they refer to each
+// other and we don't know how to handle forward-declared pointers
+// across packages yet.
// ----------------------------------------------------------------------------
}
+export Package
+type Package struct {
+ ref int; // for exporting only: >= 0 means already exported
+ file_name string;
+ ident string;
+ key string;
+ scope *Scope;
+ pno int;
+}
+
+
// ----------------------------------------------------------------------------
// Creation
}
+export NewPackage;
+func NewPackage() *Package {
+ pkg := new(Package);
+ return pkg;
+}
+
+
// ----------------------------------------------------------------------------
// List methods
+++ /dev/null
-// 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.
-
-package Package
-
-import Globals "globals"
-
-export Package
-type Package struct {
- ref int;
- file_name string;
- ident string;
- key string;
- scope *Globals.Scope;
- pno int;
-}
-
-
-export NewPackage;
-func NewPackage() *Package {
- pkg := new(Package);
- return pkg;
-}