コード例 #1
0
ファイル: nativeCore.c プロジェクト: zyb2013/kvm-src
void Java_java_lang_Class_newInstance(void)
{
    INSTANCE_CLASS currentClass = getFP()->thisMethod->ofClass;
    CLASS clazz = topStackAsType(CLASS);

    if (IS_ARRAY_CLASS(clazz)
        || ((clazz->accessFlags & (ACC_INTERFACE | ACC_ABSTRACT)) != 0)) {
        raiseException("java/lang/InstantiationException");
        return;
    }

    if (classHasAccessToClass(currentClass, clazz)) {
        METHOD method = lookupMethod(clazz, initNameAndType, currentClass);
        if (   (method != NULL)
            && (method->ofClass == (INSTANCE_CLASS)clazz)
               /* I don't understand why, but we're not allowed access to
                * a protected <init> method of a superclass. */
            && classHasAccessToMember(currentClass, 
                   (method->accessFlags & ~ACC_PROTECTED),
                   (INSTANCE_CLASS)clazz, (INSTANCE_CLASS)clazz)

            )
        {
            START_TEMPORARY_ROOTS
                DECLARE_TEMPORARY_ROOT(INSTANCE, object,
                                       instantiate((INSTANCE_CLASS)clazz));
                if (object != NULL) {
                    /*  Put the result back on the stack */
                    topStackAsType(INSTANCE) = object; /* Will get the result */
                    /* We now need to call the initializer.  We'd like to just
                     * push a second copy of the object onto the stack, and then
                     * do pushFrame(method).  But we can't, because that would
                     * not necessarily coincide with the stack map of the
                     * current method.
                     */
                    pushFrame(RunCustomCodeMethod);
                    pushStackAsType(CustomCodeCallbackFunction,
                                    newInstanceReturnObject);
                    pushStackAsType(INSTANCE, object);
                    /* pushFrame may signal a stack overflow.  */
                    pushFrame(method);
                } else {
                    /* We will already have thrown an appropriate error */
                }
            END_TEMPORARY_ROOTS
            return;
        }
    }
コード例 #2
0
ファイル: Controller.c プロジェクト: bernardo-macedo/JVM
/*
void mainInit(char* className, Interpretador* interpretador, int paramsNumber, char** cmdLineParams) {
    char* methodName = "main", methodDescriptor = "([Ljava/lang/String;)V";
    ClassFile* cFile = loadClass(interpretador, className);
    pushFrame(&(interpretador->topStackFrame));
    frameInit(interpretador->initClass, *cFile, interpretador->topStackFrame, methodName, methodDescriptor);

}
*/
void methodInit(char* className, char* methodName, char* methodDescriptor, Interpretador* interpretador, int paramsNumber, int print) {
    int i;
    ClassFile* cFile = loadClass(interpretador, className);
    printf("FEZ LOAD\n");
    if (print)
        printClass(cFile, className);

    pushFrame(&(interpretador->topStackFrame));
    printf("\n\nPUSHOUFRAME\n");
    frameInit(interpretador->initClass, *cFile, interpretador->topStackFrame, methodName, methodDescriptor);

    printf("\n\nINITIOUFRAME\n");
    if (interpretador->topStackFrame->nextFrame != NULL) {

    /*if (interpretador->topStackFrame->nextFrame != NULL) {*/

        for (i = countSlots(interpretador->topStackFrame->nextFrame->frame->topOperand, paramsNumber) - 1; i >= 0; i--) {
            if (interpretador->topStackFrame->nextFrame->frame->topOperand->operand.type32_64 == CAT2)
                i--;
            interpretador->topStackFrame->frame->localVarArray[i] = (int)&(interpretador->topStackFrame->nextFrame->frame->topOperand);
        }

    }
    printf("\n\nSAIU DA METHOD INIT\n");

    /*}*/

}
コード例 #3
0
ファイル: LuaFunction.cpp プロジェクト: GHScan/DailyProjects
void callFunc(int funcIdx, int paramCount, int requireRetN) {
    auto stack = LuaVM::instance()->getCurrentStack();
    auto func = stack->values()[funcIdx].getFunction();
    if (func->funcType == Function::FT_Lua) {
        auto stack = LuaVM::instance()->getCurrentStack();
        auto lfunc = static_cast<LuaFunction*>(func);
        int paramBase = funcIdx + 1;
        {
            int reqParamCount = lfunc->meta->argCount;
            if (paramCount < reqParamCount) {
                stack->reserveValueSpace(paramBase + reqParamCount);
                for (int i = paramCount; i < reqParamCount; ++i) {
                    stack->values()[paramBase + i] = LuaValue::NIL;
                }
                paramCount = reqParamCount;
            }
        }
        stack->pushFrame(lfunc, paramBase, paramCount, requireRetN);
    } else if (func->funcType == Function::FT_C) {
        auto stack = LuaVM::instance()->getCurrentStack();
        auto &values = stack->values();
        vector<LuaValue> args(values.begin() + funcIdx + 1, values.begin() + funcIdx + 1 + paramCount); 
        vector<LuaValue> rets;
        static_cast<CFunction*>(func)->func(args, rets);
        if (requireRetN > 0) rets.resize(requireRetN, LuaValue::NIL);
        if (rets.empty()) rets.push_back(LuaValue::NIL);
        stack->reserveValueSpace(funcIdx + (int)rets.size());
        std::copy(rets.begin(), rets.end(), values.begin() + funcIdx);
        stack->topFrame()->setExtCount((int)rets.size());
    } else {
        ASSERT(0);
    }
}
コード例 #4
0
void CanonCamera::saveFrame() {    
    Surface sf = mCanon.getLiveSurface();
    float h = sf.getWidth() * 9.0f / 16.0f;
    
    Surface frame(sf.getWidth(),h,false);
    frame.copyFrom( sf, Area(0,0,sf.getWidth(), h) );
    pushFrame( frame );
}
コード例 #5
0
ファイル: animation.cpp プロジェクト: pinkeen/nimble
void Animation::addTileFrame(Image *pImage, const Rect &tileRect)
{
        AnimationFrame *pFrame = new AnimationFrame(pImage,
                                                    tileRect,
                                                    Vec(0.0f, 0.0f));

	pushFrame(pFrame);
}
コード例 #6
0
int SGSVirtualMachine::runStatement(SGSStatement* statement)
{
    SGSStatementStackFrameBase* frame=statement->getStackFrame();
    frame->setParentFrame(&getFrameStackTop());
    pushFrame(frame);
    int result=statement->run();
    popFrame();
    return result;
}
コード例 #7
0
ファイル: JSVM.cpp プロジェクト: GHScan/DailyProjects
JSVM::JSVM() {
    GCObjectManager::createInstance();
    JSStringManager::createInstance();

    m_frames.reserve(1024);
    m_values.reserve(1024 * 64);
    m_values.push_back(JSValue::NIL);
    pushFrame(NULL, &m_values[0]);
}
コード例 #8
0
ファイル: animation.cpp プロジェクト: pinkeen/nimble
void Animation::addFrame(Image *pImage, const Vec &m_alignPoint)
{
        AnimationFrame *pFrame = new AnimationFrame(pImage,
                                                    Rect(0.0f, 0.0f,
                                                         (float)pImage->width() - 1.0f,
                                                         (float)pImage->height() - 1.0f),
                                                    m_alignPoint);

	pushFrame(pFrame);
}
コード例 #9
0
AnimatedSprite::AnimatedSprite(sf::Sprite initialFrame)
	:sf::Drawable(), sf::Transformable(),
	m_numFrames(0), m_frameLength(1.0f/24.0f), m_totalLength(0),
	m_loop(false), m_playing(false), m_resetOnPlay(false),
	m_timer(), m_pauseTimer(), m_totalTimePaused(), m_frameTimeOffset(),
	m_color(sf::Color::White), m_spriteBlendMode(sf::BlendMultiply)
{
	pushFrame(initialFrame);
	GotoFrame(0);
}
コード例 #10
0
ファイル: animation.cpp プロジェクト: pinkeen/nimble
void Animation::addFrame(Image *pImage)
{
        AnimationFrame *pFrame = new AnimationFrame(pImage,
                                                    Rect(0.0f, 0.0f,
                                                         (float)pImage->width() - 1.0f,
                                                         (float)pImage->height() - 1.0f),
                                                    Vec(0.0f, 0.0f));

	pushFrame(pFrame);
}
コード例 #11
0
void VideoDecoder::convertAndPushPicture(const AVFrame* frame) {
	// Allocate a picture to hold the YUV data
	AVFrame* yuvFrame = av_frame_alloc();
	av_frame_copy(yuvFrame, frame);
	yuvFrame->format = DESTINATION_FORMAT;

	av_image_alloc(yuvFrame->data,
				   yuvFrame->linesize,
				   m_status->videoCodecPars.width,
				   m_status->videoCodecPars.height,
				   DESTINATION_FORMAT,
				   1);

	std::unique_ptr<FFMPEGVideoFrame> videoFramePtr(new FFMPEGVideoFrame());

	if (m_status->videoCodecPars.pixel_format == DESTINATION_FORMAT) {
		av_image_copy(yuvFrame->data,
					  yuvFrame->linesize,
					  (const uint8_t**) (frame->data),
					  frame->linesize,
					  DESTINATION_FORMAT,
					  m_status->videoCodecPars.width,
					  m_status->videoCodecPars.height);
	} else {
		// Convert frame to YUV
		sws_scale(
			m_swsCtx,
			(uint8_t const* const*) frame->data,
			frame->linesize,
			0,
			m_status->videoCodecPars.height,
			yuvFrame->data,
			yuvFrame->linesize
		);
	}

	videoFramePtr->id = ++m_frameId;
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 3, 102)
	videoFramePtr->frameTime = getFrameTime(frame->best_effort_timestamp, m_status->videoStream->time_base);
#else
	videoFramePtr->frameTime = getFrameTime(av_frame_get_best_effort_timestamp(frame), m_status->videoStream->time_base);
#endif
	videoFramePtr->frame = yuvFrame;

	videoFramePtr->ySize.height = static_cast<size_t>(m_status->videoCodecPars.height);
	videoFramePtr->ySize.width = static_cast<size_t>(m_status->videoCodecPars.width);
	videoFramePtr->ySize.stride = static_cast<size_t>(yuvFrame->linesize[0]);

	// 420P means that the UV channels have half the width and height
	videoFramePtr->uvSize.height = static_cast<size_t>(m_status->videoCodecPars.height / 2);
	videoFramePtr->uvSize.width = static_cast<size_t>(m_status->videoCodecPars.width / 2);
	videoFramePtr->uvSize.stride = static_cast<size_t>(yuvFrame->linesize[1]);

	pushFrame(VideoFramePtr(videoFramePtr.release()));
}
コード例 #12
0
ファイル: syntakticka_analyza.c プロジェクト: adamVass/IFJ
tChyba PROM() {
	int analyza;
	int ret;
	//TItem *pt;
	//PROM->id TERM2
	if(token.stav == s_identifikator) {
		if(byla_funkce == false) {
			//pokud nejsme v definici funkce vytvori se lokalni ramec
			ret = pushFrame();
			if(ret != S_BEZ_CHYB) {
				return ret;
			}
		}
		
		

		if(byla_funkce == false) {
			//ukazatel na id v tabulce
			TFunction *tmp = searchFuncTable( token.data );
			if( !tmp ){
				return S_SEMANTICKA_CHYBA_NEDEF;
			}
			//kopirovani dat z tabulky definice funkce do nove vznikleho lokalniho ramce
			ret = copyTable( tmp);//, ptrhtLocal );
			if(ret != S_BEZ_CHYB) {
				return ret;
			}
		}

		token = getNextToken();
		if(token.stav == s_lex_error) {
			return S_LEXIKALNI_CHYBA;
		}
			//volani funkce na zpracovani argumentu
			analyza = TERM2();
			if(analyza != S_BEZ_CHYB) {
				return analyza;
			}
			else {
				if(byla_funkce == false) {
					//pokud nejsme v definici funkce musime na konci vypopnout ukazatel na lokalni ramec
					popFrame();
				}	
				
				return S_BEZ_CHYB;
			}
			return S_SYNTAKTICKA_CHYBA;
	}
	return S_SYNTAKTICKA_CHYBA;		
}
コード例 #13
0
void AudioDecoder::flushAudioBuffer() {
	if (m_audioBuffer.empty()) {
		// Nothing to do here
		return;
	}

	AudioFramePtr audioFrame(new AudioFrame());
	audioFrame->channels = OUT_NUM_CHANNELS;
	audioFrame->rate = OUT_SAMPLE_RATE;

	audioFrame->audioData.assign(m_audioBuffer.begin(), m_audioBuffer.end());

	pushFrame(std::move(audioFrame));
	m_audioBuffer.clear();
}
コード例 #14
0
SGSValue SGSVirtualMachine::runFunction(SGSFunction* function,SGSArguments *args)
{
    SGSStatementStackFrameBase* frame=new SGSFunctionStackFrame();
    frame->setParentFrame(&getFrameStackTop());
    int sumMax=std::max(args->count(),function->getParameter()->count());
    for (int i=0; i<sumMax; ++i)
    {
        SGSValue result=this->runExpression((*args)[i]);
        if (i==0)
            frame->registerValue(m_analyzer.getIdentifierId("function"),result);
        frame->registerValue((*function->getParameter())[i],result);
    }
    pushFrame(frame);
    SGSValue result=function->run();
    popFrame();
    return result;
}
コード例 #15
0
bool StreamOutputWidget::event(QEvent* event)
{
    if (event->type() == QEvent::User)
    {
        SeparatedSourceEvent* sepEvent = dynamic_cast<SeparatedSourceEvent*>(event);

        if (sepEvent)
        {
            //qDebug("Writing to stack...");
            if(m_enabled) 
            {
                pushFrame(sepEvent->m_data);
                notify();
            }
            return true;
        }

        return false;
    }

    return false;
}
コード例 #16
0
//------------------------------------------------------------------------------
void ofxIpVideoServerRoute::pushFrame(ofImage& img) {
    pushFrame(img.getPixelsRef());
}
コード例 #17
0
ファイル: Player.cpp プロジェクト: Hindi/Rythm-Game
/**
 * @fn	void Player::createAnimation()
 *
 * @brief	Creates the animations.
 *
 */
void Player::createAnimation()
{
	m_animation = std::shared_ptr<Animation>(new Animation(100, false, false, 0.05f));

	//On charge l'image et on découpe toutes les animations dedans
	sf::Image m_image;
	m_image = MediaManager<sf::Image>::getInstance().getMedia("../JIN4/media/player.png");
	int imgSize{ 90 };//Taille de chaque image en pixel
	
	//quand on avance
	auto idleAnim = std::make_shared<Anim>("idle");
	idleAnim->pushFrame(Frame(m_image, sf::Rect<int>(0, 0, imgSize, imgSize)));

	//Quand on saute
	auto jumpAnim = std::make_shared<Anim>("jump");
	jumpAnim->pushFrame(Frame(m_image, sf::Rect<int>(imgSize, 0, imgSize, imgSize)));
	jumpAnim->pushFrame(Frame(m_image, sf::Rect<int>(imgSize, imgSize, imgSize, imgSize)));

	//Quand on ralenti, en haut du saut
	auto onTop = std::make_shared<Anim>("onTop");
	onTop->pushFrame(Frame(m_image, sf::Rect<int>(imgSize, 0, imgSize, imgSize)));
	onTop->pushFrame(Frame(m_image, sf::Rect<int>(0, 0, imgSize, imgSize)));

	//Quand on arrive en bas
	auto onBottom = std::make_shared<Anim>("onBottom");
	onBottom->pushFrame(Frame(m_image, sf::Rect<int>(imgSize, 0, imgSize, imgSize)));
	onBottom->pushFrame(Frame(m_image, sf::Rect<int>(0, 0, imgSize, imgSize)));
	onBottom->pushFrame(Frame(m_image, sf::Rect<int>(2 * imgSize, 0, imgSize, imgSize)));
	onBottom->pushFrame(Frame(m_image, sf::Rect<int>(0, 0, imgSize, imgSize)));

	m_image = MediaManager<sf::Image>::getInstance().getMedia("../JIN4/media/PlayerCrouch.png");

	//Quand on se baisse
	auto crouchAnim = std::make_shared<Anim>("crouch");
	crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(0, 0, imgSize, imgSize)));
	//crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(imgSize, 0, imgSize, imgSize)));
	crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(imgSize, 0, imgSize, imgSize)));
	crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(2 * imgSize, 0, imgSize, imgSize)));
	//crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(0, imgSize, imgSize, imgSize)));
	crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(0, imgSize, imgSize, imgSize)));
	crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(imgSize, imgSize, imgSize, imgSize)));
	//crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(2 * imgSize, imgSize, imgSize, imgSize)));
	crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(2 * imgSize, imgSize, imgSize, imgSize)));
	crouchAnim->pushFrame(Frame(m_image, sf::Rect<int>(0, 0, imgSize, imgSize)));

	//On les rajoute à l'animation
	m_animation->addAnim("onBottom", onBottom);
	m_animation->addAnim("onTop", onTop);
	m_animation->addAnim("jump", jumpAnim);
	m_animation->addAnim("crouch", crouchAnim);
	m_animation->addAnim("idle", idleAnim);
	m_animation->setAnim("idle", true);

	AnimationManager::getInstance().addAnimation(m_animation);
	m_animation->setPosition(sf::Vector2f(m_box.left, m_box.top));
}
コード例 #18
0
ファイル: animation.cpp プロジェクト: pinkeen/nimble
void Animation::addTileFrame(Image *pImage, const Rect &tileRect, const Vec &m_alignPoint)
{
        AnimationFrame *pFrame = new AnimationFrame(pImage, tileRect, m_alignPoint);

	pushFrame(pFrame);
}