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
b0ada5dd
Commit
b0ada5dd
authored
Jul 23, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- more work on semantic checks - not yet enabled by default
R=r OCL=13391 CL=13391
parent
84c8d85f
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
233 additions
and
89 deletions
+233
-89
usr/gri/gosrc/ast.go
usr/gri/gosrc/ast.go
+28
-4
usr/gri/gosrc/export.go
usr/gri/gosrc/export.go
+16
-27
usr/gri/gosrc/globals.go
usr/gri/gosrc/globals.go
+2
-2
usr/gri/gosrc/import.go
usr/gri/gosrc/import.go
+5
-5
usr/gri/gosrc/parser.go
usr/gri/gosrc/parser.go
+179
-36
usr/gri/gosrc/scope.go
usr/gri/gosrc/scope.go
+0
-14
usr/gri/gosrc/type.go
usr/gri/gosrc/type.go
+3
-1
No files found.
usr/gri/gosrc/ast.go
View file @
b0ada5dd
...
...
@@ -8,15 +8,39 @@ import Globals "globals"
import
Universe
"universe"
// ----------------------------------------------------------------------------
// Expressions
export
Expr
type
Expr
struct
{
type
Expr
interface
{
}
export
BinaryExpr
type
BinaryExpr
struct
{
typ
*
Globals
.
Type
;
op
int
;
x
,
y
*
Expr
;
x
,
y
Expr
;
}
// ----------------------------------------------------------------------------
// Statements
export
Stat
type
Stat
struct
{
// To be completed
type
Stat
interface
{
}
export
Block
type
Block
struct
{
// TODO fill in
}
export
IfStat
type
IfStat
struct
{
cond
Expr
;
then_
Stat
;
else_
Stat
;
}
usr/gri/gosrc/export.go
View file @
b0ada5dd
...
...
@@ -149,23 +149,23 @@ func (E *Exporter) WriteObject(obj *Globals.Object) {
E
.
WriteObjTag
(
obj
.
kind
);
E
.
WriteString
(
obj
.
ident
);
E
.
WriteType
(
obj
.
typ
);
E
.
WritePackage
(
E
.
comp
.
pkgs
[
obj
.
pnolev
]);
//
E.WritePackage(E.comp.pkgs[obj.pnolev]);
switch
obj
.
kind
{
case
Object
.
BAD
:
fallthrough
;
case
Object
.
PACKAGE
:
fallthrough
;
case
Object
.
PTYPE
:
panic
"UNREACHABLE"
;
case
Object
.
CONST
:
E
.
WriteInt
(
0
);
// should be the correct value
break
;
case
Object
.
TYPE
:
// nothing to do
case
Object
.
VAR
:
E
.
WriteInt
(
0
);
// should be the correct address/offset
case
Object
.
FUNC
:
E
.
WriteInt
(
0
);
// should be the correct address/offset
default
:
print
"obj.kind = "
,
obj
.
kind
,
"
\n
"
;
panic
"UNREACHABLE"
;
}
}
...
...
@@ -200,41 +200,30 @@ func (E *Exporter) WriteType(typ *Globals.Type) {
}
switch
typ
.
form
{
case
Type
.
UNDEF
:
fallthrough
;
case
Type
.
BAD
:
fallthrough
;
case
Type
.
NIL
:
fallthrough
;
case
Type
.
BOOL
:
fallthrough
;
case
Type
.
UINT
:
fallthrough
;
case
Type
.
INT
:
fallthrough
;
case
Type
.
FLOAT
:
fallthrough
;
case
Type
.
STRING
:
fallthrough
;
case
Type
.
ANY
:
panic
"UNREACHABLE"
;
case
Type
.
ARRAY
:
E
.
WriteInt
(
typ
.
len_
);
E
.
WriteType
Field
(
typ
.
elt
);
E
.
WriteType
(
typ
.
elt
);
case
Type
.
MAP
:
E
.
WriteType
Field
(
typ
.
key
);
E
.
WriteType
Field
(
typ
.
elt
);
E
.
WriteType
(
typ
.
key
);
E
.
WriteType
(
typ
.
elt
);
case
Type
.
CHANNEL
:
E
.
WriteInt
(
typ
.
flags
);
E
.
WriteType
Field
(
typ
.
elt
);
E
.
WriteType
(
typ
.
elt
);
case
Type
.
FUNCTION
:
E
.
WriteInt
(
typ
.
flags
);
fallthrough
;
case
Type
.
STRUCT
:
fallthrough
;
case
Type
.
INTERFACE
:
E
.
WriteScope
(
typ
.
scope
)
;
case
Type
.
STRUCT
,
Type
.
INTERFACE
:
E
.
WriteScope
(
typ
.
scope
);
case
Type
.
POINTER
:
fallthrough
;
case
Type
.
REFERENCE
:
E
.
WriteTypeField
(
typ
.
elt
);
case
Type
.
POINTER
,
Type
.
REFERENCE
:
E
.
WriteType
(
typ
.
elt
);
default
:
print
"typ.form = "
,
typ
.
form
,
"
\n
"
;
panic
"UNREACHABLE"
;
}
}
...
...
usr/gri/gosrc/globals.go
View file @
b0ada5dd
...
...
@@ -32,8 +32,8 @@ type Type struct {
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, reference
s
key
*
Type
;
// maps
elt
*
Type
;
// arrays, maps, channels, pointer
s
scope
*
Scope
;
// structs, interfaces, functions
}
...
...
usr/gri/gosrc/import.go
View file @
b0ada5dd
...
...
@@ -216,15 +216,15 @@ func (I *Importer) ReadType() *Globals.Type {
case
Type
.
ARRAY
:
typ
.
len_
=
I
.
ReadInt
();
typ
.
elt
=
I
.
ReadType
Field
();
typ
.
elt
=
I
.
ReadType
();
case
Type
.
MAP
:
typ
.
key
=
I
.
ReadType
Field
();
typ
.
elt
=
I
.
ReadType
Field
();
typ
.
key
=
I
.
ReadType
();
typ
.
elt
=
I
.
ReadType
();
case
Type
.
CHANNEL
:
typ
.
flags
=
I
.
ReadInt
();
typ
.
elt
=
I
.
ReadType
Field
();
typ
.
elt
=
I
.
ReadType
();
case
Type
.
FUNCTION
:
typ
.
flags
=
I
.
ReadInt
();
...
...
@@ -235,7 +235,7 @@ func (I *Importer) ReadType() *Globals.Type {
case
Type
.
POINTER
:
fallthrough
;
case
Type
.
REFERENCE
:
typ
.
elt
=
I
.
ReadType
Field
();
typ
.
elt
=
I
.
ReadType
();
}
return
ptyp
;
// only use primary type
...
...
usr/gri/gosrc/parser.go
View file @
b0ada5dd
This diff is collapsed.
Click to expand it.
usr/gri/gosrc/scope.go
deleted
100644 → 0
View file @
84c8d85f
// 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
;
}
usr/gri/gosrc/type.go
View file @
b0ada5dd
...
...
@@ -10,7 +10,6 @@ export
ANY
,
ARRAY
,
STRUCT
,
INTERFACE
,
MAP
,
CHANNEL
,
FUNCTION
,
POINTER
,
REFERENCE
const
/* form */
(
// internal types
UNDEF
=
iota
;
BAD
;
NIL
;
...
...
@@ -23,6 +22,9 @@ const /* form */ (
)
export
SEND
,
RECV
const
/* flag */
(
SEND
=
1
<<
iota
;
// chan>
RECV
;
// chan< or method
...
...
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