version 1.1, 2018/09/19 05:45:08 |
version 1.2, 2018/09/28 08:20:29 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM$ |
* $OpenXM: OpenXM_contrib2/asir2018/parse/util.c,v 1.1 2018/09/19 05:45:08 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 100 unsigned int ator(unsigned int addr,Obj *r) |
|
Line 100 unsigned int ator(unsigned int addr,Obj *r) |
|
if ( !addr ) |
if ( !addr ) |
q = 0; |
q = 0; |
if ( addr < BASE ) |
if ( addr < BASE ) |
STOQ(addr,q); |
STOZ(addr,q); |
else { |
else { |
n = NALLOC(2); PL(n) = 2; |
n = NALLOC(2); PL(n) = 2; |
BD(n)[0] = addr-BASE; BD(n)[1] = addr>>BSH; NTOQ(n,1,q); |
BD(n)[0] = addr-BASE; BD(n)[1] = addr>>BSH; NTOQ(n,1,q); |
Line 124 void getarray(pointer a,NODE ind,pointer *vp) |
|
Line 124 void getarray(pointer a,NODE ind,pointer *vp) |
|
else if ( NEXT(ind) ) |
else if ( NEXT(ind) ) |
error("getarray : invalid index"); |
error("getarray : invalid index"); |
else { |
else { |
i = (int)BDY((BYTEARRAY)a)[QTOS((Q)len)]; |
i = (int)BDY((BYTEARRAY)a)[ZTOS((Q)len)]; |
STOQ(i,q); |
STOZ(i,q); |
*vp = (pointer)q; |
*vp = (pointer)q; |
} |
} |
return; |
return; |
Line 139 void getarray(pointer a,NODE ind,pointer *vp) |
|
Line 139 void getarray(pointer a,NODE ind,pointer *vp) |
|
if ( !rangecheck(len,((VECT)a)->len) ) |
if ( !rangecheck(len,((VECT)a)->len) ) |
error("getarray : Out of range"); |
error("getarray : Out of range"); |
else |
else |
a = (pointer)(BDY((VECT)a)[QTOS((Q)len)]); |
a = (pointer)(BDY((VECT)a)[ZTOS((Q)len)]); |
break; |
break; |
case O_MAT: |
case O_MAT: |
row = (Obj)BDY(ind); |
row = (Obj)BDY(ind); |
Line 151 void getarray(pointer a,NODE ind,pointer *vp) |
|
Line 151 void getarray(pointer a,NODE ind,pointer *vp) |
|
if ( !rangecheck(col,((MAT)a)->col) ) |
if ( !rangecheck(col,((MAT)a)->col) ) |
error("getarray : Out of range"); |
error("getarray : Out of range"); |
else |
else |
a = (pointer)(BDY((MAT)a)[QTOS((Q)row)][QTOS((Q)col)]); |
a = (pointer)(BDY((MAT)a)[ZTOS((Q)row)][ZTOS((Q)col)]); |
} else { |
} else { |
NEWVECT(v); v->len = ((MAT)a)->col; |
NEWVECT(v); v->len = ((MAT)a)->col; |
v->body = (pointer *)BDY((MAT)a)[QTOS((Q)row)]; |
v->body = (pointer *)BDY((MAT)a)[ZTOS((Q)row)]; |
a = (pointer)v; |
a = (pointer)v; |
} |
} |
break; |
break; |
Line 162 void getarray(pointer a,NODE ind,pointer *vp) |
|
Line 162 void getarray(pointer a,NODE ind,pointer *vp) |
|
row = (Obj)BDY(ind); |
row = (Obj)BDY(ind); |
ind = NEXT(ind); |
ind = NEXT(ind); |
col = (Obj)BDY(ind); |
col = (Obj)BDY(ind); |
if ( ((IMAT)a)->row < QTOS((Q)row) || |
if ( ((IMAT)a)->row < ZTOS((Q)row) || |
((IMAT)a)->col < QTOS((Q)col) || |
((IMAT)a)->col < ZTOS((Q)col) || |
(QTOS((Q)row) < 0) || (QTOS((Q)col) < 0)) |
(ZTOS((Q)row) < 0) || (ZTOS((Q)col) < 0)) |
error("putarray : Out of range"); |
error("putarray : Out of range"); |
GetIbody((IMAT)a, QTOS((Q)row), QTOS((Q)col), (Obj*)&trg); |
GetIbody((IMAT)a, ZTOS((Q)row), ZTOS((Q)col), (Obj*)&trg); |
a = (pointer)trg; |
a = (pointer)trg; |
break; |
break; |
case O_LIST: |
case O_LIST: |
n0 = BDY((LIST)a); i = QTOS((Q)BDY(ind)); |
n0 = BDY((LIST)a); i = ZTOS((Q)BDY(ind)); |
if ( i < 0 ) |
if ( i < 0 ) |
error("getarray : Out of range"); |
error("getarray : Out of range"); |
for ( n = n0; i > 0 && n; n = NEXT(n), i-- ); |
for ( n = n0; i > 0 && n; n = NEXT(n), i-- ); |
Line 200 void putarray(pointer a,NODE ind,pointer b) |
|
Line 200 void putarray(pointer a,NODE ind,pointer b) |
|
else if ( NEXT(ind) ) |
else if ( NEXT(ind) ) |
error("putarray : invalid index"); |
error("putarray : invalid index"); |
else |
else |
BDY((BYTEARRAY)a)[QTOS((Q)len)] = (unsigned char)QTOS((Q)b); |
BDY((BYTEARRAY)a)[ZTOS((Q)len)] = (unsigned char)ZTOS((Q)b); |
return; |
return; |
} |
} |
for ( ; ind; ind = NEXT(ind) ) { |
for ( ; ind; ind = NEXT(ind) ) { |
Line 212 void putarray(pointer a,NODE ind,pointer b) |
|
Line 212 void putarray(pointer a,NODE ind,pointer b) |
|
if ( !rangecheck(len,((VECT)a)->len) ) |
if ( !rangecheck(len,((VECT)a)->len) ) |
error("putarray : Out of range"); |
error("putarray : Out of range"); |
else if ( NEXT(ind) ) |
else if ( NEXT(ind) ) |
a = BDY((VECT)a)[QTOS((Q)len)]; |
a = BDY((VECT)a)[ZTOS((Q)len)]; |
else |
else |
BDY((VECT)a)[QTOS((Q)len)] = b; |
BDY((VECT)a)[ZTOS((Q)len)] = b; |
break; |
break; |
case O_MAT: |
case O_MAT: |
row = (Obj)BDY(ind); |
row = (Obj)BDY(ind); |
Line 226 void putarray(pointer a,NODE ind,pointer b) |
|
Line 226 void putarray(pointer a,NODE ind,pointer b) |
|
if ( !rangecheck(col,((MAT)a)->col) ) |
if ( !rangecheck(col,((MAT)a)->col) ) |
error("putarray : Out of range"); |
error("putarray : Out of range"); |
else if ( NEXT(ind) ) |
else if ( NEXT(ind) ) |
a = BDY((MAT)a)[QTOS((Q)row)][QTOS((Q)col)]; |
a = BDY((MAT)a)[ZTOS((Q)row)][ZTOS((Q)col)]; |
else |
else |
BDY((MAT)a)[QTOS((Q)row)][QTOS((Q)col)] = b; |
BDY((MAT)a)[ZTOS((Q)row)][ZTOS((Q)col)] = b; |
} else |
} else |
error("putarray : invalid assignment"); |
error("putarray : invalid assignment"); |
break; |
break; |
Line 236 void putarray(pointer a,NODE ind,pointer b) |
|
Line 236 void putarray(pointer a,NODE ind,pointer b) |
|
row = (Obj)BDY(ind); |
row = (Obj)BDY(ind); |
ind = NEXT(ind); |
ind = NEXT(ind); |
col = (Obj)BDY(ind); |
col = (Obj)BDY(ind); |
if ( ((IMAT)a)->row < QTOS((Q)row) || |
if ( ((IMAT)a)->row < ZTOS((Q)row) || |
((IMAT)a)->col < QTOS((Q)col) || |
((IMAT)a)->col < ZTOS((Q)col) || |
(QTOS((Q)row) < 0) || (QTOS((Q)col) < 0)) |
(ZTOS((Q)row) < 0) || (ZTOS((Q)col) < 0)) |
error("putarray : Out of range"); |
error("putarray : Out of range"); |
PutIent((IMAT)a, QTOS((Q)row), QTOS((Q)col), (Obj)b); |
PutIent((IMAT)a, ZTOS((Q)row), ZTOS((Q)col), (Obj)b); |
break; |
break; |
case O_LIST: |
case O_LIST: |
if ( NEXT(ind) ) { |
if ( NEXT(ind) ) { |
n0 = BDY((LIST)a); i = QTOS((Q)BDY(ind)); |
n0 = BDY((LIST)a); i = ZTOS((Q)BDY(ind)); |
if ( i < 0 ) |
if ( i < 0 ) |
error("putarray : Out of range"); |
error("putarray : Out of range"); |
for ( n = n0; i > 0 && n; n = NEXT(n), i-- ); |
for ( n = n0; i > 0 && n; n = NEXT(n), i-- ); |
Line 270 int rangecheck(Obj a,int n) |
|
Line 270 int rangecheck(Obj a,int n) |
|
return 1; |
return 1; |
if ( OID(a) != O_N || !RATN(a) || !INT(a) || sgnq((Q)a) < 0 ) |
if ( OID(a) != O_N || !RATN(a) || !INT(a) || sgnq((Q)a) < 0 ) |
return 0; |
return 0; |
STOQ(n,z); |
STOZ(n,z); |
if ( cmpz((Z)a,z) >= 0 ) return 0; |
if ( cmpz((Z)a,z) >= 0 ) return 0; |
else return 1; |
else return 1; |
} |
} |