Commit bef9b171 authored by Robert Griesemer's avatar Robert Griesemer

- removed uses of vector in favor of array in a few places

- fixed make.bash

R=r
DELTA=21  (1 added, 3 deleted, 17 changed)
OCL=19624
CL=19629
parent 6d30efc7
...@@ -18,9 +18,7 @@ function builddirs() { ...@@ -18,9 +18,7 @@ function builddirs() {
for i for i
do do
echo; echo; echo %%%% making lib/$i %%%%; echo echo; echo; echo %%%% making lib/$i %%%%; echo
cd $i (cd $i; make install)
make install
cd ..
done done
} }
...@@ -35,6 +33,7 @@ builddirs syscall\ ...@@ -35,6 +33,7 @@ builddirs syscall\
math\ math\
os\ os\
strconv\ strconv\
container/array\
reflect\ reflect\
buildfiles io.go buildfiles io.go
...@@ -54,4 +53,3 @@ builddirs net\ ...@@ -54,4 +53,3 @@ builddirs net\
time\ time\
http\ http\
regexp\ regexp\
container/array\
...@@ -8,7 +8,7 @@ package regexp ...@@ -8,7 +8,7 @@ package regexp
import ( import (
"os"; "os";
"vector"; "array";
) )
export var debug = false; export var debug = false;
...@@ -50,7 +50,7 @@ type RE struct { ...@@ -50,7 +50,7 @@ type RE struct {
expr string; // the original expression expr string; // the original expression
ch *chan<- *RE; // reply channel when we're done ch *chan<- *RE; // reply channel when we're done
error *os.Error; // compile- or run-time error; nil if OK error *os.Error; // compile- or run-time error; nil if OK
inst *vector.Vector; inst *array.Array;
start Inst; start Inst;
nbra int; // number of brackets in expression, for subexpressions nbra int; // number of brackets in expression, for subexpressions
} }
...@@ -123,8 +123,8 @@ type CharClass struct { ...@@ -123,8 +123,8 @@ type CharClass struct {
Common; Common;
char int; char int;
negate bool; // is character class negated? ([^a-z]) negate bool; // is character class negated? ([^a-z])
// Vector of int, stored pairwise: [a-z] is (a,z); x is (x,x): // array of int, stored pairwise: [a-z] is (a,z); x is (x,x):
ranges *vector.Vector; ranges *array.IntArray;
} }
func (cclass *CharClass) Type() int { return CHARCLASS } func (cclass *CharClass) Type() int { return CHARCLASS }
...@@ -135,8 +135,8 @@ func (cclass *CharClass) Print() { ...@@ -135,8 +135,8 @@ func (cclass *CharClass) Print() {
print(" (negated)"); print(" (negated)");
} }
for i := 0; i < cclass.ranges.Len(); i += 2 { for i := 0; i < cclass.ranges.Len(); i += 2 {
l := cclass.ranges.At(i).(int); l := cclass.ranges.At(i);
r := cclass.ranges.At(i+1).(int); r := cclass.ranges.At(i+1);
if l == r { if l == r {
print(" [", string(l), "]"); print(" [", string(l), "]");
} else { } else {
...@@ -147,14 +147,14 @@ func (cclass *CharClass) Print() { ...@@ -147,14 +147,14 @@ func (cclass *CharClass) Print() {
func (cclass *CharClass) AddRange(a, b int) { func (cclass *CharClass) AddRange(a, b int) {
// range is a through b inclusive // range is a through b inclusive
cclass.ranges.Append(a); cclass.ranges.Push(a);
cclass.ranges.Append(b); cclass.ranges.Push(b);
} }
func (cclass *CharClass) Matches(c int) bool { func (cclass *CharClass) Matches(c int) bool {
for i := 0; i < cclass.ranges.Len(); i = i+2 { for i := 0; i < cclass.ranges.Len(); i = i+2 {
min := cclass.ranges.At(i).(int); min := cclass.ranges.At(i);
max := cclass.ranges.At(i+1).(int); max := cclass.ranges.At(i+1);
if min <= c && c <= max { if min <= c && c <= max {
return !cclass.negate return !cclass.negate
} }
...@@ -164,7 +164,7 @@ func (cclass *CharClass) Matches(c int) bool { ...@@ -164,7 +164,7 @@ func (cclass *CharClass) Matches(c int) bool {
func NewCharClass() *CharClass { func NewCharClass() *CharClass {
c := new(CharClass); c := new(CharClass);
c.ranges = vector.New(); c.ranges = array.NewIntArray(0);
return c; return c;
} }
...@@ -220,7 +220,7 @@ func (re *RE) Error(err *os.Error) { ...@@ -220,7 +220,7 @@ func (re *RE) Error(err *os.Error) {
func (re *RE) Add(i Inst) Inst { func (re *RE) Add(i Inst) Inst {
i.SetIndex(re.inst.Len()); i.SetIndex(re.inst.Len());
re.inst.Append(i); re.inst.Push(i);
return i; return i;
} }
...@@ -574,7 +574,7 @@ func (re *RE) DoParse() { ...@@ -574,7 +574,7 @@ func (re *RE) DoParse() {
func Compiler(str string, ch *chan *RE) { func Compiler(str string, ch *chan *RE) {
re := new(RE); re := new(RE);
re.expr = str; re.expr = str;
re.inst = vector.New(); re.inst = array.New(0);
re.ch = ch; re.ch = ch;
re.DoParse(); re.DoParse();
ch <- re; ch <- re;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
package main package main
import vector "vector" import "array"
type S struct { type S struct {
...@@ -21,7 +21,7 @@ func (p *S) Init(val int) *S { ...@@ -21,7 +21,7 @@ func (p *S) Init(val int) *S {
func test0() { func test0() {
v := vector.New(); v := array.New(0);
if v.Len() != 0 { if v.Len() != 0 {
panic("len = ", v.Len(), "\n"); panic("len = ", v.Len(), "\n");
} }
...@@ -34,7 +34,7 @@ func test1() { ...@@ -34,7 +34,7 @@ func test1() {
a[i] = new(S).Init(i); a[i] = new(S).Init(i);
} }
v := vector.New(); v := array.New(0);
for i := 0; i < len(a); i++ { for i := 0; i < len(a); i++ {
v.Insert(0, a[i]); v.Insert(0, a[i]);
if v.Len() != i + 1 { if v.Len() != i + 1 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment