Exemplo n.º 1
0
INT16 CFsttools_OnRcByUsedPath(CDlpObject* __this)
/* DO NOT CALL THIS FUNCTION FROM C++ SCOPE.     */
/* IT MAY INTERFERE WITH THE INTERPRETER SESSION */
{
    INT16 __nErr    = O_K;
    INT32  __nErrCnt = 0;
    data* idTransRC;
    FLOAT64 nPathWeight;
    INT64 nUnit;
    BOOL bReset;
    data* idUnitTransCount;
    fst* itFst;
    GET_THIS_VIRTUAL_RV(CFsttools,NOT_EXEC);
    MIC_CHECK;
    __nErrCnt = CDlpObject_GetErrorCount();
    itFst = MIC_GET_I_EX(itFst,fst,1,1);
    idUnitTransCount = MIC_GET_I_EX(idUnitTransCount,data,2,2);
    bReset = MIC_GET_B(3,0);
    nUnit = (INT64)MIC_GET_N(4,0);
    nPathWeight = MIC_GET_N(5,1);
    idTransRC = MIC_GET_I_EX(idTransRC,data,6,3);
    if (CDlpObject_GetErrorCount()>__nErrCnt) return NOT_EXEC;
    __nErr = CFsttools_RcByUsedPath(_this, idTransRC, nPathWeight, nUnit, bReset, idUnitTransCount, itFst);
    return __nErr;
}
Exemplo n.º 2
0
/**
 * Polymorphic set operations.
 * 
 * @param lpsOpname
 *          <p>Operator name</p>
 *          <table>
 *            <tr><th><code>lpsOpname</code></th><th>Boolean</th><th>Numeric</th><th>String</th><th>Instance</th></tr>
 *            <tr><td><code>=  </code></td><td>x</td><td>x</td><td>x</td><td>x</td></tr>
 *            <tr><td><code>+= </code></td><td>x</td><td>x</td><td>x</td><td>-</td></tr>
 *            <tr><td><code>-= </code></td><td>-</td><td>x</td><td>-</td><td>-</td></tr>
 *            <tr><td><code>*= </code></td><td>x</td><td>x</td><td>-</td><td>-</td></tr>
 *            <tr><td><code>/= </code></td><td>-</td><td>x</td><td>-</td><td>-</td></tr>
 *            <tr><td><code>++=</code></td><td>-</td><td>x</td><td>-</td><td>-</td></tr>
 *            <tr><td><code>--=</code></td><td>-</td><td>x</td><td>-</td><td>-</td></tr>
 *          </table>
 *          <p>For type conversion rules see
 *            <code><a href="function.html"><code�class="link">CFunction</code></a><code>::StackLogic</code>,
 *            <code><a href="function.html"><code�class="link">CFunction</code></a><code>::StackNumber</code>,
 *            <code><a href="function.html"><code�class="link">CFunction</code></a><code>::StackString</code> and
 *            <code><a href="function.html"><code�class="link">CFunction</code></a><code>::StackInstance</code>.
 *          </p>
 * @return <code>O_K</code> if successfull, a (negative) error code otherwise
 */
INT16 CGEN_PROTECTED CVar_SetOp(CVar *_this,const char* lpsOpname)
{
  StkItm si;
  if (dlp_strcmp(lpsOpname,"++=")!=0 && dlp_strcmp(lpsOpname,"--=")!=0)
  {
    if (!CDlpObject_MicGet(BASEINST(_this))->GetX)
      return
        IERROR(_this,VAR_NOTSUPPORTED,"Polymorphic signatures"," by caller",0);
    if (!MIC_GET_X(1,&si)) return NOT_EXEC;
  }
    
  if (dlp_strcmp(lpsOpname,"=")==0)
    switch (si.nType)
    {
      case T_BOOL    : return CVar_Bset(_this,si.val.b);
      case T_COMPLEX : return CVar_Vset(_this,si.val.n);
      case T_STRING  : return CVar_Sset(_this,si.val.s);
      case T_INSTANCE: return CVar_Iset(_this,si.val.i);
      default:
        DLPASSERT(FMSG("Unknown variable type"));
        return NOT_EXEC;
    }
  else if (dlp_strcmp(lpsOpname,"+=")==0)
  {
    if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_PLUS(_this->m_nNVal,si.val.n));
    if (_this->m_nType==T_STRING)
    {
      char* lpsSi = NULL;
      MIC_PUT_X(&si);
      lpsSi = MIC_GET_S(1,0);
      _this->m_lpsSVal = (char*)dlp_realloc(_this->m_lpsSVal,
        dlp_strlen(_this->m_lpsSVal)+dlp_strlen(lpsSi)+1,sizeof(char));
      if (!_this->m_lpsSVal) return IERROR(_this,ERR_NOMEM,0,0,0);
      dlp_strcat(_this->m_lpsSVal,lpsSi);
      return O_K;
    }
    if (_this->m_nType==T_BOOL)
    {
      MIC_PUT_X(&si);
      _this->m_bBVal|=MIC_GET_B(1,0);
      return O_K;
    }
    return
      IERROR(_this,VAR_NOTSUPPORTED,"Operator +="," for this variable type",0);
  }
  else if (dlp_strcmp(lpsOpname,"*=")==0)
  {
    if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_MULT(_this->m_nNVal,si.val.n));
    if (_this->m_nType==T_BOOL)
    {
      MIC_PUT_X(&si);
      _this->m_bBVal&=MIC_GET_B(1,0);
      return O_K;
    }
    return
      IERROR(_this,VAR_NOTSUPPORTED,"Operator *="," for this variable type",0);
  }
  else if (dlp_strcmp(lpsOpname,"-=")==0)
  {
    if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_MINUS(_this->m_nNVal,si.val.n));
    return
      IERROR(_this,VAR_NOTSUPPORTED,"Operator -="," for this variable type",0);
  }
  else if (dlp_strcmp(lpsOpname,"/=")==0)
  {
    if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_MULT(_this->m_nNVal,CMPLX_INVT(si.val.n)));
    return
      IERROR(_this,VAR_NOTSUPPORTED,"Operator /="," for this variable type",0);
  }
  else if (dlp_strcmp(lpsOpname,"++=")==0)
  {
    if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_INC(_this->m_nNVal));
    return
      IERROR(_this,VAR_NOTSUPPORTED,"Operator ++="," for this variable type",0);
  }
  else if (dlp_strcmp(lpsOpname,"--=")==0)
  {
    if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_DEC(_this->m_nNVal));
    return 
      IERROR(_this,VAR_NOTSUPPORTED,"Operator --="," for this variable type",0);
  }
  
  return NOT_EXEC;
}