예제 #1
0
bool Scope::IsEmpty() const
{
    if (GetFunc()->bodyScope == this || (GetFunc()->IsGlobalFunction() && this->IsGlobalEvalBlockScope()))
    {
        return Count() == 0 && !GetFunc()->isThisLexicallyCaptured;
    }
    else
    {
        return Count() == 0;
    }
}
예제 #2
0
파일: Math.cpp 프로젝트: Tismoney/warehouse
CNode*  Math::GetPas()
{
    CNode* tmp;
    if (*S == '(')
    {
        S++;
        tmp = GetExp();
        try
        {
            if (*S != ')')
                throw string ("Expected ')'. Please correct expression\n");
        }
        catch(string ex)
        {
            cout << ex << endl;
            exit(1);
        }
        S++;
    }
    else if (*S == 'x') //пока считаем, что переменная только x( потом добавить все переменные)
    {
        S++;
        tmp = new CNode('x');
    }
    else if (((*S >= 'a') && (*S <= 'z')))
    {
        tmp = GetFunc();
    }
    else
    {
        tmp = GetNum();
    }
    return tmp;
}
예제 #3
0
C4Value C4PropList::Call(C4String * k, C4AulParSet *Pars, bool fPassErrors)
{
	if (!Status) return C4Value();
	C4AulFunc *pFn = GetFunc(k);
	if (!pFn) return C4Value();
	return pFn->Exec(this, Pars, fPassErrors);
}
예제 #4
0
 void VisitExpr( const  SymbolicExpr& v) 
         { switch (v.GetOpType()) { 
            case SYMOP_MULTIPLY:
            case SYMOP_PLUS:
                  Default0(); break;
            case SYMOP_MIN:
            case SYMOP_MAX:
                  Default1(v1,v2);
                  if (result == REL_UNKNOWN)
                     result = (index == 1)? SelectCompare(v1,v,GetFunc())(v2)
                                 : Reverse(SelectCompare(v2,v,GetFunc())(v1)); 
                     break;
            default: 
                  assert(false);
           }  
         }
예제 #5
0
    virtual void Eval(EvaluationContext& EC)
    {
        //long long ArgCount = boost::get<long long>(EC.EvalStack.back());
        long long ArgCount = EC.EvalStack.back().Visit(Utilities::Get<long long>("Fatal: missing number of arguments for function call"));
        EC.EvalStack.pop_back();

        auto FuncPos = EC.EvalStack.begin() + (EC.EvalStack.size() - 1 - ArgCount); //We jump directly to the identifer of the function
        ResolvedToken FuncToken(Utilities::Resolve(EC,*FuncPos)); //needs to stay as a LHS because apply_visitor the next line dos not like RHS
        boost::shared_ptr<IFunction> Func(boost::apply_visitor(GetFunc(EC),FuncToken));
        if( Func->ArgCount() != /*ArgCount::Variable*/-1 )
        {
            if( ArgCount > Func->ArgCount() )
                throw std::logic_error("Too many arguments for function '" + Func->Representation() + "'; should be " + boost::lexical_cast<std::string>(Func->ArgCount()) + " argument(s)");
            else if( ArgCount < Func->ArgCount() )
                throw std::logic_error("Too few arguments for function '" + Func->Representation() + "'; should be " + boost::lexical_cast<std::string>(Func->ArgCount()) + " argument(s)");
        }
        bool EraseAfterCall = true;
        if( ArgCount <= Func->ReturnCount() )
        {
            EC.EvalStack.erase(FuncPos);
            EraseAfterCall = false;
        }
        Func->SuppliedArguments(ArgCount);
        Func->Eval(EC);
        if(EraseAfterCall)
        {
            //Erase the function identifier from the stack
            //it's done after the function call because in general there are less returned arguments than paramters, resulting in a better performance
            //but it requires, that no elements are deleted in the middle of the stack in the function call
            EC.EvalStack.erase(FuncPos);
        }
    }
예제 #6
0
 void Default0()
  {
     Matrix<CompareRel> rel(e1.NumOfOpds(),1,0);
     ExprTermCompare(e1,v2,rel,GetFunc()); 
     MatchCompare(rel,1);
      
  }
예제 #7
0
FUNCID PEXPORT Kpp_CopyFunc(FUNCID idOldFunc, ITEMID idName)
{
    FUNCID      idFunc;
    LPFUNC      lpOldFunc;
    WORD        wCode=0, wType=0;
    
    if (!KppIsGoodAtom (idName)) return NULLID;

    if (KppCheckItem(FUNC, idOldFunc) == FALSE)
        return NULLID;

    if (KppGetKappaFunction (idName, &wType, &wCode))
    {
        if (GetFunc(idName) == NULLID)
            return KppRegisterKappaMessage (hResThisDll, 
                IDE_SYSTEMDEFINED, lpIDs->idMakeFunction, idName, NULLID);
    }
            
    CHECK_MAX_LIMITED_VER(FUNC, idName);

    lpOldFunc = (LPFUNC) KppGetItem(FUNC, idOldFunc);
    idFunc = __CopyFunc(lpOldFunc, idName);
    KppReleaseItem(FUNC, idOldFunc);
    return idFunc;
}
예제 #8
0
void CParmStatDlg::EnableFunc() 
{
   for (int i=0; i<FuncNum; i++) {
      CFunc func = GetFunc(i, -1);
      BOOL flag = DEMO_APP->GetIppList()->Find(func) ? TRUE : FALSE;
      m_FuncButton[i].EnableWindow(flag);
   }
}
예제 #9
0
C4Value C4PropList::Call(const char * s, C4AulParSet *Pars, bool fPassErrors)
{
	if (!Status) return C4Value();
	assert(s && s[0]);
	C4AulFunc *pFn = GetFunc(s);
	if (!pFn) return C4Value();
	return pFn->Exec(this, Pars, fPassErrors);
}
예제 #10
0
double Exhume::TwoSpace::SubParameterWeight(){
  //bit of a misnomer SubParameterWeight tells the Event class the difference between the subprocess Maximum and this specific chance
  Amp2LIPS();//not needed?
  double _SubWgt;
  _SubWgt = GetFunc(CosTheta);
  
  // std::cout<<_SubWgt/MaximumSubProcessValue<<std::endl;
  return(Fudge*_SubWgt/(MaximumSubProcessValue));
}
예제 #11
0
DWORD CPEExport::GetFuncValue(int nIndex)
{
	DWORD dwFuncRva=GetFunc(nIndex);
	if (dwFuncRva)
	{
		return *(DWORD*)RvaToPtr(dwFuncRva);
	}
	return NULL;
}
예제 #12
0
short PEXPORT KppEvalFuncName(ATOMID idFuncName, LISTID idArgList,
                              BOOL bRemoveUnusedArgs)
{
    WORD wCode = 0, wType = 0;
    FUNCID idFunc = GetFunc(idFuncName);
    CKAPPROC pFunc;

    if (!idFunc)
    {
        pFunc = KppGetKappaFunction(idFuncName, &wType, &wCode);
    
        if (pFunc)
        {
#ifdef RUNTIME
            if (KppbKappaPresent())
                KppEvalCFuncCB(pFunc, idFuncName, idArgList,
                               (LPSTR) lpKALView, wType);
            else
                NoKappaEvalCFunc(pFunc, idFuncName, idArgList,
                                 (LPSTR) lpKALView, wType);
#else
            KppEvalCFuncCB(pFunc, idFuncName, idArgList,
                           (LPSTR) lpKALView, wType);
#endif            
            
            return TRUE;
        }
        else
            return KppRegisterKappaMessage(hResThisDll, 
                                           IDE_ERRORINFUNC, idFuncName,
                                           NULLID, NULLID);
    }
        
    {
        LPFUNC lpFunc = (LPFUNC) KppGetItem(FUNC, idFunc);
        WORD i = FALSE;
        
        if (lpFunc && bRemoveUnusedArgs)
        {
            WORD wVars = NUMVARS(lpFunc);
            WORD wArgs = KppListLen(idArgList);

            while (wArgs > wVars)
            {
                KppDeleteElem(idArgList, wArgs, kPOSITIONMODE);
                wArgs--;
            }
        }
        UnwindProtect (cleanup);
        i = __EvalFunc(lpFunc, idArgList);
      cleanup:
        KppReleaseItem(FUNC, idFunc);
        EndProtect();
        return i;
    }
}
예제 #13
0
C4AulFunc * C4PropList::GetFunc(const char * s) const
{
	assert(s);
	if (s[0] == '~') ++s;
	C4String * k = Strings.FindString(s);
	// this string is entirely unused
	if (!k)
		return 0;
	return GetFunc(k);
}
예제 #14
0
void C4Effect::CallDamage(int32_t & damage, int damagetype, int plr)
{
	if (!GetCallbackScript())
	{
		C4AulFunc *pFn = GetFunc(P_Damage);
		if (pFn)
			damage = pFn->Exec(this, &C4AulParSet(damage, damagetype, plr)).getInt();
	}
	else if (pFnDamage)
		damage = pFnDamage->Exec(GetCallbackScript(), &C4AulParSet(Obj(Target), this, damage, damagetype, plr)).getInt();
}
예제 #15
0
void
_XNoticePutBitmap (Display	*dpy,
		   Drawable	draw,
		   XImage	*image)
{
    NoticePutBitmapFunc	func;

    GetFunc (NoticePutBitmapFunc, "XcursorNoticePutBitmap", func);
    if (func)
	(*func) (dpy, draw, image);
}
예제 #16
0
	static bool Get(T* val, obs_data_t* config, const char* index)
	{
		if (obs_data_has_user_value(config, index))
			*val = GetFunc(config, index);
		else
			if (obs_data_has_default_value(config, index))
				*val = GetDefaultFunc(config, index);
			else
				return false;
		return true;
	}
예제 #17
0
	static bool Get(T* val, obs_properties_t* props, const char* index)
	{
		obs_property_t* prop = obs_properties_get(props, index);
		if (prop == 0)
			return false;
		else
		{
			*val = GetFunc(props, index);
			return true;
		}
	}
예제 #18
0
파일: HLE.cpp 프로젝트: SanJaroICS/ppsspp
const char *GetFuncName(const char *moduleName, u32 nib)
{
	const HLEFunction *func = GetFunc(moduleName,nib);
	if (func)
		return func->name;
	else
	{
		static char temp[256];
		sprintf(temp,"[UNK:%08x]",nib);
		return temp;
	}
}
예제 #19
0
파일: e16_trip.c 프로젝트: Limsik/e17
__EXPORT__          Status
_XReply(Display * dpy, void *rep, int extra, Bool discard)
{
   static RF          *func = NULL;

   char                s[1024], *p, *name;
   void               *bt[128];
   int                 i, n, l;
   char              **sym;

   if (!func)
      func = (RF *) GetFunc("_XReply");

   l = 0;
   l += snprintf(s + l, sizeof(s) - l, "RT: ");
   n = backtrace(bt, 128);
   if (n <= 0)
      goto done;

   sym = backtrace_symbols(bt, n);
   if (!sym)
      goto done;

   for (i = 1; i < n; i++)
     {
#if 1
	name = strchr(sym[i], '(');
	if (name)
	  {
	     name++;
	     p = strchr(name, '+');
	     if (!p)
		p = strchr(name, ')');
	     if (p)
		*p = '\0';
	  }
	if (!name || *name == '\0')
	   name = (char *)"?";
	l += snprintf(s + l, sizeof(s) - l, name);
#else
	l += snprintf(s + l, sizeof(s) - l, sym[i]);
#endif

	if (i < n - 1)
	   l += snprintf(s + l, sizeof(s) - l, " < ");
     }
   free(sym);

 done:
   printf("%s\n", s);

   return func(dpy, rep, extra, discard);
}
예제 #20
0
const char *GetFuncName(const char *moduleName, u32 nib)
{
	_dbg_assert_msg_(HLE, moduleName != NULL, "Invalid module name.");

	const HLEFunction *func = GetFunc(moduleName,nib);
	if (func)
		return func->name;

	static char temp[256];
	sprintf(temp,"[UNK: 0x%08x]", nib);
	return temp;
}
예제 #21
0
void
_XNoticeCreateBitmap (Display	    *dpy,
		      Pixmap	    pid,
		      unsigned int  width,
		      unsigned int  height)
{
    NoticeCreateBitmapFunc  func;

    GetFunc (NoticeCreateBitmapFunc, "XcursorNoticeCreateBitmap", func);
    if (func)
	(*func) (dpy, pid, width, height);
}
예제 #22
0
C4Effect * C4Effect::Init(C4PropList *pForObj, int32_t iPrio, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
{
	Target = pForObj;
	// ask all effects with higher priority first - except for prio 1 effects, which are considered out of the priority call chain (as per doc)
	bool fRemoveUpper = (iPrio != 1);
	// note that apart from denying the creation of this effect, higher priority effects may also remove themselves
	// or do other things with the effect list
	// (which does not quite make sense, because the effect might be denied by another effect)
	// so the priority is assigned after this call, marking this effect dead before it's definitely valid
	if (fRemoveUpper && pNext)
	{
		C4Effect * pEffect2 = pNext->Check(GetName(), iPrio, iInterval, rVal1, rVal2, rVal3, rVal4);
		if (pEffect2)
		{
			// effect denied (iResult = -1), added to an effect (iResult = Number of that effect)
			// or added to an effect that destroyed itself (iResult = -2)
			if (pEffect2 != (C4Effect*)C4Fx_Effect_Deny && pEffect2 != (C4Effect*)C4Fx_Effect_Annul) return pEffect2;
			// effect is still marked dead
			return 0;
		}
	}
	// init effect
	// higher-priority effects must be deactivated temporarily, and then reactivated regarding the new effect
	// higher-level effects should not be inserted during the process of removing or adding a lower-level effect
	// because that would cause a wrong initialization order
	// (hardly ever causing trouble, however...)
	C4Effect *pLastRemovedEffect=NULL;
	C4AulFunc * pFn;
	if (!GetCallbackScript())
	{
		Call(P_Construction, &C4AulParSet(rVal1, rVal2, rVal3, rVal4)).getInt();
		if (pForObj && !pForObj->Status) return 0;
		pFn = GetFunc(P_Start);
	}
	else
		pFn = pFnStart;
	if (fRemoveUpper && pNext && pFn)
		TempRemoveUpperEffects(false, &pLastRemovedEffect);
	// bad things may happen
	if (pForObj && !pForObj->Status) return 0; // this will be invalid!
	iPriority = iPrio; // validate effect now
	if (CallStart(0, rVal1, rVal2, rVal3, rVal4) == C4Fx_Start_Deny)
		// the effect denied to start: assume it hasn't, and mark it dead
		SetDead();
	if (fRemoveUpper && pNext && pFn)
		TempReaddUpperEffects(pLastRemovedEffect);
	if (pForObj && !pForObj->Status) return 0; // this will be invalid!
	// Update OnFire cache
	if (!IsDead() && pForObj && WildcardMatch(C4Fx_AnyFire, GetName()))
		pForObj->SetOnFire(true);
	return this;
}
예제 #23
0
 virtual void VisitExpr( const  SymbolicExpr& e2) 
          {  SymOpType t1 = e1.GetOpType(), t2 = e2.GetOpType(); 
             unsigned c1 = e1.NumOfOpds(), c2 = e2.NumOfOpds();
             if (t2 == SYMOP_MULTIPLY || t2 == SYMOP_PLUS )
                    Default0(); 
             else if (t1 == t2) {
                 Matrix<CompareRel> rel(c1,c2,0);
                 ExprTermCompare(e1,e2,rel,GetFunc()); 
                 MatchCompare(rel,c2);
             }
             else if (t1 == SYMOP_MIN && t2 == SYMOP_MAX) {
                size_t le = 0, lt = 0, ge = 0, gt = 0;
                SymbolicExpr::OpdIterator p2 = e2.GetOpdIterator();
                for ( ; !p2.ReachEnd(); ++p2) {
                    CompareRel r = CompareValHelp(v1, e2.Term2Val(p2.Current()),GetFunc());
                    if (CountLE(r)) 
                        ++le; 
                    if (CountGE(r)) 
                        ++ge;
                    if (CountLT(r))
                        ++lt;
                    if (CountGT(r))
                        ++gt;
                } 
                if (gt == e2.NumOfOpds()) 
                     result = REL_GT;
                else if (lt > 0)
                      result = REL_LT;
                else if (ge == e2.NumOfOpds()) 
                     result = REL_GE;
                else if (le > 0)
                      result = REL_LE;
             } 
             else if (t1 == SYMOP_MAX && t2 == SYMOP_MIN) 
                 result = Reverse( SelectCompare(v2, e2, GetFunc())(v1) );
             else
                 assert(false);
          }
예제 #24
0
int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   glutInitWindowSize (500, 500);
   glutInitWindowPosition (100, 100);
   glutCreateWindow ("hello");
   GetFunc();
   init ();
   glutDisplayFunc(display);
   glutReshapeFunc(reshape);
   glutMainLoop();
   return 0;
}
예제 #25
0
Cursor
_XTryShapeBitmapCursor (Display		*dpy,
			Pixmap		source,
			Pixmap		mask,
			XColor		*foreground,
			XColor		*background,
			unsigned int	x,
			unsigned int	y)
{
    TryShapeBitmapCursorFunc	func;

    GetFunc (TryShapeBitmapCursorFunc, "XcursorTryShapeBitmapCursor", func);
    if (func)
	return (*func) (dpy, source, mask, foreground, background, x, y);
    return None;
}
예제 #26
0
static Cursor
_XTryShapeCursor (Display	    *dpy,
		  Font		    source_font,
		  Font		    mask_font,
		  unsigned int	    source_char,
		  unsigned int	    mask_char,
		  XColor _Xconst    *foreground,
		  XColor _Xconst    *background)
{
    TryShapeCursorFunc		func;

    GetFunc (TryShapeCursorFunc, "XcursorTryShapeCursor", func);
    if (func)
	return (*func) (dpy, source_font, mask_font, source_char, mask_char,
			foreground, background);
    return None;
}
예제 #27
0
C4Value C4Effect::DoCall(C4PropList *pObj, const char *szFn, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4, const C4Value &rVal5, const C4Value &rVal6, const C4Value &rVal7)
{
	C4PropList * p = GetCallbackScript();
	if (!p)
	{
		C4AulFunc * fn = GetFunc(szFn);
		if (fn) return fn->Exec(this, &C4AulParSet(rVal1, rVal2, rVal3, rVal4, rVal5, rVal6, rVal7));
	}
	else
	{
		// old variant
		// compose function name
		C4AulFunc * fn = p->GetFunc(FormatString(PSF_FxCustom, GetName(), szFn).getData());
		if (fn) return fn->Exec(p, &C4AulParSet(Obj(pObj), this, rVal1, rVal2, rVal3, rVal4, rVal5, rVal6, rVal7));
	}
	return C4Value();
}
예제 #28
0
	static bool Get(T* val, config_t* config, const char* index)
	{
		const char* section = index;

		const char* key = index;
		while (*key != 0) ++key;
		++key;

		if (config_has_user_value(config, section, key))
			*val = GetFunc(config, section, key);
		else
			if (config_has_default_value(config, section, key))
				*val = GetDefaultFunc(config, section, key);
			else
				return false;
		return true;
	}
inline Node2D* Eval2D(std::string & s){
    std::string T;
    if(isdigit(s[0])){
        T=GetNumber(s);
        if(s.size()>0){
            if(IsOp(s[0])){
                char Op=s[0];
                s.erase(s.begin());
                return new OperatorNode2D(T,s,Op);
            }
        }
        else return new Leaf2D(T);
    }
    else if(s[0]=='x'||s[0]=='y'){
        if(s.size()==1) return new Leaf2D(s);
        else{
            T+=s[0];
            s.erase(s.begin());
            char Op=s[0];
            s.erase(s.begin());
            return new OperatorNode2D(T,s,Op);
        }
    }
    else if(IsFunc(s[0])){
        T=GetFunc(s);
        if(OnlyFunc(T+s)){return new FunctionNode2D(T);}
        else{
            char op=s[0];
            s.erase(s.begin());
            return new OperatorNode2D(T,s,op);
        }
    }
    if(OnlyParenth(s)){
        s.erase(s.begin());
        s.pop_back();
        return Eval2D(s);
    }
    T=GetParenth(s);
    char op=s[0];
    s.erase(s.begin());
    return new OperatorNode2D(T,s,op);
}
예제 #30
0
BOOL CPythonWrapper::ExcecuteFunc( char* szModuleName, char* szFunctionName, PyObject* pArgs /*= NULL*/ )
{
	PyObject* pFunc = GetFunc(szModuleName, szFunctionName);
	BOOL bResult = FALSE;

	if(NULL == pFunc)
		return NULL;

	if(pFunc && PyCallable_Check(pFunc))
	{
		PyObject* pObject = PyObject_CallObject(pFunc, pArgs);

		if(pObject != NULL)
		{
			bResult = TRUE;
			Py_DECREF(pObject);
		}
	}

	return bResult;
}