예제 #1
0
void Block(char *L)
{
    while (! strchr("elu", Look)) {
        dprint("Block: get Look = %c\n", Look);
        switch (Look) {
            case 'i':
                DoIf(L);
                break;
            case 'w':
                DoWhile();
                break;
            case 'p':
                DoLoop();
                break;
            case 'r':
                DoRepeat();
                break;
            case 'f':
                DoFor();
                break;
            case 'd':
                DoDo();
                break;
            case 'b':
                DoBreak(L);
            default:
                Assignment();
                break;
        }
        /* this is for convinent, otherwise newline character will
        cause an error */
        /*Newline();*/
        Fin();
    }
}
예제 #2
0
void Block(char *exit_label)
{
	while ( (Look != 'e') && (Look !='l') && (Look !='u') ) {
		Fin();
		printf("# BLOCK start\n");
		switch (Look) {
		case 'i':
			DoIf(exit_label);
			break;
		case 'w':
			DoWhile();
			break;
		case 'p':
			DoLoop();
			break;
		case 'r':
			DoRepeat();
			break;
		case 'f':
			DoFor();
			break;
		case 'd':
			DoDo();
			break;
		case 'b':
			DoBreak(exit_label);
			break;
		default:
			Assignment();
			break;
		}
		Fin();
		printf("# BLOCK end\n");
	}
}
예제 #3
0
파일: Water.cpp 프로젝트: illrune/illrune
void Water::Update(DWORD tick)
{
	water_dt += tick;

	if (water_dt > water_stay)
	{
		DoBreak();
	}
}
예제 #4
0
파일: svm32.c 프로젝트: drudru/cel
int singleStep (VM32Cpu * cpu)
{
    unsigned char inst;
    unsigned char * ptr;
    
    /* Get an instruction */
    ptr = (char *) cpu->pc;
    inst = *ptr;
    
    switch (inst) {
	/* Standard Op Codes */
	case 0x00: DoBreak(cpu);
	    break;
	case 0x01: DoNothing(cpu);
	    break;
	case 0x02: DoCall(cpu);
	    break;
	case 0x03: DoPushZero(cpu);
	    break;
	case 0x04: DoPushImmediateNative(cpu);
	    break;
	case 0x05: DoReturn(cpu);
	    break;
	case 0x06: DoPop(cpu);
	    break;
	case 0x07: DoSwap(cpu);
	    break;
	case 0x08: DoSetupFrame(cpu);
	    break;
	case 0x09: DoRestoreFrame(cpu);
	    break;
	case 0x0a: CallNative(cpu);
	    break;
	case 0x0b: DoPushSelf(cpu);
	    break;
	case 0x0c: DoCheckArgCount(cpu);
	    break;
	case 0x0d: DoBranch(cpu);
	    break;
	case 0x0e: DoBranchIfTrue(cpu);
	    break;
	case 0x0f: DoBranchIfFalse(cpu);
	    break;
	default:
	    DoInvalidInstruction(cpu);
	    break;
    }
    return 0;
}
예제 #5
0
// ***************************************************************************
// Function:    CommandBreak
// Description: Our '/break' command
// Usage:       /break
// ***************************************************************************
VOID CommandBreak(PSPAWNINFO pChar, PCHAR szLine)
{
   if (!gMacroBlock)
   {
        MacroError("Can only use /break during a macro.");
        return;
    }
   bRunNextCommand = TRUE;

   if (szLine[0])
   {
       FatalError("Failed to parse /break command. Unexpected parameters.");
      SyntaxError("Usage: /break");
        return;
   }

   DoBreak(pChar, gMacroBlock);
}
예제 #6
0
STDMETHODIMP CScdSolver::put_Time(eScdTimeFormat Fmt, VARIANT newVal)
  {
  dllSCD_COMENTRY(long)
    {
    VARIANT T;
    VariantInit(&T);
    switch (Fmt)
      {
      case eScdTimeFmt_Seconds: 
      case eScdTimeFmt_Secs1970: 
        {
        HRESULT hr=VariantChangeType(&T, &newVal, 0, VT_R8);
        if (SUCCEEDED(hr))
          gs_Exec.SetTheTime(T.dblVal, "ScdSolver", true);
        else
          Scd.ReturnH(hr);
        break;
        }
      case eScdTimeFmt_Date1900: 
        {
        HRESULT hr=VariantChangeType(&T, &newVal, 0, VT_DATE);
        if (SUCCEEDED(hr))
          {
          CTimeValue RqdTime;
          if (Date1900VarToSecs(T, &RqdTime))
            {
            gs_Exec.SetTheTime(RqdTime, "ScdSolver", true);
            }
          //else
          //  Scd.ReturnH(?hr);
          }
        else
          Scd.ReturnH(hr);
        break;
        }
      default: 
        DoBreak();    
        break;
      }

    VariantClear(&T);
    }
예제 #7
0
STDMETHODIMP CScdSolver::get_Time(eScdTimeFormat Fmt, VARIANT * pVal)
  {
  dllSCD_COMENTRYGET(long, pVal)
    {
    switch (Fmt)
      {
      case eScdTimeFmt_Seconds: 
      case eScdTimeFmt_Secs1970: 
        pVal->vt=VT_R8; 
        pVal->dblVal=gs_Exec.TheTime.Seconds; 
        break;
      case eScdTimeFmt_Date1900: 
        SecsToDate1900Var(gs_Exec.TheTime/*.Seconds*/, pVal);
        break;
      default:                  
        DoBreak();
        break;
      }
    }
  SCD_COMEXIT
  }
예제 #8
0
int DoTest(unsigned int tnum)
{
    unsigned int base;

    switch (tnum)
    {
    case 0:
        printf("  SEGV\n");
        *(int *)0x8 = 0;
        return 1;
    case 1:
        printf("  Unalign\n");
        if (prctl(PR_SET_UNALIGN, PR_UNALIGN_SIGBUS) != 0)
            printf("Can't set unaligned\n");
        DoUnalign();
        return 1;
    case 2:
        printf("  Illegal\n");
        DoIllegal();
        return 1;
    case 3:
        printf("  Div0\n");
        DoDiv0();
        return 1;
    case 4:
        printf("  Inexact\n");
        DoInexact();
        return 1;
    case 5:
        printf("  Break\n");
        DoBreak();
        return 1;
    }

    return 0;
}
예제 #9
0
void X_Comp::EvalProducts()
  {
  if (NJoins()>0)
    switch (SolveMode())
      {
      case PBMODE:
        DoBreak();
        break;
      case SSMODE:
        DoBreak();
        break;
      case DYNMODE:
        {
        int JoinId=0;
        double Press=Joins[JoinId].Pressure();

        int I[MaxIOList+1];
        FillIOIndexList(JoinId, I);

        flag dbg=0;//((Debug|dbgDerivs) & DBG_Derivs);

        if (SolveMode()==PBMODE)
          Press=GetPBInputPressure(JoinId);

        StkSpConduit SdLcl("SdLcl", chLINEID(), this);
        SpConduit &Sd = SdLcl();
        Sd.QZero();
        Sd.SetPress(Press);
        double  Qot=0.0;
        int NFeeds=0;
        for (int i, ic = 0; (i=I[ic])>=0; ic++)
          if (IO_In(i))
            {
            Sd.SelectModel(IOConduit(i), NFeeds==0);
            Sd.QAddF(*IOConduit(i), som_ALL, 1.0);
            NFeeds++;
            }
          else
            Qot += IOQmEst_Out(i);

        if (dbg)
          for (ic = 0; (i=I[ic])>=0; ic++)
            if (IO_In(i))
              {
              char t[128];
              sprintf(t, "%s.%s", FullObjTag(), IODesc_Self(i)->pName);
              dbgpln("i-Xfr %-12.12s : %14.6g, %14.6g | %14.6g",t,
                     IOConduit(i)->QMass(som_SL), IOConduit(i)->QMass(som_Vap), K_2_C(IOConduit(i)->Temp()));
              }

        double denom;
        double  P1 = IOP_Rmt (IOWithId_Self(ioid_In));
        double  P2 = IOP_Self(IOWithId_Self(ioid_In));

        // hss 9/3/98 - Use data base for specific heat ratio.
        P_SpecificHeatRatio = Max(1.1, Sd.CpCv());

        if( Sd.Temp() > 0.01 )
          Tin = Sd.Temp();

        // hss Calc Polytropic Efficiency
        /*double FlowMin  = pI->QVolume() * 60.0;
        double rpm      = Max(SpeedRatio, 10000.0);
        double EffTemp  = Efficiency.Zxy(FlowMin,rpm);
        if (EffTemp >= 0.6)
          P_PolytropicEff = EffTemp;
        else
          P_PolytropicEff = 0.6;*/

        denom = P_SpecificHeatRatio * P_PolytropicEff;
        if( fabs(denom) < 1.0e-30)
          denom = 1.0e-30;
        // hss Try a fix to prevent crash when P1 is negative
        if ((P1 > 0.0) && (P2 > P1))
          Tout = Tin*pow(P2/P1,(P_SpecificHeatRatio - 1.0)/denom);
        else
          Tout = Tin;      // end of kluge

        Sd.SetTemp(Tout);

        double Qin=Sd.QMass(som_ALL);
        // What Comes in must go out
        double Scl=Range(0.0, Qin/GTZ(Qot), 1000.0);
        for (ic = 0; (i=I[ic])>=0; ic++)
          if (IO_Out(i))
            IOConduit(i)->QSetM(Sd, som_ALL, IOQmEst_Out(i)*Scl, Press);//Joins[JoinId].Pressure());//PMax);
        }
        break;
      }
  };
예제 #10
0
double CSurface3DFrame::DoOp(double X, double Y, LPCSurface3DFrame &pFrame)
  {
  if (m_iLevel>=8)
    DoBreak();

  if (m_eDivision==C3D_DivNone)
    m_eDivision=FitPanel();

  switch (m_eDivision)
    {
    case C3D_DivNxN:
      {
      if (m_nDivsX*m_nDivsY<2)
        DoBreak();
      long Ix=X2MapI(X);
      long Iy=Y2MapI(Y);
      long i=Index(Ix,Iy);
      CSurface3DFrame *&pE=m_Frames[i];
      if (pE==NULL)
        {
        pE = new CSurface3DFrame(m_p3D, m_iLevel+1,
                                 m_dXMin+Ix*m_dDivWidthX, m_dXMin+(Ix+1)*m_dDivWidthX, m_nDivsX,
                                 m_dYMin+Iy*m_dDivWidthY, m_dYMin+(Iy+1)*m_dDivWidthY, m_nDivsY);
        m_nGlblElementCnt++;
        m_p3D->m_nFrameCnt++;
        }
      
      ASSERT(pE->m_bInitDone);
      return pE->DoOp(X,Y, pFrame);
      }
    case C3D_Div2V:
      {
      if (X<=m_Frames[0]->m_dXMax)
        return m_Frames[0]->DoOp(X,Y, pFrame);
      else
        return m_Frames[1]->DoOp(X,Y, pFrame);
      }
    case C3D_Div3V:
      {
      if (X<=m_Frames[0]->m_dXMax)
        return m_Frames[0]->DoOp(X,Y, pFrame);
      else if (X>=m_Frames[2]->m_dXMin)
        return m_Frames[2]->DoOp(X,Y, pFrame);
      else
        return m_Frames[1]->DoOp(X,Y, pFrame);
      }
    case C3D_Div2H:
      {
      if (Y<=m_Frames[0]->m_dYMax)
        return m_Frames[0]->DoOp(X,Y, pFrame);
      else
        return m_Frames[1]->DoOp(X,Y, pFrame);
      }
    case C3D_Div3H:
      {
      if (Y<=m_Frames[0]->m_dYMax)
        return m_Frames[0]->DoOp(X,Y, pFrame);
      else if (Y>=m_Frames[2]->m_dYMin)
        return m_Frames[2]->DoOp(X,Y, pFrame);
      else
        return m_Frames[1]->DoOp(X,Y, pFrame);
      }
    case C3D_Div2x2:
      {
      if (X<=m_Frames[0]->m_dXMax)
        {
        if (Y<=m_Frames[0]->m_dYMax)
          return m_Frames[0]->DoOp(X,Y, pFrame);
        else
          return m_Frames[2]->DoOp(X,Y, pFrame);
        }
      else 
        {
        if (Y<=m_Frames[1]->m_dYMax)
          return m_Frames[1]->DoOp(X,Y, pFrame);
        else
          return m_Frames[3]->DoOp(X,Y, pFrame);
        }
      }
    case C3D_Div1x1:
      {
      if (m_pPanel==NULL)
        {
        m_pPanel=BuildPanel();
        ASSERT(pPanel->CheckFit());
        #if dbgSurfaces
        if (dbg3DTrack())
          dbgpln("Replace Panel %-20s %-5s %08x [%2i] %14.8f %14.8f",
                 m_p3D->Name(), s_sDivText[m_eDivision], m_pPanel, m_iLevel, 0.5*(m_dXMin+m_dXMax), 0.5*(m_dYMin+m_dYMax));
        #endif
        }

      double Val=ValueXY(X,Y);
      //dbgpln("== %12.3f %12.3f = %12.3f %s", X,Y,Val, (LPCTSTR)m_3D.m_sName);
      pFrame=this;
      
      m_p3D->MRU_Move2Head(m_pPanel);
      if (m_p3D->m_nPanelCnt>=m_p3D->m_nPanelCntMax)
        {
        CSurface3DPanel *pLast=m_p3D->MRU_RemoveTail();
        if (pLast)
          {
          pLast->m_pFrame->m_pPanel=NULL;
          #if dbgSurfaces
          if (dbg3DTrack())
            dbgpln("Remove  Panel %-20s %-5s %08x [%2i] %14.8f %14.8f",
                   m_p3D->Name(), s_sDivText[m_eDivision], pLast, m_iLevel,
                   0.5*(pLast->m_pFrame->m_dXMin+pLast->m_pFrame->m_dXMax), 
                   0.5*(pLast->m_pFrame->m_dYMin+pLast->m_pFrame->m_dYMax));
          #endif
          delete pLast;
          }
        }
      #if dbgSurfaces
      if (dbg3DState())
        if (/*m_p3D->m_nFrameCnt%ALLOCDBGCNT==0 ||*/ (GetTickCount()-m_p3D->m_dwLastTicks>60000))
          {
          m_p3D->m_dwLastTicks=GetTickCount();
          dbgpln("Surface:%-20s has Frames=%7i[%5i] Panels=%7i[%5i] Calls=%10i Builds=%10i", 
                  m_p3D->Name(), 
                  m_p3D->m_nFrameCnt,m_p3D->m_nFrameCnt*sizeof(CSurface3DFrame)/1024, 
                  m_p3D->m_nPanelCnt,m_p3D->m_nPanelCnt*sizeof(CSurface3DPanel)/1024, 
                  m_p3D->m_nCalls, m_p3D->m_nBuildCnt);
          }
      #endif
      return Val;
      }
    default:
      DoBreak();
      return dNAN;
    }
  }
예제 #11
0
byte CSurface3DFrame::FitPanel()//Rectangle()
  {
  byte eTryDiv=C3D_DivNxN;
  if (m_p3D->m_pBoundary)
    {
    CSurface3DBoundary &B=*m_p3D->m_pBoundary;
    if (m_dXMin>=B.m_XMin && m_dXMax<=B.m_XMax &&
        m_dYMin>=B.m_YMin && m_dYMax<=B.m_YMax)
      {
      double BYxmn=B.m_FnYx(m_dXMin);
      double BYxmx=B.m_FnYx(m_dXMax);
      double BXymn=B.m_FnXy(m_dYMin);
      double BXymx=B.m_FnXy(m_dYMax);
      byte LCross=(m_dYMin<BYxmn && BYxmn<m_dYMax) ? 1 : 0;
      byte RCross=(m_dYMin<BYxmx && BYxmx<m_dYMax) ? 2 : 0;
      byte BCross=(m_dXMin<BXymn && BXymn<m_dXMax) ? 4 : 0;
      byte TCross=(m_dXMin<BXymx && BXymx<m_dXMax) ? 8 : 0;
      eTryDiv=PanelLayout[LCross+RCross+TCross+BCross].Divs;

      double Val1=dNAN;
      double Val2=dNAN;
      switch (eTryDiv)
        {
        case C3D_Div2V:
          {
          Val1=BCross ? BXymn : BXymx;
          CSurface3DFrame Frames[2];
          Frames[0].Initialise(m_p3D, m_iLevel+1, m_dXMin, Val1,    1, m_dYMin, m_dYMax, 1);
          Frames[1].Initialise(m_p3D, m_iLevel+1, Val1,    m_dXMax, 1, m_dYMin, m_dYMax, 1);
          if (!FitAndTestPanels(2,1, Frames))
            eTryDiv=C3D_DivNxN;
          }
          break;
        case C3D_Div3V:
          {
          Val1=Min(BXymn, BXymx);
          Val2=Max(BXymn, BXymx);
          CSurface3DFrame Frames[3];
          Frames[0].Initialise(m_p3D, m_iLevel+1, m_dXMin, Val1,    1, m_dYMin, m_dYMax, 1);
          Frames[1].Initialise(m_p3D, m_iLevel+1, Val1,    Val2,    1, m_dYMin, m_dYMax, 1);
          Frames[2].Initialise(m_p3D, m_iLevel+1, Val2,    m_dXMax, 1, m_dYMin, m_dYMax, 1);
          if (!FitAndTestPanels(3,1, Frames))
            eTryDiv=C3D_DivNxN;
          }
          break;
        case C3D_Div2H:
          {
          Val1=LCross ? BYxmn : BYxmx;
          CSurface3DFrame Frames[2];
          Frames[0].Initialise(m_p3D, m_iLevel+1, m_dXMin, m_dXMax, 1, m_dYMin,   Val1, 1);
          Frames[1].Initialise(m_p3D, m_iLevel+1, m_dXMin, m_dXMax, 1, Val1,   m_dYMax, 1);
          if (!FitAndTestPanels(1,2, Frames))
            eTryDiv=C3D_DivNxN;
          }
          break;
        case C3D_Div3H:
          {
          Val1=Min(BYxmn, BYxmx);
          Val2=Max(BYxmn, BYxmx);
          CSurface3DFrame Frames[3];
          Frames[0].Initialise(m_p3D, m_iLevel+1, m_dXMin, m_dXMax, 1, m_dYMin,   Val1, 1);
          Frames[1].Initialise(m_p3D, m_iLevel+1, m_dXMin, m_dXMax, 1, Val1,      Val2, 1);
          Frames[2].Initialise(m_p3D, m_iLevel+1, m_dXMin, m_dXMax, 1, Val2,   m_dYMax, 1);
          if (!FitAndTestPanels(1,3, Frames))
            eTryDiv=C3D_DivNxN;
          }
          break;
        case C3D_Div2x2:
          {
          Val1=BCross ? BXymn : BXymx;
          Val2=LCross ? BYxmn : BYxmx;
          CSurface3DFrame Frames[4];
          Frames[0].Initialise(m_p3D, m_iLevel+1, m_dXMin,    Val1, 1, m_dYMin,    Val2, 1);
          Frames[1].Initialise(m_p3D, m_iLevel+1, Val1,    m_dXMax, 1, m_dYMin,    Val2, 1);
          Frames[2].Initialise(m_p3D, m_iLevel+1, m_dXMin,    Val1, 1, Val2,    m_dYMax, 1);
          Frames[3].Initialise(m_p3D, m_iLevel+1, Val1,    m_dXMax, 1, Val2,    m_dYMax, 1);
          if (!FitAndTestPanels(2,2, Frames))
            eTryDiv=C3D_DivNxN;
          }
          break;
        case C3D_DivNxN:
          if (m_nDivsX*m_nDivsY<2)
            DoBreak();
          break;
        case C3D_Bad:
          DoBreak();
        }
      }
    else
      eTryDiv=C3D_Div1x1;
    }
  else
    eTryDiv=C3D_Div1x1;
  
  if (eTryDiv==C3D_Div1x1)
    {
    CSurface3DPanel * pPanel=BuildPanel();
    
    if (m_iLevel>=8)
      DoBreak();

    if (pPanel->CheckFit(this))
      {
      m_eDivision=eTryDiv;
      m_pPanel=pPanel;
      #if dbgSurfaces
      if (dbg3DTrack())
        dbgpln("Add new Panel %-20s %-5s %08x [%2i] %14.8f %14.8f",
               m_p3D->Name(), s_sDivText[m_eDivision], m_pPanel, m_iLevel, 0.5*(m_dXMin+m_dXMax), 0.5*(m_dYMin+m_dYMax));
      #endif
      }
    else
      {
      delete pPanel;
      eTryDiv= C3D_DivNxN;
      #if dbgSurfaces
      if (dbg3DTrack())
        dbgpln("Drill Down    %-20s %-5s %8s [%2i] %14.8f %14.8f",
               m_p3D->Name(), s_sDivText[eTryDiv], "", m_iLevel, 0.5*(m_dXMin+m_dXMax), 0.5*(m_dYMin+m_dYMax));
      #endif
      }
    }
  
  if (eTryDiv==C3D_DivNxN)
    {
    if (m_nDivsX*m_nDivsY<2)
      DoBreak();
    ASSERT(m_Frames==NULL);
    long nElements=m_nDivsX*m_nDivsY;
    m_Frames=new LPCSurface3DFrame[nElements];
    for (int i=0; i<nElements; i++)
      m_Frames[i]= NULL;
    }
  m_eDivision=eTryDiv;
  return eTryDiv;
  }