/******************************************************************************* *** FUNCTION PARAMTAIL() ******************************************************************************* *** DESCRIPTION : Processes PARAMTAIL grammar rule. *** *** PARAMTAIL -> , TYPE idt PARAMTAIL | *** e ******************************************************************************/ void RecursiveParser::PARAMTAIL(int & offset, ParamPtr & paramptr, int & local_size, int & param_num, int & param_size) { if (global->Token == Global::commat) { EntryPtr ptr; VarType type; paramptr->Next = new ParamNode(); paramptr = paramptr->Next; match(Global::commat); TYPE(type); checkduplicate(global->Lexeme, depth); symtab->insert(global->Lexeme, global->Token, depth); ptr = symtab->lookup(global->Lexeme); ptr->TypeOfEntry = varEntry; ptr->var.TypeOfVariable = type; ptr->var.Offset = offset + typesize(type); ptr->var.size = typesize(type); ptr->isParam = true; param_size += typesize(type); paramptr->typeOfParameter = type; local_size += getsize(type, offset); param_num++; match(Global::idt); PARAMTAIL(offset, paramptr, local_size, param_num, param_size); } else return; }
void ilparser::pushpref() { int tp; prefrec pref; mContext->stacks->popd( OPADR, &newval ); tp = newval.tp; if ( !mContext->cycles->error ) if ( tp == ULimpf || tp == ULcom ) { pref.impl = tp == ULimpf; mContext->stacks->pop( OPAND, &pref.pcom, typesize( tp ) ); pref.sqrb = mContext->scanner->symsqrbr; pref.parp [OPADR] = mContext->stacks->getspnt( OPADR ); pref.parp [OPAND] = mContext->stacks->getspnt( OPAND ); mContext->stacks->pushd( PREFRAM, &pref ); iloperator.optornr = FUNCAL; iloperator.unaropt = false; mContext->stacks->pushd( OPTOR, &iloperator ); } else { mContext->stacks->chkdel( OPAND, &newval ); mContext->cycles->errormsg( 130 ); } }
static void print_value_array(TypeDb& db, zcm_field_t *field, void *data, int *usertype_count) { if(field->num_dim == 1) { printf("["); int len = field->dim_size[0]; size_t elt_size = typesize(field->type); void *p = (!field->dim_is_variable[0]) ? field->data : *(void **) field->data; for(int i = 0; i < len; i++) { if(i != 0 && i % MAX_ARRAY_ELT_PER_LINE == 0) { printf("\n" LINE_FMT_STR " ", "", ""); } if(i == MAX_ARRAY_DISPLAY) { printf("...more..."); break; } print_value_scalar(db, field, p, usertype_count); if(i+1 != len) printf(", "); p = (void *)((uint8_t *) p + elt_size); } printf(" ]"); } else { printf("<Multi-dim array: not yet supported>"); } }
NDArray::NDArray(Type type, const QList<int> &shape, char *dptr) : m_type(type) , m_shape(QSharedPointer<int>()) , m_strides(QSharedPointer<int>()) , m_size(0) , m_typesize(typesize(type)) , m_data_ch(0) { init(type, shape, dptr); }
NDArrayTyped<T>::NDArrayTyped(const NDArray &other, T* dptr) : NDArray(other) // , m_data((T*)other.m_data_ch) { if (!dptr) { m_data = (T*)other.data(); } else { m_data = dptr; m_data_ch = (char*)m_data; m_data_ptr = new ArrayData(m_data_ch, other.size()*sizeof(T)); m_type = TypeMap<T>::type; m_typesize = typesize(m_type); } }
/******************************************************************************* *** FUNCTION IDLIST() ******************************************************************************* *** DESCRIPTION : Processes IDLIST grammar rule. *** *** IDLIST -> idt IDTAIL ; DECL ******************************************************************************/ void RecursiveParser::IDLIST(VarType & type, int & offset) { EntryPtr ptr; checkduplicate(global->Lexeme, depth); symtab->insert(global->Lexeme, global->Token, depth); ptr = symtab->lookup(global->Lexeme); ptr->TypeOfEntry = varEntry; ptr->var.TypeOfVariable = type; ptr->var.Offset = offset; ptr->var.size = typesize(type); getsize(type, offset); match(Global::idt); IDTAIL(type, offset); match(Global::semicolont); DECL(offset); }
void ilparser::assign( bool def ) { if ( mContext->cycles->error ) return; mContext->stacks->popd( OPADR, &newval ); mContext->stacks->popd( OPADR, &idadr ); if ( mContext->cycles->error ) return; if ( idadr.tp != ULsymp ) { mContext->stacks->chkdel( OPAND, &newval ); mContext->cycles->errormsg( 139 ); return; } symptyp sympnt; mContext->stacks->getstack( OPAND, &sympnt, idadr.sp, typesize( ULsymp ) ); if ( sympnt.local ) comAssign( sympnt, def ); else glbAssign( sympnt, def ); }
void ilparser::parscondit() { booltyp cond; inttyp icond; realtyp rcond; datpnt cndadr; int cndtyp; maptyp cndm; listtyp cndl; int altfound = 0; mContext->stacks->popd( OPADR, &cndadr ); if ( mContext->cycles->error ) return; cndtyp = cndadr.tp; if ( cndtyp == ULbool ) { mContext->stacks->pop( OPAND, &cond, typesize( ULbool ) ); if ( !( mContext->cycles->error || cond ) ) altfound = mContext->scanner->srchalt(); } else if ( cndtyp == ULint ) { mContext->stacks->pop( OPAND, &icond, typesize( ULint ) ); if ( !( mContext->cycles->error || icond ) ) altfound = mContext->scanner->srchalt(); } else if ( cndtyp == ULreal ) { mContext->stacks->pop( OPAND, &rcond, typesize( ULreal ) ); if ( !( mContext->cycles->error || rcond ) ) altfound = mContext->scanner->srchalt(); } else if ( cndtyp == ULlist ) { mContext->stacks->pop( OPAND, &cndl, typesize( ULlist ) ); delitem( ULlist, &cndl ); if ( !( mContext->cycles->error || cndl ) ) altfound = mContext->scanner->srchalt(); } else if ( cndtyp == ULmap ) { mContext->stacks->pop( OPAND, &cndm, typesize( ULmap ) ); if ( cndm->type != ULbool && cndm->type != ULint && cndm->type != ULreal && cndm->type != ULbsampbuf ) mContext->cycles->errormsg( 228 ); else { mContext->stacks->pushand( ULmap, &cndm ); iloperator.optornr = cndm->type == ULbsampbuf ? SMPCONDIT : CONDIT; iloperator.unaropt = false; mContext->stacks->pushd( OPTOR, &iloperator ); } } else { mContext->stacks->chkdel( OPAND, &cndadr ); mContext->cycles->errormsg( 149 ); } if ( altfound < 0 ) { cndl = 0; mContext->stacks->pushand( ULlist, &cndl ); parsval = false; } else parsval = true; mContext->scanner->scancom(); }
void ilparser::comAssign( symptyp sympnt, bool def ) { datpnt *symdatp = mContext->hasher->tabdatadr( &sympnt ); int valstack = sympnt.local ? IDVAL : GLBVAL; int idt = symdatp->tp; int vlt = newval.tp; if ( idt ) { if ( def ) { mContext->stacks->chkdel( OPAND, &newval ); mContext->cycles->errormsg( 294 ); return; } if ( idt != vlt ) { implinst coercf; if ( idt == ULmap && ilstatic( vlt ) ) { genpar par; par.parp = mContext->stacks->stackadr( OPAND, newval.sp ); par.type = vlt; mContext->stacks->chkdel( valstack, symdatp ); cmap( 1, &par, (maptyp*)mContext->stacks->stackadr( valstack, symdatp->sp ), NULL, NULL, mContext ); } else if ( coercf = coercible( idt, vlt, -1 ) ) { genpar par; par.parp = mContext->stacks->stackadr( OPAND, newval.sp ); par.type = vlt; (*coercf)( 1, &par, mContext->stacks->stackadr( valstack, symdatp->sp ), NULL, NULL, mContext ); } else { mContext->stacks->chkdel( OPAND, &newval ); mContext->cycles->errormsg( 140 ); } } else { mContext->stacks->chkdel( valstack, symdatp ); memcpy( mContext->stacks->stackadr( valstack, symdatp->sp ), mContext->stacks->stackadr( OPAND, newval.sp ), typesize( vlt ) ); } } else { symdatp->sp = mContext->stacks->push( valstack, mContext->stacks->stackadr( OPAND, newval.sp ), typesize( newval.tp ) ); if ( mContext->cycles->error ) { mContext->stacks->chkdel( OPAND, &newval ); return; } symdatp->tp = vlt; if ( def ) mContext->hasher->pprotect( &sympnt ); } if ( mContext->cycles->error ) return; mContext->stacks->setspnt( OPAND, idadr.sp - 1 ); mContext->stacks->chkref( OPAND, &newval ); mContext->stacks->pushand( vlt, mContext->stacks->stackadr( OPAND, newval.sp ) ); }
/*===================================* * filter__make : フィルタを作成する *===================================*/ t_filter filter__make /* フィルタのポインタ */ _P5 (( int, type ), /* 型識別子 */ ( int, xsize ), /* フィルタXサイズ */ ( int, ysize ), /* フィルタYサイズ */ ( int, xspot ), /* 中心X座標 */ ( int, yspot )) /* 中心Y座標 */ { t_filter filter; int y, size; filter = typenew( t_filterRec ); size = typesize( type ); filter->xsize = xsize; filter->ysize = ysize; filter->xspot = xspot; filter->yspot = yspot; filter->type = type; filter->data.of_any = memnew2( xsize, ysize, size ); for ( y = 0; y < ysize; y++ ) filter->data.of_any[ y ] = filter->data.of_any[ y ] + ( xspot * size ); filter->data.of_any = filter->data.of_any + yspot; filter->top = - yspot; filter->bottom = ysize - yspot - 1; filter->left = - xspot; filter->right = xsize - xspot - 1;
/* Perform the I/O control operation specified by REQUEST on FD. The actual type and use of ARG and the return value depend on REQUEST. */ int __ioctl (int fd, unsigned long int request, ...) { #ifdef MACH_MSG_TYPE_CHAR /* Map individual type fields to Mach IPC types. */ static const int mach_types[] = { MACH_MSG_TYPE_CHAR, MACH_MSG_TYPE_INTEGER_16, MACH_MSG_TYPE_INTEGER_32, MACH_MSG_TYPE_INTEGER_64 }; #define io2mach_type(count, type) \ ((mach_msg_type_t) { mach_types[type], typesize (type) * 8, count, 1, 0, 0 }) #endif /* Extract the type information encoded in the request. */ unsigned int type = _IOC_TYPE (request); /* Message buffer. */ #define msg_align(x) \ (((x) + sizeof (mach_msg_type_t) - 1) & ~(sizeof (mach_msg_type_t) - 1)) struct { #ifdef MACH_MSG_TYPE_BIT union { mig_reply_header_t header; struct { mach_msg_header_t Head; int RetCodeType; kern_return_t RetCode; } header_typecheck; }; char data[3 * sizeof (mach_msg_type_t) + msg_align (_IOT_COUNT0 (type) * typesize (_IOT_TYPE0 (type))) + msg_align (_IOT_COUNT1 (type) * typesize (_IOT_TYPE1 (type))) + _IOT_COUNT2 (type) * typesize (_IOT_TYPE2 (type))]; #else /* Untyped Mach IPC format. */ mig_reply_error_t header; char data[_IOT_COUNT0 (type) * typesize (_IOT_TYPE0 (type)) + _IOT_COUNT1 (type) * typesize (_IOT_TYPE1 (type)) + _IOT_COUNT2 (type) * typesize (_IOT_TYPE2 (type))]; mach_msg_trailer_t trailer; #endif } msg; mach_msg_header_t *const m = &msg.header.Head; mach_msg_id_t msgid; unsigned int reply_size; #ifdef MACH_MSG_TYPE_BIT mach_msg_type_t *t; #else void *p; #endif void *arg = NULL; error_t err; /* Send the RPC already packed up in MSG to IOPORT and decode the return value. */ error_t send_rpc (io_t ioport) { error_t err; #ifdef MACH_MSG_TYPE_BIT mach_msg_type_t *t = &msg.header.RetCodeType; #else void *p = &msg.header.RetCode; #endif /* Marshal the request arguments into the message buffer. We must redo this work each time we retry the RPC after a SIGTTOU, because the reply message containing the EBACKGROUND error code clobbers the same message buffer also used for the request. */ if (_IOC_INOUT (request) & IOC_IN) { /* We don't want to advance ARG since it will be used to copy out too if IOC_OUT is also set. */ void *argptr = arg; /* Pack an argument into the message buffer. */ void in (unsigned int count, enum __ioctl_datum type) { if (count > 0) { const size_t len = count * typesize ((unsigned int) type); #ifdef MACH_MSG_TYPE_BIT void *p = &t[1]; *t = io2mach_type (count, type); p = __mempcpy (p, argptr, len); p = (void *) (((uintptr_t) p + sizeof (*t) - 1) & ~(sizeof (*t) - 1)); t = p; #else p = __mempcpy (p, argptr, len); #endif argptr += len; } } /* Pack the argument data. */ in (_IOT_COUNT0 (type), _IOT_TYPE0 (type)); in (_IOT_COUNT1 (type), _IOT_TYPE1 (type)); in (_IOT_COUNT2 (type), _IOT_TYPE2 (type)); }
/******************************************************************************* *** FUNCTION getsize() ******************************************************************************* *** DESCRIPTION : gets the size of the VarType for the offset and function size ******************************************************************************/ int RecursiveParser::getsize(VarType type, int & offset) { offset += typesize(type); return typesize(type); }