コード例 #1
0
ファイル: compile.c プロジェクト: kzfm1024/misc
void constDecl()			/* 定数宣言のコンパイル */
{
	Token temp;
	while(1){
		if (token.kind==Id){
			setIdKind(constId);				/* 印字のための情報のセット */
			temp = token; 					/* 名前を入れておく */
			token = checkGet(nextToken(), Equal);		/* 名前の次は"="のはず */
			if (token.kind==Num)
				enterTconst(temp.u.id, token.u.value);	/* 定数名と値をテーブルに */
			else
				errorType("number");
			token = nextToken();
		}else
			errorMissingId();
		if (token.kind!=Comma){		/* 次がコンマなら定数宣言が続く */
			if (token.kind==Id){		/* 次が名前ならコンマを忘れたことにする */
				errorInsert(Comma);
				continue;
			}else
				break;
		}
		token = nextToken();
	}
	token = checkGet(token, Semicolon);		/* 最後は";"のはず */
}
コード例 #2
0
/*
 *******************************************************************
 * Function: GetRunTimeMO
 *
 * Description : 
 *		
 * Parameters :
 *    None
 *
 * *******************************************************************
 */
CGBLCOError MeasuredObjectiveControllerMgr::GetRunTimeMO(XString nameMO, CGBLLOMeasuredObjective *theMO)
{
	CGBLCOError errorType(CGBLCOError::EGBLCOErrorType::GBLCO_OK);

    int counter = 0;
    bool found = false;

    while ( (counter < runTimeMOList.Size()) && (nameMO != runTimeMOList[counter]->GetName()) )
    {
        counter++;
    }

    if (counter >= runTimeMOList.Size())
    {
        // The run time MO has not been found - return an error
        theMO = NULL;
        errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
            GBLLO_ERROR_RUNTIMEMONOTFOUND_DESC, GBLLO_ERROR_RUNTIMEMONOTFOUND);
    }
    else
    {
        // return the MO
        theMO = runTimeMOList[counter];
    }
    
	return errorType;
}
コード例 #3
0
ファイル: compile.c プロジェクト: kzfm1024/misc
void condition()					/* 条件式のコンパイル */
{
	KeyId k;
	if (token.kind==Odd){
		token = nextToken();
		expression();
		genCodeO(odd);
	}else{
		expression();
		k = token.kind;
		switch(k){
		case Equal: case Lss: case Gtr:
		case NotEq: case LssEq: case GtrEq:
			break;
		default:
			errorType("rel-op");
			break;
		}
		token = nextToken();
		expression();
		switch(k){
		case Equal:	genCodeO(eq); break;
		case Lss:		genCodeO(ls); break;
		case Gtr:		genCodeO(gr); break;
		case NotEq:	genCodeO(neq); break;
		case LssEq:	genCodeO(lseq); break;
		case GtrEq:	genCodeO(greq); break;
		}
	}
}
コード例 #4
0
/*
*******************************************************************
* Function: GetMeasurement
*
* Description: 
*
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
CGBLCOError CGBLLOMeasuredObjective::GetMeasurement(XString measName, CGBLMeasurement *theMeas)
{
    CGBLCOError errorType(CGBLCOError::EGBLCOErrorType::GBLCO_OK);
    // Check through the array of measurements to see if there is already a measurement registered
    int counter = 0;

    bool foundMeasurement = false;

    while ((counter < measurementList.Size()) && !(foundMeasurement))
    {
        if (measurementList[counter]->GetName() == measName)
        {
            foundMeasurement = true;
        }
        else
        {
            counter++;
        }
    }

    if (foundMeasurement)
    {
        theMeas = measurementList[counter];
    }
    else
    {
        errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
            GBLLO_ERROR_MEASUREMENTNOTFOUND_DESC, GBLLO_ERROR_MEASUREMENTNOTFOUND); 
    }

    return (errorType);
}
コード例 #5
0
ErrorType MediaObject::errorType() const
{
    if (state() == Phonon::ErrorState) {
        K_D(const MediaObject);
        if (d->errorOverride) {
            return d->errorType;
        }
        return INTERFACE_CALL(errorType());
    }
    return Phonon::NoError;
}
コード例 #6
0
ErrorType MediaObject::errorType() const
{
    if (state() == Phonon::ErrorState) {
        K_D(const MediaObject);
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
        if (d->errorOverride) {
            return d->errorType;
        }
#endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM
        return INTERFACE_CALL(errorType());
    }
    return Phonon::NoError;
}
コード例 #7
0
ファイル: table.c プロジェクト: Leulz/pl0d
int searchTbyId(char *id) /* It returns the index of an element whose name is id. Only used for searches, check 'searchT' */
{
	int i;
	i = tIndex;
	strcpy(nameTable[0].name, id);			/* It puts a sentinel at the beginning of the name table. */
	while( strcmp(id, nameTable[i].name) )
		i--;
	if ( i )							/* It finds the name. */
		return i;
	else {							/* It fails to find the name. */
		errorType("undef");
		return -1;
	}
}
コード例 #8
0
/*
*******************************************************************
* Function: GetMeasurementValue
*
* Description: 
*
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
CGBLCOError MeasuredObjectiveControllerMgr::GetMeasurementValue(XString moName, XString measurementName, int *value, 
        EGBLLOMeasurementValueType valueType)
{
    CGBLCOError errorType(CGBLCOError::EGBLCOErrorType::GBLCO_OK);
    // Get the mo
    CGBLLOMeasuredObjective *theMO = NULL;
    errorType = GetRunTimeMO(moName, theMO);

    if (GBLLO_ERROR_RUNTIMEMONOTFOUND != (int)errorType)
    {
        // the MO has been found Get the measurement
        CGBLMeasurement *theMeas = NULL;
        errorType = theMO->GetMeasurement(measurementName, theMeas);

        switch (valueType)
        {
        case eCurrent:
            {
                errorType = theMeas->GetValue(value);
                break;
            }
        case eMean:
            {
                errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, 
                    GBLLO_ERROR_INAPTVALUETYPE_DESC, GBLLO_ERROR_INAPTVALUETYPE);
                break;
            }
        case eMin:
            {
                errorType = theMeas->GetMin(value);
                break;
            }
        case eMax:
            {
                errorType = theMeas->GetMax(value);
                break;
            }
        default:
            {
                errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
                    GBLLO_ERROR_TYPENOTRECOGNISED_DESC, GBLLO_ERROR_TYPENOTRECOGNISED);
                break;
            }
        }// end swtich
    }// end if Mo found

    // Return the error
    return errorType;
}
コード例 #9
0
ファイル: table.c プロジェクト: Leulz/pl0d
int searchT(char *id, KindT k)		/* It returns the index of an element whose name is id. */
							/* It declares an error if it is undefined. */
{
	int i;
	i = tIndex;
	strcpy(nameTable[0].name, id);			/* It puts a sentinel at the beginning of the name table. */
	while( strcmp(id, nameTable[i].name) )
		i--;
	if ( i )							/* It finds the name. */
		return i;
	else {							/* It fails to find the name. */
		errorType("undef");
		if (k==varId) return enterTvar(id);	/* It records id in the name table if it is a variable. */
		return 0;
	}
}
コード例 #10
0
ファイル: table.c プロジェクト: sootsprite/pl0d-compiler
/* 名前idの名前表の位置を返す (未宣言の時エラーとする) */
int searchT(char *id, KindT k)
{
	int i;
	i = tIndex;
	strcpy(nameTable[0].name, id);    /* 番兵をたてる */
	while( strcmp(id, nameTable[i].name) )
		i--;
	if ( i )                          /* 名前があった */
		return i;
	else {                            /* 名前がなかった */
		errorType("undef");
		if (k == varId)
			return enterTvar(id);     /* 変数の時は仮登録 */
		return 0;
	}
}
コード例 #11
0
/*
*******************************************************************
* Function: GetMeasurementValue
*
* Description: 
*
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
CGBLCOError MeasuredObjectiveControllerMgr::GetMeasurementValue(XString moName, 
                XString measurementName, bool *value)
{
    CGBLCOError errorType(CGBLCOError::EGBLCOErrorType::GBLCO_OK);
    // Get the mo
    CGBLLOMeasuredObjective *theMO = NULL;
    errorType = GetRunTimeMO(moName, theMO);

    if (GBLLO_ERROR_RUNTIMEMONOTFOUND != (int)errorType)
    {
        // the MO has been found Get the measurement
        CGBLMeasurement *theMeas = NULL;
        errorType = theMO->GetMeasurement(measurementName, theMeas);

        // Now call on the measurement
        errorType = theMeas->GetValue(value);
    }
    return errorType;
}
コード例 #12
0
		std::vector<std::shared_ptr<SPICE::BIG::DataEntry>> CommandThrowingError::createAndGetAdditionalCommandParameters()
		{
			// Create the parameters
			std::shared_ptr<SPICE::BIG::DataEntryTypes::DataEntryDuration> durationUntilThrowingError(new SPICE::BIG::DataEntryTypes::DataEntryDuration("durationUntilThrowingError", 0, 300));
			durationUntilThrowingError->setAdditionalInformations("This parameter defines how long the command will execute before throwing the error.", "","PT5S");
			_durationUntilThrowingError = durationUntilThrowingError;
			std::shared_ptr<SPICE::BIG::DataEntryTypes::DataEntryInt> errorType(new SPICE::BIG::DataEntryTypes::DataEntryInt("errorType", 1, 4));
			errorType->setAdditionalInformations("This parameter defines how long the command will take for execution. 1 - fatal, 2 - aborting, 3 - continuation, 4 - failing continuation", "","3");
			_errorType = errorType;

			// Set, if they are required or optional
			_durationUntilThrowingError->setIsNeeded(true);
			_errorType->setIsNeeded(true);

			// Create a vector and add the parameters
			std::vector<std::shared_ptr<SPICE::BIG::DataEntry>> returnVector;
			returnVector.push_back(_durationUntilThrowingError);
			returnVector.push_back(_errorType);

			return returnVector;
		}
コード例 #13
0
/*
*******************************************************************
* Function: AddPlayerToTeam
*
* Description: 
*
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
CGBLCOError CGBLLOMeasuredObjective::AddPlayerToTeam(CGBLUserID theUser, CGBLTeamID theTeam)
{
    CGBLCOError errorType(CGBLCOError::EGBLCOErrorType::GBLCO_OK);

    // double check that this is the right team
    if ((int)teamID == (int)theTeam)
    {
        // Send the message to the new player for the MO
        CGBLLOMessagePacket messagePacket;
        // add a player to the team list
        userArray.PushBack((int)theUser);

        // Now send the message to register for this measurement
        messagePacket.destination = theUser;
        messagePacket.source = myUserID;
        messagePacket.messageID = theArrayHandler->GetMesssageID();
        XString messageString("Register,MO,");
        messageString += theMOData->GetName();
        messagePacket.messageType = eRegistration;
        messagePacket.messageSize = sizeof(messageString);
        messagePacket.theMessage = messageString;
        // Send the message to the Array Handler
        errorType = theArrayHandler->AddToSendArray(messagePacket);

        // Now, iterate through the measurements and call Add player on them
        int counter = 0;
        while (counter < measurementList.Size())
        {
            errorType = measurementList[counter]->AddPlayerToTeam(theTeam, theUser);
            counter++;
        }
    }
    else
    {
        errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
            GBLLO_ERROR_INCORRECTTEAM_DESC, GBLLO_ERROR_INCORRECTTEAM);
    }

    return errorType;
}
コード例 #14
0
/*
 *******************************************************************
 * Function: RegisterParameters()
 *
 * Description : This function registers all required structures, parameter types or attributes for this plugin.
	
 * Returns : CGBLCOError
 *
 *******************************************************************
*/
CGBLCOError MeasuredObjectiveControllerMgr::RegisterParameters()
{


	CKParameterManager* pm = (CKParameterManager*)GetCKContext(0)->GetParameterManager();

	CKAttributeManager *aMan = static_cast<CKAttributeManager*>(m_Context->GetAttributeManager());
	
	
	CKParameterTypeDesc cgblTypeDescrMO;

	cgblTypeDescrMO.Guid=CKGUID_CGBLMO_PARAMETER;
	cgblTypeDescrMO.DerivedFrom=CKGUID(0,0);
	cgblTypeDescrMO.TypeName=GBL_API_ENTRY("Measured Objective");
	cgblTypeDescrMO.DefaultSize=sizeof(CGBLMOData);
	cgblTypeDescrMO.CreateDefaultFunction	= CGBL_MO_CREATE_FUNC;
	cgblTypeDescrMO.SaveLoadFunction = CGBL_MO_SAVELOAD_FUNC;
	
	pm->RegisterParameterType(&cgblTypeDescrMO);
																								


	CKParameterTypeDesc cgblTypeDescrMeasurement;

	cgblTypeDescrMeasurement.Guid=CKGUID_CGBLM_PARAMETER;
	cgblTypeDescrMeasurement.DerivedFrom=CKGUID(0,0);
	cgblTypeDescrMeasurement.TypeName=GBL_API_ENTRY("Measurement");
	cgblTypeDescrMeasurement.DefaultSize=sizeof(CGBLMeasurementData);
	cgblTypeDescrMeasurement.CreateDefaultFunction	= CGBL_MEASUREMENT_CREATE_FUNC;
	cgblTypeDescrMeasurement.SaveLoadFunction = CGBL_MEASUREMENT_SAVELOAD_FUNC;

	pm->RegisterParameterType(&cgblTypeDescrMeasurement);

	////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

    CGBLCOError errorType(CGBLCOError::EGBLCOErrorType::GBLCO_OK); 
	        
	return errorType;

}
コード例 #15
0
ファイル: quickinterpreter.cpp プロジェクト: aschet/qsaqt5
QVariant QuickInterpreter::execute(QObject *obj, const QString &c,
				      const QString &name)
{
    QString code = c + QString::fromLatin1("\n");

    int sourceId = debugger ? debugger->freeSourceId() : -1;
    if(!name.isNull() && sourceId >= 0)
	sourceIdNames[sourceId] = name;

    QSObject t, oldThis;
    if (obj) {
	if (!name.isNull() && sourceId >= 0)
            addSourceId(sourceId, obj);

	if (!hasTopLevelParent(obj))
            addTopLevelObject(obj);

	t = wrap(obj);
	oldThis = env()->thisValue();
	env()->setThisValue(t);
    }

    QSEngine::evaluate(t, code);

    // restore this value
    if (obj)
	env()->setThisValue(oldThis);

    if (hadError())
	if(errorType() == QSErrParseError)
	    emit parseError();
	else
	    emit runtimeError();

    // Make sure we dereference the engines return value to avoid pooling
    QVariant a = convertToArgument(returnValue());
    setReturnValue(QSObject());
    return a;
}
コード例 #16
0
/*
*******************************************************************
* Function: RemovePlayerFromTeam
*
* Description: 
*
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
CGBLCOError CGBLLOMeasuredObjective::RemovePlayerFromTeam(CGBLUserID theUser, CGBLTeamID theTeam)
{
    CGBLCOError errorType(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL);

    CGBLLOMessagePacket messagePacket;

    // double check that this is the right team
    if ((int)teamID == (int)theTeam)
    {
        // Find the player in the array
        int counter=0;
        int size = userArray.Size();
        bool found = false;
        while ( (counter < size) && !found )
        {
            if ((int)userArray[counter] == (int)theUser)
            {
                found = true;
            }
            else
            {
                counter++;
            }
        }
        if (found)
        {
            // Remove the player from the team
            userArray.RemoveAt(counter);

            // Deregister the measurement with the player
            messagePacket.destination = theUser;
            messagePacket.source = myUserID;
            messagePacket.messageID = theArrayHandler->GetMesssageID();
            XString messageString("Deregister,MO,");
            messageString += theMOData->GetName();
            messagePacket.messageType = eRegistration;
            messagePacket.messageSize = sizeof(messageString);
            messagePacket.theMessage = messageString;
            // Send the message to the Array Handler
            errorType = theArrayHandler->AddToSendArray(messagePacket);

            // Now iterate through all the measurements and call the Remove player
            int counter = 0;
            while (counter < measurementList.Size())
            {
                errorType = measurementList[counter]->RemovePlayerFromTeam(theTeam, theUser);
                counter++;
            }

        }
        else
        {
            errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
                GBLLO_ERROR_USERNOTFOUND_DESC, GBLLO_ERROR_USERNOTFOUND);
        }
    } 
    else
    {
        errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
            GBLLO_ERROR_INCORRECTTEAM_DESC, GBLLO_ERROR_INCORRECTTEAM);
    }

    return errorType;
}
コード例 #17
0
/*
*******************************************************************
* Function: DeRegister
*
* Description: 
*
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
CGBLCOError CGBLLOMeasuredObjective::DeRegister(int regID)
{

    CGBLCOError errorType(CGBLCOError::EGBLCOErrorType::GBLCO_OK);
    // find the registration - iterate through the registrations until the reg is found
    int counter = 0;
    while ( (counter < registrationIDArray.Size()) && (regID != registrationIDArray[counter]->registrationID) )
    {
        counter++;
    }

    // Has the registration been found?
    if (counter < registrationIDArray.Size())
    {

        MORegHelperClass *toDelete = registrationIDArray[counter];

        // check to see if the registration was a team registration
        if (teamID != 0)
        {
            // De register the team stuff
            int counter2 = 0;
            int size = userArray.Size();
            while (counter2 < size)
            {
                CGBLLOMessagePacket messagePacket;
                int userID = userArray[counter2];
                // Remove the player from the team
                userArray.RemoveAt(counter2);

                // Deregister the MO with the player
                messagePacket.destination = userID;
                messagePacket.source = myUserID;
                messagePacket.messageID = theArrayHandler->GetMesssageID();
                XString messageString("Deregister,MO,");
                messageString += theMOData->GetName();
                messagePacket.messageType = eRegistration;
                messagePacket.messageSize = sizeof(messageString);
                messagePacket.theMessage = messageString;
                // Send the message to the Array Handler
                errorType = theArrayHandler->AddToSendArray(messagePacket);

                counter2++;
            }

        }

        registrationIDArray.Remove(toDelete);    
        delete toDelete;
    }
    else
    {
        errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
                                GBLLO_ERROR_REGISTRATIONNOTFOUND_DESC,
                                GBLLO_ERROR_REGISTRATIONNOTFOUND);
    }
    // Check to see if it's the last registration.  If it is, mark the class for deletion
    if (0 == registrationIDArray.Size())
    {
        errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
                                GBLLO_ERROR_EMPTYREGARRAY_DESC,
                                GBLLO_ERROR_EMPTYREGARRAY);
    }


    return errorType;
}
コード例 #18
0
ファイル: compile.c プロジェクト: kzfm1024/misc
void statement()			/* 文のコンパイル */
{
	int tIndex;
	KindT k;
	int backP, backP2;				/* バックパッチ用 */

	while(1) {
		switch (token.kind) {
		case Id:					/* 代入文のコンパイル */
			tIndex = searchT(token.u.id, varId);	/* 左辺の変数のインデックス */
			setIdKind(k=kindT(tIndex));			/* 印字のための情報のセット */
			if (k != varId && k != parId) 		/* 変数名かパラメタ名のはず */
				errorType("var/par");
			token = checkGet(nextToken(), Assign);			/* ":="のはず */
			expression();					/* 式のコンパイル */
			genCodeT(sto, tIndex);				/* 左辺への代入命令 */
			return;
		case If:					/* if文のコンパイル */
			token = nextToken();
			condition();					/* 条件式のコンパイル */
			token = checkGet(token, Then);		/* "then"のはず */
			backP = genCodeV(jpc, 0);			/* jpc命令 */
			statement();					/* 文のコンパイル */
			backPatch(backP);				/* 上のjpc命令にバックパッチ */
			return;
		case Ret:					/* return文のコンパイル */
			token = nextToken();
			expression();					/* 式のコンパイル */
			genCodeR();					/* ret命令 */
			return;
		case Begin:				/* begin . . end文のコンパイル */
			token = nextToken();
			while(1){
				statement();				/* 文のコンパイル */
				while(1){
					if (token.kind==Semicolon){		/* 次が";"なら文が続く */
						token = nextToken();
						break;
					}
					if (token.kind==End){			/* 次がendなら終り */
						token = nextToken();
						return;
					}
					if (isStBeginKey(token)){		/* 次が文の先頭記号なら */
						errorInsert(Semicolon);	/* ";"を忘れたことにする */
						break;
					}
					errorDelete();	/* それ以外ならエラーとして読み捨てる */
					token = nextToken();
				}
			}
		case While:				/* while文のコンパイル */
			token = nextToken();
			backP2 = nextCode();			/* while文の最後のjmp命令の飛び先 */
			condition();				/* 条件式のコンパイル */
			token = checkGet(token, Do);	/* "do"のはず */
			backP = genCodeV(jpc, 0);		/* 条件式が偽のとき飛び出すjpc命令 */
			statement();				/* 文のコンパイル */
			genCodeV(jmp, backP2);		/* while文の先頭へのジャンプ命令 */
			backPatch(backP);	/* 偽のとき飛び出すjpc命令へのバックパッチ */
			return;
		case Write:			/* write文のコンパイル */
			token = nextToken();
			expression();				/* 式のコンパイル */
			genCodeO(wrt);				/* その値を出力するwrt命令 */
			return;
		case WriteLn:			/* writeln文のコンパイル */
			token = nextToken();
			genCodeO(wrl);				/* 改行を出力するwrl命令 */
			return;
		case End: case Semicolon:			/* 空文を読んだことにして終り */
			return;
		default:				/* 文の先頭のキーまで読み捨てる */
			errorDelete();				/* 今読んだトークンを読み捨てる */
			token = nextToken();
			continue;
		}		
	}
}