Position NetworkMessage::GetPosition() { Position pos; pos.x = GetU16(); pos.y = GetU16(); pos.z = GetByte(); return pos; }
void FCPassLabel( void ) { //===================== // Pass label to run-time routine. call_handle handle; handle = InitCall( GetU16() ); CGAddParm( handle, CGBackName( (back_handle)GetLabel( GetU16() ), TY_POINTER ), TY_POINTER ); CGDone( CGCall( handle ) ); }
Dictionary::Dictionary(char const *filename) : mDefinition(null) { mFile = LoadFile("english.dictionary", &mFileSize); if(mFile != null) { uint8 const *p = mFile; uint8 const *bufferEnd = p + mFileSize; char const *id = (char const *)p; if(strncmp(id, "dictionary", 10) == 0) { p += 10; mVersion = GetU16(p); mNumWords = GetU32(p); mWord = (char *)p; p += mNumWords * 8; mDefinition = new char *[mNumWords]; int wordIndex = 0; while(p < bufferEnd) { mDefinition[wordIndex] = (char *)p; uint16 definitionMask = GetU16(p); for(int i = 0; i < eWordType::kNumWordTypes; ++i) { if((definitionMask & (1 << i)) != 0) { if(*p++ == eReferenceType::kNone) { p += strlen((char *)p) + 1; } else { p += 3; } } } ++wordIndex; } } } SaveAsJSON(); }
void DtFieldSubstring( void ) { //========================== // Data initialize a substring character item within a structure. sym_id fd; intstar4 base; intstar4 first; intstar4 last; char name[MAX_SYMLEN+1]; base = DXPop(); first = DXPop(); fd = GetPtr(); last = GetInt(); if( last != 0 ) { last += first - 1; } else { last = DXPop(); } GetU16(); // skip typing information if( DoSubstring( first, last, fd->u.fd.xt.size ) ) { DXPush( base + first - 1 ); DtItemSize = last - first + 1; } else { STFieldName( fd, name ); Error( EV_SSTR_INVALID, name, StmtKeywords[ PR_DATA ] ); } }
void DtSubstring( void ) { //===================== // Data initialize a character substring. intstar4 first; intstar4 last; sym_id cv; cv = GetPtr(); GetU16(); // skip typing information first = DXPop(); if( cv != NULL ) { if( DtFlags & DT_SS_NO_HIGH ) { last = cv->u.ns.xt.size; DtFlags &= ~DT_SS_NO_HIGH; } else { last = DXPop(); } } else { last = first + GetInt() - 1; } if( !DoSubstring( first, last, InitVar->u.ns.xt.size ) ) { NameStmtErr( EV_SSTR_INVALID, InitVar, PR_DATA ); } DtOffset += first - 1; DtItemSize = last - first + 1; }
void DtExp( void ) { //=============== // Exponentiate constants. intstar4 op2; intstar4 op1; intstar4 result; op1 = DXPop(); op2 = DXPop(); if( op1 == 0 ) { if( op2 <= 0 ) { Error( EX_Z_2_NOT_POS ); } DXPush( 0 ); } else if( op2 < 0 ) { DXPush( 0 ); } else { result = 1; while( op2 != 0 ) { result *= op1; --op2; } DXPush( result ); } GetU16(); // skip typing information }
static void Equivalent( cg_op op_code ) { //=========================================== cg_name op1; cg_name op2; unsigned_16 typ_info; cg_type typ1; cg_type typ2; typ_info = GetU16(); typ1 = GetType1( typ_info ); typ2 = GetType2( typ_info ); op1 = XPopValue( typ1 ); op2 = XPopValue( typ2 ); typ1 = CGType( op1 ); if( typ1 != TY_BOOLEAN ) { op1 = CGCompare( O_NE, op1, CGInteger( 0, typ1 ), typ1 ); } typ2 = CGType( op2 ); if( typ2 != TY_BOOLEAN ) { op2 = CGCompare( O_NE, op2, CGInteger( 0, typ2 ), typ2 ); } XPush( CGCompare( op_code, op1, op2, TY_UINT_1 ) ); }
void FCMulMixCX( void ) { //==================== // Multiply a complex by a scalar. XMulDivMix( O_TIMES, true, GetU16() ); }
void FCDeAllocate( void ) { //============================== call_handle handle; sym_id arr; uint num; num = 0; handle = InitCall( RT_DEALLOCATE ); for(;;) { arr = GetPtr(); if( arr == NULL ) break; CGAddParm( handle, CGFEName( arr, T_POINTER ), T_POINTER ); CGAddParm( handle, getFlags( arr ), FLAG_PARM_TYPE ); ++num; } CGAddParm( handle, CGInteger( num, T_INTEGER ), T_INTEGER ); if( GetU16() & ALLOC_STAT ) { FCodeSequence(); CGAddParm( handle, XPop(), T_POINTER ); } else { CGAddParm( handle, CGInteger( 0, T_POINTER ), T_POINTER ); } CGDone( CGCall( handle ) ); }
void FCCat( void ) { //=============== // Do concatenation operation. XPush( Concat( GetU16(), XPop() ) ); }
void FCFreeLabel( void ) { //===================== // Free specified label since it will no longer be referenced. DoneLabel( GetU16() ); }
void FCMulMixXC( void ) { //==================== // Multiply a scalar by a complex. XMulDivMix( O_TIMES, false, GetU16() ); }
void FCSeek( void ) { //====================== // Seek to ObjPtr + offset. FCodeSeek( FCodeTell( GetU16() ) ); }
void FCDivMixCX( void ) { //==================== // Divide a complex by a scalar. XMulDivMix( O_DIV, true, GetU16() ); }
FCODE GetFCode( void ) { //======================== // Get an F-Code from object memory. return( GetU16() ); }
void FCMulCmplx( void ) { //==================== // Multiply one complex number by another. #if _CPU == 8086 || _CPU == 386 if( CPUOpts & CPUOPT_FPC ) { // generate call to runtime complex multiply XCmplxOp( RT_C8MUL ); } else { // do multiplication inline InLineMulCC( GetU16() ); } #else // For risc we just inline the entire code InLineMulCC( GetU16() ); #endif }
void DtUMinus( void ) { //================== // Negate constant. DXPush( -DXPop() ); GetU16(); // skip typing information }
void FCSetAtEnd( void ) { //==================== // Set END= for ATEND statement. CGDone( CGCall( InitCall( RT_SET_END ) ) ); EndEqLabel = GetU16(); }
void FCJmpFalse( void ) { //==================== unsigned_16 typ_info; cg_type typ; cg_name bool_expr; typ_info = GetU16(); typ = GetType( typ_info ); if( IntType( typ_info ) ) { bool_expr = CGCompare( O_NE, XPopValue( typ ), CGInteger( 0, typ ), typ ); } else { bool_expr = XPopValue( typ ); } CGControl( O_IF_FALSE, bool_expr, GetLabel( GetU16() ) ); }
std::string NetworkMessage::GetString() { uint16_t stringlen = GetU16(); if(stringlen >= (16384 - m_ReadPos)) return std::string(); char* v = (char*)(m_MsgBuf + m_ReadPos); m_ReadPos += stringlen; return std::string(v, stringlen); }
std::string NetworkMessage::GetString() { uint16_t stringlen = GetU16(); if(stringlen >= (NETWORKMESSAGE_MAXSIZE - m_ReadPos)) return std::string(); char* v = (char*)(m_MsgBuf + m_ReadPos); m_ReadPos += stringlen; return std::string(v, stringlen); }
void DtUnaryMul( void ) { //==================== // Multiply constants. intstar4 op; op = DXPop(); DXPush( op * op ); GetU16(); // skip typing information }
void FCConjg( void ) { //================= cg_cmplx z; cg_type typ; typ = GetType( GetU16() ); XPopCmplx( &z, typ ); XPush( CGUnary( O_UMINUS, z.imagpart, CmplxBaseType( typ ) ) ); XPush( z.realpart ); }
inttarg GetInt( void ) { //====================== // Get integer from object memory. #if _CPU == 8086 return( GetU16() ); #else // _CPU == 386 return( GetConst32() ); #endif }
void FCDbgLine( void ) { //==================== // Generate line # information. unsigned_16 line_num; line_num = GetU16(); if( ( SubProgId->ns.flags & SY_SUBPROG_TYPE ) == SY_BLOCK_DATA ) return; DBLineNum( line_num ); }
void FCStartDataStmt( void ) { //========================= // Start DATA statement processing. FCTablePtr = DataJmpTab; DtConstList = FCodeTell( GetU16() - sizeof( unsigned_16 ) ); DtRepCount = 0; DtFlags = 0; DtItemSize = 0; DtStartSequence(); }
/*! DRAGONS: We use the current UTF16String GetString trait to ensure that we always have the correct handling, * even if the user wants these strings handled differently (i.e. we do it their way!) */ std::list<std::string> SplitStringArray(const MDObjectPtr &Array) { std::list<std::string> Ret; // Quit early if an invalid parameter if(!Array) return Ret; // Build a working string static MDTypePtr ValType = MDType::Find("UTF16String"); MDObjectPtr Value = ValType ? new MDObject(ValType) : NULL; if(!Value) { error("Can't build UTF16String value required by SplitStringArray() - need this type to be defined in the dictionary file\n"); return Ret; } // Assemble the data value (which may be an array of sub-values) DataChunkPtr Data = Array->PutData(); // Get a pointer to the start of the data UInt8 *pData = Data->Data; // The number of bytes of data to split size_t BytesLeft = Data->Size; while(BytesLeft > 1) { // Find the end of the current string size_t Len = 0; UInt8 *p = pData; while(BytesLeft > 1) { BytesLeft -= 2; Len += 2; UInt16 Char = GetU16(p); p += 2; // End when we find a null if(Char == 0) break; } // Copy this string to the working value Value->SetValue(pData, Len); // Read out the traits-formatted version of the string Ret.push_back(Value->GetString()); // Move the pointer forward to the next value after the string terminator pData = p; } return Ret; }
std::string NetworkMessage::GetString(uint16_t size/* = 0*/) { if(!size) size = GetU16(); if(size >= (NETWORKMESSAGE_MAXSIZE - m_ReadPos)) return std::string(); char* v = (char*)(m_MsgBuf + m_ReadPos); m_ReadPos += size; return std::string(v, size); }
void FCChar1Move( void ) { //===================== // Perform single character assignment. cg_type typ; cg_name dest; typ = GetType( GetU16() ); dest = XPop(); XPush( CGLVAssign( SCBPointer( dest ), GetChOp( typ ), typ ) ); }
void FCFmtScan( void ) { //=================== // Call runtime routine to scan a format specification from a character // expression. call_handle handle; handle = InitCall( RT_FMT_SCAN ); CGAddParm( handle, CGInteger( GetU16(), TY_UNSIGNED ), TY_UNSIGNED ); CGAddParm( handle, XPop(), TY_POINTER ); CGDone( CGCall( handle ) ); }