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
5a81d1f2
Commit
5a81d1f2
authored
Jul 11, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- more go code
SVN=126934
parent
b07e084a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
0 deletions
+97
-0
usr/gri/gosrc/list.go
usr/gri/gosrc/list.go
+93
-0
usr/gri/gosrc/object.go
usr/gri/gosrc/object.go
+2
-0
usr/gri/gosrc/type.go
usr/gri/gosrc/type.go
+2
-0
No files found.
usr/gri/gosrc/list.go
0 → 100644
View file @
5a81d1f2
// 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
List
import
Globals
"globals"
// because of 6g warning
import
Object
"object"
import
Type
"type"
// TODO This is hideous! We need to have a decent way to do lists.
// Ideally open arrays that allow '+'.
type
Elem
struct
{
next
*
Elem
;
str
string
;
obj
*
Object
.
Object
;
typ
*
Type
.
Type
;
}
export
List
type
List
struct
{
len_
int
;
first
,
last
*
Elem
;
};
export
NewList
func
NewList
()
*
List
{
return
new
(
List
);
}
func
(
L
*
List
)
len_
()
int
{
return
L
.
len_
;
}
func
(
L
*
List
)
at
(
i
int
)
*
Elem
{
if
i
<
0
||
L
.
len_
<=
i
{
panic
"index out of bounds"
;
}
p
:=
L
.
first
;
for
;
i
>
0
;
i
--
{
p
=
p
.
next
;
}
return
p
;
}
func
(
L
*
List
)
Add
()
*
Elem
{
L
.
len_
++
;
e
:=
new
(
Elem
);
if
L
.
first
==
nil
{
L
.
first
=
e
;
}
L
.
last
.
next
=
e
;
L
.
last
=
e
;
}
func
(
L
*
List
)
StrAt
(
i
int
)
string
{
return
L
.
at
(
i
)
.
str
;
}
func
(
L
*
List
)
ObjAt
(
i
int
)
*
Object
.
Object
{
return
L
.
at
(
i
)
.
obj
;
}
func
(
L
*
List
)
TypAt
(
i
int
)
*
Type
.
Type
{
return
L
.
at
(
i
)
.
typ
;
}
func
(
L
*
List
)
AddStr
(
str
string
)
{
L
.
Add
()
.
str
=
str
;
}
func
(
L
*
List
)
AddObj
(
obj
*
Object
.
Object
)
{
L
.
Add
()
.
obj
=
obj
;
}
func
(
L
*
List
)
AddTyp
(
typ
*
Type
.
Type
)
{
L
.
Add
()
.
typ
=
typ
;
}
usr/gri/gosrc/object.go
View file @
5a81d1f2
...
...
@@ -15,9 +15,11 @@ const /* kind */ (
)
export
Object
type
Object
Globals
.
Object
export
NewObject
func
NewObject
(
kind
int
,
name
string
)
*
Object
{
obj
:=
new
(
Object
);
obj
.
mark
=
false
;
...
...
usr/gri/gosrc/type.go
View file @
5a81d1f2
...
...
@@ -24,9 +24,11 @@ const /* flag */ (
)
export
Type
type
Type
Globals
.
Type
export
NewType
func
NewType
(
form
int
)
*
Type
{
panic
"UNIMPLEMENTED"
;
return
nil
;
...
...
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