1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:14:41 -07:00

put copy into goyacc

R=rsc
https://golang.org/cl/156100
This commit is contained in:
Ken Thompson 2009-11-19 15:34:11 -08:00
parent 4e201c7f20
commit d9014dc98a

View File

@ -569,9 +569,7 @@ outer:
mem++; mem++;
if mem >= len(curprod) { if mem >= len(curprod) {
ncurprod := make([]int, mem+RULEINC); ncurprod := make([]int, mem+RULEINC);
for ll := 0; ll < mem; ll++ { copy(ncurprod, curprod);
ncurprod[ll] = curprod[ll]
}
curprod = ncurprod; curprod = ncurprod;
} }
t = gettok(); t = gettok();
@ -620,9 +618,7 @@ outer:
mem++; mem++;
if mem >= len(curprod) { if mem >= len(curprod) {
ncurprod := make([]int, mem+RULEINC); ncurprod := make([]int, mem+RULEINC);
for ll := 0; ll < mem; ll++ { copy(ncurprod, curprod);
ncurprod[ll] = curprod[ll]
}
curprod = ncurprod; curprod = ncurprod;
} }
} }
@ -656,9 +652,7 @@ outer:
} }
moreprod(); moreprod();
prdptr[nprod] = make([]int, mem); prdptr[nprod] = make([]int, mem);
for ll := 0; ll < mem; ll++ { copy(prdptr[nprod], curprod);
prdptr[nprod][ll] = curprod[ll]
}
nprod++; nprod++;
moreprod(); moreprod();
levprd[nprod] = 0; levprd[nprod] = 0;
@ -704,11 +698,9 @@ func moreprod() {
alevprd := make([]int, nn); alevprd := make([]int, nn);
arlines := make([]int, nn); arlines := make([]int, nn);
for ll := 0; ll < n; ll++ { copy(aprod, prdptr);
aprod[ll] = prdptr[ll]; copy(alevprd, levprd);
alevprd[ll] = levprd[ll]; copy(arlines, rlines);
arlines[ll] = rlines[ll];
}
prdptr = aprod; prdptr = aprod;
levprd = alevprd; levprd = alevprd;
@ -726,9 +718,7 @@ func defin(nt int, s string) int {
nnonter++; nnonter++;
if nnonter >= len(nontrst) { if nnonter >= len(nontrst) {
anontrst := make([]Symb, nnonter+SYMINC); anontrst := make([]Symb, nnonter+SYMINC);
for ll := 0; ll < len(nontrst); ll++ { copy(anontrst, nontrst);
anontrst[ll] = nontrst[ll]
}
nontrst = anontrst; nontrst = anontrst;
} }
nontrst[nnonter] = Symb{s, 0}; nontrst[nnonter] = Symb{s, 0};
@ -742,10 +732,8 @@ func defin(nt int, s string) int {
atokset := make([]Symb, nn); atokset := make([]Symb, nn);
atoklev := make([]int, nn); atoklev := make([]int, nn);
for ll := 0; ll < len(tokset); ll++ { copy(atoklev, toklev);
atoklev[ll] = toklev[ll]; copy(atokset, tokset);
atokset[ll] = tokset[ll];
}
tokset = atokset; tokset = atokset;
toklev = atoklev; toklev = atoklev;
@ -1497,9 +1485,7 @@ func cpres() {
continue; continue;
} }
pres[i] = make([][]int, n); pres[i] = make([][]int, n);
for ll := 0; ll < n; ll++ { copy(pres[i], curres);
pres[i][ll] = curres[ll]
}
} }
fatfl = 1; fatfl = 1;
if nerrors != 0 { if nerrors != 0 {
@ -1789,9 +1775,7 @@ func closure(i int) {
for p := pstate[i]; p < q; p++ { for p := pstate[i]; p < q; p++ {
wsets[cwp].pitem = statemem[p].pitem; wsets[cwp].pitem = statemem[p].pitem;
wsets[cwp].flag = 1; // this item must get closed wsets[cwp].flag = 1; // this item must get closed
for ll := 0; ll < len(wsets[cwp].ws); ll++ { copy(wsets[cwp].ws, statemem[p].look);
wsets[cwp].ws[ll] = statemem[p].look[ll]
}
cwp++; cwp++;
} }
@ -1881,9 +1865,7 @@ func closure(i int) {
// not there; make a new entry // not there; make a new entry
if cwp >= len(wsets) { if cwp >= len(wsets) {
awsets := make([]Wset, cwp+WSETINC); awsets := make([]Wset, cwp+WSETINC);
for ll := 0; ll < len(wsets); ll++ { copy(awsets, wsets);
awsets[ll] = wsets[ll]
}
wsets = awsets; wsets = awsets;
} }
wsets[cwp].pitem = Pitem{prd, 0, prd[0], -prd[len(prd)-1]}; wsets[cwp].pitem = Pitem{prd, 0, prd[0], -prd[len(prd)-1]};
@ -1891,9 +1873,7 @@ func closure(i int) {
wsets[cwp].ws = mkset(); wsets[cwp].ws = mkset();
if nolook == 0 { if nolook == 0 {
work = 1; work = 1;
for ll := 0; ll < len(wsets[cwp].ws); ll++ { copy(wsets[cwp].ws, clset);
wsets[cwp].ws[ll] = clset[ll]
}
} }
cwp++; cwp++;
} }
@ -2017,17 +1997,13 @@ func putitem(p Pitem, set Lkset) {
j := pstate[nstate+1]; j := pstate[nstate+1];
if j >= len(statemem) { if j >= len(statemem) {
asm := make([]Item, j+STATEINC); asm := make([]Item, j+STATEINC);
for ll := 0; ll < len(statemem); ll++ { copy(asm, statemem);
asm[ll] = statemem[ll]
}
statemem = asm; statemem = asm;
} }
statemem[j].pitem = p; statemem[j].pitem = p;
if nolook == 0 { if nolook == 0 {
s := mkset(); s := mkset();
for ll := 0; ll < len(set); ll++ { copy(s, set);
s[ll] = set[ll]
}
statemem[j].look = s; statemem[j].look = s;
} }
j++; j++;
@ -2990,7 +2966,7 @@ func usage() {
func bitset(set Lkset, bit int) int { return set[bit>>5] & (1 << uint(bit&31)) } func bitset(set Lkset, bit int) int { return set[bit>>5] & (1 << uint(bit&31)) }
func setbit(set Lkset, bit int) { set[bit>>5] |= (1 << uint(bit & 31)) } func setbit(set Lkset, bit int) { set[bit>>5] |= (1 << uint(bit&31)) }
func mkset() Lkset { return make([]int, tbitset) } func mkset() Lkset { return make([]int, tbitset) }