Пример #1
0
void Lab2::on_pushButton_3_clicked()
{
    if(image->isNull())
    {
        QMessageBox::information(this, "Warning!", "Сначала надо открыть файл");
        return;
    }

    int P0X = ui->lineFirstX->text().toInt();
    int P1X = ui->lineSecondX->text().toInt();
    int P2X = ui->lineThirdX->text().toInt();
    int P3X = ui->lineFourX->text().toInt();

    int P0Y = ui->lineFirstY->text().toInt();
    int P1Y = ui->lineSecondY->text().toInt();
    int P2Y = ui->lineThirdY->text().toInt();
    int P3Y = ui->lineFourY->text().toInt();


    for(double t = 0; t < 1; t+=0.001)
    {
        int x = pow(t,3)*P3X+3*pow(t,2)*(1-t)*P2X+
                3*t*pow((1-t),2)*P1X+pow((1-t), 3)*P0X;
        int y = pow(t,3)*P3Y+3*pow(t,2)*(1-t)*P2Y+
                3*t*pow((1-t),2)*P1Y+pow((1-t), 3)*P0Y;

        image->setPixel(x, y, qRgb(0, 0, 255));
    }
    emit endFunc();
}
Пример #2
0
static const char PROGMEM *jsonParseArray(char **buffer, const t_json *currentStructure) {
    char *buf =  *buffer;
    jsonHandleEndArray endFunc = (jsonHandleEndArray) pgm_read_word(&currentStructure->handleEndArray);
    if (currentStructure && !endFunc) {
        return PSTR("Unexpected array");
    }
    uint8_t count = 0;
    do {
        buf = skipSpaces(&buf[1]); // skip '[' and then ',' on each loop
        if (buf[0] == ']') {
        	break;
        }
        const char PROGMEM *res = jsonParseValue(&buf, currentStructure, count);
        if (res) {
            return res;
        }
//        DEBUG_PRINT(">>>S>");
//        DEBUG_PRINT(buf[0]);
//        DEBUG_PRINTLN(buf[1]);
        buf = skipSpaces(buf);
        count++;
    } while (buf[0] == ',');
    buf = skipSpaces(buf);
    if (buf[0] != ']') { // end of object
        return JSON_ERROR_NO_ARRAY_END;
    }

    const char PROGMEM *res = endFunc(count);
    if (res) {
        return res;
    }
    buf = skipSpaces(&buf[1]); // going out of array
    *buffer = buf;
    return 0;
}
Пример #3
0
	void gen2()
	{
		const int unit = 64;
		resetGlobalIdx();
		Operand pz(IntPtr, unit);
		Operand px(IntPtr, unit);
		Operand py(IntPtr, unit);
		std::string name = "add128";
		Function f(name, Void, pz, px, py);
		beginFunc(f);
		Operand x = load(px);
		Operand y = load(py);
		x = zext(x, 128);
		y = zext(y, 128);
		x = add(x, y);
		Operand L = trunc(x, 64);
		store(L, pz);
		Operand xH = load(getelementptr(px, makeImm(32, 1)));
		Operand yH = load(getelementptr(py, makeImm(32, 1)));
		x = trunc(lshr(x, 64), 64);
		x = add(x, xH);
		x = add(x, yH);
		store(x, getelementptr(pz, makeImm(32, 1)));
		
		ret(Void);
		endFunc();
	}
Пример #4
0
void Script_v2::o2_playMult(FuncParams &params) {
	uint16 multData = readUint16();

	startFunc(params);
	print("%d, %d", multData >> 1, multData & 0x01);
	endFunc();
}
Пример #5
0
void Lab4::on_buttonFigure_clicked()
{    
    Draw(Px, Py, Pz);
    emit endFunc();
    ui->groupBox->setEnabled(true);
    ui->groupBox_2->setEnabled(true);
    ui->groupBox_3->setEnabled(true);
}
Пример #6
0
void petabricks::CodeGenerator::continuationRequired(const std::string& hookname){
  std::string n = "cont_" + jalib::XToString(_contCounter++);
  newline();
  write("return "+hookname+" new petabricks::MethodCallTask<"+_curClass+", &"+_curClass+"::"+n+">(this));");
  endFunc();
  beginFunc("DynamicTaskPtr", n);
  if(_rf != RuleFlavor::INVALID)
    beginUserCode(_rf);
}
Пример #7
0
void Script_v2::o2_handleGoblins(FuncParams &params) {
	startFunc(params);
	print("var32_%d, ", readUint16() * 4);
	print("var32_%d, ", readUint16() * 4);
	print("var32_%d, ", readUint16() * 4);
	print("var32_%d, ", readUint16() * 4);
	print("var32_%d, ", readUint16() * 4);
	print("var32_%d", readUint16() * 4);
	endFunc();
}
Пример #8
0
void Script_v2::o2_totSub(FuncParams &params) {
	startFunc(params);

	uint8 length = readUint8();
	if (!(length & 0x80)) {
		for (uint16 i = 0; i < length; i++)
			print("%c", (char) readUint8());
	} else
		print("%s", readExpr().c_str());

	print(", %d", readUint8());

	endFunc();
}
Пример #9
0
void petabricks::CodeGenerator::continuationPoint(){
#ifndef DISABLE_CONTINUATIONS
  std::string n = "cont_" + jalib::XToString(_contCounter++);
  beginIf("useContinuation()");
  write("return new petabricks::MethodCallTask<"+_curClass+", &"+_curClass+"::"+n+">( this );");
  elseIf();
  write("return "+n+"();");
  endIf();
  endFunc();
  beginFunc("DynamicTaskPtr", n);
  if(_rf != RuleFlavor::INVALID)
    beginUserCode(_rf);
#endif
}
Пример #10
0
	void gen1()
	{
		const int bit = 1024;
		resetGlobalIdx();
		Operand pz(IntPtr, bit);
		Operand px(IntPtr, bit);
		Operand py(IntPtr, bit);
		std::string name = "add" + cybozu::itoa(bit);
		Function f(name, Void, pz, px, py);
		beginFunc(f);
		Operand x = load(px);
		Operand y = load(py);
		x = add(x, y);
		store(x, pz);
		ret(Void);
		endFunc();
	}
Пример #11
0
void Script_v2::o2_loadMapObjects(FuncParams &params) {
	int16 id;

	startFunc(params);

	print("%s, ", readVarIndex().c_str());

	id = (int16) readUint16();
	print("%d", id);
	if (id != -1) {
		int16 count = (int16) readUint16();
		print(", %d", count);
		for (int i = 0; i < count; i++)
			print(", %d", (int16) readUint16());
	}

	endFunc();
}
Пример #12
0
void Script_v6::o6_loadCursor(FuncParams &params) {
	int16 id = (int16) readUint16();

	startFunc(params);
	print("%d, ", id);
	if (id == -1) {
		print("%s, ", peekString());
		skip(9);
		print("%d, ", readUint16());
		print("%d", (int8) readUint8());
	} else if (id == -2) {
		print("%d, ", readUint16());
		print("%d, ", readUint16());
		print("%d", (int8) readUint8());
	} else {
		print("%d", (int8) readUint8());
	}
	endFunc();
}
Пример #13
0
void Script_v6::o6_createSprite(FuncParams &params) {
	uint32 pos;

	pos = getPos();
	skip(1);

	startFunc(params);
	if (peekUint8() == 0) {
		seek(pos);
		print("%d, ", readUint16());
		print("%d, ", readUint16());
		print("%d, ", readUint16());
	} else {
		seek(pos);
		print("%s, ", readExpr().c_str());
		print("%s, ", readExpr().c_str());
		print("%s, ", readExpr().c_str());
	}
	print("%d", readUint16());
	endFunc();
}
Пример #14
0
void Lab2::on_polylineButton_clicked()
{
    if(image->isNull())
    {
        QMessageBox::information(this, "Warning!", "Сначала надо открыть файл");
        return;
    }

    int h = image->height();
    int w = image->width();

    coordinateList = new QMap<int, int>();
    QMap<int, int>::iterator it;
    int pointCount = ui->pointCount->text().toInt();

    for(int count = 0; count < pointCount; count++)
    {
         coordinateList->insert(1+rand()%(w-1), 1+rand()%(h-1));
    }

    for(it = coordinateList->begin(); it != coordinateList->end()-1; ++it)
    {
        int x1 = it.key();
        int y1 = it.value();
        it++;
        int x2 = it.key();
        int y2 = it.value();
        it--;

        double x, y;

        for(x = x1; x < x2; x+=0.001)
        {
            y = ((x-x1)*(y2-y1)) / (x2-x1) + y1;
            image->setPixel(x, y, qRgb(0, 255, 0));
        }

    }
emit endFunc();
}
Пример #15
0
void Script_v2::o2_loadMult(FuncParams &params) {
	uint16 id;
	bool hasImds;

	id = readUint16();
	if (id & 0x8000) {
		id &= 0x7FFF;
		skip(1);
	}

	startFunc(params);
	print("%d", id);
	endFunc();

	if (!_extTable)
		error("EXT file needed");

	uint32 size;
	byte *extData = _extTable->getItem(id - 30000, size);
	byte *data = extData;

	int32 count1, count2;

	count1 = ((int8) data[0]) + 1;
	hasImds = ((count1 & 0x80) != 0);
		count1 &= 0x7F;
	count2 = ((int8) data[1]) + 1;
	data += 2;
	// Statics
	for (int i = 0; i < count1; i++, data += 14) {
		int16 sSize;

		readExpr();
		sSize = (int16) readUint16();
		skip(sSize * 2);
		sSize = (int16) readUint16();
		skip(2 + sSize * 8);
	}
	// Anims
	for (int i = 0; i < count2; i++, data += 14) {
		readExpr();
		int16 sSize = (int16) readUint16();
		skip(2 + sSize * 8);
	}

	// FPS
	data += 2;

	// StaticKeys
	count1 = (int16) READ_LE_UINT16(data);
	data += 2 + count1 * 4;

	// AnimKeys
	for (int i = 0; i < 4; i++) {
		count1 = (int16) READ_LE_UINT16(data);
		data += 2 + count1 * 10;
	}

	// fadePal
	data += 5 * 16 * 3;

	// palFadeKeys
	count1 = (int16) READ_LE_UINT16(data);
	data += 2 + count1 * 7;

	// palKeys
	count1 = (int16) READ_LE_UINT16(data);
	data += 2 + count1 * 80;

	// textKeys
	count1 = (int16) READ_LE_UINT16(data);
	data += 2 + count1 * (4 + (hasImds ? 0 : 24));

	// soundKeys
	count1 = (int16) READ_LE_UINT16(data);
	data += 2;
	for (int i = 0; i < count1; i++, data += (12 + (hasImds ? 0 : 24))) {
		int16 cmd = (int16) READ_LE_UINT16(data + 2);

		if ((cmd == 1) || (cmd == 4))
			skip(2);
		else if (cmd == 3)
			skip(4);
	}

	// ImdKeys
	if (hasImds) {
		int16 sSize = (int16) readUint16();
		skip(sSize * 2);

		if (getVerScript() >= 51) {
			sSize = (int16) readUint16();
			if (sSize > 0)
				skip(sSize * 14);
		}
	}

	delete[] extData;
}
Пример #16
0
void petabricks::CodeGenerator::generateMigrationFunctions(){
  CodeGenerator& in = forkhelper();
  CodeGenerator& out = forkhelper();
  CodeGenerator& size = forkhelper();
  CodeGenerator& migrateRegion = forkhelper();
  CodeGenerator& getDataHosts = forkhelper();

  std::vector<std::string> args;
  args.push_back("char* _buf");
  args.push_back("RemoteHost& _host");

  size.beginFunc("size_t", "serialSize");
  out.beginFunc("void", "serialize", args);

  args[0] = "const char* _buf";
  in.beginFunc("void", "unserialize", args);
  size.write("size_t _sz = 0;");

  std::vector<std::string> args2;
  args2.push_back("RemoteHost& sender");
  migrateRegion.beginFunc("void", "migrateRegions", args2);

  std::vector<std::string> args3;
  args3.push_back("DataHostPidList& list");
  getDataHosts.beginFunc("void", "getDataHosts", args3);

  for(ClassMembers::const_iterator i=_curMembers.begin(); i!=_curMembers.end(); ++i){
    if(jalib::StartsWith(i->type, "distributed::")) {
      out.write(i->name + ".serialize(_buf, _host);");
      out.write("_buf += " + i->name + ".serialSize();");
      in.write(i->name + ".unserialize(_buf, _host);");
      in.write("_buf += " + i->name + ".serialSize();");
      size.write("_sz += " + i->name + ".serialSize();");
      migrateRegion.comment(i->name + ".updateHandlerChain();");
      getDataHosts.write(i->name + ".dataHosts(list);");

    }else if(i->type == "IndexT" || i->type == "int" || i->type == "double") {
      out.write("*reinterpret_cast<"+i->type+"*>(_buf) = "+i->name+";");
      in.write(i->name+" = *reinterpret_cast<const "+i->type+"*>(_buf);");
      size.write("_sz  += sizeof("+i->type+");");
      in  .write("_buf += sizeof("+i->type+");");
      out .write("_buf += sizeof("+i->type+");");
    }else if(jalib::StartsWith(i->type, "std::vector<")) {
      out.write("_serialize_vector(_buf, "+i->name+");");
      in.write("_unserialize_vector(_buf, "+i->name+");");
      size.write("_sz += _serialSize_vector("+i->name+");");
    }else if(i->type == "DynamicTaskPtr") {
      if(i->initializer != "") {
        in.write(i->name+" = "+i->initializer+";");
      }
    }else{
      JASSERT(false)(i->type).Text("cant yet serialize type");
    }
  }

  size.write("return _sz;");
  in.write("_sender = &_host;");

  in.endFunc();
  out.endFunc();
  size.endFunc();
  migrateRegion.endFunc();
  getDataHosts.endFunc();

  hos() << _curClass << "(const char*, RemoteHost&, bool=false);\n";
  os() << _curClass << "::" << _curClass << "(const char* _buf, RemoteHost& _host, bool shouldInit){\n";
  incIndent();
  write("unserialize(_buf, _host);");
  beginIf("shouldInit");
  write(_curConstructorBody);
  endIf();
  decIndent();
  os() << "\n}\n";

  beginFunc(_curClass+"*", "_new_constructor", std::vector<std::string>(1,"const char* _buf, RemoteHost& _host"), true);
  write("return new "+_curClass+"(_buf, _host);");
  endFunc();

  beginFunc("RemoteObjectGenerator", "generator");
  write("return &RemoteTaskReciever<"+_curClass+">::gen;");
  endFunc();
}
Пример #17
0
void Script_v2::o2_playInfogrames(FuncParams &params) {
	startFunc(params);
	print("var8_%d", readUint16() * 4);
	endFunc();
}
Пример #18
0
void Lab4::on_translationButton_clicked()
{
    int sx = ui->lineX->text().toInt();
    int sy = ui->lineY->text().toInt();
    int sz = ui->lineZ->text().toInt();

    int tX[2][4];
    int tY[2][4];
    int tZ[2][4];

    for(int i=0; i<2; i++)
    {
        for(int j=0; j<4; j++)
        {
            tX[i][j] = Px[i][j];
            tY[i][j] = Py[i][j];
            tZ[i][j] = Pz[i][j];
        }
    }


    double Translation[4][4] = {{1, 0, 0, sx},
                            {0, 1, 0, sy},
                            {0, 0, 1, sz},
                            {0, 0, 0, 1}};
    double fun[4][1];
    double Fun[4][1];

    for(int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            fun[0][0] = tX[i][j];
            fun[1][0] = tY[i][j];
            fun[2][0] = tZ[i][j];
            fun[3][0] = 1;
            for(int I = 0; I<4; I++)
            {
                for(int J = 0; J<1; J++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        Fun[I][J] += Translation[I][k] * fun[k][J];
                    }
                }
            }

            tX[i][j] = (int)Fun[0][0];
            tY[i][j] = (int)Fun[1][0];
            tZ[i][j] = (int)Fun[2][0];

            for (int I = 0; I < 4; I++)
            {
                for (int J = 0; J < 1; J++)
                {
                    Fun[I][J] = 0;
                    fun[I][J] = 0;
                }
            }
        }
    }

    Draw(tX, tY, tZ);
    emit endFunc();
}
Пример #19
0
void Lab4::on_turnButton_clicked()
{
    int Q = ui->lineGrad->text().toInt();
    double Povorot[4][4] = {{cos(Q*M_PI/180), sin(Q*M_PI/180), 0, 0},
                            {-sin(Q*M_PI/180), cos(Q*M_PI/180),0, 0},
                            {0, 0, 1, 0},
                            {0, 0, 0, 1}

    };
    double fun[4][1];
    double Fun[4][1];

    int tX[2][4];
    int tY[2][4];
    int tZ[2][4];

    for(int i=0; i<2; i++)
    {
        for(int j=0; j<4; j++)
        {
            tX[i][j] = Px[i][j];
            tY[i][j] = Py[i][j];
            tZ[i][j] = Pz[i][j];
        }
    }

    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            fun[0][0] = tX[i][j];
            fun[1][0] = tY[i][j];
            fun[2][0] = tZ[i][j];
            fun[3][0] = 1;

            for (int I = 0; I < 4; I++)
            {
                for (int J = 0; J < 1; J++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        Fun[I][J] += Povorot[I][k] * fun[k][J];
                    }
                }
            }

            tX[i][j] = Fun[0][0];
            tY[i][j] = Fun[1][0];
            tZ[i][j] = Fun[2][0];
            for (int I = 0; I < 4; I++)
            {
                for (int J = 0; J < 1; J++)
                {
                    Fun[I][J] = 0;
                    fun[I][J] = 0;
                }
            }
        }
    }

    Draw(tX, tY, tZ);
    emit endFunc();

}
Пример #20
0
void Lab2::on_antialiasingButton_clicked()
{

    if(image->isNull())
    {
        QMessageBox::information(this, "Warning!", "Сначала надо открыть файл");
        return;
    }

    if(coordinateList->isEmpty())
    {
        QMessageBox::information(this, "Warning!", "Сначала постройте ломаную");
        return;
    }

    QMap<int, int>::iterator it;        

    for(it = coordinateList->begin(); it != coordinateList->end()-1; it++)
    {
        int xCur = it.key();
        int yCur = it.value();
        int xPre=0, yPre=0, xNext=0, yNext=0, xNextNext=0, yNextNext=0;

        if(it == coordinateList->begin())
        {
            xPre = xCur;
            yPre = yCur;
            it++;
        }
        else
        {
            it--;
            xPre = it.key();
            yPre = it.value();
            it += 2;
        }

        xNext = it.key();
        yNext = it.value();
        it--;

        if(it == coordinateList->end()-2)
        {
            xNextNext = xNext;
            yNextNext = yNext;
        }
        else
        {
            it += 2;
            xNextNext = it.key();
            yNextNext = it.value();
            it -=2;
        }

        int x, y;


        for(double t=0; t<=1; t+=0.001)
        {
            int a0 = (xPre + 4*xCur + xNext) / 6;
            int a1 = (-xPre + xNext) / 2;
            int a2 = (xPre - 2*xCur + xNext) / 2;
            int a3 = (-xPre + 3*xCur - 3*xNext + xNextNext) / 6;

            int b0 = (yPre + 4*yCur + yNext) / 6;
            int b1 = (-yPre + yNext) / 2;
            int b2 = (yPre - 2*yCur + yNext) / 2;
            int b3 = (-yPre + 3*yCur - 3*yNext + yNextNext) / 6;

            x = ((a3*t+a2)*t+a1)*t+a0;
            y = ((b3*t+b2)*t+b1)*t+b0;

            image->setPixel(x, y, qRgb(255, 0, 0));
        }
    }
    emit endFunc();
}
Пример #21
0
void Lab4::on_zoomButton_clicked()
{
    double sx = ui->lineEdit->text().toDouble();
    double sy = ui->lineEdit->text().toDouble();
    double sz = ui->lineEdit->text().toDouble();

    int px = ui->linePX->text().toInt();
    int py = ui->linePY->text().toInt();
    int pz = ui->linePZ->text().toInt();

    int tX[2][4];
    int tY[2][4];
    int tZ[2][4];

    for(int i=0; i<2; i++)
    {
        for(int j=0; j<4; j++)
        {
            tX[i][j] = Px[i][j];
            tY[i][j] = Py[i][j];
            tZ[i][j] = Pz[i][j];
        }
    }


    double Mashtab[4][4] = {{sx, 0, 0, (1-sx)*px},
                            {0, sy, 0, (1-sy)*py},
                            {0, 0, sz, (1-sz)*pz},
                            {0, 0, 0, 1}};
    double fun[4][1];
    double Fun[4][1];

    for(int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            fun[0][0] = tX[i][j];
            fun[1][0] = tY[i][j];
            fun[2][0] = tZ[i][j];
            fun[3][0] = 1;
            for(int I = 0; I<4; I++)
            {
                for(int J = 0; J<1; J++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        Fun[I][J] += Mashtab[I][k] * fun[k][J];
                    }
                }
            }

            tX[i][j] = (int)Fun[0][0];
            tY[i][j] = (int)Fun[1][0];
            tZ[i][j] = (int)Fun[2][0];

            for (int I = 0; I < 4; I++)
            {
                for (int J = 0; J < 1; J++)
                {
                    Fun[I][J] = 0;
                    fun[I][J] = 0;
                }
            }
        }
    }

    Draw(tX, tY, tZ);
    emit endFunc();
}
funcp geracod (FILE *f) {
	unsigned char *mcodes = (unsigned char *)malloc(50*16); // mcodes - execstack, onde serao armazenados os codigos das instrucoes; alocação de memória supondo gasto máximo (todas as linhas como atribuições)
	unsigned char prologo[] = {0x55,0x89,0xe5,0x83,0xec,0x28}; //salva o valor de %ebp e aloca a memória para as variáveis locais
	unsigned char finalizacao[] = {0x8b,0x45,0xfc,0x89,0xec,0x5d,0xc3}; //coloca o v0 em %eax, restaura o valor de %ebp e retorna
	unsigned char temp=' ',vartype[3],op;
	retstruct func;
	intchar temp2;
	int bytes=0,var[3], nwhiles=0; //nwhiles guarda o numero de whiles "ativos" em um dado momento da execucao do programa (para que o end saiba a qual while se refere)
	int enderecoCmplWhiles[25]; //enderecoCmplWhiles guarda os endereços dos whiles ativos e possui 25 de tamanho pois o máximo possível de whiles ativos é 25, considerando que o máximo de linhas que um programa em sb pode ter é 50 e cada while precisa de um end.
	
	linhas = 1;

	memcpy(mcodes,prologo,sizeof(prologo)); // copia prologo para mcodes
	bytes+=sizeof(prologo);
	while((fread(&vartype[0],1,1,f)>0)&&(vartype[0]!='r')&&(linhas<=50)){ // le o início de cada linha, armazenando o tipo de instrução em vartype[0]
		if(bytes>=50*16){
			printf("Erro: Numero maximo de instrucoes excedido.\n");
			exit(-1);
		}

		switch(vartype[0]){
			case 'v':
			case 'p': //assign
				fscanf(f,"%d = %c%d %c %c%d",&var[0],&vartype[1],&var[1],&op,&vartype[2],&var[2]); //lê o resto da linha da atribuição, salvando cada valor em uma variável separada
				func=assign(vartype[0],var[0],vartype[1],var[1],vartype[2],var[2],op);
				memcpy(&mcodes[bytes],func.ret,func.size);
				bytes+=func.size;
				break;

			case 'w': //while
				fscanf(f,"hile %c%d",&vartype[0],&var[0]); //lê o resto da linha do while, salvando cada valor em uma variável separada
				
				enderecoCmplWhiles[nwhiles]=bytes; // Armazena o endereço do cmpl do while atual

				func = whileFunc(vartype[0],var[0]);

				memcpy(&mcodes[bytes],func.ret,func.size);
				bytes+=func.size;
				nwhiles++; // faz com que, caso haja um while dentro do atual, o endereço de seu cmpl seja armazenado em outra posição do vetor
				break;
			case 'e': //end
				if(nwhiles==0){
					printf("Erro (linha %d): nao ha um while aberto para o end declarado.\n", linhas);
					exit(-1);
				}

				nwhiles--; // decremento necessário para que seja buscada a posição do vetor em que está armazenado o último while chamado
				temp2.i=enderecoCmplWhiles[nwhiles];
				bytes+=endFunc(mcodes,bytes,&temp2);
				fseek(f,2,SEEK_CUR);

			case 'r': //ret
				break;	
			case '/': //comentario
				fscanf(f,"%c",&temp);
				if(temp!='/'){
					printf("Erro de leitura (linha %d): caractere invalido encontrado ('%c')\nDica: comentarios se iniciam com // e nao com /\n", linhas, temp);
					exit(-1);
				}
				else while(temp!='\n') fscanf(f,"%c",&temp);
				linhas++;
				break;
			case '\n': //newline
				linhas++;
				break;
			case '\t': //tabulação
				break;

			case ' ': //tabulação
				break;
	
			default: 
				printf("Erro de leitura (linha %d): caractere invalido encontrado ('%c')\n", linhas, vartype[0]);
				exit(-1);
				break;
		}
	}

	if(nwhiles>0){
		printf("Erro: nem todos os whiles foram fechados.\n");
		exit(-1);
	}

	if(vartype[0]!='r') printf("Aviso: final do codigo alcancado sem ret chamado.\n");

	if(linhas>50){
		printf("Erro: maximo de linhas atingido.\n");
		exit(-1);
	}

	memcpy(&mcodes[bytes],finalizacao,sizeof(finalizacao));
	funcp p = (funcp)mcodes;
	rewind(f);
	return p;
}