Tree @debian/2.23-2 (Download .tar.gz)
- base
- debian
- doc
- examples
- GUI
- patches
- prc
- tests
- absyn.cc
- absyn.h
- access.cc
- access.h
- algebra3.cc
- algebra3.h
- allsymbols.h
- angle.h
- application.cc
- application.h
- arcball.cc
- arcball.h
- array.cc
- array.h
- arrayop.h
- aspy.py
- asy-keywords.el
- asy-list.pl
- asy.ico
- asy.rc
- asymptote.nsi
- asymptote.spec
- autogen.sh
- ax_pthread.m4
- bbox.h
- bbox3.h
- BUGS
- builtin.cc
- builtin.h
- builtin.symbols.h
- callable.cc
- callable.h
- camp.l
- camp.tab.cc
- camp.tab.h
- camp.y
- camperror.cc
- camperror.h
- castop.h
- ChangeLog
- coder.cc
- coder.h
- coenv.cc
- coenv.h
- common.h
- config.guess
- config.h.in
- config.sub
- configure
- configure.ac
- constructor.cc
- dec.cc
- dec.h
- Delaunay.cc
- Delaunay.h
- drawclipbegin.h
- drawclipend.h
- drawelement.h
- drawfill.cc
- drawfill.h
- drawgrestore.h
- drawgroup.h
- drawgsave.h
- drawimage.h
- drawlabel.cc
- drawlabel.h
- drawlayer.h
- drawpath.cc
- drawpath.h
- drawpath3.cc
- drawpath3.h
- drawsurface.cc
- drawsurface.h
- drawverbatim.h
- entry.cc
- entry.h
- env.cc
- env.h
- envcompleter.cc
- envcompleter.h
- EnvVarUpdate.nsh
- errormsg.cc
- errormsg.h
- errors
- errortest.asy
- exp.cc
- exp.h
- fftw++.cc
- fftw++.h
- fftw++asy.cc
- fileio.cc
- fileio.h
- findsym.pl
- flatguide.cc
- flatguide.h
- fpu.h
- frame.h
- fundec.cc
- fundec.h
- genv.cc
- genv.h
- getopt.c
- getopt.h
- getopt1.c
- glrender.cc
- glrender.h
- gsl.cc
- gsl.symbols.h
- guide.cc
- guide.h
- guideflags.h
- impdatum.cc
- inst.h
- INSTALL
- install-sh
- interact.cc
- interact.h
- item.h
- keywords.cc
- keywords.pl
- knot.cc
- knot.h
- lex.yy.cc
- lexical.h
- LICENSE
- LICENSE.LESSER
- lnkX64IconFix.nsh
- locate.cc
- locate.h
- main.cc
- Makefile.in
- mathop.h
- memory.h
- mod.h
- modifier.h
- name.cc
- name.h
- newexp.cc
- newexp.h
- opcodes.h
- opsymbols.h
- opsymbols.pl
- pair.h
- parser.cc
- parser.h
- path.cc
- path.h
- path3.cc
- path3.h
- pen.cc
- pen.h
- picture.cc
- picture.h
- pipestream.h
- policy.h
- prcfile.h
- predicates.cc
- predicates.h
- primitives.h
- process.cc
- process.h
- profile.py
- profiler.h
- program.cc
- program.h
- psfile.cc
- psfile.h
- quaternion.cc
- quaternion.h
- README
- record.cc
- record.h
- refaccess.cc
- refaccess.h
- ReleaseNotes
- rounding.h
- runarray.cc
- runarray.h
- runarray.in
- runarray.symbols.h
- runbacktrace.cc
- runbacktrace.h
- runbacktrace.in
- runbacktrace.symbols.h
- runfile.cc
- runfile.h
- runfile.in
- runfile.symbols.h
- runhistory.cc
- runhistory.h
- runhistory.in
- runhistory.symbols.h
- runlabel.cc
- runlabel.h
- runlabel.in
- runlabel.symbols.h
- runmath.cc
- runmath.h
- runmath.in
- runmath.symbols.h
- runpair.cc
- runpair.h
- runpair.in
- runpair.symbols.h
- runpath.cc
- runpath.h
- runpath.in
- runpath.symbols.h
- runpath3d.cc
- runpath3d.h
- runpath3d.in
- runpath3d.symbols.h
- runpicture.cc
- runpicture.h
- runpicture.in
- runpicture.symbols.h
- runstring.cc
- runstring.h
- runstring.in
- runstring.symbols.h
- runsystem.cc
- runsystem.h
- runsystem.in
- runsystem.symbols.h
- runtime.cc
- runtime.h
- runtime.in
- runtime.pl
- runtime.symbols.h
- runtimebase.in
- runtriple.cc
- runtriple.h
- runtriple.in
- runtriple.symbols.h
- seconds.h
- settings.cc
- settings.h
- simpson.cc
- stack.cc
- stack.h
- stm.cc
- stm.h
- symbol.cc
- symbol.h
- table.h
- texfile.cc
- texfile.h
- TODO
- tr.cc
- tr.h
- transform.h
- triple.h
- types.cc
- types.h
- types.symbols.h
- util.cc
- util.h
- varinit.cc
- varinit.h
- virtualfieldaccess.cc
- virtualfieldaccess.h
- vm.h
- wce
- xstream.h
castop.h @debian/2.23-2 — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | /***** * castop.h * Tom Prince 2005/3/18 * * Defines some runtime functions used by the stack machine. * *****/ #ifndef CASTOP_H #define CASTOP_H #include <cfloat> #include "common.h" #include "stack.h" #include "fileio.h" #include "lexical.h" #include "mathop.h" #include "array.h" namespace run { using vm::read; using vm::pop; template<class T, class S> void cast(vm::stack *s) { s->push((S) pop<T>(s)); } void castDoubleInt(vm::stack *s) { double x=pop<double>(s); s->push(Intcast(x)); } template<class T> void stringCast(vm::stack *s) { ostringstream buf; buf.precision(DBL_DIG); buf << pop<T>(s); s->push(buf.str()); } template<class T> void castString(vm::stack *s) { string *S=pop<string*>(s); if(S->empty()) { T x=0; s->push(x); } else { try { s->push(lexical::cast<T>(*S)); } catch (lexical::bad_cast&) { ostringstream buf; buf << "invalid cast from string \"" << *S << "\""; vm::error(buf); } } } template<class T, class S> void arrayToArray(vm::stack *s) { vm::array *a=pop<vm::array*>(s); size_t size=checkArray(a); vm::array *c=new vm::array(size); for(size_t i=0; i < size; i++) (*c)[i]=(S) read<T>(a,i); s->push(c); } template<class T, class S> void array2ToArray2(vm::stack *s) { vm::array *a=pop<vm::array*>(s); size_t size=checkArray(a); vm::array *c=new vm::array(size); for(size_t i=0; i < size; ++i) { vm::array *ai=vm::read<vm::array*>(a,i); size_t aisize=checkArray(ai); vm::array *ci=new vm::array(aisize); (*c)[i]=ci; for(size_t j=0; j < aisize; ++j) (*ci)[j]=(S) read<T>(ai,j); } s->push(c); } template<class T> void read(vm::stack *s) { camp::file *f = pop<camp::file*>(s); T val=T(); if(f->isOpen()) { f->read(val); if(f->LineMode()) f->nexteol(); if(interact::interactive) f->purgeStandard(val); } s->push(val); } inline Int Limit(Int nx) {return nx == 0 ? Int_MAX : nx;} inline void reportEof(camp::file *f, Int count) { if(count > 0) { ostringstream buf; buf << "EOF after reading " << count << " values from file '" << f->filename() << "'."; vm::error(buf); } } template<class T> void readArray(vm::stack *s) { camp::file *f = pop<camp::file*>(s); vm::array *c=new vm::array(0); if(f->isOpen()) { Int nx=f->Nx(); if(nx == -2) {f->read(nx); f->Nx(-1); if(nx == 0) {s->push(c); return;}} Int ny=f->Ny(); if(ny == -2) {f->read(ny); f->Ny(-1); if(ny == 0) {s->push(c); return;}} Int nz=f->Nz(); if(nz == -2) {f->read(nz); f->Nz(-1); if(nz == 0) {s->push(c); return;}} T v; if(nx >= 0) { for(Int i=0; i < Limit(nx); i++) { if(ny >= 0) { vm::array *ci=new vm::array(0); for(Int j=0; j < Limit(ny); j++) { if(nz >= 0) { vm::array *cij=new vm::array(0); bool break2=false; for(Int k=0; k < Limit(nz); k++) { f->read(v); if(f->error()) { if(nx && ny && nz) reportEof(f,(i*ny+j)*nz+k); s->push(c); return; } if(k == 0) { if(j == 0) c->push(ci); ci->push(cij); } cij->push(v); if(f->LineMode() && f->nexteol()) { if(f->nexteol()) break2=true; break; } } if(break2) break; } else { f->read(v); if(f->error()) { if(nx && ny) reportEof(f,i*ny+j); s->push(c); return; } if(j == 0) c->push(ci); ci->push(v); if(f->LineMode() && f->nexteol()) break; } } } else { f->read(v); if(f->error()) { if(nx) reportEof(f,i); s->push(c); return; } c->push(v); if(f->LineMode() && f->nexteol()) break; } } } else { for(;;) { f->read(v); if(f->error()) break; c->push(v); if(f->LineMode() && f->nexteol()) break; } } if(interact::interactive) f->purgeStandard(v); } s->push(c); } } // namespace run #endif // CASTOP_H |