Пример #1
0
/**
 * Entry function which will process the assembled code and perform the required actions
 */
void processAssembledCode(char * assembled, unsigned int length, unsigned short numberSymbols,
		int coreId, int numberActiveCores, int baseHostPid) {
	stopInterpreter=0;
	currentSymbolEntries=0;
	localCoreId=coreId;
	numActiveCores=numberActiveCores;
	symbolTable=initialiseSymbolTable(numberSymbols);
	hostCoresBasePid=baseHostPid;
	unsigned int i;
	for (i=0;i<length;) {
		unsigned short command=getUShort(&assembled[i]);
		i+=sizeof(unsigned short);
		if (command == LET_TOKEN) i=handleLet(assembled, i);
		if (command == ARRAYSET_TOKEN) i=handleArraySet(assembled, i);
		if (command == DIMARRAY_TOKEN) i=handleDimArray(assembled, i, 0);
		if (command == DIMSHAREDARRAY_TOKEN) i=handleDimArray(assembled, i, 1);
		if (command == PRINT_TOKEN) i=handlePrint(assembled, i);
		if (command == STOP_TOKEN) return;
		if (command == SYNC_TOKEN) i=handleSync(assembled, i);
		if (command == IF_TOKEN) i=handleIf(assembled, i);
		if (command == IFELSE_TOKEN) i=handleIf(assembled, i);
		if (command == FOR_TOKEN) i=handleFor(assembled, i);
		if (command == GOTO_TOKEN) i=handleGoto(assembled, i);
		if (command == INPUT_TOKEN) i=handleInput(assembled, i);
		if (command == INPUT_STRING_TOKEN) i=handleInputWithString(assembled, i);
		if (command == SEND_TOKEN) i=handleSend(assembled, i);
		if (command == RECV_TOKEN) i=handleRecv(assembled, i);
		if (command == RECVTOARRAY_TOKEN) i=handleRecvToArray(assembled, i);
		if (command == SENDRECV_TOKEN) i=handleSendRecv(assembled, i);
		if (command == SENDRECVARRAY_TOKEN) i=handleSendRecvArray(assembled, i);
		if (command == BCAST_TOKEN) i=handleBcast(assembled, i);
		if (command == REDUCTION_TOKEN) i=handleReduction(assembled, i);
		if (stopInterpreter) return;
	}
}
Пример #2
0
/**
 * Entry function which will process the assembled code and perform the required actions
 */
struct value_defn processAssembledCode(char * assembled, unsigned int currentPoint, unsigned int length) {
    struct value_defn empty;
    empty.type=NONE_TYPE;
    empty.dtype=SCALAR;
    unsigned int i, fnAddr;
    for (i=currentPoint; i<length;) {
        unsigned char command=getUChar(&assembled[i]);
        i+=sizeof(unsigned char);
        if (command == LET_TOKEN) i=handleLet(assembled, i, length, 0);
        if (command == LETNOALIAS_TOKEN) i=handleLet(assembled, i, length, 1);
        if (command == ARRAYSET_TOKEN) i=handleArraySet(assembled, i, length);
        if (command == STOP_TOKEN) return empty;
        if (command == IF_TOKEN) i=handleIf(assembled, i, length);
        if (command == IFELSE_TOKEN) i=handleIf(assembled, i, length);
        if (command == FOR_TOKEN) i=handleFor(assembled, i, length);
        if (command == GOTO_TOKEN) i=handleGoto(assembled, i, length);
        if (command == FNCALL_TOKEN || command == FNCALL_BY_VAR_TOKEN) {
            i=handleFnCall(assembled, i, &fnAddr, length, command == FNCALL_BY_VAR_TOKEN ? 1:0);
            fnLevel++;
            processAssembledCode(assembled, fnAddr, length);
            clearVariablesToLevel(fnLevel);
            fnLevel--;
        }
        if (command == NATIVE_TOKEN) i=handleNative(assembled, i, length, NULL);
        if (command == RETURN_TOKEN) return empty;
        if (command == RETURN_EXP_TOKEN) {
            return getExpressionValue(assembled, &i, length);
        }
        if (stopInterpreter) return empty;
    }
    return empty;
}