Exemple #1
0
S exc(C c){
    static S psb; //string buffer
    static S pcbb; //codeblock buffer
    ST st=top(rst);O o;I d; //current stack,temp var for various computations,another temp var
    if(init){memset(v,0,sizeof(v));init=0;}
    if(pl&&!ps&&!pcb&&!pc){C b[2]={c,0};pl=0;psh(st,newocb(b,1));}
    else if(v[c]&&(isalpha(c)?1:!icb)&&!pv&&!ps&&!pc&&!pcb){ //if variable && not defining variable && not parsing string/char
        o=v[c];if(o->t==TCB)excb(o); //if variable is code block and not in code block, run codeblock
        else psh(st,dup(o)); //push variable contents
    } //push/run variable if defined
    else if(pcb&&c&&!ps&&!pc){
        if(c=='{')cbi++;else if(c=='}')cbi--; //create indents if new block is made
        if(cbi<=0){pcbb[pcb-1]=0;psh(st,newocbk(pcbb,pcb-1));pcb=0;} //finish block if indent is 0
        else{pcbb=rlc(pcbb,pcb+1);pcbb[pcb-1]=c;++pcb;} //create code block
    }
    else if(pc&&!ps){if(c=='\\'&&!pe)pe=1;else{psh(st,newosc(pe?pec(c):c));pc=pe=0;}}
    else if(ps&&c)
        if(c=='\''&&!pe){exc('"');exc('"');}else{ //string restarting
        if(c=='"'&&!pe){psb[ps-1]=0;psh(st,newosk(psb,ps-1));ps=0;}else if(c=='\\'&&!pe)pe=1;else{psb=rlc(psb,ps+1);psb[ps-1]=pe?pec(c):c;++ps;pe=0;}} //string parsing
    else if(pm&&c){ //math
        pm=0;switch(c){
        #define MO(c,f) case c:math(f,st);BK;
        MO('q',sqrt)MO('[',floor)MO(']',ceil)MO('s',sin)MO('S',asin)MO('c',cos)MO('C',acos)MO('t',tan)MO('T',atan)
        #undef MO
        #define MO(c,f) case c:f(st);BK;
        MO('d',mdst)MO('r',mrng)
        #undef MO
        #define MO(c,v) case c:psh(st,newod(v));BK;
        MO('p',M_PI)MO('e',exp(1.0))MO('l',299792458)
        #undef MO
        default:PE;
    }} //math
Exemple #2
0
V range(ST s){
    I i;O o=pop(s);if(o->t!=TD)TE;
    if(o->d>0){for(i=o->d/*truncate*/;i>-1;--i)psh(s,newod(i));}
    else if (o->d<0){for(i=o->d/*truncate*/;i<1;++i)psh(s,newod(i));}
    else psh(s,newod(0));
    dlo(o);
}
Exemple #3
0
int adhoc_main()
{
	std::auto_ptr<Animal> pd(new Dog);
	std::auto_ptr<Animal> ph(new Horse);
	std::auto_ptr<Animal> psh(new SmallHorse);
	Loki::FlexAdHocVisitor<Loki::Seq<SmallHorse, Horse,  Dog>::Type, Effector > v;
	v.StartVisit(ph.get());
	v.StartVisit(psh.get());
	v.StartVisit(pd.get());
	return 0;
}
Exemple #4
0
VOID CRenoApp::OnToolsOptions()
{
	// Create a new options sheet
	CPropertySheet psh(TEXT("Options"),AfxGetMainWnd());
	CPropertyPage pp(IDD_OPTIONS_GENERAL);
	
	psh.m_psh.dwFlags &= ~PSH_HASHELP;
	psh.m_psh.dwFlags |= PSH_NOAPPLYNOW;
	pp.m_psp.dwFlags &= ~PSP_HASHELP;

	psh.AddPage(&pp);

	psh.DoModal();
}
void
CMainFrame::OnCmdShowDeviceProperties(DWORD dwSlotNo)
{
	ndas::DevicePtr pDevice;
	if (!ndas::FindDeviceBySlotNumber(pDevice, dwSlotNo))
	{
		ATLTRACE("Invalid slot no: %d\n", dwSlotNo);
		return;
	}

	CString strTitle;
	strTitle.FormatMessage(IDS_DEVICE_PROP_TITLE, pDevice->GetName());

	CNdasDevicePropSheet psh(static_cast<LPCTSTR>(strTitle), 0, m_hWnd);
	psh.SetDevice(pDevice);
	psh.DoModal();

}
Exemple #6
0
V take(){O o;if(len(rst)<2)ex("take needs open array");psh(top(rst),pop(rst->st[len(rst)-2]/*previous stack*/));} //take
Exemple #7
0
V rdq(ST s,I u){S e,i=rdln();F d=strtod(i,&e);if(*e)psh(s,newoskz(i));else{DL(i);psh(s,newod(d));}if(u)v['Q']=dup(top(s));} //q,Q
Exemple #8
0
void anti_restr_fnc(lv,le,lq,newlv,newle)
{register int i,v ;
  itr(lv,i,v,if( mbr(lq,v)==FALSE ){
               psh(newlv,v);
               psh(newle,val(le,i));
            });
Exemple #9
0
V eq(ST s){O a,b;b=pop(s);a=pop(s);if(a->t==TA||b->t==TA)TE;psh(s,newod(eqo(a,b)));dlo(a);dlo(b);} //equal
Exemple #10
0
V swp(ST s){P a,b;a=pop(s);b=pop(s);psh(s,a);psh(s,b);} //swap
Exemple #11
0
O dup(O);O dupa(O o){ST s=newst(BZ);L i=0;for(i=0;i<len(o->a);++i)psh(s,dup(o->a->st[i]));R newoa(s);} //dup array
Exemple #12
0
O hsha(O o){ST a=newst(BZ);L i;for(i=0;i<len(o->a);++i)psh(a,hsho(o->a->st[i]));R newoa(a);} //hash array
Exemple #13
0
V key(ST st){
    O b=pop(st);if(b->t==TA){O t=pop(b->a);psh(st,b);psh(st,t);R;}
    O a=top(st);if(b->t==TD&&a->t==TA){I i=b->d;psh(st,dup(a->a->st[i]));dlo(b);}
    else TE;} //key
Exemple #14
0
V evn(ST s){O o=pop(s);if(o->t==TD)psh(s,newod((I)o->d%2==0));else if(o->t==TS){psh(s,dup(o));psh(s,newod(o->s.z));}else if(o->t==TA){psh(s,dup(o));psh(s,newod(len(o->a)));}else TE;dlo(o);} //even? or push string length or push array length
Exemple #15
0
V divd(O a,O b,ST s){if(b->d==0)ex("zero division");psh(s,newod(a->d/b->d));} //div decimal
Exemple #16
0
V opar(){ST r;O a=pop(top(rst));L i;psh(rst,r=newst(BZ));for(i=0;i<len(a->a);++i)psh(r,dup(a->a->st[i]));dlo(a);} //open array
Exemple #17
0
V idc(ST s,C c){O o=pop(s);if(o->t!=TD)TE;psh(s,newod(c=='('?o->d-1:o->d+1));dlo(o);} //inc/dec
Exemple #18
0
V rvx(ST s){S r;L z;O o=pop(s);if(o->t!=TS)TE;r=alc(o->s.z+1);for(z=0;z<o->s.z;++z)r[o->s.z-z-1]=o->s.s[z];dlo(o);psh(s,newosk(r,z));}  //reverse object
Exemple #19
0
V toca(ST st,O o){ST ca=newst(o->s.z+1);I p=0;for(;p<o->s.z;++p)psh(ca,newosc(o->s.s[p]));psh(st,newoa(ca));dlo(o);} //string to char array
Exemple #20
0
V hsh(ST s){O o=pop(s);psh(s,hsho(o));dlo(o);} //hash
Exemple #21
0
V cmprs(ST st,O o){psh(st,newosc(o->d));dlo(o);} //compress string to array
Exemple #22
0
V math(MF f,ST s){O n=pop(s);if(n->t!=TD)TE;psh(s,newod(f(n->d)));dlo(n);} //generic math op
Exemple #23
0
V mod(ST s){
    O o,a,b=pop(s);a=pop(s);
    if(a->t==TA&&b->t==TCB){ST na=newst(BZ);O on=v['n'];rev(a->a);while(len(a->a)){
            v['n']=pop(a->a);excb(b);if(truth(o=pop(s)))psh(na,dup(v['n']));dlo(o);dlo(v['n']);}
        v['n']=on;dlo(a);dlo(b);psh(s,newoa(na)); //filter
    }else{if(a->t!=b->t||a->t==TCB||b->t==TCB)TE;psh(s,modfn[a->t](a,b));dlo(a);dlo(b);}} //mod
Exemple #24
0
V mul(ST s){O a,b;b=pop(s);if(b->t==TA){while(len(b->a)>1)mul(b->a);psh(s,dup(top(b->a)));dlo(b);R;};a=pop(s);if(a->t==TA)TE;if(a->t==TS){if(b->t!=TD)TE;psh(s,muls(a,b));}else psh(s,muld(a,b));dlo(a);dlo(b);} //mul
Exemple #25
0
V rot(ST s){P a,b,c;a=pop(s);b=pop(s);c=pop(s);psh(s,b);psh(s,a);psh(s,c);} //rotate 3
Exemple #26
0
V mrng(ST s){O ox,oy;F f,x,y;oy=pop(s);ox=pop(s);if(ox->t!=TD||oy->t!=TD)TE;x=ox->d;y=oy->d;if(y>x)for(f=x;f<=y;++f)psh(s,newod(f));else if(x>y)for(f=x;f>=y;--f)psh(s,newod(f));dlo(ox);dlo(oy);} //math mr range
Exemple #27
0
O moda(O a,O b){ST r=newst(BZ);L i;for(i=0;i<len(a->a);++i)psh(r,dup(a->a->st[i]));for(i=0;i<len(b->a);++i)psh(r,dup(b->a->st[i]));R newoa(r);} //mod array
Exemple #28
0
V fif(ST s){O f=pop(s),t=pop(s),c=pop(s),r;r=truth(c)?t:f;if(r->t==TCB)excb(r);else psh(s,dup(r));dlo(c);dlo(t);dlo(f);} //if stmt
Exemple #29
0
V mdst(ST s){O ox,oy;F x,y;oy=pop(s);ox=pop(s);if(ox->t!=TD||oy->t!=TD)TE;x=pow(ox->d,2);y=pow(oy->d,2);psh(s,newod(sqrt(x+y)));dlo(ox);dlo(oy);} //math md
Exemple #30
0
V divs(O a,O b,ST s){S p,l=a->s.s;if(b->s.z==0){for(p=a->s.s;p<a->s.s+a->s.z;++p)psh(s,newosc(*p));R;}for(p=strstr(a->s.s,b->s.s);p;p=strstr(p+1,b->s.s)){psh(s,newos(l,p-l));l=p+1;}if(*l)psh(s,newos(l,a->s.z-(l-a->s.s)));}