Exemple #1
0
Fichier : p.c Projet : 0branch/kona
Z void dum7(K*_v,I a){
  K v=*_v;
  int n=0;I vt=v->t,vn=v->n,f=1;
  S typ7[]={"wd","wordfn","cfn","charfn",":[]","if[]","while[]","do[]"};
  V e=0;V*kw=kW(v);
  if(!a)O("\n");
  if(7==vt){
    A(a);O("[%lld,%lld,%lld,%s]\n",vt,vn,rc(v),typ7[vn]);
    SW(vn){
    CS(2, A(a);O(" val: %p %p %p\n",kw[0],kw[1],kw[2]))
    CD: {
      K par=(K)kV(v)[PARAMS],loc=(K)kV(v)[PARAMS],conj=(K)kV(v)[CONJ];
      if(par->n){A(a);O("params: ");dum7(&par,a+2);}
      if(loc->n){A(a);O("locals: ");dum7(&loc,a+2);}
      if(conj){A(a);O("  conj: ");dum7(&conj,a+2);}
      if(3==vn){
        K cw=(K)kV(v)[CACHE_WD];K ct=(K)kV(v)[CACHE_TREE];
        if(cw){A(a);O("  cachewd: ");dum7(&cw,a+2);}
        if(ct){A(a);O("cachetree: ");dum7(&ct,a+2);}
        A(a);showx(v);
      } else
        while((e=*kw++)){
          if(f){A(a);O("entries-->\n");f=0;}
          A(a);O("%d entry",n++);
          if((L)e<DT_SIZE){O("  dt: %s (%p)\n",DT[(L)e].text,e);}
          else dum7((K*)e,a+2); } } } }
Exemple #2
0
Fichier : ko.c Projet : elrzn/kona
K kclone(K a)//Deep copy -- eliminate where possible
{
  if(!a) R 0;
  I t=a->t,n=a->n;
  K z= 7==t?Kv():newK(t,n);
  if     (4==ABS(t)) DO(n, kS(z)[i]=kS(a)[i])  //memcpy everywhere is better
  else if(3==ABS(t)) DO(n, kC(z)[i]=kC(a)[i]) 
  else if(2==ABS(t)) DO(n, kF(z)[i]=kF(a)[i]) 
  else if(1==ABS(t)) DO(n, kI(z)[i]=kI(a)[i]) 
  else if(0==    t ) DO(n, kK(z)[i]=kclone(kK(a)[i])) 
  else if(5==    t ) DO(n, kK(z)[i]=kclone(kK(a)[i]))
  else if(7==    t )
  {
    I k=0;

    z->t=a->t; 
    I vt=z->n = a->n;
    K kv;

    V*v;
    SW(vt)
    {
      CS(1, k=((K)kV(a)[CODE])->n-1;
            M(z,kv=newK(-4,k+1))
            v=(V*)kK(kv);
            //v[k]=0;//superfluous reminder
            DO(k, V w=kW(a)[i];
                  if(VA(w))v[i]=w;  //TODO: is this ok for NAMES? see similar code in capture()
                  else
                  {
                    K r=kclone(*(K*)w); //oom
                    V q=newE(LS,r); //oom
                    kap((K*) kV(z)+LOCALS,&q);//oom
                    cd(q);//kap does ci
                    q=EVP(q); //oom free z etc. kap needs checking 
                    v[i]=q;
                  }
              )
      )
      CS(2, M(z,kv=newK(-4,3))
            v=(V*)kK(kv);
            memcpy(v,kW(a),3*sizeof(V));
        )
Exemple #3
0
moDVector<Real> moDMatrix<Real>::GetColumn (int iCol) const
{
    //assert(0 <= iCol && iCol < m_iCols);
    moDVector<Real> kV(m_iRows);
    for (int iRow = 0; iRow < m_iRows; iRow++)
    {
        kV[iRow] = m_aafEntry[iRow][iCol];
    }
    return kV;
}
Exemple #4
0
moDVector<Real> moDMatrix<Real>::GetRow (int iRow) const
{
    //assert(0 <= iRow && iRow < m_iRows);
    moDVector<Real> kV(m_iCols);
    for (int iCol = 0; iCol < m_iCols; iCol++)
    {
        kV[iCol] = m_aafEntry[iRow][iCol];
    }
    return kV;
}
Exemple #5
0
//----------------------------------------------------------------------------
bool Skinning::Setup ()
{
    m_spkScene = new Node(1);

    int iRadialSamples = 10;
    Vector3f kCenter(0.0f,0.0f,100.0f);
    Vector3f kU(0.0f,0.0f,-1.0f);
    Vector3f kV(0.0f,1.0f,0.0f);
    Vector3f kAxis(1.0f,0.0f,0.0f);
    float fRadius = 10.0f;
    float fHeight = 80.0f;

    m_spkTriMesh = CreateCylinder(iRadialSamples,kCenter,kU,kV,kAxis,fRadius,
        fHeight,true,true,true);

    m_spkTriMesh->SetVertexShader(m_spkVertShader);
    m_spkScene->AttachChild(m_spkTriMesh); 
    return true;
}
Exemple #6
0
Fichier : ko.c Projet : elrzn/kona
                  else
                  {
                    K r=kclone(*(K*)w); //oom
                    V q=newE(LS,r); //oom
                    kap((K*) kV(z)+LOCALS,&q);//oom
                    cd(q);//kap does ci
                    q=EVP(q); //oom free z etc. kap needs checking 
                    v[i]=q;
                  }
              )
      )
      CS(2, M(z,kv=newK(-4,3))
            v=(V*)kK(kv);
            memcpy(v,kW(a),3*sizeof(V));
        )
      CS(3,M(z,kv=kclone((K)kV(a)[CODE])))
    }
    kV(z)[CODE]=kv;
    kV(z)[DEPTH]=kV(a)[DEPTH];   
    kV(z)[CONTEXT]=kV(a)[CONTEXT];   
    cd(kV(z)[PARAMS]); kV(z)[PARAMS]=kclone(kV(a)[PARAMS]); //oom ; fill instead of kclone?
    cd(kV(z)[LOCALS]); kV(z)[LOCALS]=kclone(kV(a)[LOCALS]); //oom ; fill instead of kclone?
    kV(z)[CONJ]=kclone(kV(a)[CONJ]);  //oom
  }

  R z;
}

K collapse(K x) //oom
{
  K z;
Exemple #7
0
Fichier : km.c Projet : indera/kona
  SW(xt)
  {
    CSR(5,)
    CS(0, DO(xn, cd(kK(x)[xn-i-1]))) //repool in reverse, attempt to maintain order
  }

  if(x->c > 0) R x;

  #ifdef DEBUG
  DO(kreci, if(x==krec[i]){krec[i]=0; break; })
  #endif 

  SW(xt)
  {
    CS(7, DO(-2+TYPE_SEVEN_SIZE,cd(kV(x)[2+i]))) //-4 special trick: don't recurse on V members. assumes sizeof S==K==V.  (don't free CONTeXT or DEPTH)
  }

  #ifdef DEBUG
  if(0)R 0; //for viewing K that have been over-freed
  #endif
  //assumes seven_type x->k is < PG
  I o=((size_t)x)&(PG-1);//file-mapped? 1:
  I k=sz(xt,xn), r=lsz(k);
  //assert file-maps have sizeof(V)==o and unpooled blocks never do (reasonable)
  //in 32-bit Linux: sizeof(V)==4 but file-maps have o==8
  //in 64-bit Linux: sizeof(V)==8 and file-maps have o==8
  if(o==8 || r>KP_MAX){    //(file-mapped or really big) do not go back into pool.
    I res=munmap(((V)x)-o,k+o); if(res)R UE; if(r>KP_MAX) mUsed -= (k+o);
  }
  else repool(x,r);
Exemple #8
0
  va_start(a,g);while(o!=(v=va_arg(a,V)))cd(v); va_end(a);
  R 0;
}
//Arthur says he doesn't use malloc or free. Andrei Moutchkine claims smallest unit is vm page (his truss says no malloc + add pages one at a time).
//Arthur not using malloc is probably true. No strdup & related functions in binary's strings. Note: Skelton references "different allocator" not in \w report
//This source would be improved by getting ridding of remaing malloc/calloc/realloc
K cd(K a)
{
  #ifdef DEBUG
  if(a && a->c <=0 ) { er(Tried to cd() already freed item) dd(tests) dd(a) dd(a->c) dd(a->t) dd(a->n) show(a); }
  #endif 
  if(!a || --a->c) R a;
  #ifdef DEBUG
  DO(kreci, if(a==krec[i]){krec[i]=0; break; })
  #endif 
  if(7==a->t){ DO(-2+TYPE_SEVEN_SIZE,cd(kV(a)[2+i]))} //-4 special trick: don't recurse on V members. assumes sizeof S==K==V.  (don't free CONTEXT or DEPTH)
  if(0==a->t || 5==a->t) DO(a->n, cd(kK(a)[a->n-i-1])) //repool in reverse, attempt to maintain order
  #ifdef DEBUG
  if(0)R 0; //for viewing K that have been over-freed
  #endif
  //assumes seven_type a->k is < PG
  I o=((size_t)a)&(PG-1);//file-mapped? 1:
  I k=sz(a->t,a->n), r=lsz(k);
  //assert file-maps have sizeof(V)==o and unpooled blocks never do (reasonable)
  if(sizeof(V)==o || r>KP_MAX)munmap(((V)a)-o,k+o); //(file-mapped or really big) do not go back into pool. 
  else repool(a,r);
  R 0;
}
K ci(K a){if(a)a->c++; R a;}

I bp(I t) {SW(ABS(t)){CSR(1, R sizeof(I)) CSR(2, R sizeof(F)) CSR(3, R sizeof(C)) CD: R sizeof(V); } } //Default 0/+-4/5/6/7  (assumes sizeof(K)==sizeof(S)==...)