示例#1
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#2
0
文件: o.c 项目: ConorOBrien-Foxx/o
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);
}
示例#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;
}
示例#4
0
文件: Reno.cpp 项目: m1h4/Reno
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();
}
示例#5
0
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();

}
示例#6
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#7
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#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));
            });
示例#9
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#10
0
文件: o.c 项目: ConorOBrien-Foxx/o
V swp(ST s){P a,b;a=pop(s);b=pop(s);psh(s,a);psh(s,b);} //swap
示例#11
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#12
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#13
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#14
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#15
0
文件: o.c 项目: ConorOBrien-Foxx/o
V divd(O a,O b,ST s){if(b->d==0)ex("zero division");psh(s,newod(a->d/b->d));} //div decimal
示例#16
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#17
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#18
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#19
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#20
0
文件: o.c 项目: ConorOBrien-Foxx/o
V hsh(ST s){O o=pop(s);psh(s,hsho(o));dlo(o);} //hash
示例#21
0
文件: o.c 项目: ConorOBrien-Foxx/o
V cmprs(ST st,O o){psh(st,newosc(o->d));dlo(o);} //compress string to array
示例#22
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#23
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#24
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#25
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#26
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#27
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#28
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#29
0
文件: o.c 项目: ConorOBrien-Foxx/o
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
示例#30
0
文件: o.c 项目: ConorOBrien-Foxx/o
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)));}