summaryrefslogtreecommitdiff
path: root/usr/gri/src
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2008-07-10 17:21:23 -0700
committerRobert Griesemer <gri@golang.org>2008-07-10 17:21:23 -0700
commitd1284ef9f08ad1b342a27b2f5de064b07bb45d03 (patch)
tree77d68f216b633c3bf58b95518cdcee6695774049 /usr/gri/src
parentca6079deade34725c2cfbd59dccec7d26a3ed305 (diff)
downloadgolang-d1284ef9f08ad1b342a27b2f5de064b07bb45d03.tar.gz
- more frontend pieces in Go
SVN=126744
Diffstat (limited to 'usr/gri/src')
-rw-r--r--usr/gri/src/globals.go66
-rwxr-xr-xusr/gri/src/object.go29
-rw-r--r--usr/gri/src/scope.go14
-rw-r--r--usr/gri/src/type.go33
4 files changed, 142 insertions, 0 deletions
diff --git a/usr/gri/src/globals.go b/usr/gri/src/globals.go
new file mode 100644
index 000000000..f8d0c116b
--- /dev/null
+++ b/usr/gri/src/globals.go
@@ -0,0 +1,66 @@
+// 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 Globals;
+
+
+// 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.
+
+
+// ----------------------------------------------------------------------------
+
+export Object
+type Object struct {
+ mark bool; // mark => object marked for export
+ kind int;
+ name string;
+ type_ *Type;
+ pnolev int; // >= 0: package no., <= 0: level, 0: global level of compilation
+}
+
+
+// ----------------------------------------------------------------------------
+
+export Type
+type Type struct {
+ ref int; // for exporting only: >= 0 means already exported
+ form int;
+ flags int; // channels, functions
+ size int; // in bytes
+ len_ int; // array length, no. of parameters (w/o recv)
+ obj *Object; // primary type object or NULL
+ key *Object; // maps
+ elt *Object; // arrays, maps, channels, pointers, references
+ scope *Scope; // incomplete types, structs, interfaces, functions, packages
+}
+
+
+// ----------------------------------------------------------------------------
+
+export Scope
+type Scope struct {
+ parent *Scope;
+ // list ObjList
+
+}
+
+
+func (scope *Scope) Lookup(ident string) *Object {
+ panic "UNIMPLEMENTED";
+ return nil;
+}
+
+
+func (scope *Scope) Insert(obj *Object) {
+ panic "UNIMPLEMENTED";
+}
+
+
+func (scope *Scope) InsertImport(obj *Object) *Object {
+ panic "UNIMPLEMENTED";
+ return nil;
+}
diff --git a/usr/gri/src/object.go b/usr/gri/src/object.go
new file mode 100755
index 000000000..cf1a432aa
--- /dev/null
+++ b/usr/gri/src/object.go
@@ -0,0 +1,29 @@
+// 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 Object
+
+import Globals "globals"
+
+
+export BAD, CONST, TYPE, VAR, FUNC, PACKAGE
+const /* kind */ (
+ BAD = iota; // error handling
+ CONST; TYPE; VAR; FUNC; PACKAGE;
+ PTYPE; // primary type (import/export only)
+)
+
+
+type Object Globals.Object
+
+
+func NewObject(kind int, name string) *Object {
+ obj := new(Object);
+ obj.mark = false;
+ obj.kind = kind;
+ obj.name = name;
+ obj.type_ = nil; // Universe::undef_t;
+ obj.pnolev = 0;
+ return obj;
+}
diff --git a/usr/gri/src/scope.go b/usr/gri/src/scope.go
new file mode 100644
index 000000000..13a14ce49
--- /dev/null
+++ b/usr/gri/src/scope.go
@@ -0,0 +1,14 @@
+// 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 Scope
+
+import Globals "Globals"
+
+type Scope Globals.Scope
+
+func New(parent *Scope) *Scope {
+ panic "UNIMPLEMENTED";
+ return nil;
+}
diff --git a/usr/gri/src/type.go b/usr/gri/src/type.go
new file mode 100644
index 000000000..975adec68
--- /dev/null
+++ b/usr/gri/src/type.go
@@ -0,0 +1,33 @@
+// 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 Type
+
+import Globals "globals"
+
+const /* form */ (
+ // internal types
+ UNDEF = iota; BAD; NIL;
+ // basic types
+ BOOL; UINT; INT; FLOAT; STRING;
+ // 'any' type
+ ANY;
+ // composite types
+ ARRAY; STRUCT; INTERFACE; MAP; CHANNEL; FUNCTION; POINTER; REFERENCE;
+)
+
+
+const /* flag */ (
+ SEND = 1 << iota; // chan>
+ RECV; // chan< or method
+)
+
+
+type Type Globals.Type
+
+
+func NewType(form int) *Type {
+ panic "UNIMPLEMENTED";
+ return nil;
+}