Ejemplo n.º 1
0
inline void TR_X86OpCode::OpCode_t::finalize(uint8_t* cursor) const
   {
   // Finalize VEX prefix
   switch (*cursor)
      {
      case 0xC4:
         {
         auto pVEX = (TR::Instruction::VEX<3>*)cursor;
         if (vex_v == VEX_vReg_)
            {
            pVEX->v = ~(modrm_form == ModRM_EXT_ ? pVEX->RM() : pVEX->Reg());
            }
         }
         break;
      case 0xC5:
         {
         auto pVEX = (TR::Instruction::VEX<2>*)cursor;
         if (vex_v == VEX_vReg_)
            {
            pVEX->v = ~(modrm_form == ModRM_EXT_ ? pVEX->RM() : pVEX->Reg());
            }
         }
         break;
      default:
         break;
      }
   }
// update the new centre positions after one outer clustering iteration
void update_centres(centre_type *centres_in,centre_index_type k, data_type *centres_positions_out)
{
    #pragma HLS inline
    centre_update_loop: for (centre_index_type i=0; i<=k; i++) {
        #pragma HLS pipeline II=1
        centre_type tmp_cent = Reg(centres_in[i]);
        coord_type tmp_count = tmp_cent.count;
        if ( tmp_count == 0 )
            tmp_count = 1;

        data_type_ext tmp_wgtCent = tmp_cent.wgtCent;
        data_type tmp_new_pos;
        for (uint d=0; d<D; d++) {
            #pragma HLS unroll
            coord_type_ext tmp_div_ext = (get_coord_type_vector_ext_item(tmp_wgtCent.value,d) / tmp_count); //let's see what it does with that...
            coord_type tmp_div = (coord_type) tmp_div_ext;
            #pragma HLS resource variable=tmp_div core=DivnS
            set_coord_type_vector_item(&tmp_new_pos.value,Reg(tmp_div),d);
        }
        centres_positions_out[i] = Reg(tmp_new_pos);
        if (i==k) {
            break;
        }
    }
}
Ejemplo n.º 3
0
BOOL WINAPI _IsRegMatchA(CHAR* lpszPatt,CHAR* lpszStr)
{
	CRegexpA Reg(lpszPatt);

	auto mr=Reg.Match(lpszStr);
	return mr.IsMatched();
}
Ejemplo n.º 4
0
const Vector<Reg>& regsInPriorityOrder(Arg::Type type)
{
    static Vector<Reg>* result[Arg::numTypes];
    static std::once_flag once;
    std::call_once(
        once,
        [] {
            result[Arg::GP] = new Vector<Reg>();
            for (GPRReg reg : gprsInPriorityOrder())
                result[Arg::GP]->append(Reg(reg));
            result[Arg::FP] = new Vector<Reg>();
            for (FPRReg reg : fprsInPriorityOrder())
                result[Arg::FP]->append(Reg(reg));
        });
    return *result[type];
}
Ejemplo n.º 5
0
TType *TCodeGenerator::EmitArctanCosExpLnSinSqrtCall
(const TSymtabNode *pRoutineId)
{
    char *stdFuncName;

    GetToken();  // (
    GetToken();

    //--Evaluate the parameter, and convert an integer value to
    //--real if necessary.
    TType *pParmType = EmitExpression()->Base();
    if (pParmType == pIntegerType) {
        Emit1(push, Reg(ax));
        Emit1(call, NameLit(FLOAT_CONVERT));
        Emit2(add,  Reg(sp), IntegerLit(2));
    }

    EmitPushOperand(pRealType);

    switch (pRoutineId->defn.routine.which) {
    case rcArctan:
        stdFuncName = STD_ARCTAN;
        break;
    case rcCos:
        stdFuncName = STD_COS;
        break;
    case rcExp:
        stdFuncName = STD_EXP;
        break;
    case rcLn:
        stdFuncName = STD_LN;
        break;
    case rcSin:
        stdFuncName = STD_SIN;
        break;
    case rcSqrt:
        stdFuncName = STD_SQRT;
        break;
    }

    Emit1(call, NameLit(stdFuncName));
    Emit2(add,  Reg(sp), IntegerLit(4));

    GetToken();  // token after )
    return pRealType;
}
Ejemplo n.º 6
0
vector<Reg> Reg::Concavities() {
    vector<Reg> ret = vector<Reg>();
    vector<Seg> ch = convexhull;
    unsigned int j = 0;

    cerr << "Calculating Concavities Start " << depth++ << "\n";
    cerr << "Hull\n";
    for (unsigned int a = 0; a < ch.size(); a++) {
        cerr << ch[a].ToString() << "\n";
    }
    cerr << "Pol\n";
    for (unsigned int a = 0; a < v.size(); a++) {
        cerr << v[a].ToString() << "\n";
    }

    for (j = 0; j < v.size(); j++) {
        if ((ch[0].x1 == v[j].x1) && (ch[0].y1 == v[j].y1)) {
            break;
        }
    }

    for (unsigned int i = 0; i < ch.size(); i++) {
        if (!(ch[i] == v[j])) {
            cerr << "Found new Concavity: " << depth << "\n";
            Reg r = Reg(this, i);
            unsigned int hpidx;
            if (j == 0) {
                hpidx = v.size() - 1;
            } else {
                hpidx = j - 1;
            }
            r.hullPoint = new Pt(v[hpidx].x1, v[hpidx].x2);
            cerr << "End: " << ch[i].x2 << "/" << ch[i].y2 << "\n";
            do {
                Seg s = Seg(v[j].x2, v[j].y2, v[j].x1, v[j].y1);
                r.AddSeg(s);
                j = (j + 1) % v.size();
            } while ((ch[i].x2 != v[j].x1) || (ch[i].y2 != v[j].y1));
            std::reverse(r.v.begin(), r.v.end());
            r.Close();
            //            r.Print();
            cerr << "End Found new Concavity: " << depth << "\n";
            ret.push_back(r);
        } else {
            j = (j + 1) % v.size();
        }
    }

    cvs = ret;

    cerr << "Found " << cvs.size() << " Concavities\n";

    cerr << "Calculating Concavities End " << --depth << "\n";

    return ret;
}
Ejemplo n.º 7
0
TType *TCodeGenerator::EmitOddCall(void)
{
    GetToken();  // (
    GetToken();
    EmitExpression();

    Emit2(and, Reg(ax), IntegerLit(1));

    GetToken();  // token after )
    return pBooleanType;
}
Ejemplo n.º 8
0
// Read user interface options from registry
void GDisplay::ReadOptions()
{
	CRegistry Reg(HKEY_CURRENT_USER);
	DWORD dw;

	Reg.OpenKey(APP_MAIN_KEY);
	if (Reg.ReadInteger(_T("Manoeuverable"), &dw))
		m_fManoeuverable = dw;

	Reg.CloseKey();
}
Ejemplo n.º 9
0
void GDisplay::SaveOptions()
{
	CRegistry Reg(HKEY_CURRENT_USER);
	DWORD dw;

	Reg.OpenKey(APP_MAIN_KEY);
	dw = m_fManoeuverable;
	Reg.WriteInteger(_T("Manoeuverable"), &dw);
	Reg.CloseKey();

}
Ejemplo n.º 10
0
TType *TCodeGenerator::EmitPredSuccCall(const TSymtabNode *pRoutineId)
{
    GetToken();  // (
    GetToken();

    TType *pParmType = EmitExpression();

    Emit1(pRoutineId->defn.routine.which == rcPred ? decr : incr,
          Reg(ax));

    GetToken();  // token after )
    return pParmType;
}
Ejemplo n.º 11
0
TType *TCodeGenerator::EmitRoundTruncCall(const TSymtabNode *pRoutineId)
{
    GetToken();  // (
    GetToken();
    EmitExpression();

    EmitPushOperand(pRealType);
    Emit1(call, NameLit(pRoutineId->defn.routine.which == rcRound
                        ? STD_ROUND : STD_TRUNC));
    Emit2(add, Reg(sp), IntegerLit(4));

    GetToken();  // token after )
    return pIntegerType;
}
Ejemplo n.º 12
0
Archivo: cpu.c Proyecto: Gigi1237/armgo
void writeReg(int index, INT32 value)
{
  if(index == 15)
  {
	if(TFLAG)
  	{
	  Reg(index) = ( value & 0xfffffffe );
  	}
	else
	{
      Reg(index) = ( value & 0xfffffffc );
	}
	// instruction pipeline should be refreshed
	cpu.pipelineRefreshed = 1;
  }
  else if(index>=0 && index <=14)
  {
	Reg(index) = ( value & 0xffffffff );
  }
  else
  {
	PROGRAM_ERROR;
  }
}
Ejemplo n.º 13
0
TType *TCodeGenerator::EmitAbsSqrCall(const TSymtabNode *pRoutineId)
{
    GetToken();  // (
    GetToken();

    TType *pParmType = EmitExpression()->Base();

    switch (pRoutineId->defn.routine.which) {

    case rcAbs:
        if (pParmType == pIntegerType) {
            int nonNegativeLabelIndex = ++asmLabelIndex;

            Emit2(cmp, Reg(ax), IntegerLit(0));
            Emit1(jge,
                  Label(STMT_LABEL_PREFIX, nonNegativeLabelIndex));
            Emit1(neg, Reg(ax));

            EmitStatementLabel(nonNegativeLabelIndex);
        }
        else {
            EmitPushOperand(pParmType);
            Emit1(call, NameLit(STD_ABS));
            Emit2(add,  Reg(sp), IntegerLit(4));
        }
        break;

    case rcSqr:
        if (pParmType == pIntegerType) {
            Emit2(mov,  Reg(dx), Reg(ax));
            Emit1(imul, Reg(dx));
        }
        else {
            EmitPushOperand(pParmType);
            EmitPushOperand(pParmType);
            Emit1(call, NameLit(FLOAT_MULTIPLY));
            Emit2(add,  Reg(sp), IntegerLit(8));
        }
        break;
    }

    GetToken();  // token after )
    return pParmType;
}
Ejemplo n.º 14
0
void  main()
 {  clrscr();
    double a, b;
    int itr;
    cout << "\nEnter number of iterations : ";
    cin >> itr;
    cout<<"\n Enter a : ";
    cin >> a;
    cout<<"Enter b : ";
    cin >> b;
    if (f(a) * f(b) < 0)
       Reg( itr, a, b);
    else
	cout << "This won't work." << endl;
   cout<<"\n\n Name : Priyanka Jindal  ";
   cout<<"\n  Branch : CSE-B";
   cout<<"\n SUB=Applied mathematics lab";
   cout<<"\n Enrollment no.=08120802714";
    getch();
}
Ejemplo n.º 15
0
Archivo: cpu.c Proyecto: Gigi1237/armgo
void dumpCpu()
{
  inscount++;
  //printf("ins count = %d\n", inscount);;
  //if((cpu.pipeline32[0].address == 0x33f8ae40) || (bbb==1) )

  if( (bp !=0 ) && ( inscount >= bp ) )
  {
    printf("ins count = %d\n", inscount);
    printf("r0  = 0x%08x, r1  = 0x%08x, r2  = 0x%08x, r3  = 0x%08x\n", Reg(0),  Reg(1),  Reg(2),  Reg(3));
    printf("r4  = 0x%08x, r5  = 0x%08x, r6  = 0x%08x, r7  = 0x%08x\n", Reg(4),  Reg(5),  Reg(6),  Reg(7));
    printf("r8  = 0x%08x, r9  = 0x%08x, r10 = 0x%08x, r11 = 0x%08x\n", Reg(8),  Reg(9),  Reg(10), Reg(11));
    printf("r12 = 0x%08x, r13 = 0x%08x, r14 = 0x%08x, r15 = 0x%08x\n", Reg(12), Reg(13), Reg(14), Reg(15));
    printf("\n");


  char str[100];
  while(1)
  {
    fflush(stdin);
    gets(str);

      if(str[0] != 'm')
        break;


      INT32 address = arrayHexToDigit(str+1);

    printf("[0x%08x] = 0x%08x\n", address + 0x00, readMemoryWord(address + 0x00));
    printf("[0x%08x] = 0x%08x\n", address + 0x04, readMemoryWord(address + 0x04));
    printf("[0x%08x] = 0x%08x\n", address + 0x08, readMemoryWord(address + 0x08));
    printf("[0x%08x] = 0x%08x\n", address + 0x0c, readMemoryWord(address + 0x0c));
    printf("[0x%08x] = 0x%08x\n", address + 0x10, readMemoryWord(address + 0x10));
    printf("[0x%08x] = 0x%08x\n", address + 0x14, readMemoryWord(address + 0x14));
    printf("[0x%08x] = 0x%08x\n", address + 0x18, readMemoryWord(address + 0x18));
    printf("[0x%08x] = 0x%08x\n", address + 0x1c, readMemoryWord(address + 0x1c));
  }
  }
}
Ejemplo n.º 16
0
TType *TCodeGenerator::EmitReadReadlnCall(const TSymtabNode *pRoutineId)
{
    //--Actual parameters are optional for readln.
    GetToken();
    if (token == tcLParen) {

        //--Loop to emit code to read each parameter value.
        do {
            //--Variable
            GetToken();
            TSymtabNode *pVarId   = pNode;
            TType       *pVarType = EmitVariable(pVarId, true)->Base();

            //--Read the value.
            if (pVarType == pIntegerType) {
                Emit1(call, NameLit(READ_INTEGER));
                Emit1(pop,  Reg(bx));
                Emit2(mov,  WordIndirect(bx), Reg(ax));
            }
            else if (pVarType == pRealType) {
                Emit1(call, NameLit(READ_REAL));
                Emit1(pop,  Reg(bx));
                Emit2(mov,  WordIndirect(bx), Reg(ax));
                Emit2(mov,  HighDWordIndirect(bx), Reg(dx));
            }
            else if (pVarType == pCharType) {
                Emit1(call, NameLit(READ_CHAR));
                Emit1(pop,  Reg(bx));
                Emit2(mov,  ByteIndirect(bx), Reg(al));
            }
        } while (token == tcComma);

        GetToken();  // token after )
    }

    //--Skip the rest of the input line if readln.
    if (pRoutineId->defn.routine.which == rcReadln) {
        Emit1(call, NameLit(READ_LINE));
    }

    return pDummyType;
}
Ejemplo n.º 17
0
  QString Cdebug_ti57cpu::Debugging(TI57regs *r) {
      QString s="";
  s=QString("A\t= ").append(Reg(r->RA)).append("\n");
  s.append("B\t= ").append(Reg(r->RB)).append("\n");
  s.append("C\t= ").append(Reg(r->RC)).append("\n");
  s.append("D\t= ").append(Reg(r->RD)).append("\n");
  s.append("COND\t= %1").arg(r->COND).append("\n");
  s.append("BASE\t= %1\n").arg(r->BASE);
  s.append("R5\t= ").append(IntToHex(r->R5,2)).append("\n");
  s.append("RAB\t= ").append(IntToHex(r->RAB,1)).append("\n\n");
  s.append("ST\t= ").append(IntToHex(r->ST[0],3)).append(" ").append(IntToHex(r->ST[1],3)).append(" ").append(IntToHex(r->ST[2],3)).append("\n\n");
  for (int i=0; i<8;i++)
      s.append(QString("X%1 = %2   Y%3 = %4\n").arg(i).arg(Reg(r->RX[i])).arg(i).arg(Reg(r->RY[i])));
  //if Application.MessageBox(PChar(s),PChar(Decode),MB_OKCancel)<>IDOK then
//Debugger=False;

  return s;
}
Ejemplo n.º 18
0
 bool Modbus::Ists(word offset) {
     if (Reg(offset + 10001) == 0xFF00) {
         return true;
     } else return false;
 }
Ejemplo n.º 19
0
TType *TCodeGenerator::EmitExpression(void)
{
    TType        *pOperand1Type;  // ptr to first  operand's type
    TType        *pOperand2Type;  // ptr to second operand's type
    TType        *pResultType;    // ptr to result type
    TTokenCode    op;             // operator
    TInstruction  jumpOpcode;     // jump instruction opcode
    int           jumpLabelIndex; // assembly jump label index

    //--Emit code for the first simple expression.
    pResultType = EmitSimpleExpression();

    //--If we now see a relational operator,
    //--emit code for the second simple expression.
    if (TokenIn(token, tlRelOps)) {
	EmitPushOperand(pResultType);
	op            = token;
	pOperand1Type = pResultType->Base();

	GetToken();
	pOperand2Type = EmitSimpleExpression()->Base();

	//--Perform the operation, and push the resulting value
	//--onto the stack.
	if (   ((pOperand1Type == pIntegerType) &&
		(pOperand2Type == pIntegerType))
	    || ((pOperand1Type == pCharType) &&
		(pOperand2Type == pCharType))
	    || (pOperand1Type->form == fcEnum)) {

	    //--integer <op> integer
	    //--boolean <op> boolean
	    //--char    <op> char
	    //--enum    <op> enum
	    //--Compare dx (operand 1) to ax (operand 2).
	    Emit1(pop, Reg(dx));
	    Emit2(cmp, Reg(dx), Reg(ax));
	}
	else if ((pOperand1Type == pRealType) ||
		 (pOperand2Type == pRealType)) {

	    //--real    <op> real
	    //--real    <op> integer
	    //--integer <op> real
	    //--Convert the integer operand to real.
	    //--Call _FloatCompare to do the comparison, which
	    //--returns -1 (less), 0 (equal), or +1 (greater).
	    EmitPushOperand(pOperand2Type);
	    EmitPromoteToReal(pOperand1Type, pOperand2Type);

	    Emit1(call, NameLit(FLOAT_COMPARE));
	    Emit2(add,  Reg(sp), IntegerLit(8));
	    Emit2(cmp,  Reg(ax), IntegerLit(0));
	}
	else {

	    //--string <op> string
	    //--Compare the string pointed to by si (operand 1)
	    //--to the string pointed to by di (operand 2).
	    Emit1(pop, Reg(di));
	    Emit1(pop, Reg(si));
	    Emit2(mov, Reg(ax), Reg(ds));
	    Emit2(mov, Reg(es), Reg(ax));
	    Emit0(cld);
	    Emit2(mov, Reg(cx),
		       IntegerLit(pOperand1Type->array.elmtCount));
	    Emit0(repe_cmpsb);
	}

	Emit2(mov, Reg(ax), IntegerLit(1));  // default: load 1 

	switch (op) {
	    case tcLt:    jumpOpcode = jl;   break;
	    case tcLe:    jumpOpcode = jle;  break;
	    case tcEqual: jumpOpcode = je;   break;
	    case tcNe:    jumpOpcode = jne;  break;
	    case tcGe:    jumpOpcode = jge;  break;
	    case tcGt:    jumpOpcode = jg;   break;
	}

	jumpLabelIndex = ++asmLabelIndex;
	Emit1(jumpOpcode, Label(STMT_LABEL_PREFIX, jumpLabelIndex));

	Emit2(sub, Reg(ax), Reg(ax));     // load 0 if false
	EmitStatementLabel(jumpLabelIndex);

	pResultType = pBooleanType;
    }

    return pResultType;
}
Ejemplo n.º 20
0
TType *TCodeGenerator::EmitSimpleExpression(void)
{
    TType      *pOperandType;      // ptr to operand's type
    TType      *pResultType;       // ptr to result type
    TTokenCode  op;                // operator
    TTokenCode  unaryOp = tcPlus;  // unary operator

    //--Unary + or -
    if (TokenIn(token, tlUnaryOps)) {
	unaryOp = token;
	GetToken();
    }

    //--Emit code for the first term.
    pResultType = EmitTerm();

    //--If there was a unary operator, negate in integer value in ax
    //--with the neg instruction, or negate a real value in dx:ax
    //--by calling _FloatNegate.
    if (unaryOp == tcMinus) {
	if (pResultType->Base() == pIntegerType) Emit1(neg, Reg(ax))
	else if (pResultType == pRealType) {
	    EmitPushOperand(pResultType);
	    Emit1(call, NameLit(FLOAT_NEGATE));
	    Emit2(add,  Reg(sp), IntegerLit(4));
	}
    }

    //--Loop to execute subsequent additive operators and terms.
    while (TokenIn(token, tlAddOps)) {
	op = token;
	pResultType = pResultType->Base();
	EmitPushOperand(pResultType);

	GetToken();
	pOperandType = EmitTerm()->Base();

	//--Perform the operation, and push the resulting value
	//--onto the stack.
	if (op == tcOR) {

	    //--boolean OR boolean => boolean
	    //--ax = ax OR dx
	    Emit1(pop, Reg(dx));
	    Emit2(or,  Reg(ax), Reg(dx));
	    pResultType = pBooleanType;
	}
	else if ((pResultType  == pIntegerType) &&
		 (pOperandType == pIntegerType)) {

	    //--integer +|- integer => integer
	    Emit1(pop, Reg(dx));
	    if (op == tcPlus) Emit2(add, Reg(ax), Reg(dx))
	    else {
		Emit2(sub, Reg(dx), Reg(ax));
		Emit2(mov, Reg(ax), Reg(dx));
	    }
	    pResultType = pIntegerType;
	}
	else {
Ejemplo n.º 21
0
	    }
	    pResultType = pIntegerType;
	}
	else {

	    //--real    +|- real    => real
	    //--real    +|- integer => real
	    //--integer +|- real    => real
	    //--Convert the integer operand to real and then
	    //--call _FloatAdd or _FloatSubtract.
	    EmitPushOperand(pOperandType);
	    EmitPromoteToReal(pResultType, pOperandType);

	    Emit1(call, NameLit(op == tcPlus ? FLOAT_ADD
					     : FLOAT_SUBTRACT));
	    Emit2(add, Reg(sp), IntegerLit(8));
	    pResultType = pRealType;
	}
    }

    return pResultType;
}

//--------------------------------------------------------------
//  EmitTerm            Emit code for a term (binary operators
//                      * / DIV tcMOD and AND).
//
//  Return: ptr to term's type object
//--------------------------------------------------------------

TType *TCodeGenerator::EmitTerm(void)
Ejemplo n.º 22
0
 word Modbus::Ireg(word offset) {
     return Reg(offset + 30001);
 }
Ejemplo n.º 23
0
TType *TCodeGenerator::EmitWriteWritelnCall
(const TSymtabNode *pRoutineId)
{
    const int defaultFieldWidth = 10;
    const int defaultPrecision  =  2;

    //--Actual parameters are optional for writeln.
    GetToken();
    if (token == tcLParen) {

        //--Loop to emit code for each parameter value.
        do {
            //--<expr-1>
            GetToken();
            TType *pExprType = EmitExpression()->Base();

            //--Push the scalar value to be written onto the stack.
            //--A string value is already on the stack.
            if (pExprType->form != fcArray) {
                EmitPushOperand(pExprType);
            }

            if (token == tcColon) {

                //--Field width <expr-2>
                //--Push its value onto the stack.
                GetToken();
                EmitExpression();
                Emit1(push, Reg(ax));

                if (token == tcColon) {

                    //--Precision <expr-3>
                    //--Push its value onto the stack.
                    GetToken();
                    EmitExpression();
                    Emit1(push, Reg(ax));
                }
                else if (pExprType == pRealType) {

                    //--No precision: Push the default precision.
                    Emit2(mov, Reg(ax), IntegerLit(defaultPrecision));
                    Emit1(push, Reg(ax));
                }
            }
            else {

                //--No field width: Push the default field width and
                //--                the default precision.
                if (pExprType == pIntegerType) {
                    Emit2(mov,  Reg(ax), IntegerLit(defaultFieldWidth));
                    Emit1(push, Reg(ax));
                }
                else if (pExprType == pRealType) {
                    Emit2(mov,  Reg(ax), IntegerLit(defaultFieldWidth));
                    Emit1(push, Reg(ax));
                    Emit2(mov,  Reg(ax), IntegerLit(defaultPrecision));
                    Emit1(push, Reg(ax));
                }
                else {
                    Emit2(mov,  Reg(ax), IntegerLit(0));
                    Emit1(push, Reg(ax));
                }
            }

            //--Emit the code to write the value.
            if (pExprType == pIntegerType) {
                Emit1(call, NameLit(WRITE_INTEGER));
                Emit2(add,  Reg(sp), IntegerLit(4));
            }
            else if (pExprType == pRealType) {
                Emit1(call, NameLit(WRITE_REAL));
                Emit2(add,  Reg(sp), IntegerLit(8));
            }
            else if (pExprType == pBooleanType) {
                Emit1(call, NameLit(WRITE_BOOLEAN));
                Emit2(add,  Reg(sp), IntegerLit(4));
            }
            else if (pExprType == pCharType) {
                Emit1(call, NameLit(WRITE_CHAR));
                Emit2(add,  Reg(sp), IntegerLit(4));
            }
            else {      // string

                //--Push the string length onto the stack.
                Emit2(mov, Reg(ax),
                      IntegerLit(pExprType->array.elmtCount));

                Emit1(push, Reg(ax));
                Emit1(call, NameLit(WRITE_STRING));
                Emit2(add,  Reg(sp), IntegerLit(6));
            }

        } while (token == tcComma);

        GetToken();  // token after )
    }

    //--End the line if writeln.
    if (pRoutineId->defn.routine.which == rcWriteln) {
        Emit1(call, NameLit(WRITE_LINE));
    }

    return pDummyType;
}
Ejemplo n.º 24
0
word Modbus::Hreg(word offset) {
    return Reg(offset + 40001);
}
Ejemplo n.º 25
0
 bool Modbus::Coil(word offset, bool value) {
     return Reg(offset + 1, value?0xFF00:0x0000);
 }
Ejemplo n.º 26
0
 bool Modbus::Ists(word offset, bool value) {
     return Reg(offset + 10001, value?0xFF00:0x0000);
 }
Ejemplo n.º 27
0
 bool Modbus::Ireg(word offset, word value) {
     return Reg(offset + 30001, value);
 }
Ejemplo n.º 28
0
BOOL CjobpostApp::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControls()。否则,将无法创建窗口。
	InitCommonControls();

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
	gl_strMac = GetMac();
	CString strAppPath = "";
	GetAppPath(strAppPath);
	strAppPath += "set.ini";
	char szTemp[2048] = {0};
	CString strNode = "set";
	::GetPrivateProfileString(strNode,"username", "",(LPSTR)szTemp,2047, strAppPath);
	CString strUser = szTemp;	
	memset(szTemp,0,2048);
	::GetPrivateProfileString(strNode,"password", "",(LPSTR)szTemp,2047, strAppPath);
	CString strPwd = szTemp;
	int iRet = 0;
	if (strUser != "" && strPwd != "")
	{
		//进行验证
		iRet = Reg(strUser,strPwd,gl_strMac.c_str());
	}
	if (!iRet)
	{
		CRegDlg dlgReg;
		dlgReg.DoModal();
		iRet = dlgReg.m_iRegSuc;
		if (!iRet)
		{
			return FALSE;
		}
	}
	CjobpostDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: 在此放置处理何时用“确定”来关闭
		//对话框的代码
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: 在此放置处理何时用“取消”来关闭
		//对话框的代码
	}

	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	// 而不是启动应用程序的消息泵。
	return FALSE;
}
Ejemplo n.º 29
0
Archivo: Sound.cpp Proyecto: ace13/LD31
            r = eng->RegisterEnumValue("Status", "Stopped", sf::Sound::Stopped); assert(r >= 0);
            r = eng->RegisterEnumValue("Status", "Paused", sf::Sound::Paused); assert(r >= 0);
            r = eng->RegisterEnumValue("Status", "Playing", sf::Sound::Playing); assert(r >= 0);

            r = eng->SetDefaultNamespace(""); assert(r >= 0);

            r = eng->RegisterObjectType("Sound", sizeof(sf::Sound), asOBJ_VALUE | asGetTypeTraits<sf::Sound>()); assert(r >= 0);
            
            r = eng->RegisterObjectBehaviour("Sound", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(create_sound), asCALL_CDECL_OBJLAST); assert(r >= 0);
            r = eng->RegisterObjectBehaviour("Sound", asBEHAVE_CONSTRUCT, "void f(Sound::Buffer@)", asFUNCTION(create_sound_buffer), asCALL_CDECL_OBJLAST); assert(r >= 0);
            r = eng->RegisterObjectBehaviour("Sound", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(destruct_sound), asCALL_CDECL_OBJLAST); assert(r >= 0);
            
            r = eng->RegisterObjectMethod("Sound", "bool get_Loops()", asMETHOD(sf::Sound, getLoop), asCALL_THISCALL); assert(r >= 0);
            r = eng->RegisterObjectMethod("Sound", "void set_Loops(bool)", asMETHOD(sf::Sound, setLoop), asCALL_THISCALL); assert(r >= 0);
            r = eng->RegisterObjectMethod("Sound", "Sound::Status get_Status()", asMETHOD(sf::Sound, getStatus), asCALL_THISCALL); assert(r >= 0);

            r = eng->RegisterObjectMethod("Sound", "Sound::Buffer@ GetBuffer()", asFUNCTION(getBuffer), asCALL_CDECL_OBJLAST); assert(r >= 0);
            r = eng->RegisterObjectMethod("Sound", "void SetBuffer(Sound::Buffer@)", asFUNCTION(setBuffer), asCALL_CDECL_OBJLAST); assert(r >= 0);
            r = eng->RegisterObjectMethod("Sound", "void Play()", asMETHOD(sf::Sound, play), asCALL_THISCALL); assert(r >= 0);
            r = eng->RegisterObjectMethod("Sound", "void Pause()", asMETHOD(sf::Sound, pause), asCALL_THISCALL); assert(r >= 0);
            r = eng->RegisterObjectMethod("Sound", "void Stop()", asMETHOD(sf::Sound, stop), asCALL_THISCALL); assert(r >= 0);

            Script::SFML::registerSoundSource<sf::Sound>("Sound", eng);
        });

        return true;
    }
}

bool Script::SFML::Extensions::Sound = Reg();
Ejemplo n.º 30
0
vector<Reg> Reg::Concavities2(Reg *reg2) {
    vector<Reg> ret;
    Reg *reg1 = this;

    reg1->Begin();
    reg2->Begin();

    Reg r1 = Reg(reg1->convexhull);
    Reg r2 = Reg(reg2->convexhull);
    cerr << "\n\nConcavities2: START\n";

    do {
        double a1 = r1.Cur().angle();
        double a2 = r2.Cur().angle();
        int sx1 = 0, sy1 = 0, sx2 = 0, sy2 = 0,
                dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0;

        if (((a1 <= a2) && !r1.End()) || r2.End()) {
            cerr << "Concavities2/r1: Comparing " << r1.Cur().ToString()
                    << " (hull) / " << reg1->Cur().ToString() << " (region)\n";
            if (r1.Cur() == reg1->Cur()) {
                r1.Next();
                reg1->Next();
            } else {

                // We found a concavity in the source region

                cerr << "Concavities2: Found concavity\n";
                Reg ccv; // The concavity
                while (r1.Cur().x2 != reg1->Cur().x1 ||
                        r1.Cur().y2 != reg1->Cur().y1) {
                    sx1 = reg1->Cur().x1;
                    sy1 = reg1->Cur().y1;
                    sx2 = reg1->Cur().x2;
                    sy2 = reg1->Cur().y2;
                    dx1 = dx2 = r2.Cur().x1;
                    dy1 = dy2 = r2.Cur().y1;
                    reg1->Next();
                    //    msegs.AddMSeg(sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
                    Seg s(sx1, sy1, sx2, sy2);
                    ccv.AddSeg(s);
                    cerr << "Concavities2: Adding segment " << s.ToString()
                            << "\n";
                }
                ccv.hullPoint = new Pt(reg1->Cur().x1, reg1->Cur().y1);
                ccv.peerPoint = new Pt(r2.Cur().x1, r2.Cur().y1);
                cerr << "HP" << ccv.hullPoint->ToString()
                        << " PP " << ccv.peerPoint->ToString() << "\n\n";
                cerr << "Concavities2: Found concavity end\n\n";
                ccv.Close();
                ret.push_back(ccv);
                r1.Next();
            }
        } else if ((a1 >= a2) || r1.End()) {
            cerr << "Concavities2/r2: Comparing " << r2.Cur().ToString()
                    << " (hull) / " << reg2->Cur().ToString() << " (region)\n";
            if (r2.Cur() == reg2->Cur()) {
                reg2->Next();
                r2.Next();
            } else {
                while (r2.Cur().x2 != reg2->Cur().x1 ||
                        r2.Cur().y2 != reg2->Cur().y1) {
                    reg2->Next();
                }
                r2.Next();
            }
        }

        if (r1.End() && r2.End())
            break;

    } while (1);
    cerr << "\nConcavities2: END\n\n";

    return ret;
}