Example #1
0
/**
 * @brief add ir code for variable assignments to the codelist
 */
void addAssign(struct symbol *var, struct symbol *value) {

	if(!var->is.var.isArray)
	{
		genQuad(opASSIGN, var, value, NULL, -1);
	}
	else
	{
		if(var->is.var.arrayLocStr == NULL)
		{
			yyerror(" --\t Type mismatch! Array assignment needs indexing...");
		}
		genQuad(opArr1, var->next, var->is.var.arrayLocStr, value, -1);
	}
}
Example #2
0
void addIf(enum code_ops *op, struct symbol *exp1, struct symbol *exp2)
{
	/**While calling the addif function a jmpto parameter is not necessary, because it would be always NULL for the first time**/
	//save rows for jumps in order to backpatch the right jump address later
	truelist->TRUELIST.row_id = code_list->code.counter_id;
	falselist->FALSELIST.row_id = code_list->code.counter_id+1;
	genQuad(op, exp1, exp2, NULL,NULL);
}
Example #3
0
void addWhile(enum code_ops *op, struct symbol *exp1, struct symbol *exp2)
{
	/**After each loop iteration, the GOTO label points to the row in before the while-header and
	 * the while condition is checked again...
	 * In case of a false while condition the row after the while loop will be aimed
	 * So for the truelist entry, the GOTO label at the end of the while loop is needed
	 */
	falselist->FALSELIST.row_id = code_list->code.counter_id;
	genQuad(op, exp1, exp2, NULL, NULL);
}
Example #4
0
/**
 * @brief add ir code for basic calculations using temp registers
 */
struct symbol* addCalc(enum code_ops op, struct symbol *exp1,
		struct symbol *exp2) {

	struct symbol *result = NULL;
	char name[20];
	sprintf(name, ".t%d", register_cnt);
	result = (struct symbol*) malloc(sizeof(struct symbol));
	result->name = (char *) malloc(strlen(name) + 1);
	strcpy(result->name, name);
	register_cnt++;
	genQuad(op, result, exp1, exp2, -1);
	return (result);
}
Example #5
0
/**
 * @brief array management for ir_code
 * @param id
 * @param index
 * @return
 */
struct symbol* addArray(struct symbol *id, struct symbol *index)
{
	struct symbol *result = NULL;
	result = (struct symbol*) malloc(sizeof(struct symbol));
	id->is.var.isArray = index->is.var.value;
	result->next = id;

	char name[20];
	sprintf(name, ".t%d", register_cnt);
	result->name = (char *) malloc(strlen(name) + 1);
	strcpy(result->name, name);
	register_cnt++;
	genQuad(opArr2, result, id, index, -1);
	result->is.var.arrayPos = num_of_codes-1;
	return(result);
}
Example #6
0
/**
 * @brief In case of opDO_WHILE_BEGIN the list entry is deleted
 * @param exp is needed, because DoWhile check at the end with an IF-statement, whether another iteration is necessary. Therefore an IF-op is generated
 */
void addDoWhileEnd (struct symbol *exp)
{
	struct code *c = code_list;
	while (code_list != (c = c->prev))
	{
		if(c->operation == opDO_WHILE_BEGIN)
		{
			if(c->jmpTo == -777)
			{
				DL_DELETE(code_list,c);
				break;
			}
		}
	}
	genQuad(opIF, exp, NULL, NULL, c->counter_id);
}
Example #7
0
/**
 * 
 * @return 
 */
bool shaderLoader::reload( void)
{
        _parentQGL->makeCurrent();
        fboY->bind();
        ADM_info("Compiling shader %s \n",params.shaderFile.c_str());
        // Load the file info memory
        ready=loadShader(params.shaderFile.c_str());        
        glList=glGenLists(1);
        genQuad();
        fboY->release();
        _parentQGL->doneCurrent();
        if(!ready)
        {
             GUI_Error_HIG (QT_TRANSLATE_NOOP("adm","Cannot compile shader"), NULL);
             return false;
        }
        return true;
}
/**
    \fn rotateGl
    \brief constructor
*/
rotateGl::rotateGl(  ADM_coreVideoFilter *in,CONFcouple *setup) : ADM_coreVideoFilterQtGl(in,setup)
{
	if (widget == NULL)
	{
		original = NULL;
		return;
	}

UNUSED_ARG(setup);
        original=new ADMImageDefault(in->getInfo()->width,in->getInfo()->height);
        if(!setup || !ADM_paramLoad(setup,gl_rotate_param,&params))
        {
            // Default value
            params.angle=0;
        }
        widget->makeCurrent();
        fboY->bind();
        printf("Compiling shader \n");
        glProgramY = new QGLShaderProgram(context);
        ADM_assert(glProgramY);
        if ( !glProgramY->addShaderFromSourceCode(QGLShader::Fragment, myShaderY))
        {
                ADM_error("[GL Render] Fragment log: %s\n", glProgramY->log().toUtf8().constData());
                ADM_assert(0);
        }
        if ( !glProgramY->link())
        {
            ADM_error("[GL Render] Link log: %s\n", glProgramY->log().toUtf8().constData());
            ADM_assert(0);
        }

        if ( !glProgramY->bind())
        {
                ADM_error("[GL Render] Binding FAILED\n");
                ADM_assert(0);
        }
        glList=glGenLists(1);
        genQuad();
        fboY->release();
        widget->doneCurrent();

}
Example #9
0
/**
    \fn configure
*/
bool rotateGl::configure( void) 
{
    
     
     diaElemInteger  tAngle(&(params.angle),QT_TRANSLATE_NOOP("glRotate","Angle (°):"),-190,190);
   
     
     diaElem *elems[]={&tAngle};
     
     if(diaFactoryRun(QT_TRANSLATE_NOOP("glRotate","glRotate"),sizeof(elems)/sizeof(diaElem *),elems))
     {
                ADM_info("New angle : %d \n",params.angle);
                _parentQGL->makeCurrent();
                genQuad();
                _parentQGL->doneCurrent();
                return 1;
     }
    
     return 0;
}
Example #10
0
/**
    \fn shaderLoader
    \brief constructor
*/
shaderLoader::shaderLoader(  ADM_coreVideoFilter *in,CONFcouple *setup) : ADM_coreVideoFilterQtGl(in,setup)
{
        if(!setup || !ADM_paramLoad(setup,shaderLoaderConf_param,&params))
        {
            params.shaderFile=strdup("");
        }
        original=new ADMImageDefault(in->getInfo()->width,in->getInfo()->height);
        _parentQGL->makeCurrent();
        fboY->bind();
        ready=false;

        ADM_info("Compiling shader %s \n",params.shaderFile.c_str());

        // Load the file info memory
        ready=loadShader(params.shaderFile.c_str());
        
        glList=glGenLists(1);
        genQuad();
        fboY->release();
        _parentQGL->doneCurrent();
}
Example #11
0
void backpatchWhile()
{
	struct code *c = code_list;
	while (code_list != (c = c->prev))
	{
		if(c->operation == opGOTO)
		{
			if(c->jmpTo == -777)
			{
				c->jmpTo = num_of_codes+1;
			}
		}
		else if(c->operation == opWHILE_BEGIN)
		{
			if(c->jmpTo == -777)
			{
				genQuad(opGOTO, NULL, NULL, NULL, c->counter_id);
				DL_DELETE(code_list,c);
				break;
			}
		}
	}
}
/**
    \fn configure
*/
bool rotateGl::configure( void) 
{
	if (widget == NULL)
	{
		GUI_Error_HIG("OpenGL", "Unable to initialise OpenGL");
		return false;
	}
     
     diaElemInteger  tAngle(&(params.angle),QT_TR_NOOP("Angle (°):"),-190,190);
   
     
     diaElem *elems[]={&tAngle};
     
     if(diaFactoryRun(QT_TR_NOOP("glRotate"),sizeof(elems)/sizeof(diaElem *),elems))
     {
                ADM_info("New angle : %d \n",params.angle);
                widget->makeCurrent();
                genQuad();
                widget->doneCurrent();
                return 1;
     }
    
     return 0;
}
Example #13
0
void addAssign(enum code_ops *op, struct symbol *var, struct symbol *value)
{
	genQuad(op,var,value,NULL,NULL);
}
Example #14
0
/**
 * adds a return operation, a marker "-777" is set for further use (--> backpatchReturn),
 * in order to backpatch the right return jump address
 * @param op
 * @param exp
 */
void addReturn(enum code_ops op, struct symbol *exp)
{
	genQuad(op, exp, NULL, NULL, -777);
}
Example #15
0
/**
 * @brief generates ir_code for if-statements; temp_label defines jmpLabels
 */
void addIfStart(struct symbol *exp) {
	genQuad(opIF, exp, NULL, NULL, num_of_codes+2);
}
Example #16
0
/**
 * @brief In order to setup an while loop at first it has to be decided whether an loop interation is necessary, therefore opIF is used
 * @param exp
 */
void addWhile(struct symbol *exp)
{
	genQuad(opIF, exp, NULL, NULL, num_of_codes+2);
}
Example #17
0
/**
 * @brief sets the GOTO of an if-statement; -777 is a marker for backpatching; temp_label defines jmpLabels
 */
void addIfGoto()
{
	genQuad(opGOTO, NULL, NULL, NULL, -777);

}
Example #18
0
void addWhileGotoStart()
{
	genQuad(opGOTO, NULL, NULL, NULL, -777);
}
Example #19
0
/**
 * @brief Preparing While-loop start
 */
void addWhileStart()
{
	genQuad(opWHILE_BEGIN,NULL, NULL, NULL, -777);
}
Example #20
0
struct symbol* addFuncCall(struct symbol *func, int funcDefjmpTo)
{
	genQuad(opCALL, NULL, NULL, func, funcDefjmpTo);
	return (func);
}
Example #21
0
/**
 * @brief params for function Calls
 * @param param
 */
void addIrParam(struct symbol *param)
{
	genQuad(opPARAM, param, NULL, NULL, -1);

}
Example #22
0
/**
 * @brief add ir code for Begin / End of a function to the codelist
 */
void addFunc(enum code_ops op, struct symbol *var, struct symbol *func) {
	genQuad(op, var, func, NULL, -1);
}
Example #23
0
void addCalc(enum code_ops *op, struct symbol *result, struct symbol *exp1,
		struct symbol *exp2)
{
	genQuad(op, result, exp1, exp2,NULL);
}
Example #24
0
/**
 * @brief Preparing DO_While-loop start
 */
void addDoWhile()
{
	genQuad(opDO_WHILE_BEGIN, NULL, NULL, NULL, -777);
}