📄 sctpred.c
字号:
return ;
}
if ( (*BVar).Bits != (SDL_Bit *)0 && (*BVar).Bits == BExpr.Bits )
return;
if ( (*BVar).Bits != (SDL_Bit *)0 && AssType == XASS )
xFree_SDL_Bit_String((void **)BVar);
(*BVar).Length = BExpr.Length;
(*BVar).IsAssigned = (xbool)1;
if (!BExpr.IsAssigned && (AssType != XASS2MAKE))
(*BVar).Bits = BExpr.Bits;
else if (BExpr.Bits == (SDL_Bit *)0)
(*BVar).Bits = (SDL_Bit *)0;
else {
(*BVar).Bits = xAlloc_SDL_Bit_String((xptrint)(BExpr.Length));
(void)memcpy((void *)(*BVar).Bits, (void *)BExpr.Bits, BExpr.Length);
}
/* Used in output : */
if (AssType == XASSMAKE)
{
/*
** Tag destination variable as not assigned (occurs in
** PRD returns x <sortname> and Make!), so that
** the memory later can be reused when it is assigned
** to the SDL variable.
*/
(*BVar).IsAssigned = (xbool)0;
}
if (IsXASSPARA)
{
(*BVar).IsUsedInSignal = (xbool)XMK_TRUE;
}
/* Used in input : */
if (BExpr.IsUsedInSignal)
{
xFree_SDL_Bit_String((void **)&BExpr);
}
}
/*---+---------------------------------------------------------------
xEq_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Boolean xEq_SDL_Bit_String (
SDL_Bit_String B1,
SDL_Bit_String B2 )
#else
SDL_Boolean xEq_SDL_Bit_String (B1, B2)
SDL_Bit_String B1;
SDL_Bit_String B2;
#endif
{
SDL_Bit * p1;
SDL_Bit * p2;
SDL_Boolean Result;
int i;
Result = SDL_True;
if (B1.Length != B2.Length) Result = SDL_False;
p1 = B1.Bits; p2 = B2.Bits;
for (i=0; i<B1.Length && Result; i++)
if ( *(p1++) != *(p2++) ) Result = SDL_False;
if (! B1.IsAssigned) xFree_SDL_Bit_String((void **)&B1);
if (! B2.IsAssigned) xFree_SDL_Bit_String((void **)&B2);
return Result;
}
/*---+---------------------------------------------------------------
yAddr_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit * yAddr_SDL_Bit_String(
SDL_Bit_String *B,
SDL_Integer Index)
#else
SDL_Bit * yAddr_SDL_Bit_String( B, Index )
SDL_Bit_String *B;
SDL_Integer Index;
#endif
{
if ( (Index < 0) || (Index >= (*B).Length) ) {
#ifdef XECSOP
xSDLOpError("Modify! in sort Bit_String",
"Index out of bounds." );
#endif
if ((*B).Bits != 0)
return &((*B).Bits[0]);
else
return (SDL_Bit *)xAlloc((xptrint)1); /* ??? */
} else
return &((*B).Bits[Index]);
}
/*---+---------------------------------------------------------------
xExtr_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit xExtr_SDL_Bit_String(
SDL_Bit_String B,
SDL_Integer Index )
#else
SDL_Bit xExtr_SDL_Bit_String( B, Index )
SDL_Bit_String B;
SDL_Integer Index;
#endif
{
SDL_Bit Result;
if ( (Index < 0) || (Index >= B.Length) ) {
#ifdef XECSOP
xSDLOpError("Extract! in sort Bit_String",
"Index out of bounds." );
#endif
Result = 0;
} else
Result = B.Bits[Index];
if (! B.IsAssigned) xFree_SDL_Bit_String((void **)&B);
return Result;
}
/*---+---------------------------------------------------------------
xNot_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xNot_SDL_Bit_String (
SDL_Bit_String B )
#else
SDL_Bit_String xNot_SDL_Bit_String (B)
SDL_Bit_String B;
#endif
{
SDL_Bit_String Result;
int i;
Result.Length = B.Length;
Result.IsAssigned = (xbool)0;
Result.IsUsedInSignal = (xbool)0;
Result.Bits = xAlloc_SDL_Bit_String((xptrint)(B.Length));
for (i=0; i<B.Length; i++) {
Result.Bits[i] = (unsigned char)( ! B.Bits[i]);
}
if (! B.IsAssigned) xFree_SDL_Bit_String((void **)&B);
return Result;
}
/*---+---------------------------------------------------------------
xAnd_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xAnd_SDL_Bit_String (
SDL_Bit_String B1,
SDL_Bit_String B2 )
#else
SDL_Bit_String xAnd_SDL_Bit_String (B1, B2)
SDL_Bit_String B1;
SDL_Bit_String B2;
#endif
{
SDL_Bit_String Result;
int i, Min_Length;
if (B1.Length >= B2.Length) {
Result.Length = B1.Length;
Min_Length = B2.Length;
} else {
Result.Length = B2.Length;
Min_Length = B1.Length;
}
Result.IsAssigned = (xbool)0;
Result.IsUsedInSignal = (xbool)0;
Result.Bits = xAlloc_SDL_Bit_String((xptrint)(Result.Length));
for (i=0; i<Min_Length; i++)
Result.Bits[i] = B1.Bits[i] & B2.Bits[i];
for (i=Min_Length; i<Result.Length; i++)
Result.Bits[i] = 0;
if (! B1.IsAssigned) xFree_SDL_Bit_String((void **)&B1);
if (! B2.IsAssigned) xFree_SDL_Bit_String((void **)&B2);
return Result;
}
/*---+---------------------------------------------------------------
xOr_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xOr_SDL_Bit_String (
SDL_Bit_String B1,
SDL_Bit_String B2 )
#else
SDL_Bit_String xOr_SDL_Bit_String (B1, B2)
SDL_Bit_String B1;
SDL_Bit_String B2;
#endif
{
SDL_Bit_String Result;
int i, Min_Length;
if (B1.Length >= B2.Length) {
Result.Length = B1.Length;
Min_Length = B2.Length;
} else {
Result.Length = B2.Length;
Min_Length = B1.Length;
}
Result.IsAssigned = (xbool)0;
Result.Bits = xAlloc_SDL_Bit_String((xptrint)(Result.Length));
for (i=0; i<Min_Length; i++)
Result.Bits[i] = B1.Bits[i] | B2.Bits[i];
for (i=Min_Length; i<Result.Length; i++)
Result.Bits[i] = 1;
if (! B1.IsAssigned) xFree_SDL_Bit_String((void **)&B1);
if (! B2.IsAssigned) xFree_SDL_Bit_String((void **)&B2);
return Result;
}
/*---+---------------------------------------------------------------
xXor_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xXor_SDL_Bit_String (
SDL_Bit_String B1,
SDL_Bit_String B2 )
#else
SDL_Bit_String xXor_SDL_Bit_String (B1, B2)
SDL_Bit_String B1;
SDL_Bit_String B2;
#endif
{
SDL_Bit_String Result;
int i, Min_Length;
if (B1.Length >= B2.Length) {
Result.Length = B1.Length;
Min_Length = B2.Length;
} else {
Result.Length = B2.Length;
Min_Length = B1.Length;
}
Result.IsAssigned = (xbool)0;
Result.Bits = xAlloc_SDL_Bit_String((xptrint)(Result.Length));
for (i=0; i<Min_Length; i++)
Result.Bits[i] = B1.Bits[i] ^ B2.Bits[i];
for (i=Min_Length; i<Result.Length; i++)
Result.Bits[i] = 1;
if (! B1.IsAssigned) xFree_SDL_Bit_String((void **)&B1);
if (! B2.IsAssigned) xFree_SDL_Bit_String((void **)&B2);
return Result;
}
/*---+---------------------------------------------------------------
xImpl_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xImpl_SDL_Bit_String (
SDL_Bit_String B1,
SDL_Bit_String B2 )
#else
SDL_Bit_String xImpl_SDL_Bit_String (B1, B2)
SDL_Bit_String B1;
SDL_Bit_String B2;
#endif
{
SDL_Bit_String Result;
int i, Min_Length;
if (B1.Length >= B2.Length) {
Result.Length = B1.Length;
Min_Length = B2.Length;
} else {
Result.Length = B2.Length;
Min_Length = B1.Length;
}
Result.IsAssigned = (xbool)0;
Result.IsUsedInSignal = (xbool)0;
Result.Bits = xAlloc_SDL_Bit_String((xptrint)(Result.Length));
for (i=0; i<Min_Length; i++)
Result.Bits[i] = (unsigned char)(B1.Bits[i] <= B2.Bits[i]);
for (i=Min_Length; i<Result.Length; i++)
Result.Bits[i] = 1;
if (! B1.IsAssigned) xFree_SDL_Bit_String((void **)&B1);
if (! B2.IsAssigned) xFree_SDL_Bit_String((void **)&B2);
return Result;
}
/*---+---------------------------------------------------------------
xMkString_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xMkString_SDL_Bit_String (
SDL_Bit B )
#else
SDL_Bit_String xMkString_SDL_Bit_String ( B )
SDL_Bit B;
#endif
{
SDL_Bit_String Result;
Result.Length = 1;
Result.IsAssigned = (xbool)0;
Result.IsUsedInSignal = (xbool)0;
Result.Bits = xAlloc_SDL_Bit_String((xptrint)1);
Result.Bits[0] = B;
return Result;
}
/*---+---------------------------------------------------------------
xLength_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Integer xLength_SDL_Bit_String (
SDL_Bit_String B )
#else
SDL_Integer xLength_SDL_Bit_String ( B )
SDL_Bit_String B;
#endif
{
return B.Length;
}
/*---+---------------------------------------------------------------
xFirst_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit xFirst_SDL_Bit_String (
SDL_Bit_String B )
#else
SDL_Bit xFirst_SDL_Bit_String ( B )
SDL_Bit_String B;
#endif
{
SDL_Bit Result;
if (B.Length == 0) {
#ifdef XECSOP
xSDLOpError("First in sort Bit_String",
"Bit_String length is zero." );
#endif
Result = (SDL_Bit)0;
} else {
Result = B.Bits[0];
}
if (! B.IsAssigned) xFree_SDL_Bit_String((void **)&B);
return Result;
}
/*---+---------------------------------------------------------------
xLast_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit xLast_SDL_Bit_String (
SDL_Bit_String B )
#else
SDL_Bit xLast_SDL_Bit_String ( B )
SDL_Bit_String B;
#endif
{
SDL_Bit Result;
if (B.Length == 0) {
#ifdef XECSOP
xSDLOpError("Last in sort Bit_String",
"Bit_String length is zero." );
#endif
Result = (SDL_Bit)0;
} else {
Result = B.Bits[B.Length-1];
}
if (! B.IsAssigned) xFree_SDL_Bit_String((void **)&B);
return Result;
}
/*---+---------------------------------------------------------------
xConcat_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xConcat_SDL_Bit_String (
SDL_Bit_String B1,
SDL_Bit_String B2 )
#else
SDL_Bit_String xConcat_SDL_Bit_String ( B1, B2 )
SDL_Bit_String B1;
SDL_Bit_String B2;
#endif
{
SDL_Bit_String Result;
Result.Length = B1.Length+B2.Length;
Result.IsAssigned = (xbool)0;
Result.IsUsedInSignal = (xbool)0;
Result.Bits = xAlloc_SDL_Bit_String((xptrint)(Result.Length));
if (B1.Length>0)
(void)memcpy((void *)Result.Bits, (void *)B1.Bits, B1.Length);
if (B2.Length>0)
(void)memcpy((void *)&(Result.Bits[B1.Length]), (void *)B2.Bits, B2.Length);
if (! B1.IsAssigned) xFree_SDL_Bit_String((void **)&B1);
if (! B2.IsAssigned) xFree_SDL_Bit_String((void **)&B2);
return Result;
}
/*---+---------------------------------------------------------------
xSubString_SDL_Bit_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xSubString_SDL_Bit_String (
SDL_Bit_String B,
SDL_Integer Start,
SDL_Integer SubLength )
#else
SDL_Bit_String xSubString_SDL_Bit_String (B, Start, SubLength)
SDL_Bit_String B;
SDL_Integer Start;
SDL_Integer SubLength;
#endif
{
SDL_Bit_String Result;
Result.IsAssigned = (xbool)0;
Result.IsUsedInSignal = (xbool)0;
Result.Bits = 0;
if ( B.Length == 0 ) {
#ifdef XECSOP
xSDLOpError("SubString in sort Bit_String",
"Bit_String length is zero." );
#endif
Result.Length = 0;
} else if ( Start < 0 ) {
#ifdef XECSOP
xSDLOpError("SubString in sort Bit_String",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -