diff options
Diffstat (limited to 'Build/source/utils/asymptote/runtime.cc')
-rw-r--r-- | Build/source/utils/asymptote/runtime.cc | 9027 |
1 files changed, 9027 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/runtime.cc b/Build/source/utils/asymptote/runtime.cc new file mode 100644 index 00000000000..90b78b7302c --- /dev/null +++ b/Build/source/utils/asymptote/runtime.cc @@ -0,0 +1,9027 @@ +/***** Autogenerated from runtime.in; changes will be overwritten *****/ + +#line 1 "runtime.in" +/***** + * runtime.in + * Tom Prince 2005/4/15 + * + * Generate the runtime functions used by the vm::stack machine. + * + *****/ + +/* Autogenerated routines are specified like this (separated by a formfeed): + type asyname:cname(cparams) + { + C code + } + +*/ + +// Use Void f() instead of void f() to force an explicit Stack argument. + + +#line 63 "runtime.in" +#include <cfloat> +#include <time.h> +#include <sys/times.h> +#include <locale.h> + +#include "angle.h" +#include "pair.h" +#include "triple.h" +#include "transform.h" +#include "path.h" +#include "path3.h" +#include "pen.h" +#include "guide.h" +#include "picture.h" +#include "drawpath.h" +#include "drawpath3.h" +#include "drawsurface.h" +#include "drawfill.h" +#include "drawclipbegin.h" +#include "drawclipend.h" +#include "drawlabel.h" +#include "drawverbatim.h" +#include "drawgsave.h" +#include "drawgrestore.h" +#include "drawlayer.h" +#include "drawimage.h" +#include "drawgroup.h" +#include "fileio.h" +#include "genv.h" +#include "builtin.h" +#include "texfile.h" +#include "pipestream.h" +#include "parser.h" +#include "stack.h" +#include "util.h" +#include "locate.h" +#include "mathop.h" +#include "callable.h" +#include "stm.h" +#include "lexical.h" +#include "process.h" +#include "arrayop.h" +#include "predicates.h" +#include "Delaunay.h" + +#ifdef HAVE_LIBFFTW3 +#include "fftw++.h" +#endif + +#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#include <readline/readline.h> +#include <readline/history.h> +#endif + +#if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE) + extern "C" { + void *GC_generate_random_valid_address(void); + void GC_debug_print_heap_obj_proc(void *); + } +#endif + +using namespace vm; +using namespace camp; +using namespace settings; + +namespace run { +using camp::pair; +using vm::array; +using vm::frame; +using vm::stack; +using camp::transform; +using absyntax::runnable; + +typedef double real; + +#define CURRENTPEN processData().currentpen + +typedef array boolarray; +typedef array Intarray; +typedef array Intarray2; +typedef array realarray; +typedef array realarray2; +typedef array pairarray; +typedef array pairarray2; +typedef array triplearray; +typedef array triplearray2; +typedef array patharray; +typedef array patharray2; +typedef array guidearray; +typedef array transformarray; +typedef array penarray; +typedef array penarray2; +typedef array stringarray; +typedef array stringarray2; + +typedef callable callableBp; +typedef callable callableReal; +typedef callable callableTransform; +} + +using vm::array; +using types::function; + +#define PRIMITIVE(name,Name,asyName) using types::prim##Name; +#include <primitives.h> +#undef PRIMITIVE + +using types::boolArray; +using types::IntArray; +using types::IntArray2; +using types::realArray; +using types::realArray2; +using types::pairArray; +using types::pairArray2; +using types::tripleArray; +using types::tripleArray2; +using types::pathArray; +using types::pathArray2; +using types::guideArray; +using types::transformArray; +using types::penArray; +using types::penArray2; +using types::stringArray; +using types::stringArray2; +using types::formal; + +function *voidFunction() +{ + return new function(primVoid()); +} + +function *breakpointFunction() +{ + return new function(primString(),primString(),primInt(),primInt(), + primCode()); +} + +function *realRealFunction() +{ + return new function(primReal(),primReal()); +} + +function *transformFunction() +{ + return new function(primTransform()); +} + +function *realTripleFunction() +{ + return new function(primReal(),primTriple()); +} + +const size_t camp::ColorComponents[]={0,0,1,3,4,0}; + +namespace vm { +} + +namespace run { + +const char *invalidargument="invalid argument"; +const char *arrayempty="cannot take min or max of empty array"; + +// Return the factorial of a non-negative integer using a lookup table. +Int factorial(Int n) +{ + static Int *table; + static Int size=0; + if(size == 0) { + Int f=1; + size=2; + while(f <= Int_MAX/size) + f *= (size++); + table=new Int[size]; + table[0]=f=1; + for(Int i=1; i < size; ++i) { + f *= i; + table[i]=f; + } + } + if(n >= size) integeroverflow(0); + return table[n]; +} + +static inline Int Round(double x) +{ + return Int(x+((x >= 0) ? 0.5 : -0.5)); +} + +inline Int sgn(double x) +{ + return (x > 0.0 ? 1 : (x < 0.0 ? -1 : 0)); +} + +void outOfBounds(const char *op, size_t len, Int n) +{ + ostringstream buf; + buf << op << " array of length " << len << " with out-of-bounds index " << n; + error(buf); +} + +inline item& arrayRead(array *a, Int n) +{ + size_t len=checkArray(a); + bool cyclic=a->cyclic(); + if(cyclic && len > 0) n=imod(n,len); + else if(n < 0 || n >= (Int) len) outOfBounds("reading",len,n); + return (*a)[(unsigned) n]; +} + +// Helper function to create deep arrays. +static array* deepArray(Int depth, Int *dims) +{ + assert(depth > 0); + + if (depth == 1) { + return new array(dims[0]); + } else { + Int length = dims[0]; + depth--; dims++; + + array *a = new array(length); + + for (Int index = 0; index < length; index++) { + (*a)[index] = deepArray(depth, dims); + } + return a; + } +} + +array *nop(array *a) +{ + return a; +} + +array *Identity(Int n) +{ + size_t N=(size_t) n; + array *c=new array(N); + for(size_t i=0; i < N; ++i) { + array *ci=new array(N); + (*c)[i]=ci; + for(size_t j=0; j < N; ++j) + (*ci)[j]=0.0; + (*ci)[i]=1.0; + } + return c; +} + +array *copyArray(array *a) +{ + size_t size=checkArray(a); + array *c=new array(size); + for(size_t i=0; i < size; i++) + (*c)[i]=(*a)[i]; + return c; +} + +inline size_t checkdimension(array *a, size_t dim) +{ + size_t size=checkArray(a); + if(dim && size != dim) { + ostringstream buf; + buf << "array of length " << dim << " expected" << endl; + error(buf); + } + return size; +} + +double *copyArrayC(array *a, size_t dim=0) +{ + size_t size=checkdimension(a,dim); + double *c=new double[size]; + for(size_t i=0; i < size; i++) + c[i]=read<double>(a,i); + return c; +} + +triple *copyTripleArrayC(array *a, size_t dim=0) +{ + size_t size=checkdimension(a,dim); + triple *c=new triple[size]; + for(size_t i=0; i < size; i++) + c[i]=read<triple>(a,i); + return c; +} + +array *copyArray2(array *a) +{ + size_t size=checkArray(a); + array *c=new array(size); + for(size_t i=0; i < size; i++) { + array *ai=read<array*>(a,i); + size_t aisize=checkArray(ai); + array *ci=new array(aisize); + (*c)[i]=ci; + for(size_t j=0; j < aisize; j++) + (*ci)[j]=(*ai)[j]; + } + return c; +} + +array *copyArray3(array *a) +{ + size_t size=checkArray(a); + array *c=new array(size); + for(size_t i=0; i < size; i++) { + array *ai=read<array*>(a,i); + size_t aisize=checkArray(ai); + array *ci=new array(aisize); + (*c)[i]=ci; + for(size_t j=0; j < aisize; j++) { + array *aij=read<array*>(ai,j); + size_t aijsize=checkArray(aij); + array *cij=new array(aijsize); + (*ci)[j]=cij; + for(size_t k=0; k < aijsize; k++) + (*cij)[k]=(*aij)[k]; + } + } + return c; +} + +double *copyArray2C(array *a, bool square=true, size_t dim2=0) +{ + size_t n=checkArray(a); + size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); + if(n > 0 && dim2 && m != dim2) { + ostringstream buf; + buf << "second matrix dimension must be " << dim2 << endl; + error(buf); + } + + double *c=new double[n*m]; + for(size_t i=0; i < n; i++) { + array *ai=read<array*>(a,i); + size_t aisize=checkArray(ai); + if(aisize == m) { + double *ci=c+i*m; + for(size_t j=0; j < m; j++) + ci[j]=read<double>(ai,j); + } else + error(square ? "matrix must be square" : "matrix must be rectangular"); + } + return c; +} + +static const char *incommensurate="Incommensurate matrices"; +static const char *singular="Singular matrix"; +static size_t *pivot,*Row,*Col; + +triple operator *(const array& t, const triple& v) +{ + size_t n=checkArray(&t); + if(n != 4) error(incommensurate); + array *t0=read<array*>(t,0); + array *t1=read<array*>(t,1); + array *t2=read<array*>(t,2); + array *t3=read<array*>(t,3); + + if(checkArray(t0) != 4 || checkArray(t1) != 4 || + checkArray(t2) != 4 || checkArray(t3) != 4) + error(incommensurate); + + double x=v.getx(); + double y=v.gety(); + double z=v.getz(); + + double f=read<real>(t3,0)*x+read<real>(t3,1)*y+read<real>(t3,2)*z+ + read<real>(t3,3); + if(f == 0.0) run::dividebyzero(); + f=1.0/f; + + return triple((read<real>(t0,0)*x+read<real>(t0,1)*y+read<real>(t0,2)*z+ + read<real>(t0,3))*f, + (read<real>(t1,0)*x+read<real>(t1,1)*y+read<real>(t1,2)*z+ + read<real>(t1,3))*f, + (read<real>(t2,0)*x+read<real>(t2,1)*y+read<real>(t2,2)*z+ + read<real>(t2,3))*f); +} + +triple multshiftless(const array& t, const triple& v) +{ + size_t n=checkArray(&t); + if(n != 4) error(incommensurate); + array *t0=read<array*>(t,0); + array *t1=read<array*>(t,1); + array *t2=read<array*>(t,2); + array *t3=read<array*>(t,3); + + if(checkArray(t0) != 4 || checkArray(t1) != 4 || + checkArray(t2) != 4 || checkArray(t3) != 4) + error(incommensurate); + + double x=v.getx(); + double y=v.gety(); + double z=v.getz(); + + double f=read<real>(t3,0)*x+read<real>(t3,1)*y+read<real>(t3,2)*z+ + read<real>(t3,3); + if(f == 0.0) run::dividebyzero(); + f=1.0/f; + + return triple((read<real>(t0,0)*x+read<real>(t0,1)*y+read<real>(t0,2)*z)*f, + (read<real>(t1,0)*x+read<real>(t1,1)*y+read<real>(t1,2)*z)*f, + (read<real>(t2,0)*x+read<real>(t2,1)*y+read<real>(t2,2)*z)*f); +} + +static inline void inverseAllocate(size_t n) +{ + pivot=new size_t[n]; + Row=new size_t[n]; + Col=new size_t[n]; +} + +static inline void inverseDeallocate() +{ + delete[] pivot; + delete[] Row; + delete[] Col; +} + +void writestring(stack *s) +{ + callable *suffix=pop<callable *>(s,NULL); + string S=pop<string>(s); + vm::item it=pop(s); + bool defaultfile=isdefault(it); + camp::file *f=defaultfile ? &camp::Stdout : vm::get<camp::file*>(it); + if(!f->isOpen()) return; + if(S != "") f->write(S); + if(f->text()) { + if(suffix) { + s->push(f); + suffix->call(s); + } else if(defaultfile) f->writeline(); + } +} + +void checkSquare(array *a) +{ + size_t n=checkArray(a); + for(size_t i=0; i < n; i++) + if(checkArray(read<array*>(a,i)) != n) + error("matrix a must be square"); +} + +// Crout's algorithm for computing the LU decomposition of a square matrix. +// cf. routine ludcmp (Press et al., Numerical Recipes, 1991). +Int LUdecompose(double *a, size_t n, size_t* index, bool warn=true) +{ + double *vv=new double[n]; + Int swap=1; + for(size_t i=0; i < n; ++i) { + double big=0.0; + double *ai=a+i*n; + for(size_t j=0; j < n; ++j) { + double temp=fabs(ai[j]); + if(temp > big) big=temp; + } + if(big == 0.0) { + delete[] vv; + if(warn) error(singular); + else return 0; + } + vv[i]=1.0/big; + } + for(size_t j=0; j < n; ++j) { + for(size_t i=0; i < j; ++i) { + double *ai=a+i*n; + double sum=ai[j]; + for(size_t k=0; k < i; ++k) { + sum -= ai[k]*a[k*n+j]; + } + ai[j]=sum; + } + double big=0.0; + size_t imax=j; + for(size_t i=j; i < n; ++i) { + double *ai=a+i*n; + double sum=ai[j]; + for(size_t k=0; k < j; ++k) + sum -= ai[k]*a[k*n+j]; + ai[j]=sum; + double temp=vv[i]*fabs(sum); + if(temp >= big) { + big=temp; + imax=i; + } + } + double *aj=a+j*n; + double *aimax=a+imax*n; + if(j != imax) { + for(size_t k=0; k < n; ++k) { + double temp=aimax[k]; + aimax[k]=aj[k]; + aj[k]=temp; + } + swap *= -1; + vv[imax]=vv[j]; + } + if(index) + index[j]=imax; + if(j != n) { + double denom=aj[j]; + if(denom == 0.0) { + delete[] vv; + if(warn) error(singular); + else return 0; + } + for(size_t i=j+1; i < n; ++i) + a[i*n+j] /= denom; + } + } + delete[] vv; + return swap; +} + +void dividebyzero(size_t i) +{ + ostringstream buf; + if(i > 0) buf << "array element " << i << ": "; + buf << "Divide by zero"; + error(buf); +} + +void integeroverflow(size_t i) +{ + ostringstream buf; + if(i > 0) buf << "array element " << i << ": "; + buf << "Integer overflow"; + error(buf); +} + +#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +struct historyState { + bool store; + HISTORY_STATE state; +}; + +typedef mem::map<CONST string, historyState> historyMap_t; +historyMap_t historyMap; +static HISTORY_STATE history_save; + +// Store a deep copy of the current readline history in dest. +void store_history(HISTORY_STATE *dest) +{ + HISTORY_STATE *src=history_get_history_state(); + if(src) { + *dest=*src; + for(Int i=0; i < src->length; ++i) + dest->entries[i]=src->entries[i]; + free(src); + } +} + +stringarray* get_history(Int n) +{ + int N=intcast(n); + if(N <= 0) N=history_length; + else N=Min(N,history_length); + array *a=new array((size_t) N); + int offset=history_length-N+1; + for(int i=0; i < N; ++i) { + HIST_ENTRY *last=history_get(offset+i); + string s=last ? last->line : ""; + (*a)[i]=s; + } + return a; +} + +string historyfilename(const string &name) +{ + return historyname+"_"+name; +} +#endif + +#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +int readline_startup_hook() +{ +#ifdef __CYGWIN__ + rl_set_key("\\M-[3~",rl_delete,rl_get_keymap()); + rl_set_key("\\M-[2~",rl_overwrite_mode,rl_get_keymap()); +#endif + return 0; +} + +void init_readline(bool tabcompletion=true) +{ + static bool first=true; + if(first) { + first=false; +#ifdef __CYGWIN__ + rl_startup_hook=readline_startup_hook; +#endif + } + rl_bind_key('\t',tabcompletion ? rl_complete : rl_insert); +} +#endif + +void cleanup() +{ + processDataStruct &pd=processData(); + pd.atExitFunction=NULL; + pd.atUpdateFunction=NULL; + pd.atBreakpointFunction=NULL; + +#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) + store_history(&history_save); + int nlines=intcast(getSetting<Int>("historylines")); + for(historyMap_t::iterator h=historyMap.begin(); h != historyMap.end(); + ++h) { + history_set_history_state(&h->second.state); + stifle_history(nlines); + if(h->second.store) write_history(historyfilename(h->first).c_str()); + } + history_set_history_state(&history_save); +#endif +} + +void purge(Int divisor=0) +{ +#ifdef USEGC + if(divisor > 0) GC_set_free_space_divisor((GC_word) divisor); + GC_gcollect(); +#endif +} + +void updateFunction(stack *Stack) +{ + callable *atUpdateFunction=processData().atUpdateFunction; + if(atUpdateFunction && !nullfunc::instance()->compare(atUpdateFunction)) + atUpdateFunction->call(Stack); +} + +void exitFunction(stack *Stack) +{ + callable *atExitFunction=processData().atExitFunction; + if(atExitFunction && !nullfunc::instance()->compare(atExitFunction)) + atExitFunction->call(Stack); + cleanup(); +} + +default_t def; +string emptystring; +array *emptyarray=new array(0); +string commentchar="#"; +pair zero; + +void breakpoint(stack *Stack, runnable *r) +{ + callable *atBreakpointFunction=processData().atBreakpointFunction; + if(atBreakpointFunction && + !nullfunc::instance()->compare(atBreakpointFunction)) { + position curPos=getPos(); + Stack->push<string>(curPos.filename()); + Stack->push<Int>((Int) curPos.Line()); + Stack->push<Int>((Int) curPos.Column()); + Stack->push(r ? r : item(def)); + atBreakpointFunction->call(Stack); // returns a string + } else Stack->push<string>(""); +} + +} + +namespace types { +extern const char *names[]; +} + +void checkformat(const char *ptr, bool intformat) +{ + while(*ptr != '\0') { + if(*ptr != '%') /* While we have regular characters, print them. */ + ptr++; + else { /* We've got a format specifier. */ + ptr++; + + while(*ptr && strchr ("-+ #0'I", *ptr)) /* Move past flags. */ + *ptr++; + + if(*ptr == '*') + ptr++; + else while(isdigit(*ptr)) /* Handle explicit numeric value. */ + ptr++; + + if(*ptr == '.') { + *ptr++; /* Go past the period. */ + if(*ptr == '*') { + ptr++; + } else + while(isdigit(*ptr)) /* Handle explicit numeric value. */ + *ptr++; + } + while(*ptr && strchr ("hlL", *ptr)) + *ptr++; + + if(*ptr == '%') ++ptr; + else if(*ptr != '\0') { + if(intformat) { + switch(*ptr) { + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': + case 'c': + break; + default: + ostringstream buf; + buf << "Invalid format '" << *ptr << "' for type " + << types::names[types::ty_Int]; + error(buf); + break; + } + } else { + switch(*ptr) { + case 'f': + case 'F': + case 'e': + case 'E': + case 'g': + case 'G': + break; + default: + ostringstream buf; + buf << "Invalid format '" << *ptr << "' for type " + << types::names[types::ty_real]; + error(buf); + break; + } + } + } + } /* End of else statement */ + } +} + +// Return an angle in the interval [0,360). +inline double principalBranch(double deg) +{ + if(deg < 0) deg += 360; + return deg; +} + +static string defaulttransparency=string("Compatible"); + +static const string defaulttimeformat=string("%a %b %d %T %Z %Y"); +#ifdef HAVE_STRFTIME +static const size_t nTime=256; +static char Time[nTime]; +#endif + +void clear(string file, Int line, bool warn=false) +{ + bpinfo bp(file,line); + for(mem::list<bpinfo>::iterator p=bplist.begin(); p != bplist.end(); ++p) { + if(*p == bp) { + cout << "cleared breakpoint at " << file << ": " << line << endl; + bplist.remove(bp); + return; + } + } + if(warn) + cout << "No such breakpoint at " << file << ": " << line << endl; +} + +Int windingnumber(array *p, camp::pair z) +{ + size_t size=checkArray(p); + Int count=0; + for(size_t i=0; i < size; i++) + count += read<path *>(p,i)->windingnumber(z); + return count; +} + +string convertname(string name, const string& format, bool check=true) +{ + if(name.empty()) + return buildname(outname(),format,""); + else + if(check) checkLocal(name); + return format.empty() ? name : format+":"+name; +} + +callable *Func; +stack *FuncStack; +double wrapFunction(double x) +{ + FuncStack->push(x); + Func->call(FuncStack); + return pop<double>(FuncStack); +} + +callable *compareFunc; +bool compareFunction(const vm::item& i, const vm::item& j) +{ + FuncStack->push(i); + FuncStack->push(j); + compareFunc->call(FuncStack); + return pop<bool>(FuncStack); +} + +void unused(void *) +{ +} + +pair readpair(stringstream& s, bool tex) +{ + static const double f=12.0/100.0; + double x,y; + s >> y; + s >> x; + return tex ? pair(f*x,-f*y) : pair(x,y); +} + +// Ignore unclosed begingroups but not spurious endgroups. +const char *nobegin="endgroup without matching begingroup"; + +// Return the component of vector v perpendicular to a unit vector u. +inline triple perp(triple v, triple u) +{ + return v-dot(v,u)*u; +} + +string ASYo="/ASYo {( ) print 12 string cvs print} bind def"; +string pathforall="{(M) print ASYo ASYo} {(L) print ASYo ASYo} {(C) print ASYo ASYo ASYo ASYo ASYo ASYo} {(c) print} pathforall"; +string currentpoint="print currentpoint ASYo ASYo "; + +array *readpath(const string& psname, bool tex, bool keep) +{ + array *P=new array(0); + ostringstream pipe; + pipe << "'" << getSetting<string>("gs") + << "' -q -dNOPAUSE -dBATCH"; + if(safe) pipe << " -dSAFER"; +#ifdef __CYGWIN__ + string null="NUL"; +#else + string null="/dev/null"; +#endif + pipe << " -sDEVICE=epswrite -sOutputFile="+null+" '" << psname << "'"; + iopipestream gs(pipe.str().c_str(),"gs","Ghostscript"); + stringstream buf; + while(true) { + string out; + gs >> out; + buf << out; + string s=buf.str(); + if(gs.tailequals(s.c_str(),s.size(),"E",1)) break; + } + if(verbose > 2) cout << endl; + + mem::vector<solvedKnot> nodes; + solvedKnot node; + bool cyclic=false; + bool active=false; + + pair offset; + while(!buf.eof()) { + char c; + buf >> c; + switch(c) { + case 'M': + { + if(active) { + if(cyclic) { + if(node.point == nodes[0].point) + nodes[0].pre=node.pre; + else { + pair delta=(nodes[0].point-node.point)*third; + node.post=node.point+delta; + nodes[0].pre=nodes[0].point-delta; + node.straight=true; + nodes.push_back(node); + } + } else { + node.post=node.point; + node.straight=false; + nodes.push_back(node); + } + P->push(path(nodes,nodes.size(),cyclic)); + nodes.clear(); + } + active=false; + cyclic=false; + node.pre=node.point=readpair(buf,tex)-offset; + node.straight=false; + break; + } + case 'L': + { + pair point=readpair(buf,tex)-offset; + pair delta=(point-node.point)*third; + node.post=node.point+delta; + node.straight=true; + nodes.push_back(node); + active=true; + node.pre=point-delta; + node.point=point; + break; + } + case 'C': + { + pair point=readpair(buf,tex)-offset; + pair pre=readpair(buf,tex)-offset; + node.post=readpair(buf,tex)-offset; + node.straight=false; + nodes.push_back(node); + active=true; + node.pre=pre; + node.point=point; + break; + } + case 'c': + { + cyclic=true; + break; + } + case 'Z': + { + offset=readpair(buf,tex); + break; + } + } + } + + if(!keep) + unlink(psname.c_str()); + return P; +} + +pair sin(pair z) +{ + return pair(sin(z.getx())*cosh(z.gety()),cos(z.getx())*sinh(z.gety())); +} + +pair exp(pair z) +{ + return exp(z.getx())*expi(z.gety()); +} + +pair gamma(pair z) +{ + static double p[]={0.99999999999980993,676.5203681218851,-1259.1392167224028, + 771.32342877765313,-176.61502916214059,12.507343278686905, + -0.13857109526572012,9.9843695780195716e-6, + 1.5056327351493116e-7}; + static int n=sizeof(p)/sizeof(double); + static double root2pi=sqrt(2*PI); + if(z.getx() < 0.5) + return PI/(sin(PI*z)*gamma(1.0-z)); + z -= 1.0; + pair x=p[0]; + for(int i=1; i < n; ++i) + x += p[i]/(z+i); + pair t=n-1.5+z; + return root2pi*pow(t,z+0.5)*exp(-t)*x; +} + +// Autogenerated routines: + + + +namespace run { + +// Initializers +#line 1026 "runtime.in" +void IntZero(stack *Stack) +{ +#line 1027 "runtime.in" + {Stack->push<Int>(0); return;} +} + +#line 1032 "runtime.in" +void realZero(stack *Stack) +{ +#line 1033 "runtime.in" + {Stack->push<real>(0.0); return;} +} + +#line 1037 "runtime.in" +void boolFalse(stack *Stack) +{ +#line 1038 "runtime.in" + {Stack->push<bool>(false); return;} +} + +#line 1042 "runtime.in" +void pushNullArray(stack *Stack) +{ +#line 1043 "runtime.in" + {Stack->push<array*>(0); return;} +} + +#line 1047 "runtime.in" +void pushNullRecord(stack *Stack) +{ +#line 1048 "runtime.in" + {Stack->push<frame*>(0); return;} +} + +#line 1052 "runtime.in" +void pushNullFunction(stack *Stack) +{ +#line 1053 "runtime.in" + {Stack->push(nullfunc::instance()); return;} +} + + +// Default operations + +// Put the default value token on the stack (in place of an argument when +// making a function call). +#line 1062 "runtime.in" +void pushDefault(stack *Stack) +{ +#line 1063 "runtime.in" + {Stack->push(def); return;} +} + + +// Test if the value on the stack is the default value token. +#line 1069 "runtime.in" +void isDefault(stack *Stack) +{ + item i=vm::pop(Stack); +#line 1070 "runtime.in" + {Stack->push<bool>(isdefault(i)); return;} +} + + +// Logical operations +#line 1076 "runtime.in" +// bool !(bool b); +void gen8(stack *Stack) +{ + bool b=vm::pop<bool>(Stack); +#line 1077 "runtime.in" + {Stack->push<bool>(!b); return;} +} + +#line 1082 "runtime.in" +void boolMemEq(stack *Stack) +{ + frame * b=vm::pop<frame *>(Stack); + frame * a=vm::pop<frame *>(Stack); +#line 1083 "runtime.in" + {Stack->push<bool>(a == b); return;} +} + +#line 1087 "runtime.in" +void boolMemNeq(stack *Stack) +{ + frame * b=vm::pop<frame *>(Stack); + frame * a=vm::pop<frame *>(Stack); +#line 1088 "runtime.in" + {Stack->push<bool>(a != b); return;} +} + +#line 1092 "runtime.in" +void boolFuncEq(stack *Stack) +{ + callable * b=vm::pop<callable *>(Stack); + callable * a=vm::pop<callable *>(Stack); +#line 1093 "runtime.in" + {Stack->push<bool>(a->compare(b)); return;} +} + +#line 1097 "runtime.in" +void boolFuncNeq(stack *Stack) +{ + callable * b=vm::pop<callable *>(Stack); + callable * a=vm::pop<callable *>(Stack); +#line 1098 "runtime.in" + {Stack->push<bool>(!(a->compare(b))); return;} +} + + +// Bit operations +#line 1104 "runtime.in" +// Int AND(Int a, Int b); +void gen13(stack *Stack) +{ + Int b=vm::pop<Int>(Stack); + Int a=vm::pop<Int>(Stack); +#line 1105 "runtime.in" + {Stack->push<Int>(a & b); return;} +} + +#line 1110 "runtime.in" +// Int OR(Int a, Int b); +void gen14(stack *Stack) +{ + Int b=vm::pop<Int>(Stack); + Int a=vm::pop<Int>(Stack); +#line 1111 "runtime.in" + {Stack->push<Int>(a | b); return;} +} + +#line 1115 "runtime.in" +// Int XOR(Int a, Int b); +void gen15(stack *Stack) +{ + Int b=vm::pop<Int>(Stack); + Int a=vm::pop<Int>(Stack); +#line 1116 "runtime.in" + {Stack->push<Int>(a ^ b); return;} +} + +#line 1120 "runtime.in" +// Int NOT(Int a); +void gen16(stack *Stack) +{ + Int a=vm::pop<Int>(Stack); +#line 1121 "runtime.in" + {Stack->push<Int>(~a); return;} +} + + +// Casts +#line 1127 "runtime.in" +void pairToGuide(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 1128 "runtime.in" + {Stack->push<guide*>(new pairguide(z)); return;} +} + +#line 1133 "runtime.in" +void pathToGuide(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 1134 "runtime.in" + {Stack->push<guide*>(new pathguide(p)); return;} +} + +#line 1138 "runtime.in" +void guideToPath(stack *Stack) +{ + guide * g=vm::pop<guide *>(Stack); +#line 1139 "runtime.in" + {Stack->push<path>(g->solve()); return;} +} + + +// Picture operations +#line 1145 "runtime.in" +void newPicture(stack *Stack) +{ +#line 1146 "runtime.in" + {Stack->push<picture*>(new picture()); return;} +} + +#line 1151 "runtime.in" +// bool empty(picture *f); +void gen21(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1152 "runtime.in" + {Stack->push<bool>(f->null()); return;} +} + +#line 1156 "runtime.in" +// void erase(picture *f); +void gen22(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1157 "runtime.in" + f->nodes.clear(); +} + +#line 1161 "runtime.in" +// pair min(picture *f); +void gen23(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1162 "runtime.in" + {Stack->push<pair>(f->bounds().Min()); return;} +} + +#line 1166 "runtime.in" +// pair max(picture *f); +void gen24(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1167 "runtime.in" + {Stack->push<pair>(f->bounds().Max()); return;} +} + +#line 1171 "runtime.in" +// void label(picture *f, string *s, string *size, transform t, pair position, pair align, pen p); +void gen25(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); + pair align=vm::pop<pair>(Stack); + pair position=vm::pop<pair>(Stack); + transform t=vm::pop<transform>(Stack); + string * size=vm::pop<string *>(Stack); + string * s=vm::pop<string *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1173 "runtime.in" + f->append(new drawLabel(*s,*size,t,position,align,p)); +} + +#line 1177 "runtime.in" +// bool labels(picture *f); +void gen26(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1178 "runtime.in" + {Stack->push<bool>(f->havelabels()); return;} +} + +#line 1182 "runtime.in" +// patharray* _texpath(string *s, pen p=CURRENTPEN); +void gen27(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); + string * s=vm::pop<string *>(Stack); +#line 1183 "runtime.in" + array *P=new array(0); + if(s->empty()) {Stack->push<patharray*>(P); return;} + + string prefix=outname(); + spaceToUnderscore(prefix); + string psname=auxname(prefix,"ps"); + + string texname=auxname(prefix,"tex"); + string dviname=auxname(prefix,"dvi"); + bbox b; + texfile tex(texname,b,true); + tex.miniprologue(); + + tex.setfont(p); + tex.verbatimline("\\special{ps:"); + tex.verbatimline(ASYo); + tex.verbatimline("/ASY1 true def"); + tex.verbatimline("/v {neg exch 4 copy 4 2 roll 2 copy 6 2 roll 2 copy (M) print ASYo ASYo (L) print ASYo add ASYo (L) print add ASYo add ASYo (L) print add ASYo ASYo (c) print} bind def"); + tex.verbatimline("/show {ASY1 {(Z) "+currentpoint+ + "/ASY1 false def} if currentpoint newpath moveto false charpath "+ + pathforall+"} bind def}"); + tex.verbatim(*s); + tex.verbatimline("\\special{ps: (E) print}"); + tex.epilogue(true); + tex.close(); + + ostringstream cmd; + string aux=auxname(prefix,"aux"); + unlink(aux.c_str()); + cmd << texprogram(true) << " \\nonstopmode\\input '" << texname << "'"; + bool quiet=verbose <= 2; + int status=System(cmd,quiet ? 1 : 0,"texpath",texpathmessage()); + if(!status && getSetting<bool>("twice")) + status=System(cmd,quiet ? 1 : 0,"texpath",texpathmessage()); + if(status) { + if(quiet) { + ostringstream cmd; + cmd << texprogram(true) << " \\scrollmode\\input '" << texname << "'"; + System(cmd,0); + } + } + + if(!status) { + ostringstream cmd; + cmd << "'" << getSetting<string>("dvips") << "' -R -Pdownload35 -D600 " + << getSetting<string>("dvipsOptions"); + if(verbose <= 2) cmd << " -q"; + cmd << " -o '" << psname << "' '" << dviname << "'"; + status=System(cmd,0,true,"dvips"); + } + + if(status != 0) + error("texpath failed"); + + bool keep=getSetting<bool>("keep"); + if(!keep) { // Delete temporary files. + unlink(texname.c_str()); + if(!getSetting<bool>("keepaux")) + unlink(aux.c_str()); + unlink(auxname(prefix,"log").c_str()); + unlink(dviname.c_str()); + } + {Stack->push<patharray*>(readpath(psname,true,keep)); return;} +} + +#line 1249 "runtime.in" +// patharray* _strokepath(path g, pen p=CURRENTPEN); +void gen28(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); + path g=vm::pop<path>(Stack); +#line 1250 "runtime.in" + array *P=new array(0); + if(g.size() == 0) {Stack->push<patharray*>(P); return;} + + string prefix=outname(); + spaceToUnderscore(prefix); + string psname=auxname(prefix,"ps"); + bbox b; + psfile ps(psname, false); + ps.prologue(b); + ps.verbatimline(ASYo); + ps.verbatimline("/stroke {(Z) "+currentpoint+pathforall+"} bind def"); + ps.resetpen(); + ps.setpen(p); + ps.write(g); + ps.strokepath(); + ps.stroke(); + ps.verbatimline("(M) "+currentpoint+"(E) print"); + ps.epilogue(); + ps.close(); + {Stack->push<patharray*>(readpath(psname,false,getSetting<bool>("keep"))); return;} +} + +#line 1273 "runtime.in" +// void _draw(picture *f, path g, pen p); +void gen29(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); + path g=vm::pop<path>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1274 "runtime.in" + f->append(new drawPath(g,p)); +} + +#line 1278 "runtime.in" +// void fill(picture *f, patharray *g, pen p=CURRENTPEN, bool copy=true); +void gen30(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + pen p=vm::pop<pen>(Stack,CURRENTPEN); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1279 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + f->append(new drawFill(*copyarray(g),false,p)); +} + +#line 1284 "runtime.in" +// void latticeshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray2 *p, bool copy=true); +void gen31(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + penarray2 * p=vm::pop<penarray2 *>(Stack); + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1286 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + f->append(new drawLatticeShade(*copyarray(g),stroke,fillrule,*copyarray(p))); +} + +#line 1291 "runtime.in" +// void axialshade(picture *f, patharray *g, bool stroke=false, pen pena, pair a, pen penb, pair b, bool copy=true); +void gen32(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + pair b=vm::pop<pair>(Stack); + pen penb=vm::pop<pen>(Stack); + pair a=vm::pop<pair>(Stack); + pen pena=vm::pop<pen>(Stack); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1293 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + f->append(new drawAxialShade(*copyarray(g),stroke,pena,a,penb,b)); +} + +#line 1298 "runtime.in" +// void radialshade(picture *f, patharray *g, bool stroke=false, pen pena, pair a, real ra, pen penb, pair b, real rb, bool copy=true); +void gen33(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + real rb=vm::pop<real>(Stack); + pair b=vm::pop<pair>(Stack); + pen penb=vm::pop<pen>(Stack); + real ra=vm::pop<real>(Stack); + pair a=vm::pop<pair>(Stack); + pen pena=vm::pop<pen>(Stack); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1300 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + f->append(new drawRadialShade(*copyarray(g),stroke,pena,a,ra,penb,b,rb)); +} + +#line 1305 "runtime.in" +// void gouraudshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray *p, pairarray *z, Intarray *edges, bool copy=true); +void gen34(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + Intarray * edges=vm::pop<Intarray *>(Stack); + pairarray * z=vm::pop<pairarray *>(Stack); + penarray * p=vm::pop<penarray *>(Stack); + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1308 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + checkArrays(p,z); + checkArrays(z,edges); + f->append(new drawGouraudShade(*copyarray(g),stroke,fillrule,*copyarray(p), + *copyarray(z),*copyarray(edges))); +} + +#line 1316 "runtime.in" +// void gouraudshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray *p, Intarray *edges, bool copy=true); +void gen35(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + Intarray * edges=vm::pop<Intarray *>(Stack); + penarray * p=vm::pop<penarray *>(Stack); + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1319 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + size_t n=checkArrays(p,edges); + size_t m=checkArray(g); + array *z=new array(n); + Int k=0; + Int in=(Int) n; + for(size_t j=0; j < m; ++j) { + path *P=read<path *>(g,j); + assert(P); + Int stop=Min(P->size(),in-k); + mem::vector<solvedKnot>& nodes=P->Nodes(); + for(Int i=0; i < stop; ++i) + (*z)[k++]=nodes[i].point; + } + checkArrays(p,z); + + f->append(new drawGouraudShade(*copyarray(g),stroke,fillrule,*copyarray(p), + *z,*copyarray(edges))); +} + +#line 1340 "runtime.in" +// void tensorshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray2 *p, patharray *b=NULL, pairarray2 *z=emptyarray, bool copy=true); +void gen36(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + pairarray2 * z=vm::pop<pairarray2 *>(Stack,emptyarray); + patharray * b=vm::pop<patharray *>(Stack,NULL); + penarray2 * p=vm::pop<penarray2 *>(Stack); + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1343 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + array *(*copyarray2)(array *a)=copy ? copyArray2: nop; + if(b == NULL) b=g; + size_t n=checkArrays(p,b); + size_t nz=checkArray(z); + if(nz != 0) + checkEqual(nz,n); + f->append(new drawTensorShade(*copyarray(g),stroke,fillrule,*copyarray2(p), + *copyarray(b),*copyarray2(z))); +} + +#line 1355 "runtime.in" +// void functionshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, string shader=emptystring, bool copy=true); +void gen37(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + string shader=vm::pop<string>(Stack,emptystring); + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1358 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + f->append(new drawFunctionShade(*copyarray(g),stroke,fillrule,shader)); +} + +// Clip a picture to a superpath using the given fill rule. +// Subsequent additions to the picture will not be affected by the clipping. +#line 1365 "runtime.in" +// void clip(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, bool copy=true); +void gen38(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1367 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + drawClipBegin *begin=new drawClipBegin(*copyarray(g),stroke,fillrule,true); + f->enclose(begin,new drawClipEnd(true,begin)); +} + +#line 1373 "runtime.in" +// void beginclip(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, bool copy=true); +void gen39(stack *Stack) +{ + bool copy=vm::pop<bool>(Stack,true); + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + bool stroke=vm::pop<bool>(Stack,false); + patharray * g=vm::pop<patharray *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1375 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + f->append(new drawClipBegin(*copyarray(g),stroke,fillrule,false)); +} + +#line 1380 "runtime.in" +// void endclip(picture *f); +void gen40(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1381 "runtime.in" + f->append(new drawClipEnd(false)); +} + +#line 1385 "runtime.in" +// void gsave(picture *f); +void gen41(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1386 "runtime.in" + f->append(new drawGsave()); +} + +#line 1390 "runtime.in" +// void grestore(picture *f); +void gen42(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1391 "runtime.in" + f->append(new drawGrestore()); +} + +#line 1395 "runtime.in" +// void begingroup(picture *f); +void gen43(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1396 "runtime.in" + f->append(new drawBegin()); +} + +#line 1400 "runtime.in" +// void endgroup(picture *f); +void gen44(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1401 "runtime.in" + f->append(new drawEnd()); +} + +#line 1405 "runtime.in" +// void add(picture *dest, picture *src); +void gen45(stack *Stack) +{ + picture * src=vm::pop<picture *>(Stack); + picture * dest=vm::pop<picture *>(Stack); +#line 1406 "runtime.in" + dest->add(*src); +} + +#line 1410 "runtime.in" +// void prepend(picture *dest, picture *src); +void gen46(stack *Stack) +{ + picture * src=vm::pop<picture *>(Stack); + picture * dest=vm::pop<picture *>(Stack); +#line 1411 "runtime.in" + dest->prepend(*src); +} + +#line 1415 "runtime.in" +// void postscript(picture *f, string s); +void gen47(stack *Stack) +{ + string s=vm::pop<string>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1416 "runtime.in" + f->append(new drawVerbatim(PostScript,s)); +} + +#line 1420 "runtime.in" +// void tex(picture *f, string s); +void gen48(stack *Stack) +{ + string s=vm::pop<string>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1421 "runtime.in" + f->append(new drawVerbatim(TeX,s)); +} + +#line 1425 "runtime.in" +// void postscript(picture *f, string s, pair min, pair max); +void gen49(stack *Stack) +{ + pair max=vm::pop<pair>(Stack); + pair min=vm::pop<pair>(Stack); + string s=vm::pop<string>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1426 "runtime.in" + f->append(new drawVerbatim(PostScript,s,min,max)); +} + +#line 1430 "runtime.in" +// void tex(picture *f, string s, pair min, pair max); +void gen50(stack *Stack) +{ + pair max=vm::pop<pair>(Stack); + pair min=vm::pop<pair>(Stack); + string s=vm::pop<string>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1431 "runtime.in" + f->append(new drawVerbatim(TeX,s,min,max)); +} + +#line 1435 "runtime.in" +// void texpreamble(string s); +void gen51(stack *Stack) +{ + string s=vm::pop<string>(Stack); +#line 1436 "runtime.in" + string t=s+"\n"; + processDataStruct &pd=processData(); + pd.TeXpipepreamble.push_back(t); + pd.TeXpreamble.push_back(t); +} + +#line 1443 "runtime.in" +// void deletepreamble(); +void gen52(stack *) +{ +#line 1444 "runtime.in" + if(getSetting<bool>("inlinetex")) { + unlink(auxname(outname(),"pre").c_str()); + } +} + +#line 1450 "runtime.in" +// void _labelpath(picture *f, string s, string size, path g, string justify, pair offset, pen p); +void gen53(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); + pair offset=vm::pop<pair>(Stack); + string justify=vm::pop<string>(Stack); + path g=vm::pop<path>(Stack); + string size=vm::pop<string>(Stack); + string s=vm::pop<string>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1452 "runtime.in" + f->append(new drawLabelPath(s,size,g,justify,offset,p)); +} + +#line 1456 "runtime.in" +// void texreset(); +void gen54(stack *) +{ +#line 1457 "runtime.in" + processDataStruct &pd=processData(); + pd.TeXpipepreamble.clear(); + pd.TeXpreamble.clear(); + pd.tex.pipeclose(); +} + +#line 1464 "runtime.in" +// void layer(picture *f); +void gen55(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1465 "runtime.in" + f->append(new drawLayer()); +} + +#line 1469 "runtime.in" +// void newpage(picture *f); +void gen56(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 1470 "runtime.in" + f->append(new drawNewPage()); +} + +#line 1474 "runtime.in" +// void _image(picture *f, realarray2 *data, pair initial, pair final, penarray *palette=NULL, transform t=identity, bool copy=true, bool antialias=false); +void gen57(stack *Stack) +{ + bool antialias=vm::pop<bool>(Stack,false); + bool copy=vm::pop<bool>(Stack,true); + transform t=vm::pop<transform>(Stack,identity); + penarray * palette=vm::pop<penarray *>(Stack,NULL); + pair final=vm::pop<pair>(Stack); + pair initial=vm::pop<pair>(Stack); + realarray2 * data=vm::pop<realarray2 *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1477 "runtime.in" + array *(*copyarray)(array *a)=copy ? copyArray: nop; + array *(*copyarray2)(array *a)=copy ? copyArray2: nop; + f->append(new drawImage(*copyarray2(data),*copyarray(palette), + t*matrix(initial,final),antialias)); +} + +#line 1484 "runtime.in" +// void _image(picture *f, penarray2 *data, pair initial, pair final, transform t=identity, bool copy=true, bool antialias=false); +void gen58(stack *Stack) +{ + bool antialias=vm::pop<bool>(Stack,false); + bool copy=vm::pop<bool>(Stack,true); + transform t=vm::pop<transform>(Stack,identity); + pair final=vm::pop<pair>(Stack); + pair initial=vm::pop<pair>(Stack); + penarray2 * data=vm::pop<penarray2 *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 1486 "runtime.in" + array *(*copyarray2)(array *a)=copy ? copyArray2: nop; + f->append(new drawImage(*copyarray2(data),t*matrix(initial,final),antialias)); +} + +#line 1491 "runtime.in" +// string nativeformat(); +void gen59(stack *Stack) +{ +#line 1492 "runtime.in" + {Stack->push<string>(nativeformat()); return;} +} + +#line 1496 "runtime.in" +// bool latex(); +void gen60(stack *Stack) +{ +#line 1497 "runtime.in" + {Stack->push<bool>(latex(getSetting<string>("tex"))); return;} +} + +#line 1501 "runtime.in" +// bool pdf(); +void gen61(stack *Stack) +{ +#line 1502 "runtime.in" + {Stack->push<bool>(pdf(getSetting<string>("tex"))); return;} +} + +#line 1506 "runtime.in" +// void shipout(string prefix=emptystring, picture *f, picture *preamble=NULL, string format=emptystring, bool wait=false, bool view=true, callableTransform *xform); +void gen62(stack *Stack) +{ + callableTransform * xform=vm::pop<callableTransform *>(Stack); + bool view=vm::pop<bool>(Stack,true); + bool wait=vm::pop<bool>(Stack,false); + string format=vm::pop<string>(Stack,emptystring); + picture * preamble=vm::pop<picture *>(Stack,NULL); + picture * f=vm::pop<picture *>(Stack); + string prefix=vm::pop<string>(Stack,emptystring); +#line 1509 "runtime.in" + if(prefix.empty()) prefix=outname(); + + picture *result=new picture; + unsigned level=0; + picture::nodelist::iterator p; + for(p = f->nodes.begin(); p != f->nodes.end(); ++p) { + xform->call(Stack); + transform t=pop<transform>(Stack); + static transform Zero=transform(0.0,0.0,0.0,0.0,0.0,0.0); + bool Delete=(t == Zero); + picture *group=new picture; + assert(*p); + if((*p)->endgroup()) error(nobegin); + if((*p)->begingroup()) { + ++level; + while(p != f->nodes.end() && level) { + if(!Delete) { + drawElement *e=t.isIdentity() ? *p : (*p)->transformed(t); + group->append(e); + } + ++p; + if(p == f->nodes.end()) break; + assert(*p); + if((*p)->begingroup()) ++level; + if((*p)->endgroup()) { + if(level) --level; + else error(nobegin); + } + } + } + if(p == f->nodes.end()) break; + assert(*p); + if(!Delete) { + drawElement *e=t.isIdentity() ? *p : (*p)->transformed(t); + group->append(e); + result->add(*group); + } + } + + result->shipout(preamble,prefix,format,0.0,wait,view); +} + +#line 1552 "runtime.in" +// void shipout3(string prefix, picture *f, string format=emptystring, real width, real height, real angle, triple m, triple M, realarray2 *t, triplearray *lights, realarray2 *diffuse, realarray2 *ambient, realarray2 *specular, bool viewportlighting, bool view=true); +void gen63(stack *Stack) +{ + bool view=vm::pop<bool>(Stack,true); + bool viewportlighting=vm::pop<bool>(Stack); + realarray2 * specular=vm::pop<realarray2 *>(Stack); + realarray2 * ambient=vm::pop<realarray2 *>(Stack); + realarray2 * diffuse=vm::pop<realarray2 *>(Stack); + triplearray * lights=vm::pop<triplearray *>(Stack); + realarray2 * t=vm::pop<realarray2 *>(Stack); + triple M=vm::pop<triple>(Stack); + triple m=vm::pop<triple>(Stack); + real angle=vm::pop<real>(Stack); + real height=vm::pop<real>(Stack); + real width=vm::pop<real>(Stack); + string format=vm::pop<string>(Stack,emptystring); + picture * f=vm::pop<picture *>(Stack); + string prefix=vm::pop<string>(Stack); +#line 1557 "runtime.in" + size_t n=checkArrays(lights,diffuse); + checkEqual(n,checkArray(ambient)); + checkEqual(n,checkArray(specular)); + + f->shipout3(prefix,format,width,height,angle,m,M,copyArray2C(t,true,4),n, + copyTripleArrayC(lights),copyArray2C(diffuse,false,4), + copyArray2C(ambient,false,4),copyArray2C(specular,false,4), + viewportlighting,view); +} + +#line 1568 "runtime.in" +// void shipout3(string prefix, picture *f); +void gen64(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); + string prefix=vm::pop<string>(Stack); +#line 1569 "runtime.in" + f->shipout3(prefix); +} + +#line 1573 "runtime.in" +// void deconstruct(picture *f, picture *preamble=NULL, real magnification=1, callableTransform *xform); +void gen65(stack *Stack) +{ + callableTransform * xform=vm::pop<callableTransform *>(Stack); + real magnification=vm::pop<real>(Stack,1); + picture * preamble=vm::pop<picture *>(Stack,NULL); + picture * f=vm::pop<picture *>(Stack); +#line 1575 "runtime.in" + unsigned level=0; + unsigned n=0; + + string prefix=outname(); + string xformat=getSetting<string>("xformat"); + + static long arg_max=sysconf(_SC_ARG_MAX); + const unsigned maxargs=::min(arg_max/(prefix.size()+xformat.size()+25ul), + 256ul); + + cout << xformat << newl; + cout << maxargs << newl; + + string preformat=nativeformat(); + const string Done="Done"; + const string Error="Error"; + + ostringstream cmd; + + // Enforce ghostscript limitations. + magnification=::max(magnification,0.0001); + real res=::min(::max(magnification*72.0,2.0),8192.0); + + const char *converter=NULL, *hint=NULL; + + bool png=xformat == "png"; + + if(magnification > 0.0) { + mem::list<string> nameStack; + string outname; + unsigned arg=0; + unsigned batch=0; + for(picture::nodelist::iterator p=f->nodes.begin();;) { + if(p == f->nodes.end()) break; + if(arg == 0) { + cmd.str(""); + ostringstream buf; + buf << batch << "_"; + outname=buildname(prefix+buf.str()+"%d",xformat,""); + if(png) { + cmd << "'" << getSetting<string>("gs") + << "' -q -dNOPAUSE -dBATCH -sDEVICE=pngalpha -dEPSCrop"; + if(safe) + cmd << " -dSAFER"; + cmd << " -r" << res << "x" << res + << " -sOutputFile='" << outname << "'"; + converter="gs"; + hint="Ghostscript"; + } else { + cmd << "'" << getSetting<string>("convert") + << "' -density " << res << "x" << res + << " -transparent white"; + hint=converter="convert"; + } + } + + picture *group=new picture; + xform->call(Stack); + transform t=pop<transform>(Stack); + assert(*p); + if((*p)->endgroup()) { + cout << Error << endl; + error(nobegin); + } + if((*p)->begingroup()) { + ++level; + while(p != f->nodes.end() && level) { + drawElement *e=t.isIdentity() ? *p : (*p)->transformed(t); + group->append(e); + ++p; + if(p == f->nodes.end()) break; + assert(*p); + if((*p)->begingroup()) ++level; + if((*p)->endgroup()) { + if(level) --level; + else { + cout << Error << endl; + error(nobegin); + } + } + } + } + if(p != f->nodes.end()) { + assert(*p); + drawElement *e=t.isIdentity() ? *p : (*p)->transformed(t); + group->append(e); + bbox b; + ostringstream buf; + buf << prefix << "_" << n; + group->shipout(preamble,buf.str(),preformat,magnification,false,false); + string Preformat=png && group->Transparency() ? "pdf" : preformat; + string name=buildname(buf.str(),Preformat); + nameStack.push_back(name); + cmd << " '"; + if(!png) cmd << preformat+":"; + cmd << name << "'"; + b=group->bounds(); + b *= magnification; + + cout << b << newl; + ++n; + ++p; + ++arg; + } + + if(p == f->nodes.end() || arg >= maxargs) { + arg=0; + ++batch; + cout.flush(); + if(!png) + cmd << " -scene 1 '" << xformat << ":" << outname << "'"; + + int status=System(cmd,0,true,converter,hint); + if(status) { + cout << Error << endl; + error("deconstruct failed"); + } + } + } + + if(!getSetting<bool>("keep")) { + for(mem::list<string>::iterator p=nameStack.begin(); + p != nameStack.end(); ++p) + unlink(p->c_str()); + } + + cout << Done << endl; + } +} + +#line 1706 "runtime.in" +// void purge(Int divisor=0); +void gen66(stack *Stack) +{ + Int divisor=vm::pop<Int>(Stack,0); +#line 1707 "runtime.in" + purge(divisor); +} + + +// Pen operations +#line 1713 "runtime.in" +void newPen(stack *Stack) +{ +#line 1714 "runtime.in" + {Stack->push<pen>(pen()); return;} +} + +#line 1719 "runtime.in" +// bool ==(pen a, pen b); +void gen68(stack *Stack) +{ + pen b=vm::pop<pen>(Stack); + pen a=vm::pop<pen>(Stack); +#line 1720 "runtime.in" + {Stack->push<bool>(a == b); return;} +} + +#line 1724 "runtime.in" +// bool !=(pen a, pen b); +void gen69(stack *Stack) +{ + pen b=vm::pop<pen>(Stack); + pen a=vm::pop<pen>(Stack); +#line 1725 "runtime.in" + {Stack->push<bool>(a != b); return;} +} + +#line 1729 "runtime.in" +// pen +(pen a, pen b); +void gen70(stack *Stack) +{ + pen b=vm::pop<pen>(Stack); + pen a=vm::pop<pen>(Stack); +#line 1730 "runtime.in" + {Stack->push<pen>(a+b); return;} +} + +#line 1734 "runtime.in" +// pen *(real a, pen b); +void gen71(stack *Stack) +{ + pen b=vm::pop<pen>(Stack); + real a=vm::pop<real>(Stack); +#line 1735 "runtime.in" + {Stack->push<pen>(a*b); return;} +} + +#line 1739 "runtime.in" +// pen *(pen a, real b); +void gen72(stack *Stack) +{ + real b=vm::pop<real>(Stack); + pen a=vm::pop<pen>(Stack); +#line 1740 "runtime.in" + {Stack->push<pen>(b*a); return;} +} + +#line 1744 "runtime.in" +// pair max(pen p); +void gen73(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1745 "runtime.in" + {Stack->push<pair>(p.bounds().Max()); return;} +} + +#line 1749 "runtime.in" +// pair min(pen p); +void gen74(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1750 "runtime.in" + {Stack->push<pair>(p.bounds().Min()); return;} +} + +// Reset the meaning of pen default attributes. +#line 1755 "runtime.in" +// void resetdefaultpen(); +void gen75(stack *) +{ +#line 1756 "runtime.in" + processData().defaultpen=camp::pen::initialpen(); +} + +#line 1760 "runtime.in" +// void defaultpen(pen p); +void gen76(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1761 "runtime.in" + processData().defaultpen=pen(resolvepen,p); +} + +#line 1765 "runtime.in" +// pen defaultpen(); +void gen77(stack *Stack) +{ +#line 1766 "runtime.in" + {Stack->push<pen>(processData().defaultpen); return;} +} + +#line 1770 "runtime.in" +// bool invisible(pen p); +void gen78(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1771 "runtime.in" + {Stack->push<bool>(p.invisible()); return;} +} + +#line 1775 "runtime.in" +// pen invisible(); +void gen79(stack *Stack) +{ +#line 1776 "runtime.in" + {Stack->push<pen>(pen(invisiblepen)); return;} +} + +#line 1780 "runtime.in" +// pen gray(pen p); +void gen80(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1781 "runtime.in" + p.togrey(); + {Stack->push<pen>(p); return;} +} + +#line 1786 "runtime.in" +// pen rgb(pen p); +void gen81(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1787 "runtime.in" + p.torgb(); + {Stack->push<pen>(p); return;} +} + +#line 1792 "runtime.in" +// pen cmyk(pen p); +void gen82(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1793 "runtime.in" + p.tocmyk(); + {Stack->push<pen>(p); return;} +} + +#line 1798 "runtime.in" +// pen interp(pen a, pen b, real t); +void gen83(stack *Stack) +{ + real t=vm::pop<real>(Stack); + pen b=vm::pop<pen>(Stack); + pen a=vm::pop<pen>(Stack); +#line 1799 "runtime.in" + {Stack->push<pen>(interpolate(a,b,t)); return;} +} + +#line 1803 "runtime.in" +// pen rgb(real r, real g, real b); +void gen84(stack *Stack) +{ + real b=vm::pop<real>(Stack); + real g=vm::pop<real>(Stack); + real r=vm::pop<real>(Stack); +#line 1804 "runtime.in" + {Stack->push<pen>(pen(r,g,b)); return;} +} + +#line 1808 "runtime.in" +// pen cmyk(real c, real m, real y, real k); +void gen85(stack *Stack) +{ + real k=vm::pop<real>(Stack); + real y=vm::pop<real>(Stack); + real m=vm::pop<real>(Stack); + real c=vm::pop<real>(Stack); +#line 1809 "runtime.in" + {Stack->push<pen>(pen(c,m,y,k)); return;} +} + +#line 1813 "runtime.in" +// pen gray(real gray); +void gen86(stack *Stack) +{ + real gray=vm::pop<real>(Stack); +#line 1814 "runtime.in" + {Stack->push<pen>(pen(gray)); return;} +} + +#line 1818 "runtime.in" +// realarray* colors(pen p); +void gen87(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1819 "runtime.in" + size_t n=ColorComponents[p.colorspace()]; + array *a=new array(n); + + switch(n) { + case 0: + break; + case 1: + (*a)[0]=p.gray(); + break; + case 3: + (*a)[0]=p.red(); + (*a)[1]=p.green(); + (*a)[2]=p.blue(); + break; + case 4: + (*a)[0]=p.cyan(); + (*a)[1]=p.magenta(); + (*a)[2]=p.yellow(); + (*a)[3]=p.black(); + break; + default: + break; + } + {Stack->push<realarray*>(a); return;} +} + +#line 1846 "runtime.in" +// string colorspace(pen p); +void gen88(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1847 "runtime.in" + string s=ColorDeviceSuffix[p.colorspace()]; + std::transform(s.begin(),s.end(),s.begin(),tolower); + {Stack->push<string>(s); return;} +} + +#line 1853 "runtime.in" +// pen pattern(string *s); +void gen89(stack *Stack) +{ + string * s=vm::pop<string *>(Stack); +#line 1854 "runtime.in" + {Stack->push<pen>(pen(setpattern,*s)); return;} +} + +#line 1858 "runtime.in" +// string pattern(pen p); +void gen90(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1859 "runtime.in" + {Stack->push<string>(p.fillpattern()); return;} +} + +#line 1863 "runtime.in" +// pen fillrule(Int n); +void gen91(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 1864 "runtime.in" + {Stack->push<pen>(pen(n >= 0 && n < nFill ? (FillRule) n : DEFFILL)); return;} +} + +#line 1868 "runtime.in" +// Int fillrule(pen p); +void gen92(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1869 "runtime.in" + {Stack->push<Int>(p.Fillrule()); return;} +} + +#line 1873 "runtime.in" +// pen opacity(real opacity=1.0, string blend=defaulttransparency); +void gen93(stack *Stack) +{ + string blend=vm::pop<string>(Stack,defaulttransparency); + real opacity=vm::pop<real>(Stack,1.0); +#line 1874 "runtime.in" + for(Int i=0; i < nBlendMode; ++i) + if(blend == BlendMode[i]) {Stack->push<pen>(pen(Transparency(blend,opacity))); return;} + + ostringstream buf; + buf << "Unknown blend mode: " << "'" << blend << "'"; + error(buf); +} + +#line 1883 "runtime.in" +// real opacity(pen p); +void gen94(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1884 "runtime.in" + {Stack->push<real>(p.opacity()); return;} +} + +#line 1888 "runtime.in" +// string blend(pen p); +void gen95(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1889 "runtime.in" + {Stack->push<string>(p.blend()); return;} +} + +#line 1893 "runtime.in" +// pen linetype(string *s, real offset=0, bool scale=true, bool adjust=true); +void gen96(stack *Stack) +{ + bool adjust=vm::pop<bool>(Stack,true); + bool scale=vm::pop<bool>(Stack,true); + real offset=vm::pop<real>(Stack,0); + string * s=vm::pop<string *>(Stack); +#line 1894 "runtime.in" + {Stack->push<pen>(pen(LineType(*s,offset,scale,adjust))); return;} +} + +#line 1898 "runtime.in" +// string linetype(pen p=CURRENTPEN); +void gen97(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1899 "runtime.in" + {Stack->push<string>(p.stroke()); return;} +} + +#line 1903 "runtime.in" +// real offset(pen p); +void gen98(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1904 "runtime.in" + {Stack->push<real>(p.linetype().offset); return;} +} + +#line 1908 "runtime.in" +// bool scale(pen p); +void gen99(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1909 "runtime.in" + {Stack->push<bool>(p.linetype().scale); return;} +} + +#line 1913 "runtime.in" +// bool adjust(pen p); +void gen100(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 1914 "runtime.in" + {Stack->push<bool>(p.linetype().adjust); return;} +} + +#line 1918 "runtime.in" +// pen adjust(pen p, real arclength, bool cyclic); +void gen101(stack *Stack) +{ + bool cyclic=vm::pop<bool>(Stack); + real arclength=vm::pop<real>(Stack); + pen p=vm::pop<pen>(Stack); +#line 1919 "runtime.in" + {Stack->push<pen>(adjustdash(p,arclength,cyclic)); return;} +} + +#line 1923 "runtime.in" +// pen linecap(Int n); +void gen102(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 1924 "runtime.in" + {Stack->push<pen>(pen(setlinecap,n >= 0 && n < nCap ? n : DEFCAP)); return;} +} + +#line 1928 "runtime.in" +// Int linecap(pen p=CURRENTPEN); +void gen103(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1929 "runtime.in" + {Stack->push<Int>(p.cap()); return;} +} + +#line 1933 "runtime.in" +// pen linejoin(Int n); +void gen104(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 1934 "runtime.in" + {Stack->push<pen>(pen(setlinejoin,n >= 0 && n < nJoin ? n : DEFJOIN)); return;} +} + +#line 1938 "runtime.in" +// Int linejoin(pen p=CURRENTPEN); +void gen105(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1939 "runtime.in" + {Stack->push<Int>(p.join()); return;} +} + +#line 1943 "runtime.in" +// pen miterlimit(real x); +void gen106(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 1944 "runtime.in" + {Stack->push<pen>(pen(setmiterlimit,x >= 1.0 ? x : DEFJOIN)); return;} +} + +#line 1948 "runtime.in" +// real miterlimit(pen p=CURRENTPEN); +void gen107(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1949 "runtime.in" + {Stack->push<real>(p.miter()); return;} +} + +#line 1953 "runtime.in" +// pen linewidth(real x); +void gen108(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 1954 "runtime.in" + {Stack->push<pen>(pen(setlinewidth,x >= 0.0 ? x : DEFWIDTH)); return;} +} + +#line 1958 "runtime.in" +// real linewidth(pen p=CURRENTPEN); +void gen109(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1959 "runtime.in" + {Stack->push<real>(p.width()); return;} +} + +#line 1963 "runtime.in" +// pen fontcommand(string *s); +void gen110(stack *Stack) +{ + string * s=vm::pop<string *>(Stack); +#line 1964 "runtime.in" + {Stack->push<pen>(pen(setfont,*s)); return;} +} + +#line 1968 "runtime.in" +// string font(pen p=CURRENTPEN); +void gen111(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1969 "runtime.in" + {Stack->push<string>(p.Font()); return;} +} + +#line 1973 "runtime.in" +// pen fontsize(real size, real lineskip); +void gen112(stack *Stack) +{ + real lineskip=vm::pop<real>(Stack); + real size=vm::pop<real>(Stack); +#line 1974 "runtime.in" + {Stack->push<pen>(pen(setfontsize,size > 0.0 ? size : 0.0, + lineskip > 0.0 ? lineskip : 0.0)); return;} +} + +#line 1979 "runtime.in" +// real fontsize(pen p=CURRENTPEN); +void gen113(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1980 "runtime.in" + {Stack->push<real>(p.size()); return;} +} + +#line 1984 "runtime.in" +// real lineskip(pen p=CURRENTPEN); +void gen114(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1985 "runtime.in" + {Stack->push<real>(p.Lineskip()); return;} +} + +#line 1989 "runtime.in" +// pen overwrite(Int n); +void gen115(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 1990 "runtime.in" + {Stack->push<pen>(pen(setoverwrite,n >= 0 && n < nOverwrite ? (overwrite_t) n : + DEFWRITE)); return;} +} + +#line 1995 "runtime.in" +// Int overwrite(pen p=CURRENTPEN); +void gen116(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 1996 "runtime.in" + {Stack->push<Int>(p.Overwrite()); return;} +} + +#line 2000 "runtime.in" +// pen basealign(Int n); +void gen117(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 2001 "runtime.in" + {Stack->push<pen>(pen(n >= 0 && n < nBaseLine ? (BaseLine) n : DEFBASE)); return;} +} + +#line 2005 "runtime.in" +// Int basealign(pen p=CURRENTPEN); +void gen118(stack *Stack) +{ + pen p=vm::pop<pen>(Stack,CURRENTPEN); +#line 2006 "runtime.in" + {Stack->push<Int>(p.Baseline()); return;} +} + +#line 2010 "runtime.in" +// transform transform(pen p); +void gen119(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 2011 "runtime.in" + {Stack->push<transform>(p.getTransform()); return;} +} + +#line 2015 "runtime.in" +// path nib(pen p); +void gen120(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 2016 "runtime.in" + {Stack->push<path>(p.Path()); return;} +} + +#line 2020 "runtime.in" +// pen makepen(path p); +void gen121(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2021 "runtime.in" + {Stack->push<pen>(pen(p)); return;} +} + +#line 2025 "runtime.in" +// pen colorless(pen p); +void gen122(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); +#line 2026 "runtime.in" + p.colorless(); + {Stack->push<pen>(p); return;} +} + +// Interactive mode +#line 2032 "runtime.in" +// bool interactive(); +void gen123(stack *Stack) +{ +#line 2033 "runtime.in" + {Stack->push<bool>(interact::interactive); return;} +} + +#line 2038 "runtime.in" +// bool uptodate(); +void gen124(stack *Stack) +{ +#line 2039 "runtime.in" + {Stack->push<bool>(interact::uptodate); return;} +} + + +// System commands +#line 2045 "runtime.in" +// Int system(string s); +void gen125(stack *Stack) +{ + string s=vm::pop<string>(Stack); +#line 2046 "runtime.in" + if(safe) error("system() call disabled; override with option -nosafe"); + if(s.empty()) {Stack->push<Int>(0); return;} + else {Stack->push<Int>(System(s.c_str())); return;} +} + +#line 2053 "runtime.in" +// bool view(); +void gen126(stack *Stack) +{ +#line 2054 "runtime.in" + {Stack->push<bool>(view()); return;} +} + +#line 2058 "runtime.in" +// string asydir(); +void gen127(stack *Stack) +{ +#line 2059 "runtime.in" + {Stack->push<string>(systemDir); return;} +} + +#line 2063 "runtime.in" +// string locale(string s=emptystring); +void gen128(stack *Stack) +{ + string s=vm::pop<string>(Stack,emptystring); +#line 2064 "runtime.in" + char *L=setlocale(LC_ALL,s.empty() ? NULL : s.c_str()); + {Stack->push<string>(L != NULL ? string(L) : ""); return;} +} + +#line 2069 "runtime.in" +// void abort(string s=emptystring); +void gen129(stack *Stack) +{ + string s=vm::pop<string>(Stack,emptystring); +#line 2070 "runtime.in" + if(s.empty()) throw handled_error(); + error(s.c_str()); +} + +#line 2075 "runtime.in" +// void exit(); +void gen130(stack *) +{ +#line 2076 "runtime.in" + throw quit(); +} + +#line 2080 "runtime.in" +// void assert(bool b, string s=emptystring); +void gen131(stack *Stack) +{ + string s=vm::pop<string>(Stack,emptystring); + bool b=vm::pop<bool>(Stack); +#line 2081 "runtime.in" + flush(cout); + if(!b) { + ostringstream buf; + buf << "assert FAILED"; + if(s != "") buf << ": " << s << endl; + error(buf); + } +} + +#line 2091 "runtime.in" +// void sleep(Int seconds); +void gen132(stack *Stack) +{ + Int seconds=vm::pop<Int>(Stack); +#line 2092 "runtime.in" + if(seconds <= 0) return; + sleep(seconds); +} + +#line 2097 "runtime.in" +// void usleep(Int microseconds); +void gen133(stack *Stack) +{ + Int microseconds=vm::pop<Int>(Stack); +#line 2098 "runtime.in" + if(microseconds <= 0) return; + usleep((unsigned long) microseconds); +} + +#line 2103 "runtime.in" +// void _eval(string *s, bool embedded, bool interactiveWrite=false); +void gen134(stack *Stack) +{ + bool interactiveWrite=vm::pop<bool>(Stack,false); + bool embedded=vm::pop<bool>(Stack); + string * s=vm::pop<string *>(Stack); +#line 2104 "runtime.in" + if (embedded) { + trans::coenv *e=Stack->getEnvironment(); + vm::interactiveStack *is=dynamic_cast<vm::interactiveStack *>(Stack); + if (e && is) { + runStringEmbedded(*s, *e, *is); + } else { + cerr << "no runtime environment for embedded eval" << endl; + } + } else { + runString(*s,interactiveWrite); + } +} + +#line 2118 "runtime.in" +// void _eval(runnable *s, bool embedded); +void gen135(stack *Stack) +{ + bool embedded=vm::pop<bool>(Stack); + runnable * s=vm::pop<runnable *>(Stack); +#line 2119 "runtime.in" + absyntax::block *ast=new absyntax::block(s->getPos(), false); + ast->add(s); + + if (embedded) { + trans::coenv *e=Stack->getEnvironment(); + vm::interactiveStack *is=dynamic_cast<vm::interactiveStack *>(Stack); + if (e && is) { + runCodeEmbedded(ast, *e, *is); + } else { + cerr << "no runtime environment for embedded eval" << endl; + } + } else { + runCode(ast); + } +} + +#line 2136 "runtime.in" +// string location(); +void gen136(stack *Stack) +{ +#line 2137 "runtime.in" + ostringstream buf; + buf << getPos(); + {Stack->push<string>(buf.str()); return;} +} + +// Wrapper for the stack::load() method. +#line 2143 "runtime.in" +void loadModule(stack *Stack) +{ + string * index=vm::pop<string *>(Stack); +#line 2144 "runtime.in" + Stack->load(*index); +} + +#line 2148 "runtime.in" +// string cd(string s=emptystring); +void gen138(stack *Stack) +{ + string s=vm::pop<string>(Stack,emptystring); +#line 2149 "runtime.in" + if(!s.empty() && !globalwrite()) writeDisabled(); + {Stack->push<string>(setPath(s.c_str())); return;} +} + +#line 2154 "runtime.in" +// void list(string *s, bool imports=false); +void gen139(stack *Stack) +{ + bool imports=vm::pop<bool>(Stack,false); + string * s=vm::pop<string *>(Stack); +#line 2155 "runtime.in" + if(*s == "-") return; + trans::genv ge; + symbol *name=symbol::trans(*s); + record *r=ge.getModule(name,*s); + r->e.list(imports ? 0 : r); +} + + +// Path operations +#line 2165 "runtime.in" +void nullPath(stack *Stack) +{ +#line 2166 "runtime.in" + {Stack->push<path>(nullpath); return;} +} + +#line 2171 "runtime.in" +// bool ==(path a, path b); +void gen141(stack *Stack) +{ + path b=vm::pop<path>(Stack); + path a=vm::pop<path>(Stack); +#line 2172 "runtime.in" + {Stack->push<bool>(a == b); return;} +} + +#line 2176 "runtime.in" +// bool !=(path a, path b); +void gen142(stack *Stack) +{ + path b=vm::pop<path>(Stack); + path a=vm::pop<path>(Stack); +#line 2177 "runtime.in" + {Stack->push<bool>(!(a == b)); return;} +} + +#line 2181 "runtime.in" +// pair point(path p, Int t); +void gen143(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path p=vm::pop<path>(Stack); +#line 2182 "runtime.in" + {Stack->push<pair>(p.point((Int) t)); return;} +} + +#line 2186 "runtime.in" +// pair point(path p, real t); +void gen144(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path p=vm::pop<path>(Stack); +#line 2187 "runtime.in" + {Stack->push<pair>(p.point(t)); return;} +} + +#line 2191 "runtime.in" +// pair precontrol(path p, Int t); +void gen145(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path p=vm::pop<path>(Stack); +#line 2192 "runtime.in" + {Stack->push<pair>(p.precontrol((Int) t)); return;} +} + +#line 2196 "runtime.in" +// pair precontrol(path p, real t); +void gen146(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path p=vm::pop<path>(Stack); +#line 2197 "runtime.in" + {Stack->push<pair>(p.precontrol(t)); return;} +} + +#line 2201 "runtime.in" +// pair postcontrol(path p, Int t); +void gen147(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path p=vm::pop<path>(Stack); +#line 2202 "runtime.in" + {Stack->push<pair>(p.postcontrol((Int) t)); return;} +} + +#line 2206 "runtime.in" +// pair postcontrol(path p, real t); +void gen148(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path p=vm::pop<path>(Stack); +#line 2207 "runtime.in" + {Stack->push<pair>(p.postcontrol(t)); return;} +} + +#line 2211 "runtime.in" +// pair dir(path p, Int t, Int sign=0, bool normalize=true); +void gen149(stack *Stack) +{ + bool normalize=vm::pop<bool>(Stack,true); + Int sign=vm::pop<Int>(Stack,0); + Int t=vm::pop<Int>(Stack); + path p=vm::pop<path>(Stack); +#line 2212 "runtime.in" + {Stack->push<pair>(p.dir(t,sign,normalize)); return;} +} + +#line 2216 "runtime.in" +// pair dir(path p, real t, bool normalize=true); +void gen150(stack *Stack) +{ + bool normalize=vm::pop<bool>(Stack,true); + real t=vm::pop<real>(Stack); + path p=vm::pop<path>(Stack); +#line 2217 "runtime.in" + {Stack->push<pair>(p.dir(t,normalize)); return;} +} + +#line 2221 "runtime.in" +// pair accel(path p, Int t, Int sign=0); +void gen151(stack *Stack) +{ + Int sign=vm::pop<Int>(Stack,0); + Int t=vm::pop<Int>(Stack); + path p=vm::pop<path>(Stack); +#line 2222 "runtime.in" + {Stack->push<pair>(p.accel(t,sign)); return;} +} + +#line 2226 "runtime.in" +// pair accel(path p, real t); +void gen152(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path p=vm::pop<path>(Stack); +#line 2227 "runtime.in" + {Stack->push<pair>(p.accel(t)); return;} +} + +#line 2231 "runtime.in" +// real radius(path p, real t); +void gen153(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path p=vm::pop<path>(Stack); +#line 2232 "runtime.in" + pair v=p.dir(t,false); + pair a=p.accel(t); + real d=dot(a,v); + real v2=v.abs2(); + real a2=a.abs2(); + real denom=v2*a2-d*d; + real r=v2*sqrt(v2); + {Stack->push<real>(denom > 0 ? r/sqrt(denom) : 0.0); return;} +} + +#line 2243 "runtime.in" +// path reverse(path p); +void gen154(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2244 "runtime.in" + {Stack->push<path>(p.reverse()); return;} +} + +#line 2248 "runtime.in" +// path subpath(path p, Int a, Int b); +void gen155(stack *Stack) +{ + Int b=vm::pop<Int>(Stack); + Int a=vm::pop<Int>(Stack); + path p=vm::pop<path>(Stack); +#line 2249 "runtime.in" + {Stack->push<path>(p.subpath((Int) a, (Int) b)); return;} +} + +#line 2253 "runtime.in" +// path subpath(path p, real a, real b); +void gen156(stack *Stack) +{ + real b=vm::pop<real>(Stack); + real a=vm::pop<real>(Stack); + path p=vm::pop<path>(Stack); +#line 2254 "runtime.in" + {Stack->push<path>(p.subpath(a,b)); return;} +} + +#line 2258 "runtime.in" +// path nurb(pair z0, pair z1, pair z2, pair z3, real w0, real w1, real w2, real w3, Int m); +void gen157(stack *Stack) +{ + Int m=vm::pop<Int>(Stack); + real w3=vm::pop<real>(Stack); + real w2=vm::pop<real>(Stack); + real w1=vm::pop<real>(Stack); + real w0=vm::pop<real>(Stack); + pair z3=vm::pop<pair>(Stack); + pair z2=vm::pop<pair>(Stack); + pair z1=vm::pop<pair>(Stack); + pair z0=vm::pop<pair>(Stack); +#line 2260 "runtime.in" + {Stack->push<path>(nurb(z0,z1,z2,z3,w0,w1,w2,w3,m)); return;} +} + +#line 2264 "runtime.in" +// Int length(path p); +void gen158(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2265 "runtime.in" + {Stack->push<Int>(p.length()); return;} +} + +#line 2269 "runtime.in" +// bool cyclic(path p); +void gen159(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2270 "runtime.in" + {Stack->push<bool>(p.cyclic()); return;} +} + +#line 2274 "runtime.in" +// bool straight(path p, Int t); +void gen160(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path p=vm::pop<path>(Stack); +#line 2275 "runtime.in" + {Stack->push<bool>(p.straight(t)); return;} +} + +#line 2279 "runtime.in" +// path unstraighten(path p); +void gen161(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2280 "runtime.in" + {Stack->push<path>(p.unstraighten()); return;} +} + +#line 2284 "runtime.in" +// bool piecewisestraight(path p); +void gen162(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2285 "runtime.in" + {Stack->push<bool>(p.piecewisestraight()); return;} +} + +#line 2289 "runtime.in" +// real arclength(path p); +void gen163(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2290 "runtime.in" + {Stack->push<real>(p.arclength()); return;} +} + +#line 2294 "runtime.in" +// real arctime(path p, real dval); +void gen164(stack *Stack) +{ + real dval=vm::pop<real>(Stack); + path p=vm::pop<path>(Stack); +#line 2295 "runtime.in" + {Stack->push<real>(p.arctime(dval)); return;} +} + +#line 2299 "runtime.in" +// real dirtime(path p, pair z); +void gen165(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); + path p=vm::pop<path>(Stack); +#line 2300 "runtime.in" + {Stack->push<real>(p.directiontime(z)); return;} +} + +#line 2304 "runtime.in" +// realarray* intersect(path p, path q, real fuzz=-1); +void gen166(stack *Stack) +{ + real fuzz=vm::pop<real>(Stack,-1); + path q=vm::pop<path>(Stack); + path p=vm::pop<path>(Stack); +#line 2305 "runtime.in" + bool exact=fuzz <= 0.0; + if(fuzz < 0) + fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())), + ::max(length(q.max()),length(q.min()))); + std::vector<real> S,T; + real s,t; + if(intersections(s,t,S,T,p,q,fuzz,true,exact)) { + array *V=new array(2); + (*V)[0]=s; + (*V)[1]=t; + {Stack->push<realarray*>(V); return;} + } else + {Stack->push<realarray*>(new array(0)); return;} +} + +#line 2321 "runtime.in" +// realarray2* intersections(path p, path q, real fuzz=-1); +void gen167(stack *Stack) +{ + real fuzz=vm::pop<real>(Stack,-1); + path q=vm::pop<path>(Stack); + path p=vm::pop<path>(Stack); +#line 2322 "runtime.in" + bool exact=fuzz <= 0.0; + if(fuzz < 0.0) + fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())), + ::max(length(q.max()),length(q.min()))); + real s,t; + std::vector<real> S,T; + intersections(s,t,S,T,p,q,fuzz,false,true); + size_t n=S.size(); + if(n == 0 && !exact) { + if(intersections(s,t,S,T,p,q,fuzz,true,false)) { + array *V=new array(1); + array *Vi=new array(2); + (*V)[0]=Vi; + (*Vi)[0]=s; + (*Vi)[1]=t; + {Stack->push<realarray2*>(V); return;} + } + } + array *V=new array(n); + for(size_t i=0; i < n; ++i) { + array *Vi=new array(2); + (*V)[i]=Vi; + (*Vi)[0]=S[i]; + (*Vi)[1]=T[i]; + } + stable_sort(V->begin(),V->end(),run::compare2<real>()); + {Stack->push<realarray2*>(V); return;} +} + +#line 2352 "runtime.in" +// realarray* intersections(path p, explicit pair a, explicit pair b, real fuzz=-1); +void gen168(stack *Stack) +{ + real fuzz=vm::pop<real>(Stack,-1); + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); + path p=vm::pop<path>(Stack); +#line 2353 "runtime.in" + if(fuzz < 0) + fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())), + ::max(length(a),length(b))); + std::vector<real> S; + intersections(S,p,a,b,fuzz); + sort(S.begin(),S.end()); + size_t n=S.size(); + array *V=new array(n); + for(size_t i=0; i < n; ++i) + (*V)[i]=S[i]; + {Stack->push<realarray*>(V); return;} +} + +// Return the intersection point of the extensions of the line segments +// PQ and pq. +#line 2369 "runtime.in" +// pair extension(pair P, pair Q, pair p, pair q); +void gen169(stack *Stack) +{ + pair q=vm::pop<pair>(Stack); + pair p=vm::pop<pair>(Stack); + pair Q=vm::pop<pair>(Stack); + pair P=vm::pop<pair>(Stack); +#line 2370 "runtime.in" + pair ac=P-Q; + pair bd=q-p; + real det=ac.getx()*bd.gety()-ac.gety()*bd.getx(); + if(det == 0) {Stack->push<pair>(pair(infinity,infinity)); return;} + {Stack->push<pair>(P+((p.getx()-P.getx())*bd.gety()-(p.gety()-P.gety())*bd.getx())*ac/det); return;} +} + +#line 2378 "runtime.in" +// Int size(path p); +void gen170(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2379 "runtime.in" + {Stack->push<Int>(p.size()); return;} +} + +#line 2383 "runtime.in" +// path &(path p, path q); +void gen171(stack *Stack) +{ + path q=vm::pop<path>(Stack); + path p=vm::pop<path>(Stack); +#line 2384 "runtime.in" + {Stack->push<path>(camp::concat(p,q)); return;} +} + +#line 2388 "runtime.in" +// pair min(path p); +void gen172(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2389 "runtime.in" + {Stack->push<pair>(p.min()); return;} +} + +#line 2393 "runtime.in" +// pair max(path p); +void gen173(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2394 "runtime.in" + {Stack->push<pair>(p.max()); return;} +} + +#line 2398 "runtime.in" +// realarray* mintimes(path p); +void gen174(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2399 "runtime.in" + array *V=new array(2); + pair z=p.mintimes(); + (*V)[0]=z.getx(); + (*V)[1]=z.gety(); + {Stack->push<realarray*>(V); return;} +} + +#line 2407 "runtime.in" +// realarray* maxtimes(path p); +void gen175(stack *Stack) +{ + path p=vm::pop<path>(Stack); +#line 2408 "runtime.in" + array *V=new array(2); + pair z=p.maxtimes(); + (*V)[0]=z.getx(); + (*V)[1]=z.gety(); + {Stack->push<realarray*>(V); return;} +} + +#line 2416 "runtime.in" +// real relativedistance(real theta, real phi, real t, bool atleast); +void gen176(stack *Stack) +{ + bool atleast=vm::pop<bool>(Stack); + real t=vm::pop<real>(Stack); + real phi=vm::pop<real>(Stack); + real theta=vm::pop<real>(Stack); +#line 2417 "runtime.in" + {Stack->push<real>(camp::velocity(theta,phi,tension(t,atleast))); return;} +} + +#line 2421 "runtime.in" +// Int windingnumber(patharray *p, pair z); +void gen177(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); + patharray * p=vm::pop<patharray *>(Stack); +#line 2422 "runtime.in" + {Stack->push<Int>(windingnumber(p,z)); return;} +} + +#line 2426 "runtime.in" +// bool inside(explicit patharray *g, pair z, pen fillrule=CURRENTPEN); +void gen178(stack *Stack) +{ + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + pair z=vm::pop<pair>(Stack); + patharray * g=vm::pop<patharray *>(Stack); +#line 2427 "runtime.in" + {Stack->push<bool>(fillrule.inside(windingnumber(g,z))); return;} +} + +#line 2431 "runtime.in" +// bool inside(path g, pair z, pen fillrule=CURRENTPEN); +void gen179(stack *Stack) +{ + pen fillrule=vm::pop<pen>(Stack,CURRENTPEN); + pair z=vm::pop<pair>(Stack); + path g=vm::pop<path>(Stack); +#line 2432 "runtime.in" + {Stack->push<bool>(fillrule.inside(g.windingnumber(z))); return;} +} + +// Determine the side of a--b that c lies on +// (negative=left, zero=on line, positive=right). +#line 2438 "runtime.in" +// real side(pair a, pair b, pair c); +void gen180(stack *Stack) +{ + pair c=vm::pop<pair>(Stack); + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); +#line 2439 "runtime.in" + {Stack->push<real>(orient2d(a,b,c)); return;} +} + +// Determine the side of the counterclockwise circle through a,b,c that d +// lies on (negative=inside, 0=on circle, positive=right). +#line 2445 "runtime.in" +// real incircle(pair a, pair b, pair c, pair d); +void gen181(stack *Stack) +{ + pair d=vm::pop<pair>(Stack); + pair c=vm::pop<pair>(Stack); + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); +#line 2446 "runtime.in" + {Stack->push<real>(incircle(a.getx(),a.gety(),b.getx(),b.gety(),c.getx(),c.gety(), + d.getx(),d.gety())); return;} +} + + +// Path3 operations +#line 2453 "runtime.in" +// path3 path3(triplearray *pre, triplearray *point, triplearray *post, boolarray *straight, bool cyclic); +void gen182(stack *Stack) +{ + bool cyclic=vm::pop<bool>(Stack); + boolarray * straight=vm::pop<boolarray *>(Stack); + triplearray * post=vm::pop<triplearray *>(Stack); + triplearray * point=vm::pop<triplearray *>(Stack); + triplearray * pre=vm::pop<triplearray *>(Stack); +#line 2455 "runtime.in" + size_t n=checkArrays(pre,point); + checkEqual(n,checkArray(post)); + checkEqual(n,checkArray(straight)); + mem::vector<solvedKnot3> nodes(n); + for(size_t i=0; i < n; ++i) { + nodes[i].pre=read<triple>(pre,i); + nodes[i].point=read<triple>(point,i); + nodes[i].post=read<triple>(post,i); + nodes[i].straight=read<bool>(straight,i); + } + + {Stack->push<path3>(path3(nodes,(Int) n,cyclic)); return;} +} + +#line 2471 "runtime.in" +void nullPath3(stack *Stack) +{ +#line 2472 "runtime.in" + {Stack->push<path3>(nullpath3); return;} +} + +#line 2476 "runtime.in" +// bool ==(path3 a, path3 b); +void gen184(stack *Stack) +{ + path3 b=vm::pop<path3>(Stack); + path3 a=vm::pop<path3>(Stack); +#line 2477 "runtime.in" + {Stack->push<bool>(a == b); return;} +} + +#line 2481 "runtime.in" +// bool !=(path3 a, path3 b); +void gen185(stack *Stack) +{ + path3 b=vm::pop<path3>(Stack); + path3 a=vm::pop<path3>(Stack); +#line 2482 "runtime.in" + {Stack->push<bool>(!(a == b)); return;} +} + +#line 2486 "runtime.in" +// triple point(path3 p, Int t); +void gen186(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2487 "runtime.in" + {Stack->push<triple>(p.point((Int) t)); return;} +} + +#line 2491 "runtime.in" +// triple point(path3 p, real t); +void gen187(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2492 "runtime.in" + {Stack->push<triple>(p.point(t)); return;} +} + +#line 2496 "runtime.in" +// triple precontrol(path3 p, Int t); +void gen188(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2497 "runtime.in" + {Stack->push<triple>(p.precontrol((Int) t)); return;} +} + +#line 2501 "runtime.in" +// triple precontrol(path3 p, real t); +void gen189(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2502 "runtime.in" + {Stack->push<triple>(p.precontrol(t)); return;} +} + +#line 2506 "runtime.in" +// triple postcontrol(path3 p, Int t); +void gen190(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2507 "runtime.in" + {Stack->push<triple>(p.postcontrol((Int) t)); return;} +} + +#line 2511 "runtime.in" +// triple postcontrol(path3 p, real t); +void gen191(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2512 "runtime.in" + {Stack->push<triple>(p.postcontrol(t)); return;} +} + +#line 2516 "runtime.in" +// triple dir(path3 p, Int t, Int sign=0, bool normalize=true); +void gen192(stack *Stack) +{ + bool normalize=vm::pop<bool>(Stack,true); + Int sign=vm::pop<Int>(Stack,0); + Int t=vm::pop<Int>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2517 "runtime.in" + {Stack->push<triple>(p.dir(t,sign,normalize)); return;} +} + +#line 2521 "runtime.in" +// triple dir(path3 p, real t, bool normalize=true); +void gen193(stack *Stack) +{ + bool normalize=vm::pop<bool>(Stack,true); + real t=vm::pop<real>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2522 "runtime.in" + {Stack->push<triple>(p.dir(t,normalize)); return;} +} + +#line 2526 "runtime.in" +// triple accel(path3 p, Int t, Int sign=0); +void gen194(stack *Stack) +{ + Int sign=vm::pop<Int>(Stack,0); + Int t=vm::pop<Int>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2527 "runtime.in" + {Stack->push<triple>(p.accel(t,sign)); return;} +} + +#line 2531 "runtime.in" +// triple accel(path3 p, real t); +void gen195(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2532 "runtime.in" + {Stack->push<triple>(p.accel(t)); return;} +} + +#line 2536 "runtime.in" +// real radius(path3 p, real t); +void gen196(stack *Stack) +{ + real t=vm::pop<real>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2537 "runtime.in" + triple v=p.dir(t,false); + triple a=p.accel(t); + real d=dot(a,v); + real v2=v.abs2(); + real a2=a.abs2(); + real denom=v2*a2-d*d; + real r=v2*sqrt(v2); + {Stack->push<real>(denom > 0 ? r/sqrt(denom) : 0.0); return;} +} + +#line 2548 "runtime.in" +// real radius(triple z0, triple c0, triple c1, triple z1, real t); +void gen197(stack *Stack) +{ + real t=vm::pop<real>(Stack); + triple z1=vm::pop<triple>(Stack); + triple c1=vm::pop<triple>(Stack); + triple c0=vm::pop<triple>(Stack); + triple z0=vm::pop<triple>(Stack); +#line 2549 "runtime.in" + triple v=(3.0*(z1-z0)+9.0*(c0-c1))*t*t+(6.0*(z0+c1)-12.0*c0)*t+3.0*(c0-z0); + triple a=6.0*(z1-z0+3.0*(c0-c1))*t+6.0*(z0+c1)-12.0*c0; + real d=dot(a,v); + real v2=v.abs2(); + real a2=a.abs2(); + real denom=v2*a2-d*d; + real r=v2*sqrt(v2); + {Stack->push<real>(denom > 0 ? r/sqrt(denom) : 0.0); return;} +} + +#line 2560 "runtime.in" +// path3 reverse(path3 p); +void gen198(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2561 "runtime.in" + {Stack->push<path3>(p.reverse()); return;} +} + +#line 2565 "runtime.in" +// path3 subpath(path3 p, Int a, Int b); +void gen199(stack *Stack) +{ + Int b=vm::pop<Int>(Stack); + Int a=vm::pop<Int>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2566 "runtime.in" + {Stack->push<path3>(p.subpath((Int) a, (Int) b)); return;} +} + +#line 2570 "runtime.in" +// path3 subpath(path3 p, real a, real b); +void gen200(stack *Stack) +{ + real b=vm::pop<real>(Stack); + real a=vm::pop<real>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2571 "runtime.in" + {Stack->push<path3>(p.subpath(a,b)); return;} +} + +#line 2575 "runtime.in" +// Int length(path3 p); +void gen201(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2576 "runtime.in" + {Stack->push<Int>(p.length()); return;} +} + +#line 2580 "runtime.in" +// bool cyclic(path3 p); +void gen202(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2581 "runtime.in" + {Stack->push<bool>(p.cyclic()); return;} +} + +#line 2585 "runtime.in" +// bool straight(path3 p, Int t); +void gen203(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2586 "runtime.in" + {Stack->push<bool>(p.straight(t)); return;} +} + +// Return the component of vector v perpendicular to a unit vector u. +#line 2591 "runtime.in" +// triple perp(triple v, triple u); +void gen204(stack *Stack) +{ + triple u=vm::pop<triple>(Stack); + triple v=vm::pop<triple>(Stack); +#line 2592 "runtime.in" + {Stack->push<triple>(v-dot(v,u)*u); return;} +} + +// Return the maximum perpendicular deviation of segment i of path3 g +// from a straight line. +#line 2598 "runtime.in" +// real straightness(path3 p, Int t); +void gen205(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2599 "runtime.in" + if(p.straight(t)) {Stack->push<real>(0); return;} + triple z0=p.point(t); + triple u=unit(p.point(t+1)-z0); + {Stack->push<real>(::max(length(perp(p.postcontrol(t)-z0,u)), + length(perp(p.precontrol(t+1)-z0,u)))); return;} +} + +// Return the maximum perpendicular deviation of z0..controls c0 and c1..z1 +// from a straight line. +#line 2609 "runtime.in" +// real straightness(triple z0, triple c0, triple c1, triple z1); +void gen206(stack *Stack) +{ + triple z1=vm::pop<triple>(Stack); + triple c1=vm::pop<triple>(Stack); + triple c0=vm::pop<triple>(Stack); + triple z0=vm::pop<triple>(Stack); +#line 2610 "runtime.in" + triple u=unit(z1-z0); + {Stack->push<real>(::max(length(perp(c0-z0,u)),length(perp(c1-z0,u)))); return;} +} + +#line 2615 "runtime.in" +// bool piecewisestraight(path3 p); +void gen207(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2616 "runtime.in" + {Stack->push<bool>(p.piecewisestraight()); return;} +} + +#line 2620 "runtime.in" +// real arclength(path3 p); +void gen208(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2621 "runtime.in" + {Stack->push<real>(p.arclength()); return;} +} + +#line 2625 "runtime.in" +// real arctime(path3 p, real dval); +void gen209(stack *Stack) +{ + real dval=vm::pop<real>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2626 "runtime.in" + {Stack->push<real>(p.arctime(dval)); return;} +} + +#line 2630 "runtime.in" +// realarray* intersect(path3 p, path3 q, real fuzz=-1); +void gen210(stack *Stack) +{ + real fuzz=vm::pop<real>(Stack,-1); + path3 q=vm::pop<path3>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2631 "runtime.in" + bool exact=fuzz <= 0.0; + if(fuzz < 0) + fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())), + ::max(length(q.max()),length(q.min()))); + + std::vector<real> S,T; + real s,t; + if(intersections(s,t,S,T,p,q,fuzz,true,exact)) { + array *V=new array(2); + (*V)[0]=s; + (*V)[1]=t; + {Stack->push<realarray*>(V); return;} + } else + {Stack->push<realarray*>(new array(0)); return;} +} + +#line 2648 "runtime.in" +// realarray2* intersections(path3 p, path3 q, real fuzz=-1); +void gen211(stack *Stack) +{ + real fuzz=vm::pop<real>(Stack,-1); + path3 q=vm::pop<path3>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2649 "runtime.in" + bool exact=fuzz <= 0.0; + if(fuzz < 0) + fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())), + ::max(length(q.max()),length(q.min()))); + bool single=!exact; + + real s,t; + std::vector<real> S,T; + bool found=intersections(s,t,S,T,p,q,fuzz,single,exact); + if(!found) {Stack->push<realarray2*>(new array(0)); return;} + array *V; + if(single) { + V=new array(1); + array *Vi=new array(2); + (*V)[0]=Vi; + (*Vi)[0]=s; + (*Vi)[1]=t; + } else { + size_t n=S.size(); + V=new array(n); + for(size_t i=0; i < n; ++i) { + array *Vi=new array(2); + (*V)[i]=Vi; + (*Vi)[0]=S[i]; + (*Vi)[1]=T[i]; + } + } + stable_sort(V->begin(),V->end(),run::compare2<real>()); + {Stack->push<realarray2*>(V); return;} +} + +#line 2681 "runtime.in" +// Int size(path3 p); +void gen212(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2682 "runtime.in" + {Stack->push<Int>(p.size()); return;} +} + +#line 2686 "runtime.in" +// path3 &(path3 p, path3 q); +void gen213(stack *Stack) +{ + path3 q=vm::pop<path3>(Stack); + path3 p=vm::pop<path3>(Stack); +#line 2687 "runtime.in" + {Stack->push<path3>(camp::concat(p,q)); return;} +} + +#line 2691 "runtime.in" +// triple min(path3 p); +void gen214(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2692 "runtime.in" + {Stack->push<triple>(p.min()); return;} +} + +#line 2696 "runtime.in" +// triple max(path3 p); +void gen215(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2697 "runtime.in" + {Stack->push<triple>(p.max()); return;} +} + +#line 2701 "runtime.in" +// realarray* mintimes(path3 p); +void gen216(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2702 "runtime.in" + array *V=new array(3); + triple v=p.mintimes(); + (*V)[0]=v.getx(); + (*V)[1]=v.gety(); + (*V)[2]=v.getz(); + {Stack->push<realarray*>(V); return;} +} + +#line 2711 "runtime.in" +// realarray* maxtimes(path3 p); +void gen217(stack *Stack) +{ + path3 p=vm::pop<path3>(Stack); +#line 2712 "runtime.in" + array *V=new array(3); + triple v=p.maxtimes(); + (*V)[0]=v.getx(); + (*V)[1]=v.gety(); + (*V)[2]=v.getz(); + {Stack->push<realarray*>(V); return;} +} + +#line 2721 "runtime.in" +// path3 *(realarray2 *t, path3 g); +void gen218(stack *Stack) +{ + path3 g=vm::pop<path3>(Stack); + realarray2 * t=vm::pop<realarray2 *>(Stack); +#line 2722 "runtime.in" + {Stack->push<path3>(transformed(*t,g)); return;} +} + + +// Guide operations +#line 2728 "runtime.in" +void nullGuide(stack *Stack) +{ +#line 2729 "runtime.in" + {Stack->push<guide*>(new pathguide(path())); return;} +} + +#line 2734 "runtime.in" +void dotsGuide(stack *Stack) +{ + guidearray * a=vm::pop<guidearray *>(Stack); +#line 2735 "runtime.in" + guidevector v; + size_t size=checkArray(a); + for (size_t i=0; i < size; ++i) + v.push_back(a->read<guide*>(i)); + + {Stack->push<guide*>(new multiguide(v)); return;} +} + +#line 2744 "runtime.in" +void dashesGuide(stack *Stack) +{ + guidearray * a=vm::pop<guidearray *>(Stack); +#line 2745 "runtime.in" + static camp::curlSpec curly; + static specguide curlout(&curly, camp::OUT); + static specguide curlin(&curly, camp::IN); + + size_t n=checkArray(a); + + // a--b is equivalent to a{curl 1}..{curl 1}b + guidevector v; + if (n > 0) + v.push_back(a->read<guide*>(0)); + + if (n==1) { + v.push_back(&curlout); + v.push_back(&curlin); + } + else + for (size_t i=1; i<n; ++i) { + v.push_back(&curlout); + v.push_back(&curlin); + v.push_back(a->read<guide*>(i)); + } + + {Stack->push<guide*>(new multiguide(v)); return;} +} + +#line 2771 "runtime.in" +void newCycleToken(stack *Stack) +{ +#line 2772 "runtime.in" + {Stack->push<cycleToken>(cycleToken()); return;} +} + +#line 2776 "runtime.in" +// guide* operator cast(cycleToken tok); +void gen223(stack *Stack) +{ + cycleToken tok=vm::pop<cycleToken>(Stack); +#line 2777 "runtime.in" +// Avoid unused variable warning messages. + unused(&tok); + {Stack->push<guide*>(new cycletokguide()); return;} +} + +#line 2783 "runtime.in" +// guide* operator spec(pair z, Int p); +void gen224(stack *Stack) +{ + Int p=vm::pop<Int>(Stack); + pair z=vm::pop<pair>(Stack); +#line 2784 "runtime.in" + camp::side d=(camp::side) p; + camp::dirSpec *sp=new camp::dirSpec(z); + + {Stack->push<guide*>(new specguide(sp,d)); return;} +} + +#line 2791 "runtime.in" +// curlSpecifier operator curl(real gamma, Int p); +void gen225(stack *Stack) +{ + Int p=vm::pop<Int>(Stack); + real gamma=vm::pop<real>(Stack); +#line 2792 "runtime.in" + camp::side s=(camp::side) p; + {Stack->push<curlSpecifier>(curlSpecifier(gamma,s)); return;} +} + +#line 2797 "runtime.in" +void curlSpecifierValuePart(stack *Stack) +{ + curlSpecifier spec=vm::pop<curlSpecifier>(Stack); +#line 2798 "runtime.in" + {Stack->push<real>(spec.getValue()); return;} +} + +#line 2802 "runtime.in" +void curlSpecifierSidePart(stack *Stack) +{ + curlSpecifier spec=vm::pop<curlSpecifier>(Stack); +#line 2803 "runtime.in" + {Stack->push<Int>(spec.getSide()); return;} +} + +#line 2807 "runtime.in" +// guide* operator cast(curlSpecifier spec); +void gen228(stack *Stack) +{ + curlSpecifier spec=vm::pop<curlSpecifier>(Stack); +#line 2808 "runtime.in" + {Stack->push<guide*>(new specguide(spec)); return;} +} + +#line 2812 "runtime.in" +// tensionSpecifier operator tension(real tout, real tin, bool atleast); +void gen229(stack *Stack) +{ + bool atleast=vm::pop<bool>(Stack); + real tin=vm::pop<real>(Stack); + real tout=vm::pop<real>(Stack); +#line 2813 "runtime.in" + {Stack->push<tensionSpecifier>(tensionSpecifier(tout, tin, atleast)); return;} +} + +#line 2817 "runtime.in" +void tensionSpecifierOutPart(stack *Stack) +{ + tensionSpecifier t=vm::pop<tensionSpecifier>(Stack); +#line 2818 "runtime.in" + {Stack->push<real>(t.getOut()); return;} +} + +#line 2822 "runtime.in" +void tensionSpecifierInPart(stack *Stack) +{ + tensionSpecifier t=vm::pop<tensionSpecifier>(Stack); +#line 2823 "runtime.in" + {Stack->push<real>(t.getIn()); return;} +} + +#line 2827 "runtime.in" +void tensionSpecifierAtleastPart(stack *Stack) +{ + tensionSpecifier t=vm::pop<tensionSpecifier>(Stack); +#line 2828 "runtime.in" + {Stack->push<bool>(t.getAtleast()); return;} +} + +#line 2832 "runtime.in" +// guide* operator cast(tensionSpecifier t); +void gen233(stack *Stack) +{ + tensionSpecifier t=vm::pop<tensionSpecifier>(Stack); +#line 2833 "runtime.in" + {Stack->push<guide*>(new tensionguide(t)); return;} +} + +#line 2837 "runtime.in" +// guide* operator controls(pair zout, pair zin); +void gen234(stack *Stack) +{ + pair zin=vm::pop<pair>(Stack); + pair zout=vm::pop<pair>(Stack); +#line 2838 "runtime.in" + {Stack->push<guide*>(new controlguide(zout, zin)); return;} +} + +#line 2842 "runtime.in" +// Int size(guide *g); +void gen235(stack *Stack) +{ + guide * g=vm::pop<guide *>(Stack); +#line 2843 "runtime.in" + flatguide f; + g->flatten(f,false); + {Stack->push<Int>(f.size()); return;} +} + +#line 2849 "runtime.in" +// Int length(guide *g); +void gen236(stack *Stack) +{ + guide * g=vm::pop<guide *>(Stack); +#line 2850 "runtime.in" + flatguide f; + g->flatten(f,false); + {Stack->push<Int>(g->cyclic() ? f.size() : f.size()-1); return;} +} + +#line 2856 "runtime.in" +// bool cyclic(guide *g); +void gen237(stack *Stack) +{ + guide * g=vm::pop<guide *>(Stack); +#line 2857 "runtime.in" + flatguide f; + g->flatten(f,false); + {Stack->push<bool>(g->cyclic()); return;} +} + +#line 2863 "runtime.in" +// pair point(guide *g, Int t); +void gen238(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + guide * g=vm::pop<guide *>(Stack); +#line 2864 "runtime.in" + flatguide f; + g->flatten(f,false); + {Stack->push<pair>(f.Nodes(adjustedIndex(t,f.size(),g->cyclic())).z); return;} +} + +#line 2870 "runtime.in" +// pairarray* dirSpecifier(guide *g, Int t); +void gen239(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + guide * g=vm::pop<guide *>(Stack); +#line 2871 "runtime.in" + flatguide f; + g->flatten(f,false); + Int n=f.size(); + if(!g->cyclic() && (t < 0 || t >= n-1)) {Stack->push<pairarray*>(new array(0)); return;} + array *c=new array(2); + (*c)[0]=f.Nodes(t).out->dir(); + (*c)[1]=f.Nodes(t+1).in->dir(); + {Stack->push<pairarray*>(c); return;} +} + +#line 2882 "runtime.in" +// pairarray* controlSpecifier(guide *g, Int t); +void gen240(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + guide * g=vm::pop<guide *>(Stack); +#line 2883 "runtime.in" + flatguide f; + g->flatten(f,false); + Int n=f.size(); + if(!g->cyclic() && (t < 0 || t >= n-1)) {Stack->push<pairarray*>(new array(0)); return;} + knot curr=f.Nodes(t); + knot next=f.Nodes(t+1); + if(curr.out->controlled()) { + assert(next.in->controlled()); + array *c=new array(2); + (*c)[0]=curr.out->control(); + (*c)[1]=next.in->control(); + {Stack->push<pairarray*>(c); return;} + } else {Stack->push<pairarray*>(new array(0)); return;} +} + +#line 2899 "runtime.in" +// tensionSpecifier tensionSpecifier(guide *g, Int t); +void gen241(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + guide * g=vm::pop<guide *>(Stack); +#line 2900 "runtime.in" + flatguide f; + g->flatten(f,false); + Int n=f.size(); + if(!g->cyclic() && (t < 0 || t >= n-1)) {Stack->push<tensionSpecifier>(tensionSpecifier(1.0,1.0,false)); return;} + knot curr=f.Nodes(t); + {Stack->push<tensionSpecifier>(tensionSpecifier(curr.tout.val,f.Nodes(t+1).tin.val,curr.tout.atleast)); return;} +} + +#line 2909 "runtime.in" +// realarray* curlSpecifier(guide *g, Int t); +void gen242(stack *Stack) +{ + Int t=vm::pop<Int>(Stack); + guide * g=vm::pop<guide *>(Stack); +#line 2910 "runtime.in" + flatguide f; + g->flatten(f,false); + Int n=f.size(); + if(!g->cyclic() && (t < 0 || t >= n-1)) {Stack->push<realarray*>(new array(0)); return;} + array *c=new array(2); + real c0=f.Nodes(t).out->curl(); + real c1=f.Nodes(t+1).in->curl(); + (*c)[0]=c0 >= 0.0 ? c0 : 1.0; + (*c)[1]=c1 >= 0.0 ? c1 : 1.0; + {Stack->push<realarray*>(c); return;} +} + +#line 2923 "runtime.in" +// guide* reverse(guide *g); +void gen243(stack *Stack) +{ + guide * g=vm::pop<guide *>(Stack); +#line 2924 "runtime.in" + flatguide f; + g->flatten(f,false); + if(f.precyclic()) + {Stack->push<guide*>(new pathguide(g->solve().reverse())); return;} + + size_t n=f.size(); + bool cyclic=g->cyclic(); + guidevector v; + if(n >= 0) { + size_t start=cyclic ? n : n-1; + knot curr=f.Nodes(start); + knot next; + for(size_t i=start; i > 0; --i) { + next=f.Nodes(i-1); + v.push_back(new pairguide(curr.z)); + if(next.out->controlled()) { + assert(curr.in->controlled()); + v.push_back(new controlguide(curr.in->control(),next.out->control())); + } else { + pair d=curr.in->dir(); + if(d != zero) + v.push_back(new specguide(new dirSpec(-d),camp::OUT)); + else { + real C=curr.in->curl(); + if(C >= 0.0) + v.push_back(new specguide(new curlSpec(C),camp::OUT)); + } + real tout=curr.tin.val; + real tin=next.tout.val; + bool atleast=next.tout.atleast; + if(tout != 1.0 || tin != 1.0 || next.tout.atleast) + v.push_back(new tensionguide(tensionSpecifier(tout,tin,atleast))); + d=next.out->dir(); + if(d != zero) + v.push_back(new specguide(new dirSpec(-d),camp::IN)); + else { + real C=next.out->curl(); + if(C >= 0.0) + v.push_back(new specguide(new curlSpec(C),camp::IN)); + } + } + curr=next; + } + if(cyclic) + v.push_back(new cycletokguide()); + else + v.push_back(new pairguide(next.z)); + + } + {Stack->push<guide*>(new multiguide(v)); return;} +} + + +// Three-dimensional picture and surface operations +#line 2979 "runtime.in" +// void _draw(picture *f, path3 g, pen p); +void gen244(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); + path3 g=vm::pop<path3>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 2980 "runtime.in" + f->append(new drawPath3(g,p)); +} + +#line 2985 "runtime.in" +// void draw(picture *f, triplearray2 *g, bool straight, penarray *p, real opacity, real shininess, real granularity, triple normal, bool lighton, penarray *colors); +void gen245(stack *Stack) +{ + penarray * colors=vm::pop<penarray *>(Stack); + bool lighton=vm::pop<bool>(Stack); + triple normal=vm::pop<triple>(Stack); + real granularity=vm::pop<real>(Stack); + real shininess=vm::pop<real>(Stack); + real opacity=vm::pop<real>(Stack); + penarray * p=vm::pop<penarray *>(Stack); + bool straight=vm::pop<bool>(Stack); + triplearray2 * g=vm::pop<triplearray2 *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 2988 "runtime.in" + f->append(new drawSurface(*g,straight,*p,opacity,shininess,granularity, + normal,lighton,*colors)); +} + +#line 2993 "runtime.in" +// triple min3(picture *f); +void gen246(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 2994 "runtime.in" + {Stack->push<triple>(f->bounds3().Min()); return;} +} + +#line 2998 "runtime.in" +// triple max3(picture *f); +void gen247(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 2999 "runtime.in" + {Stack->push<triple>(f->bounds3().Max()); return;} +} + +#line 3003 "runtime.in" +// pair min(picture *f, realarray2 *t); +void gen248(stack *Stack) +{ + realarray2 * t=vm::pop<realarray2 *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 3004 "runtime.in" + real *T=copyArray2C(t,4); + pair m=f->bounds(::min,xproject,yproject,T); + delete[] T; + {Stack->push<pair>(m); return;} +} + +#line 3011 "runtime.in" +// pair max(picture *f, realarray2 *t); +void gen249(stack *Stack) +{ + realarray2 * t=vm::pop<realarray2 *>(Stack); + picture * f=vm::pop<picture *>(Stack); +#line 3012 "runtime.in" + real *T=copyArray2C(t,4); + pair M=f->bounds(::max,xproject,yproject,T); + delete[] T; + {Stack->push<pair>(M); return;} +} + +#line 3019 "runtime.in" +// pair minratio(picture *f); +void gen250(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 3020 "runtime.in" + {Stack->push<pair>(f->bounds(::min,xratio,yratio)); return;} +} + +#line 3024 "runtime.in" +// pair maxratio(picture *f); +void gen251(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 3025 "runtime.in" + {Stack->push<pair>(f->bounds(::max,xratio,yratio)); return;} +} + +#line 3029 "runtime.in" +// real minbound(realarray *a, real b); +void gen252(stack *Stack) +{ + real b=vm::pop<real>(Stack); + realarray * a=vm::pop<realarray *>(Stack); +#line 3030 "runtime.in" + real *A=copyArrayC(a,16); + b=bound(A,::min,b); + delete[] A; + {Stack->push<real>(b); return;} +} + +#line 3037 "runtime.in" +// real maxbound(realarray *a, real b); +void gen253(stack *Stack) +{ + real b=vm::pop<real>(Stack); + realarray * a=vm::pop<realarray *>(Stack); +#line 3038 "runtime.in" + real *A=copyArrayC(a,16); + b=bound(A,::max,b); + delete[] A; + {Stack->push<real>(b); return;} +} + +#line 3045 "runtime.in" +// pair minbound(triplearray *a, realarray2 *t, pair b); +void gen254(stack *Stack) +{ + pair b=vm::pop<pair>(Stack); + realarray2 * t=vm::pop<realarray2 *>(Stack); + triplearray * a=vm::pop<triplearray *>(Stack); +#line 3046 "runtime.in" + triple *A=copyTripleArrayC(a,16); + real *T=copyArray2C(t,4); + b=pair(bound(A,::min,xproject,T,b.getx()), + bound(A,::min,yproject,T,b.gety())); + delete[] T; + delete[] A; + {Stack->push<pair>(b); return;} +} + +#line 3056 "runtime.in" +// pair maxbound(triplearray *a, realarray2 *t, pair b); +void gen255(stack *Stack) +{ + pair b=vm::pop<pair>(Stack); + realarray2 * t=vm::pop<realarray2 *>(Stack); + triplearray * a=vm::pop<triplearray *>(Stack); +#line 3057 "runtime.in" + triple *A=copyTripleArrayC(a,16); + real *T=copyArray2C(t,4); + b=pair(bound(A,::max,xproject,T,b.getx()), + bound(A,::max,yproject,T,b.gety())); + delete[] T; + delete[] A; + {Stack->push<pair>(b); return;} +} + +#line 3067 "runtime.in" +// pair max(path3 g, realarray2 *t); +void gen256(stack *Stack) +{ + realarray2 * t=vm::pop<realarray2 *>(Stack); + path3 g=vm::pop<path3>(Stack); +#line 3068 "runtime.in" + real *T=copyArray2C(t,4); + pair b=g.bounds(::max,xproject,yproject,T); + delete[] T; + {Stack->push<pair>(b); return;} +} + +#line 3075 "runtime.in" +// pair min(path3 g, realarray2 *t); +void gen257(stack *Stack) +{ + realarray2 * t=vm::pop<realarray2 *>(Stack); + path3 g=vm::pop<path3>(Stack); +#line 3076 "runtime.in" + real *T=copyArray2C(t,4); + pair b=g.bounds(::min,xproject,yproject,T); + delete[] T; + {Stack->push<pair>(b); return;} +} + +#line 3083 "runtime.in" +// real change2(triplearray2 *a); +void gen258(stack *Stack) +{ + triplearray2 * a=vm::pop<triplearray2 *>(Stack); +#line 3084 "runtime.in" + size_t n=checkArray(a); + if(n == 0) {Stack->push<real>(0.0); return;} + + vm::array *a0=vm::read<vm::array*>(a,0); + size_t m=checkArray(a0); + if(m == 0) {Stack->push<real>(0.0); return;} + triple a00=vm::read<triple>(a0,0); + real M=0.0; + + for(size_t i=0; i < n; ++i) { + vm::array *ai=vm::read<vm::array*>(a,i); + size_t m=checkArray(ai); + for(size_t j=0; j < m; ++j) { + real a=(vm::read<triple>(ai,j)-a00).abs2(); + if(a > M) M=a; + } + } + {Stack->push<real>(M); return;} +} + +#line 3105 "runtime.in" +// bool is3D(picture *f); +void gen259(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); +#line 3106 "runtime.in" + {Stack->push<bool>(f->have3D()); return;} +} + +#line 3110 "runtime.in" +// pair bezier(pair a, pair b, pair c, pair d, real t); +void gen260(stack *Stack) +{ + real t=vm::pop<real>(Stack); + pair d=vm::pop<pair>(Stack); + pair c=vm::pop<pair>(Stack); + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); +#line 3111 "runtime.in" + real onemt=1-t; + real onemt2=onemt*onemt; + {Stack->push<pair>(onemt2*onemt*a+t*(3.0*(onemt2*b+t*onemt*c)+t*t*d)); return;} +} + +#line 3117 "runtime.in" +// pair bezierP(pair a, pair b, pair c, pair d, real t); +void gen261(stack *Stack) +{ + real t=vm::pop<real>(Stack); + pair d=vm::pop<pair>(Stack); + pair c=vm::pop<pair>(Stack); + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); +#line 3118 "runtime.in" + {Stack->push<pair>(3.0*(t*t*(d-a+3.0*(b-c))+t*(2.0*(a+c)-4.0*b)+b-a)); return;} +} + +#line 3122 "runtime.in" +// pair bezierPP(pair a, pair b, pair c, pair d, real t); +void gen262(stack *Stack) +{ + real t=vm::pop<real>(Stack); + pair d=vm::pop<pair>(Stack); + pair c=vm::pop<pair>(Stack); + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); +#line 3123 "runtime.in" + {Stack->push<pair>(6.0*(t*(d-a+3.0*(b-c))+a+c-2.0*b)); return;} +} + +#line 3127 "runtime.in" +// pair bezierPPP(pair a, pair b, pair c, pair d); +void gen263(stack *Stack) +{ + pair d=vm::pop<pair>(Stack); + pair c=vm::pop<pair>(Stack); + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); +#line 3128 "runtime.in" + {Stack->push<pair>(6.0*(d-a+3.0*(b-c))); return;} +} + +#line 3132 "runtime.in" +// triple bezier(triple a, triple b, triple c, triple d, real t); +void gen264(stack *Stack) +{ + real t=vm::pop<real>(Stack); + triple d=vm::pop<triple>(Stack); + triple c=vm::pop<triple>(Stack); + triple b=vm::pop<triple>(Stack); + triple a=vm::pop<triple>(Stack); +#line 3133 "runtime.in" + real onemt=1-t; + real onemt2=onemt*onemt; + {Stack->push<triple>(onemt2*onemt*a+t*(3.0*(onemt2*b+t*onemt*c)+t*t*d)); return;} +} + +#line 3139 "runtime.in" +// triple bezierP(triple a, triple b, triple c, triple d, real t); +void gen265(stack *Stack) +{ + real t=vm::pop<real>(Stack); + triple d=vm::pop<triple>(Stack); + triple c=vm::pop<triple>(Stack); + triple b=vm::pop<triple>(Stack); + triple a=vm::pop<triple>(Stack); +#line 3140 "runtime.in" + {Stack->push<triple>(3.0*(t*t*(d-a+3.0*(b-c))+t*(2.0*(a+c)-4.0*b)+b-a)); return;} +} + +#line 3144 "runtime.in" +// triple bezierPP(triple a, triple b, triple c, triple d, real t); +void gen266(stack *Stack) +{ + real t=vm::pop<real>(Stack); + triple d=vm::pop<triple>(Stack); + triple c=vm::pop<triple>(Stack); + triple b=vm::pop<triple>(Stack); + triple a=vm::pop<triple>(Stack); +#line 3145 "runtime.in" + {Stack->push<triple>(6.0*(t*(d-a+3.0*(b-c))+a+c-2.0*b)); return;} +} + +#line 3149 "runtime.in" +// triple bezierPPP(triple a, triple b, triple c, triple d); +void gen267(stack *Stack) +{ + triple d=vm::pop<triple>(Stack); + triple c=vm::pop<triple>(Stack); + triple b=vm::pop<triple>(Stack); + triple a=vm::pop<triple>(Stack); +#line 3150 "runtime.in" + {Stack->push<triple>(6.0*(d-a+3.0*(b-c))); return;} +} + + +// String operations +#line 3156 "runtime.in" +void emptyString(stack *Stack) +{ +#line 3157 "runtime.in" + {Stack->push<string>(emptystring); return;} +} + +#line 3162 "runtime.in" +// Int length(string *s); +void gen269(stack *Stack) +{ + string * s=vm::pop<string *>(Stack); +#line 3163 "runtime.in" + {Stack->push<Int>((Int) s->length()); return;} +} + +#line 3167 "runtime.in" +// Int find(string *s, string t, Int pos=0); +void gen270(stack *Stack) +{ + Int pos=vm::pop<Int>(Stack,0); + string t=vm::pop<string>(Stack); + string * s=vm::pop<string *>(Stack); +#line 3168 "runtime.in" + size_t n=s->find(t,pos); + {Stack->push<Int>(n == string::npos ? (Int) -1 : (Int) n); return;} +} + +#line 3173 "runtime.in" +// Int rfind(string *s, string t, Int pos=-1); +void gen271(stack *Stack) +{ + Int pos=vm::pop<Int>(Stack,-1); + string t=vm::pop<string>(Stack); + string * s=vm::pop<string *>(Stack); +#line 3174 "runtime.in" + size_t n=s->rfind(t,pos); + {Stack->push<Int>(n == string::npos ? (Int) -1 : (Int) n); return;} +} + +#line 3179 "runtime.in" +// string reverse(string s); +void gen272(stack *Stack) +{ + string s=vm::pop<string>(Stack); +#line 3180 "runtime.in" + reverse(s.begin(),s.end()); + {Stack->push<string>(s); return;} +} + +#line 3185 "runtime.in" +// string insert(string s, Int pos, string t); +void gen273(stack *Stack) +{ + string t=vm::pop<string>(Stack); + Int pos=vm::pop<Int>(Stack); + string s=vm::pop<string>(Stack); +#line 3186 "runtime.in" + if ((size_t) pos < s.length()) + {Stack->push<string>(s.insert(pos,t)); return;} + {Stack->push<string>(s); return;} +} + +#line 3192 "runtime.in" +// string substr(string* s, Int pos, Int n=-1); +void gen274(stack *Stack) +{ + Int n=vm::pop<Int>(Stack,-1); + Int pos=vm::pop<Int>(Stack); + string* s=vm::pop<string*>(Stack); +#line 3193 "runtime.in" + if ((size_t) pos < s->length()) + {Stack->push<string>(s->substr(pos,n)); return;} + {Stack->push<string>(emptystring); return;} +} + +#line 3199 "runtime.in" +// string erase(string s, Int pos, Int n); +void gen275(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); + Int pos=vm::pop<Int>(Stack); + string s=vm::pop<string>(Stack); +#line 3200 "runtime.in" + if ((size_t) pos < s.length()) + {Stack->push<string>(s.erase(pos,n)); return;} + {Stack->push<string>(s); return;} +} + +#line 3206 "runtime.in" +// string downcase(string s); +void gen276(stack *Stack) +{ + string s=vm::pop<string>(Stack); +#line 3207 "runtime.in" + std::transform(s.begin(),s.end(),s.begin(),tolower); + {Stack->push<string>(s); return;} +} + +#line 3212 "runtime.in" +// string upcase(string s); +void gen277(stack *Stack) +{ + string s=vm::pop<string>(Stack); +#line 3213 "runtime.in" + std::transform(s.begin(),s.end(),s.begin(),toupper); + {Stack->push<string>(s); return;} +} + +// returns a string constructed by translating all occurrences of the string +// from in an array of string pairs {from,to} to the string to in string s. +#line 3220 "runtime.in" +// string replace(string *S, stringarray2 *translate); +void gen278(stack *Stack) +{ + stringarray2 * translate=vm::pop<stringarray2 *>(Stack); + string * S=vm::pop<string *>(Stack); +#line 3221 "runtime.in" + size_t size=checkArray(translate); + for(size_t i=0; i < size; i++) { + array *a=read<array*>(translate,i); + checkArray(a); + } + const char *p=S->c_str(); + ostringstream buf; + while(*p) { + for(size_t i=0; i < size;) { + array *a=read<array*>(translate,i); + string* from=read<string*>(a,0); + size_t len=from->length(); + if(strncmp(p,from->c_str(),len) != 0) {i++; continue;} + buf << read<string>(a,1); + p += len; + if(*p == 0) {Stack->push<string>(buf.str()); return;} + i=0; + } + buf << *(p++); + } + {Stack->push<string>(buf.str()); return;} +} + +#line 3245 "runtime.in" +// string format(string *format, Int x); +void gen279(stack *Stack) +{ + Int x=vm::pop<Int>(Stack); + string * format=vm::pop<string *>(Stack); +#line 3246 "runtime.in" + const char *f=format->c_str(); + + checkformat(f,true); + + Int size=snprintf(NULL,0,f,x)+1; + if(size < 1) size=255; // Workaround for non-C99 compliant systems. + char *buf=new char[size]; + snprintf(buf,size,f,x); + string s=string(buf); + delete[] buf; + {Stack->push<string>(s); return;} +} + +#line 3260 "runtime.in" +// string format(string *format, real x, string locale=emptystring); +void gen280(stack *Stack) +{ + string locale=vm::pop<string>(Stack,emptystring); + real x=vm::pop<real>(Stack); + string * format=vm::pop<string *>(Stack); +#line 3261 "runtime.in" + ostringstream out; + + checkformat(format->c_str(),false); + + const char *phantom="\\phantom{+}"; + const char *p0=format->c_str(); + + const char *p=p0; + const char *start=NULL; + while (*p != 0) { + if(*p == '%') { + p++; + if(*p != '%') {start=p-1; break;} + } + out << *(p++); + } + + if(!start) {Stack->push<string>(out.str()); return;} + + // Allow at most 1 argument + while (*p != 0) { + if(*p == '*' || *p == '$') {Stack->push<string>(out.str()); return;} + if(isupper(*p) || islower(*p)) {p++; break;} + p++; + } + + const char *tail=p; + string f=format->substr(start-p0,tail-start); + + const char *oldlocale=NULL; + if(!locale.empty()) { + oldlocale=setlocale(LC_ALL,NULL); + if(oldlocale) oldlocale=StrdupNoGC(oldlocale); + setlocale(LC_ALL,locale.c_str()); + } + + Int size=snprintf(NULL,0,f.c_str(),x)+1; + if(size < 1) size=255; // Workaround for non-C99 compliant systems. + char *buf=new char[size]; + snprintf(buf,size,f.c_str(),x); + + if(oldlocale) { + setlocale(LC_ALL,oldlocale); + delete[] oldlocale; + } + + bool trailingzero=f.find("#") < string::npos; + bool plus=f.find("+") < string::npos; + bool space=f.find(" ") < string::npos; + + char *q=buf; // beginning of formatted number + + if(*q == ' ') { + out << phantom; + q++; + } + + const char decimal=*(localeconv()->decimal_point); + + // Remove any spurious sign + if(*q == '-' || *q == '+') { + p=q+1; + bool zero=true; + while(*p != 0) { + if(!isdigit(*p) && *p != decimal) break; + if(isdigit(*p) && *p != '0') {zero=false; break;} + p++; + } + if(zero) { + q++; + if(plus || space) out << phantom; + } + } + + const char *r=p=q; + bool dp=false; + while(*r != 0 && (isdigit(*r) || *r == decimal || *r == '+' || *r == '-')) { + if(*r == decimal) dp=true; + r++; + } + if(dp) { // Remove trailing zeros and/or decimal point + r--; + unsigned n=0; + while(r > q && *r == '0') {r--; n++;} + if(*r == decimal) {r--; n++;} + while(q <= r) out << *(q++); + if(!trailingzero) q += n; + } + + bool zero=(r == p && *r == '0') && !trailingzero; + + // Translate "E+/E-/e+/e-" exponential notation to TeX + while(*q != 0) { + if((*q == 'E' || *q == 'e') && (*(q+1) == '+' || *(q+1) == '-')) { + if(!zero) out << "\\!\\times\\!10^{"; + bool plus=(*(q+1) == '+'); + q++; + if(plus) q++; + if(*q == '-') out << *(q++); + while(*q == '0' && (zero || isdigit(*(q+1)))) q++; + while(isdigit(*q)) out << *(q++); + if(!zero) + out << "}"; + break; + } + out << *(q++); + } + + while(*tail != 0) + out << *(tail++); + + delete[] buf; + + {Stack->push<string>(out.str()); return;} +} + +#line 3378 "runtime.in" +// Int hex(string s); +void gen281(stack *Stack) +{ + string s=vm::pop<string>(Stack); +#line 3379 "runtime.in" + istringstream is(s); + is.setf(std::ios::hex,std::ios::basefield); + Int value; + if(is && is >> value && ((is >> std::ws).eof())) {Stack->push<Int>(value); return;} + ostringstream buf; + buf << "invalid hexidecimal cast from string \"" << s << "\""; + error(buf); +} + +#line 3389 "runtime.in" +// string string(Int x); +void gen282(stack *Stack) +{ + Int x=vm::pop<Int>(Stack); +#line 3390 "runtime.in" + ostringstream buf; + buf << x; + {Stack->push<string>(buf.str()); return;} +} + +#line 3396 "runtime.in" +// string string(real x, Int digits=DBL_DIG); +void gen283(stack *Stack) +{ + Int digits=vm::pop<Int>(Stack,DBL_DIG); + real x=vm::pop<real>(Stack); +#line 3397 "runtime.in" + ostringstream buf; + buf.precision(digits); + buf << x; + {Stack->push<string>(buf.str()); return;} +} + +#line 3404 "runtime.in" +// string time(string format=defaulttimeformat); +void gen284(stack *Stack) +{ + string format=vm::pop<string>(Stack,defaulttimeformat); +#line 3405 "runtime.in" +#ifdef HAVE_STRFTIME + const time_t bintime=time(NULL); + if(!strftime(Time,nTime,format.c_str(),localtime(&bintime))) {Stack->push<string>(""); return;} + {Stack->push<string>(Time); return;} +#else + {Stack->push<string>(format); return;} +#endif +} + +#line 3415 "runtime.in" +// string time(Int seconds, string format=defaulttimeformat); +void gen285(stack *Stack) +{ + string format=vm::pop<string>(Stack,defaulttimeformat); + Int seconds=vm::pop<Int>(Stack); +#line 3416 "runtime.in" +#ifdef HAVE_STRFTIME + const time_t bintime=seconds; + if(!strftime(Time,nTime,format.c_str(),localtime(&bintime))) {Stack->push<string>(""); return;} + {Stack->push<string>(Time); return;} +#else +// Avoid unused variable warning messages + unused(&seconds); + {Stack->push<string>(format); return;} +#endif +} + +#line 3428 "runtime.in" +// Int seconds(string t=emptystring, string format=emptystring); +void gen286(stack *Stack) +{ + string format=vm::pop<string>(Stack,emptystring); + string t=vm::pop<string>(Stack,emptystring); +#line 3429 "runtime.in" +#if defined(HAVE_STRPTIME) + const time_t bintime=time(NULL); + tm tm=*localtime(&bintime); + if(t != "" && !strptime(t.c_str(),format.c_str(),&tm)) {Stack->push<Int>(-1); return;} + {Stack->push<Int>((Int) mktime(&tm)); return;} +#else + {Stack->push<Int>(-1); return;} +#endif +} + +#line 3440 "runtime.in" +// realarray* _cputime(); +void gen287(stack *Stack) +{ +#line 3441 "runtime.in" + static const real ticktime=1.0/sysconf(_SC_CLK_TCK); + struct tms buf; + + ::times(&buf); + array *t=new array(4); + (*t)[0] = ((real) buf.tms_utime)*ticktime; + (*t)[1] = ((real) buf.tms_stime)*ticktime; + (*t)[2] = ((real) buf.tms_cutime)*ticktime; + (*t)[3] = ((real) buf.tms_cstime)*ticktime; + {Stack->push<realarray*>(t); return;} +} + + +// Math +#line 3456 "runtime.in" +// real ^(real x, Int y); +void gen288(stack *Stack) +{ + Int y=vm::pop<Int>(Stack); + real x=vm::pop<real>(Stack); +#line 3457 "runtime.in" + {Stack->push<real>(pow(x,y)); return;} +} + +#line 3462 "runtime.in" +// pair ^(pair z, Int y); +void gen289(stack *Stack) +{ + Int y=vm::pop<Int>(Stack); + pair z=vm::pop<pair>(Stack); +#line 3463 "runtime.in" + {Stack->push<pair>(pow(z,y)); return;} +} + +#line 3467 "runtime.in" +// Int quotient(Int x, Int y); +void gen290(stack *Stack) +{ + Int y=vm::pop<Int>(Stack); + Int x=vm::pop<Int>(Stack); +#line 3468 "runtime.in" + if(y == 0) dividebyzero(); + if(y == -1) {Stack->push<Int>(Negate(x)); return;} +// Implementation-independent definition of integer division: round down + {Stack->push<Int>((x-portableMod(x,y))/y); return;} +} + +#line 3475 "runtime.in" +// Int abs(Int x); +void gen291(stack *Stack) +{ + Int x=vm::pop<Int>(Stack); +#line 3476 "runtime.in" + {Stack->push<Int>(Abs(x)); return;} +} + +#line 3480 "runtime.in" +// Int sgn(real x); +void gen292(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3481 "runtime.in" + {Stack->push<Int>(sgn(x)); return;} +} + +#line 3485 "runtime.in" +// Int rand(); +void gen293(stack *Stack) +{ +#line 3486 "runtime.in" + {Stack->push<Int>(rand()); return;} +} + +#line 3490 "runtime.in" +// void srand(Int seed); +void gen294(stack *Stack) +{ + Int seed=vm::pop<Int>(Stack); +#line 3491 "runtime.in" + srand(intcast(seed)); +} + +// a random number uniformly distributed in the interval [0,1] +#line 3496 "runtime.in" +// real unitrand(); +void gen295(stack *Stack) +{ +#line 3497 "runtime.in" + {Stack->push<real>(((real) rand())/RAND_MAX); return;} +} + +#line 3501 "runtime.in" +// Int ceil(real x); +void gen296(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3502 "runtime.in" + {Stack->push<Int>(Intcast(ceil(x))); return;} +} + +#line 3506 "runtime.in" +// Int floor(real x); +void gen297(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3507 "runtime.in" + {Stack->push<Int>(Intcast(floor(x))); return;} +} + +#line 3511 "runtime.in" +// Int round(real x); +void gen298(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3512 "runtime.in" + if(validInt(x)) {Stack->push<Int>(Round(x)); return;} + integeroverflow(0); +} + +#line 3517 "runtime.in" +// Int Ceil(real x); +void gen299(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3518 "runtime.in" + {Stack->push<Int>(Ceil(x)); return;} +} + +#line 3522 "runtime.in" +// Int Floor(real x); +void gen300(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3523 "runtime.in" + {Stack->push<Int>(Floor(x)); return;} +} + +#line 3527 "runtime.in" +// Int Round(real x); +void gen301(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3528 "runtime.in" + {Stack->push<Int>(Round(Intcap(x))); return;} +} + +#line 3532 "runtime.in" +// real fmod(real x, real y); +void gen302(stack *Stack) +{ + real y=vm::pop<real>(Stack); + real x=vm::pop<real>(Stack); +#line 3533 "runtime.in" + if (y == 0.0) dividebyzero(); + {Stack->push<real>(fmod(x,y)); return;} +} + +#line 3538 "runtime.in" +// real atan2(real y, real x); +void gen303(stack *Stack) +{ + real x=vm::pop<real>(Stack); + real y=vm::pop<real>(Stack); +#line 3539 "runtime.in" + {Stack->push<real>(atan2(y,x)); return;} +} + +#line 3543 "runtime.in" +// real hypot(real x, real y); +void gen304(stack *Stack) +{ + real y=vm::pop<real>(Stack); + real x=vm::pop<real>(Stack); +#line 3544 "runtime.in" + {Stack->push<real>(hypot(x,y)); return;} +} + +#line 3548 "runtime.in" +// real remainder(real x, real y); +void gen305(stack *Stack) +{ + real y=vm::pop<real>(Stack); + real x=vm::pop<real>(Stack); +#line 3549 "runtime.in" + {Stack->push<real>(remainder(x,y)); return;} +} + +#line 3553 "runtime.in" +// real J(Int n, real x); +void gen306(stack *Stack) +{ + real x=vm::pop<real>(Stack); + Int n=vm::pop<Int>(Stack); +#line 3554 "runtime.in" + {Stack->push<real>(jn(n,x)); return;} +} + +#line 3558 "runtime.in" +// real Y(Int n, real x); +void gen307(stack *Stack) +{ + real x=vm::pop<real>(Stack); + Int n=vm::pop<Int>(Stack); +#line 3559 "runtime.in" + {Stack->push<real>(yn(n,x)); return;} +} + +#line 3563 "runtime.in" +// real erf(real x); +void gen308(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3564 "runtime.in" + {Stack->push<real>(erf(x)); return;} +} + +#line 3568 "runtime.in" +// real erfc(real x); +void gen309(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3569 "runtime.in" + {Stack->push<real>(erfc(x)); return;} +} + +#line 3573 "runtime.in" +// Int factorial(Int n); +void gen310(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 3574 "runtime.in" + if(n < 0) error(invalidargument); + {Stack->push<Int>(factorial(n)); return;} +} + +#line 3578 "runtime.in" +// Int choose(Int n, Int k); +void gen311(stack *Stack) +{ + Int k=vm::pop<Int>(Stack); + Int n=vm::pop<Int>(Stack); +#line 3579 "runtime.in" + if(n < 0 || k < 0 || k > n) error(invalidargument); + Int f=1; + Int r=n-k; + for(Int i=n; i > r; --i) { + if(f > Int_MAX/i) integeroverflow(0); + f=(f*i)/(n-i+1); + } + {Stack->push<Int>(f); return;} +} + +#line 3589 "runtime.in" +// real gamma(real x); +void gen312(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3590 "runtime.in" +#ifdef HAVE_TGAMMA + {Stack->push<real>(tgamma(x)); return;} +#else + real lg = lgamma(x); + {Stack->push<real>(signgam*exp(lg)); return;} +#endif +} + +// Complex Gamma function +#line 3600 "runtime.in" +// pair gamma(explicit pair z); +void gen313(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3601 "runtime.in" + {Stack->push<pair>(gamma(z)); return;} +} + +#line 3605 "runtime.in" +// realarray* quadraticroots(real a, real b, real c); +void gen314(stack *Stack) +{ + real c=vm::pop<real>(Stack); + real b=vm::pop<real>(Stack); + real a=vm::pop<real>(Stack); +#line 3606 "runtime.in" + quadraticroots q(a,b,c); + array *roots=new array(q.roots); + if(q.roots >= 1) (*roots)[0]=q.t1; + if(q.roots == 2) (*roots)[1]=q.t2; + {Stack->push<realarray*>(roots); return;} +} + +#line 3614 "runtime.in" +// pairarray* quadraticroots(explicit pair a, explicit pair b, explicit pair c); +void gen315(stack *Stack) +{ + pair c=vm::pop<pair>(Stack); + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); +#line 3615 "runtime.in" + Quadraticroots q(a,b,c); + array *roots=new array(q.roots); + if(q.roots >= 1) (*roots)[0]=q.z1; + if(q.roots == 2) (*roots)[1]=q.z2; + {Stack->push<pairarray*>(roots); return;} +} + +#line 3623 "runtime.in" +// realarray* cubicroots(real a, real b, real c, real d); +void gen316(stack *Stack) +{ + real d=vm::pop<real>(Stack); + real c=vm::pop<real>(Stack); + real b=vm::pop<real>(Stack); + real a=vm::pop<real>(Stack); +#line 3624 "runtime.in" + cubicroots q(a,b,c,d); + array *roots=new array(q.roots); + if(q.roots >= 1) (*roots)[0]=q.t1; + if(q.roots >= 2) (*roots)[1]=q.t2; + if(q.roots == 3) (*roots)[2]=q.t3; + {Stack->push<realarray*>(roots); return;} +} + + +// Transforms +#line 3635 "runtime.in" +// bool ==(transform a, transform b); +void gen317(stack *Stack) +{ + transform b=vm::pop<transform>(Stack); + transform a=vm::pop<transform>(Stack); +#line 3636 "runtime.in" + {Stack->push<bool>(a == b); return;} +} + +#line 3641 "runtime.in" +// bool !=(transform a, transform b); +void gen318(stack *Stack) +{ + transform b=vm::pop<transform>(Stack); + transform a=vm::pop<transform>(Stack); +#line 3642 "runtime.in" + {Stack->push<bool>(a != b); return;} +} + +#line 3646 "runtime.in" +// transform +(transform a, transform b); +void gen319(stack *Stack) +{ + transform b=vm::pop<transform>(Stack); + transform a=vm::pop<transform>(Stack); +#line 3647 "runtime.in" + {Stack->push<transform>(a+b); return;} +} + +#line 3651 "runtime.in" +// transform *(transform a, transform b); +void gen320(stack *Stack) +{ + transform b=vm::pop<transform>(Stack); + transform a=vm::pop<transform>(Stack); +#line 3652 "runtime.in" + {Stack->push<transform>(a*b); return;} +} + +#line 3656 "runtime.in" +// pair *(transform t, pair z); +void gen321(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); + transform t=vm::pop<transform>(Stack); +#line 3657 "runtime.in" + {Stack->push<pair>(t*z); return;} +} + +#line 3661 "runtime.in" +// path *(transform t, path g); +void gen322(stack *Stack) +{ + path g=vm::pop<path>(Stack); + transform t=vm::pop<transform>(Stack); +#line 3662 "runtime.in" + {Stack->push<path>(transformed(t,g)); return;} +} + +#line 3666 "runtime.in" +// pen *(transform t, pen p); +void gen323(stack *Stack) +{ + pen p=vm::pop<pen>(Stack); + transform t=vm::pop<transform>(Stack); +#line 3667 "runtime.in" + {Stack->push<pen>(transformed(t,p)); return;} +} + +#line 3671 "runtime.in" +// picture* *(transform t, picture *f); +void gen324(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); + transform t=vm::pop<transform>(Stack); +#line 3672 "runtime.in" + {Stack->push<picture*>(transformed(t,f)); return;} +} + +#line 3676 "runtime.in" +// picture* *(realarray2 *t, picture *f); +void gen325(stack *Stack) +{ + picture * f=vm::pop<picture *>(Stack); + realarray2 * t=vm::pop<realarray2 *>(Stack); +#line 3677 "runtime.in" + {Stack->push<picture*>(transformed(*t,f)); return;} +} + +#line 3681 "runtime.in" +// transform ^(transform t, Int n); +void gen326(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); + transform t=vm::pop<transform>(Stack); +#line 3682 "runtime.in" + transform T; + if(n < 0) { + n=-n; + t=inverse(t); + } + for(Int i=0; i < n; i++) T=T*t; + {Stack->push<transform>(T); return;} +} + +#line 3692 "runtime.in" +void transformXPart(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3693 "runtime.in" + {Stack->push<real>(t.getx()); return;} +} + +#line 3697 "runtime.in" +void transformYPart(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3698 "runtime.in" + {Stack->push<real>(t.gety()); return;} +} + +#line 3702 "runtime.in" +void transformXXPart(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3703 "runtime.in" + {Stack->push<real>(t.getxx()); return;} +} + +#line 3707 "runtime.in" +void transformXYPart(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3708 "runtime.in" + {Stack->push<real>(t.getxy()); return;} +} + +#line 3712 "runtime.in" +void transformYXPart(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3713 "runtime.in" + {Stack->push<real>(t.getyx()); return;} +} + +#line 3717 "runtime.in" +void transformYYPart(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3718 "runtime.in" + {Stack->push<real>(t.getyy()); return;} +} + +#line 3722 "runtime.in" +void real6ToTransform(stack *Stack) +{ + real yy=vm::pop<real>(Stack); + real yx=vm::pop<real>(Stack); + real xy=vm::pop<real>(Stack); + real xx=vm::pop<real>(Stack); + real y=vm::pop<real>(Stack); + real x=vm::pop<real>(Stack); +#line 3724 "runtime.in" + {Stack->push<transform>(transform(x,y,xx,xy,yx,yy)); return;} +} + +#line 3728 "runtime.in" +// transform shift(transform t); +void gen334(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3729 "runtime.in" + {Stack->push<transform>(transform(t.getx(),t.gety(),0,0,0,0)); return;} +} + +#line 3733 "runtime.in" +// transform shiftless(transform t); +void gen335(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3734 "runtime.in" + {Stack->push<transform>(transform(0,0,t.getxx(),t.getxy(),t.getyx(),t.getyy())); return;} +} + +#line 3738 "runtime.in" +// transform identity(); +void transformIdentity(stack *Stack) +{ +#line 3739 "runtime.in" + {Stack->push<transform>(identity); return;} +} + +#line 3743 "runtime.in" +// transform inverse(transform t); +void gen337(stack *Stack) +{ + transform t=vm::pop<transform>(Stack); +#line 3744 "runtime.in" + {Stack->push<transform>(inverse(t)); return;} +} + +#line 3748 "runtime.in" +// transform shift(pair z); +void gen338(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3749 "runtime.in" + {Stack->push<transform>(shift(z)); return;} +} + +#line 3753 "runtime.in" +// transform shift(real x, real y); +void gen339(stack *Stack) +{ + real y=vm::pop<real>(Stack); + real x=vm::pop<real>(Stack); +#line 3754 "runtime.in" + {Stack->push<transform>(shift(pair(x,y))); return;} +} + +#line 3758 "runtime.in" +// transform xscale(real x); +void gen340(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3759 "runtime.in" + {Stack->push<transform>(xscale(x)); return;} +} + +#line 3763 "runtime.in" +// transform yscale(real y); +void gen341(stack *Stack) +{ + real y=vm::pop<real>(Stack); +#line 3764 "runtime.in" + {Stack->push<transform>(yscale(y)); return;} +} + +#line 3768 "runtime.in" +// transform scale(real x); +void gen342(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3769 "runtime.in" + {Stack->push<transform>(scale(x)); return;} +} + +#line 3773 "runtime.in" +// transform scale(real x, real y); +void gen343(stack *Stack) +{ + real y=vm::pop<real>(Stack); + real x=vm::pop<real>(Stack); +#line 3774 "runtime.in" + {Stack->push<transform>(xscale(x)*yscale(y)); return;} +} + +#line 3778 "runtime.in" +// transform slant(real s); +void gen344(stack *Stack) +{ + real s=vm::pop<real>(Stack); +#line 3779 "runtime.in" + {Stack->push<transform>(slant(s)); return;} +} + +#line 3783 "runtime.in" +// transform rotate(real angle, pair z=0); +void gen345(stack *Stack) +{ + pair z=vm::pop<pair>(Stack,0); + real angle=vm::pop<real>(Stack); +#line 3784 "runtime.in" + {Stack->push<transform>(rotatearound(z,radians(angle))); return;} +} + +#line 3788 "runtime.in" +// transform reflect(pair a, pair b); +void gen346(stack *Stack) +{ + pair b=vm::pop<pair>(Stack); + pair a=vm::pop<pair>(Stack); +#line 3789 "runtime.in" + {Stack->push<transform>(reflectabout(a,b)); return;} +} + + +// Pair operations +#line 3795 "runtime.in" +void pairZero(stack *Stack) +{ +#line 3796 "runtime.in" + {Stack->push<pair>(zero); return;} +} + +#line 3801 "runtime.in" +void realRealToPair(stack *Stack) +{ + real y=vm::pop<real>(Stack); + real x=vm::pop<real>(Stack); +#line 3802 "runtime.in" + {Stack->push<pair>(pair(x,y)); return;} +} + +#line 3806 "runtime.in" +void pairNegate(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3807 "runtime.in" + {Stack->push<pair>(-z); return;} +} + +#line 3811 "runtime.in" +// real xpart(pair z); +void pairXPart(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3812 "runtime.in" + {Stack->push<real>(z.getx()); return;} +} + +#line 3816 "runtime.in" +// real ypart(pair z); +void pairYPart(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3817 "runtime.in" + {Stack->push<real>(z.gety()); return;} +} + +#line 3821 "runtime.in" +// real length(pair z); +void gen352(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3822 "runtime.in" + {Stack->push<real>(z.length()); return;} +} + +#line 3826 "runtime.in" +// real abs(pair z); +void gen353(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3827 "runtime.in" + {Stack->push<real>(z.length()); return;} +} + +#line 3831 "runtime.in" +// pair sqrt(explicit pair z); +void gen354(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3832 "runtime.in" + {Stack->push<pair>(Sqrt(z)); return;} +} + +// Return the angle of z in radians. +#line 3837 "runtime.in" +// real angle(pair z, bool warn=true); +void gen355(stack *Stack) +{ + bool warn=vm::pop<bool>(Stack,true); + pair z=vm::pop<pair>(Stack); +#line 3838 "runtime.in" + if(!warn && z.getx() == 0.0 && z.gety() == 0.0) {Stack->push<real>(0.0); return;} + {Stack->push<real>(z.angle()); return;} +} + +// Return the angle of z in degrees in the interval [0,360). +#line 3844 "runtime.in" +// real degrees(pair z, bool warn=true); +void gen356(stack *Stack) +{ + bool warn=vm::pop<bool>(Stack,true); + pair z=vm::pop<pair>(Stack); +#line 3845 "runtime.in" + if(!warn && z.getx() == 0.0 && z.gety() == 0.0) {Stack->push<real>(0.0); return;} + {Stack->push<real>(principalBranch(degrees(z.angle()))); return;} +} + +// Convert degrees to radians. +#line 3851 "runtime.in" +// real radians(real degrees); +void gen357(stack *Stack) +{ + real degrees=vm::pop<real>(Stack); +#line 3852 "runtime.in" + {Stack->push<real>(radians(degrees)); return;} +} + +// Convert radians to degrees. +#line 3857 "runtime.in" +// real degrees(real radians); +void gen358(stack *Stack) +{ + real radians=vm::pop<real>(Stack); +#line 3858 "runtime.in" + {Stack->push<real>(degrees(radians)); return;} +} + +// Convert radians to degrees in [0,360). +#line 3863 "runtime.in" +// real Degrees(real radians); +void gen359(stack *Stack) +{ + real radians=vm::pop<real>(Stack); +#line 3864 "runtime.in" + {Stack->push<real>(principalBranch(degrees(radians))); return;} +} + +#line 3868 "runtime.in" +// real Sin(real deg); +void gen360(stack *Stack) +{ + real deg=vm::pop<real>(Stack); +#line 3869 "runtime.in" + {Stack->push<real>(sin(radians(deg))); return;} +} + +#line 3873 "runtime.in" +// real Cos(real deg); +void gen361(stack *Stack) +{ + real deg=vm::pop<real>(Stack); +#line 3874 "runtime.in" + {Stack->push<real>(cos(radians(deg))); return;} +} + +#line 3878 "runtime.in" +// real Tan(real deg); +void gen362(stack *Stack) +{ + real deg=vm::pop<real>(Stack); +#line 3879 "runtime.in" + {Stack->push<real>(tan(radians(deg))); return;} +} + +#line 3883 "runtime.in" +// real aSin(real x); +void gen363(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3884 "runtime.in" + {Stack->push<real>(degrees(asin(x))); return;} +} + +#line 3888 "runtime.in" +// real aCos(real x); +void gen364(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3889 "runtime.in" + {Stack->push<real>(degrees(acos(x))); return;} +} + +#line 3893 "runtime.in" +// real aTan(real x); +void gen365(stack *Stack) +{ + real x=vm::pop<real>(Stack); +#line 3894 "runtime.in" + {Stack->push<real>(degrees(atan(x))); return;} +} + +#line 3898 "runtime.in" +// pair unit(pair z); +void gen366(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3899 "runtime.in" + {Stack->push<pair>(unit(z)); return;} +} + +#line 3903 "runtime.in" +// pair dir(real degrees); +void gen367(stack *Stack) +{ + real degrees=vm::pop<real>(Stack); +#line 3904 "runtime.in" + {Stack->push<pair>(expi(radians(degrees))); return;} +} + +#line 3908 "runtime.in" +// pair dir(explicit pair z); +void gen368(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3909 "runtime.in" + {Stack->push<pair>(unit(z)); return;} +} + +#line 3913 "runtime.in" +// pair expi(real angle); +void gen369(stack *Stack) +{ + real angle=vm::pop<real>(Stack); +#line 3914 "runtime.in" + {Stack->push<pair>(expi(angle)); return;} +} + +#line 3918 "runtime.in" +// pair exp(explicit pair z); +void gen370(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3919 "runtime.in" + {Stack->push<pair>(exp(z)); return;} +} + +#line 3923 "runtime.in" +// pair log(explicit pair z); +void gen371(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3924 "runtime.in" + {Stack->push<pair>(pair(log(z.length()),z.angle())); return;} +} + +#line 3928 "runtime.in" +// pair sin(explicit pair z); +void gen372(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3929 "runtime.in" + {Stack->push<pair>(sin(z)); return;} +} + +#line 3933 "runtime.in" +// pair cos(explicit pair z); +void gen373(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3934 "runtime.in" + {Stack->push<pair>(pair(cos(z.getx())*cosh(z.gety()),-sin(z.getx())*sinh(z.gety()))); return;} +} + +#line 3938 "runtime.in" +// pair conj(pair z); +void gen374(stack *Stack) +{ + pair z=vm::pop<pair>(Stack); +#line 3939 "runtime.in" + {Stack->push<pair>(conj(z)); return;} +} + +#line 3943 "runtime.in" +// pair realmult(pair z, pair w); +void gen375(stack *Stack) +{ + pair w=vm::pop<pair>(Stack); + pair z=vm::pop<pair>(Stack); +#line 3944 "runtime.in" + {Stack->push<pair>(pair (z.getx()*w.getx(),z.gety()*w.gety())); return;} +} + +#line 3948 "runtime.in" +// triple realmult(triple u, triple v); +void gen376(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); + triple u=vm::pop<triple>(Stack); +#line 3949 "runtime.in" + {Stack->push<triple>(triple (u.getx()*v.getx(),u.gety()*v.gety(),u.getz()*v.getz())); return;} +} + +// To avoid confusion, a dot product requires explicit pair arguments. +#line 3954 "runtime.in" +// real dot(explicit pair z, explicit pair w); +void gen377(stack *Stack) +{ + pair w=vm::pop<pair>(Stack); + pair z=vm::pop<pair>(Stack); +#line 3955 "runtime.in" + {Stack->push<real>(dot(z,w)); return;} +} + + +// Triple operations +#line 3961 "runtime.in" +void tripleZero(stack *Stack) +{ +#line 3962 "runtime.in" + static triple zero; + {Stack->push<triple>(zero); return;} +} + +#line 3968 "runtime.in" +void realRealRealToTriple(stack *Stack) +{ + real z=vm::pop<real>(Stack); + real y=vm::pop<real>(Stack); + real x=vm::pop<real>(Stack); +#line 3969 "runtime.in" + {Stack->push<triple>(triple(x,y,z)); return;} +} + +#line 3973 "runtime.in" +// real xpart(triple v); +void tripleXPart(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 3974 "runtime.in" + {Stack->push<real>(v.getx()); return;} +} + +#line 3978 "runtime.in" +// real ypart(triple v); +void tripleYPart(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 3979 "runtime.in" + {Stack->push<real>(v.gety()); return;} +} + +#line 3983 "runtime.in" +// real zpart(triple v); +void tripleZPart(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 3984 "runtime.in" + {Stack->push<real>(v.getz()); return;} +} + +#line 3988 "runtime.in" +// triple *(real x, triple v); +void gen383(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); + real x=vm::pop<real>(Stack); +#line 3989 "runtime.in" + {Stack->push<triple>(x*v); return;} +} + +#line 3993 "runtime.in" +// triple *(triple v, real x); +void gen384(stack *Stack) +{ + real x=vm::pop<real>(Stack); + triple v=vm::pop<triple>(Stack); +#line 3994 "runtime.in" + {Stack->push<triple>(v*x); return;} +} + +#line 3998 "runtime.in" +// triple /(triple v, real x); +void gen385(stack *Stack) +{ + real x=vm::pop<real>(Stack); + triple v=vm::pop<triple>(Stack); +#line 3999 "runtime.in" + {Stack->push<triple>(v/x); return;} +} + +#line 4003 "runtime.in" +// real length(triple v); +void gen386(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 4004 "runtime.in" + {Stack->push<real>(v.length()); return;} +} + +#line 4008 "runtime.in" +// real abs(triple v); +void gen387(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 4009 "runtime.in" + {Stack->push<real>(v.length()); return;} +} + +#line 4013 "runtime.in" +// real polar(triple v); +void gen388(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 4014 "runtime.in" + {Stack->push<real>(v.polar()); return;} +} + +#line 4018 "runtime.in" +// real azimuth(triple v); +void gen389(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 4019 "runtime.in" + {Stack->push<real>(v.azimuth()); return;} +} + +#line 4023 "runtime.in" +// real colatitude(triple v); +void gen390(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 4024 "runtime.in" + {Stack->push<real>(degrees(v.polar())); return;} +} + +#line 4028 "runtime.in" +// real latitude(triple v); +void gen391(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 4029 "runtime.in" + {Stack->push<real>(90.0-degrees(v.polar())); return;} +} + +// Return the longitude of v in [0,360). +#line 4034 "runtime.in" +// real longitude(triple v, bool warn=true); +void gen392(stack *Stack) +{ + bool warn=vm::pop<bool>(Stack,true); + triple v=vm::pop<triple>(Stack); +#line 4035 "runtime.in" + if(!warn && v.getx() == 0.0 && v.gety() == 0.0) {Stack->push<real>(0.0); return;} + {Stack->push<real>(principalBranch(degrees(v.azimuth()))); return;} +} + +#line 4040 "runtime.in" +// triple unit(triple v); +void gen393(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); +#line 4041 "runtime.in" + {Stack->push<triple>(unit(v)); return;} +} + +#line 4045 "runtime.in" +// real dot(triple u, triple v); +void gen394(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); + triple u=vm::pop<triple>(Stack); +#line 4046 "runtime.in" + {Stack->push<real>(dot(u,v)); return;} +} + +#line 4050 "runtime.in" +// triple cross(triple u, triple v); +void gen395(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); + triple u=vm::pop<triple>(Stack); +#line 4051 "runtime.in" + {Stack->push<triple>(cross(u,v)); return;} +} + +#line 4055 "runtime.in" +// triple expi(real polar, real azimuth); +void gen396(stack *Stack) +{ + real azimuth=vm::pop<real>(Stack); + real polar=vm::pop<real>(Stack); +#line 4056 "runtime.in" + {Stack->push<triple>(expi(polar,azimuth)); return;} +} + +#line 4060 "runtime.in" +// triple dir(real colatitude, real longitude); +void gen397(stack *Stack) +{ + real longitude=vm::pop<real>(Stack); + real colatitude=vm::pop<real>(Stack); +#line 4061 "runtime.in" + {Stack->push<triple>(expi(radians(colatitude),radians(longitude))); return;} +} + + +// System routines +#line 4067 "runtime.in" +// void atupdate(callable *f); +void gen398(stack *Stack) +{ + callable * f=vm::pop<callable *>(Stack); +#line 4068 "runtime.in" + processData().atUpdateFunction=f; +} + +#line 4073 "runtime.in" +// callable* atupdate(); +void gen399(stack *Stack) +{ +#line 4074 "runtime.in" + {Stack->push<callable*>(processData().atUpdateFunction); return;} +} + +#line 4078 "runtime.in" +// void atexit(callable *f); +void gen400(stack *Stack) +{ + callable * f=vm::pop<callable *>(Stack); +#line 4079 "runtime.in" + processData().atExitFunction=f; +} + +#line 4083 "runtime.in" +// callable* atexit(); +void gen401(stack *Stack) +{ +#line 4084 "runtime.in" + {Stack->push<callable*>(processData().atExitFunction); return;} +} + +#line 4088 "runtime.in" +// void atbreakpoint(callableBp *f); +void gen402(stack *Stack) +{ + callableBp * f=vm::pop<callableBp *>(Stack); +#line 4089 "runtime.in" + processData().atBreakpointFunction=f; +} + +#line 4093 "runtime.in" +// void breakpoint(runnable *s=NULL); +void gen403(stack *Stack) +{ + runnable * s=vm::pop<runnable *>(Stack,NULL); +#line 4094 "runtime.in" + breakpoint(Stack,s); +} + +#line 4098 "runtime.in" +// string locatefile(string file); +void gen404(stack *Stack) +{ + string file=vm::pop<string>(Stack); +#line 4099 "runtime.in" + {Stack->push<string>(locateFile(file)); return;} +} + +#line 4103 "runtime.in" +// void stop(string file, Int line, runnable *s=NULL); +void gen405(stack *Stack) +{ + runnable * s=vm::pop<runnable *>(Stack,NULL); + Int line=vm::pop<Int>(Stack); + string file=vm::pop<string>(Stack); +#line 4104 "runtime.in" + file=locateFile(file); + clear(file,line); + cout << "setting breakpoint at " << file << ": " << line << endl; + bplist.push_back(bpinfo(file,line,s)); +} + +#line 4111 "runtime.in" +// void breakpoints(); +void gen406(stack *) +{ +#line 4112 "runtime.in" + for(mem::list<bpinfo>::iterator p=bplist.begin(); p != bplist.end(); ++p) + cout << p->f.name() << ": " << p->f.line() << endl; +} + +#line 4117 "runtime.in" +// void clear(string file, Int line); +void gen407(stack *Stack) +{ + Int line=vm::pop<Int>(Stack); + string file=vm::pop<string>(Stack); +#line 4118 "runtime.in" + file=locateFile(file); + clear(file,line,true); +} + +#line 4123 "runtime.in" +// void clear(); +void gen408(stack *) +{ +#line 4124 "runtime.in" + bplist.clear(); +} + +// Strip directory from string +#line 4129 "runtime.in" +// string stripdirectory(string *s); +void gen409(stack *Stack) +{ + string * s=vm::pop<string *>(Stack); +#line 4130 "runtime.in" + {Stack->push<string>(stripDir(*s)); return;} +} + +// Strip directory from string +#line 4135 "runtime.in" +// string stripfile(string *s); +void gen410(stack *Stack) +{ + string * s=vm::pop<string *>(Stack); +#line 4136 "runtime.in" + {Stack->push<string>(stripFile(*s)); return;} +} + +// Strip file extension from string +#line 4141 "runtime.in" +// string stripextension(string *s); +void gen411(stack *Stack) +{ + string * s=vm::pop<string *>(Stack); +#line 4142 "runtime.in" + {Stack->push<string>(stripExt(*s)); return;} +} + +// Call ImageMagick convert. +#line 4147 "runtime.in" +// Int convert(string args=emptystring, string file=emptystring, string format=emptystring); +void gen412(stack *Stack) +{ + string format=vm::pop<string>(Stack,emptystring); + string file=vm::pop<string>(Stack,emptystring); + string args=vm::pop<string>(Stack,emptystring); +#line 4149 "runtime.in" + ostringstream cmd; + + string name=convertname(file,format); + cmd << "'" << getSetting<string>("convert") << "' " << args + << " '" << name << "'"; + bool quiet=verbose <= 1; + Int ret=System(cmd,quiet ? 1 : 0,true,"convert","your ImageMagick convert utility"); + + if(ret == 0 && verbose > 0) + cout << "Wrote " << ((file.empty()) ? name : file) << endl; + + {Stack->push<Int>(ret); return;} +} + +// Call ImageMagick animate. +#line 4165 "runtime.in" +// Int animate(string args=emptystring, string file=emptystring, string format=emptystring); +void gen413(stack *Stack) +{ + string format=vm::pop<string>(Stack,emptystring); + string file=vm::pop<string>(Stack,emptystring); + string args=vm::pop<string>(Stack,emptystring); +#line 4167 "runtime.in" +#ifndef __CYGWIN__ + string name=convertname(file,format,false); + if(view()) { + ostringstream cmd; + cmd << "'" << getSetting<string>("animate") << "' " << args + << " '" << name << "'"; + {Stack->push<Int>(System(cmd,0,false,"animate","your animated GIF viewer")); return;} + } +#endif + {Stack->push<Int>(0); return;} +} + +// Delete file named s. +#line 4181 "runtime.in" +// Int delete(string *s); +void gen414(stack *Stack) +{ + string * s=vm::pop<string *>(Stack); +#line 4182 "runtime.in" + checkLocal(*s); + Int rc=unlink(s->c_str()); + if(rc == 0 && verbose > 0) + cout << "Deleted " << *s << endl; + {Stack->push<Int>(rc); return;} +} + +// Rename file "from" to file "to". +#line 4191 "runtime.in" +// Int rename(string *from, string *to); +void gen415(stack *Stack) +{ + string * to=vm::pop<string *>(Stack); + string * from=vm::pop<string *>(Stack); +#line 4192 "runtime.in" + checkLocal(*from); + checkLocal(*to); + Int rc=rename(from->c_str(),to->c_str()); + if(rc == 0 && verbose > 0) + cout << "Renamed " << *from << " to " << *to << endl; + {Stack->push<Int>(rc); return;} +} + + +// Array operations + +// Create an empty array. +#line 4205 "runtime.in" +void emptyArray(stack *Stack) +{ +#line 4206 "runtime.in" + {Stack->push<array*>(new array(0)); return;} +} + +// Create a new array (technically a vector). +// This array will be multidimensional. First the number of dimensions +// is popped off the stack, followed by each dimension in reverse order. +// The array itself is technically a one dimensional array of one +// dimension arrays and so on. +#line 4215 "runtime.in" +void newDeepArray(stack *Stack) +{ + Int depth=vm::pop<Int>(Stack); +#line 4216 "runtime.in" + assert(depth > 0); + + Int *dims = new Int[depth]; + + for (Int index = depth-1; index >= 0; index--) { + Int i=pop<Int>(Stack); + if(i < 0) error("cannot create a negative length array"); + dims[index]=i; + } + + array *a=deepArray(depth, dims); + delete[] dims; + {Stack->push<array*>(a); return;} +} + +// Creates an array with elements already specified. First, the number +// of elements is popped off the stack, followed by each element in +// reverse order. +#line 4235 "runtime.in" +void newInitializedArray(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 4236 "runtime.in" + assert(n >= 0); + + array *a = new array(n); + + for (Int index = n-1; index >= 0; index--) + (*a)[index] = pop(Stack); + + {Stack->push<array*>(a); return;} +} + +// Similar to newInitializedArray, but after the n elements, append another +// array to it. +#line 4249 "runtime.in" +void newAppendedArray(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); + array* tail=vm::pop<array*>(Stack); +#line 4250 "runtime.in" + assert(n >= 0); + + array *a = new array(n); + + for (Int index = n-1; index >= 0; index--) + (*a)[index] = pop(Stack); + + copy(tail->begin(), tail->end(), back_inserter(*a)); + + {Stack->push<array*>(a); return;} +} + +// The function T[] array(int n, T value, int depth=0) produces a array of n +// copies of x, where each copy is copied up to depth. +#line 4265 "runtime.in" +void newDuplicateArray(stack *Stack) +{ + Int depth=vm::pop<Int>(Stack,Int_MAX); + item value=vm::pop(Stack); + Int n=vm::pop<Int>(Stack); +#line 4266 "runtime.in" + if(n < 0) error("cannot create a negative length array"); + if(depth < 0) error("cannot copy to a negative depth"); + + {Stack->push<array*>(new array(n, value, depth)); return;} +} + +// Read an element from an array. Checks for initialization & bounds. +#line 4274 "runtime.in" +void arrayRead(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4275 "runtime.in" + item& i=arrayRead(a,n); + if (i.empty()) { + ostringstream buf; + buf << "read uninitialized value from array at index " << n; + error(buf); + } + {Stack->push(i); return;} +} + +// Slice a substring from an array. +#line 4286 "runtime.in" +void arraySliceRead(stack *Stack) +{ + Int right=vm::pop<Int>(Stack); + Int left=vm::pop<Int>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4287 "runtime.in" + checkArray(a); + {Stack->push(a->slice(left, right)); return;} +} + +// Slice a substring from an array. This implements the cases a[i:] and a[:] +// where the endpoint is not given, and assumed to be the length of the array. +#line 4294 "runtime.in" +void arraySliceReadToEnd(stack *Stack) +{ + Int left=vm::pop<Int>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4295 "runtime.in" + size_t len=checkArray(a); + {Stack->push(a->slice(left, (Int)len)); return;} +} + +// Read an element from an array of arrays. Check bounds and initialize +// as necessary. +#line 4302 "runtime.in" +void arrayArrayRead(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4303 "runtime.in" + item& i=arrayRead(a,n); + if (i.empty()) i=new array(0); + {Stack->push(i); return;} +} + +// Write an element to an array. Increase size if necessary. +#line 4310 "runtime.in" +void arrayWrite(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); + array * a=vm::pop<array *>(Stack); + item value=vm::pop(Stack); +#line 4311 "runtime.in" + size_t len=checkArray(a); + bool cyclic=a->cyclic(); + if(cyclic && len > 0) n=imod(n,len); + else { + if(cyclic) outOfBounds("writing cyclic",len,n); + if(n < 0) outOfBounds("writing",len,n); + if(len <= (size_t) n) + a->resize(n+1); + } + (*a)[n] = value; + {Stack->push(value); return;} +} + +#line 4325 "runtime.in" +void arraySliceWrite(stack *Stack) +{ + Int right=vm::pop<Int>(Stack); + Int left=vm::pop<Int>(Stack); + array * dest=vm::pop<array *>(Stack); + array * src=vm::pop<array *>(Stack); +#line 4326 "runtime.in" + checkArray(src); + checkArray(dest); + dest->setSlice(left, right, src); + {Stack->push<array*>(src); return;} +} + +#line 4333 "runtime.in" +void arraySliceWriteToEnd(stack *Stack) +{ + Int left=vm::pop<Int>(Stack); + array * dest=vm::pop<array *>(Stack); + array * src=vm::pop<array *>(Stack); +#line 4334 "runtime.in" + checkArray(src); + size_t len=checkArray(dest); + dest->setSlice(left, (Int) len, src); + {Stack->push<array*>(src); return;} +} + +// Returns the length of an array. +#line 4342 "runtime.in" +void arrayLength(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4343 "runtime.in" + {Stack->push<Int>((Int) checkArray(a)); return;} +} + +// Returns an array of integers representing the keys of the array. +#line 4348 "runtime.in" +void arrayKeys(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4349 "runtime.in" + size_t size=checkArray(a); + + array *keys=new array(); + for (size_t i=0; i<size; ++i) { + item& cell = (*a)[i]; + if (!cell.empty()) + keys->push((Int)i); + } + + {Stack->push<array*>(keys); return;} +} + +// Return the cyclic flag for an array. +#line 4363 "runtime.in" +void arrayCyclicFlag(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4364 "runtime.in" + checkArray(a); + {Stack->push<bool>(a->cyclic()); return;} +} + +// Check to see if an array element is initialized. +#line 4370 "runtime.in" +void arrayInitializedHelper(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); + Int n=vm::pop<Int>(Stack); +#line 4371 "runtime.in" + size_t len=checkArray(a); + bool cyclic=a->cyclic(); + if(cyclic && len > 0) n=imod(n,len); + else if(n < 0 || n >= (Int) len) {Stack->push<bool>(false); return;} + item&i=(*a)[(unsigned) n]; + {Stack->push<bool>(!i.empty()); return;} +} + +// Returns the initialize method for an array. +#line 4381 "runtime.in" +void arrayInitialized(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4382 "runtime.in" + {Stack->push<callable*>(new thunk(new bfunc(arrayInitializedHelper),a)); return;} +} + +// The helper function for the cyclic method that sets the cyclic flag. +#line 4387 "runtime.in" +void arrayCyclicHelper(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); + bool b=vm::pop<bool>(Stack); +#line 4388 "runtime.in" + checkArray(a); + a->cyclic(b); +} + +// Set the cyclic flag for an array. +#line 4394 "runtime.in" +void arrayCyclic(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4395 "runtime.in" + {Stack->push<callable*>(new thunk(new bfunc(arrayCyclicHelper),a)); return;} +} + +// The helper function for the push method that does the actual operation. +#line 4400 "runtime.in" +void arrayPushHelper(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); + item x=vm::pop(Stack); +#line 4401 "runtime.in" + checkArray(a); + a->push(x); + {Stack->push(x); return;} +} + +// Returns the push method for an array. +#line 4408 "runtime.in" +void arrayPush(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4409 "runtime.in" + {Stack->push<callable*>(new thunk(new bfunc(arrayPushHelper),a)); return;} +} + +// The helper function for the append method that appends b to a. +#line 4414 "runtime.in" +void arrayAppendHelper(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); + array * b=vm::pop<array *>(Stack); +#line 4415 "runtime.in" + checkArray(a); + size_t size=checkArray(b); + for(size_t i=0; i < size; i++) + a->push((*b)[i]); +} + +// Returns the append method for an array. +#line 4423 "runtime.in" +void arrayAppend(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4424 "runtime.in" + {Stack->push<callable*>(new thunk(new bfunc(arrayAppendHelper),a)); return;} +} + +// The helper function for the pop method. +#line 4429 "runtime.in" +void arrayPopHelper(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4430 "runtime.in" + size_t asize=checkArray(a); + if(asize == 0) + error("cannot pop element from empty array"); + {Stack->push(a->pop()); return;} +} + +// Returns the pop method for an array. +#line 4438 "runtime.in" +void arrayPop(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4439 "runtime.in" + {Stack->push<callable*>(new thunk(new bfunc(arrayPopHelper),a)); return;} +} + +// The helper function for the insert method. +#line 4444 "runtime.in" +void arrayInsertHelper(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); + array * x=vm::pop<array *>(Stack); + Int i=vm::pop<Int>(Stack); +#line 4445 "runtime.in" + size_t asize=checkArray(a); + checkArray(x); + if(a->cyclic() && asize > 0) i=imod(i,asize); + if(i < 0 || i > (Int) asize) + outOfBounds("inserting",asize,i); + (*a).insert((*a).begin()+i,(*x).begin(),(*x).end()); +} + +// Returns the insert method for an array. +#line 4455 "runtime.in" +void arrayInsert(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4456 "runtime.in" + {Stack->push<callable*>(new thunk(new bfunc(arrayInsertHelper),a)); return;} +} + +// Returns the delete method for an array. +#line 4461 "runtime.in" +void arrayDelete(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4462 "runtime.in" + {Stack->push<callable*>(new thunk(new bfunc(arrayDeleteHelper),a)); return;} +} + +#line 4466 "runtime.in" +void arrayAlias(stack *Stack) +{ + array * b=vm::pop<array *>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4467 "runtime.in" + {Stack->push<bool>(a==b); return;} +} + +// Return array formed by indexing array a with elements of integer array b +#line 4472 "runtime.in" +void arrayIntArray(stack *Stack) +{ + array * b=vm::pop<array *>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4473 "runtime.in" + size_t asize=checkArray(a); + size_t bsize=checkArray(b); + array *r=new array(bsize); + bool cyclic=a->cyclic(); + for(size_t i=0; i < bsize; i++) { + Int index=read<Int>(b,i); + if(cyclic && asize > 0) index=imod(index,asize); + else + if(index < 0 || index >= (Int) asize) + outOfBounds("reading",asize,index); + (*r)[i]=(*a)[index]; + } + {Stack->push<array*>(r); return;} +} + +// returns the complement of the integer array a in {0,2,...,n-1}, +// so that b[complement(a,b.length)] yields the complement of b[a]. +#line 4491 "runtime.in" +// Intarray* complement(Intarray *a, Int n); +void gen446(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); + Intarray * a=vm::pop<Intarray *>(Stack); +#line 4492 "runtime.in" + size_t asize=checkArray(a); + array *r=new array(0); + bool *keep=new bool[n]; + for(Int i=0; i < n; ++i) keep[i]=true; + for(size_t i=0; i < asize; ++i) { + Int j=read<Int>(a,i); + if(j >= 0 && j < n) keep[j]=false; + } + for(Int i=0; i < n; i++) + if(keep[i]) r->push(i); + + delete[] keep; + {Stack->push<Intarray*>(r); return;} +} + +// Generate the sequence {f(i) : i=0,1,...n-1} given a function f and integer n +#line 4509 "runtime.in" +void arraySequence(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); + callable * f=vm::pop<callable *>(Stack); +#line 4510 "runtime.in" + if(n < 0) n=0; + array *a=new array(n); + for(Int i=0; i < n; ++i) { + Stack->push(i); + f->call(Stack); + (*a)[i]=pop(Stack); + } + {Stack->push<Intarray*>(a); return;} +} + +// Return the array {0,1,...n-1} +#line 4522 "runtime.in" +// Intarray* sequence(Int n); +void gen448(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 4523 "runtime.in" + if(n < 0) n=0; + array *a=new array(n); + for(Int i=0; i < n; ++i) { + (*a)[i]=i; + } + {Stack->push<Intarray*>(a); return;} +} + +// Apply a function to each element of an array +#line 4533 "runtime.in" +void arrayFunction(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); + callable * f=vm::pop<callable *>(Stack); +#line 4534 "runtime.in" + size_t size=checkArray(a); + array *b=new array(size); + for(size_t i=0; i < size; ++i) { + Stack->push((*a)[i]); + f->call(Stack); + (*b)[i]=pop(Stack); + } + {Stack->push<array*>(b); return;} +} + +#line 4545 "runtime.in" +void arraySort(stack *Stack) +{ + callable * f=vm::pop<callable *>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4546 "runtime.in" + array *c=copyArray(a); + compareFunc=f; + FuncStack=Stack; + stable_sort(c->begin(),c->end(),compareFunction); + {Stack->push<array*>(c); return;} +} + +#line 4554 "runtime.in" +// bool all(boolarray *a); +void gen451(stack *Stack) +{ + boolarray * a=vm::pop<boolarray *>(Stack); +#line 4555 "runtime.in" + size_t size=checkArray(a); + bool c=true; + for(size_t i=0; i < size; i++) + if(!get<bool>((*a)[i])) {c=false; break;} + {Stack->push<bool>(c); return;} +} + +#line 4563 "runtime.in" +// boolarray* !(boolarray* a); +void gen452(stack *Stack) +{ + boolarray* a=vm::pop<boolarray*>(Stack); +#line 4564 "runtime.in" + size_t size=checkArray(a); + array *c=new array(size); + for(size_t i=0; i < size; i++) + (*c)[i]=!read<bool>(a,i); + {Stack->push<boolarray*>(c); return;} +} + +#line 4572 "runtime.in" +// Int sum(boolarray *a); +void gen453(stack *Stack) +{ + boolarray * a=vm::pop<boolarray *>(Stack); +#line 4573 "runtime.in" + size_t size=checkArray(a); + Int sum=0; + for(size_t i=0; i < size; i++) + sum += read<bool>(a,i) ? 1 : 0; + {Stack->push<Int>(sum); return;} +} + +#line 4581 "runtime.in" +void arrayCopy(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4582 "runtime.in" + {Stack->push<array*>(copyArray(a)); return;} +} + +#line 4586 "runtime.in" +void arrayConcat(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4587 "runtime.in" + // a is an array of arrays to be concatenated together. + // The signature is + // T[] concat(... T[][] a); + + size_t numArgs=checkArray(a); + size_t resultSize=0; + for (size_t i=0; i < numArgs; ++i) { + resultSize += checkArray(a->read<array *>(i)); + } + + array *result=new array(resultSize); + + size_t ri=0; + for (size_t i=0; i < numArgs; ++i) { + array *arg=a->read<array *>(i); + size_t size=checkArray(arg); + + for (size_t j=0; j < size; ++j) { + (*result)[ri]=(*arg)[j]; + ++ri; + } + } + + {Stack->push<array*>(result); return;} +} + +#line 4614 "runtime.in" +void array2Copy(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4615 "runtime.in" + {Stack->push<array*>(copyArray2(a)); return;} +} + +#line 4619 "runtime.in" +void array3Copy(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4620 "runtime.in" + {Stack->push<array*>(copyArray3(a)); return;} +} + +#line 4624 "runtime.in" +void array2Transpose(stack *Stack) +{ + array * a=vm::pop<array *>(Stack); +#line 4625 "runtime.in" + size_t asize=checkArray(a); + array *c=new array(0); + for(size_t i=0; i < asize; i++) { + size_t ip=i+1; + array *ai=read<array*>(a,i); + size_t aisize=checkArray(ai); + size_t csize=checkArray(c); + if(csize < aisize) { + c->resize(aisize); + for(size_t j=csize; j < aisize; j++) { + (*c)[j]=new array(ip); + } + } + for(size_t j=0; j < aisize; j++) { + array *cj=read<array*>(c,j); + if(checkArray(cj) < ip) cj->resize(ip); + (*cj)[i]=(*ai)[j]; + } + } + {Stack->push<array*>(c); return;} +} + +// a is a rectangular 3D array; perm is an Int array indicating the type of +// permutation (021 or 120, etc; original is 012). +// Transpose by sending respective members to the permutated locations: +// return the array obtained by putting a[i][j][k] into position perm{ijk}. +#line 4652 "runtime.in" +void array3Transpose(stack *Stack) +{ + array * perm=vm::pop<array *>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4653 "runtime.in" + const size_t DIM=3; + + if(checkArray(perm) != DIM) { + ostringstream buf; + buf << "permutation array must have length " << DIM; + error(buf); + } + + size_t* size=new size_t[DIM]; + for(size_t i=0; i < DIM; ++i) size[i]=DIM; + + for(size_t i=0; i < DIM; ++i) { + Int p=read<Int>(perm,i); + size_t P=(size_t) p; + if(p < 0 || P >= DIM) { + ostringstream buf; + buf << "permutation index out of range: " << p; + error(buf); + } + size[P]=P; + } + + for(size_t i=0; i < DIM; ++i) + if(size[i] == DIM) error("permutation indices must be distinct"); + + static const char *rectangular= + "3D transpose implemented for rectangular matrices only"; + + size_t isize=size[0]=checkArray(a); + array *a0=read<array*>(a,0); + size[1]=checkArray(a0); + array *a00=read<array*>(a0,0); + size[2]=checkArray(a00); + for(size_t i=0; i < isize; i++) { + array *ai=read<array*>(a,i); + size_t jsize=checkArray(ai); + if(jsize != size[1]) error(rectangular); + for(size_t j=0; j < jsize; j++) { + array *aij=read<array*>(ai,j); + if(checkArray(aij) != size[2]) error(rectangular); + } + } + + size_t perm0=(size_t) read<Int>(perm,0); + size_t perm1=(size_t) read<Int>(perm,1); + size_t perm2=(size_t) read<Int>(perm,2); + + size_t sizep0=size[perm0]; + size_t sizep1=size[perm1]; + size_t sizep2=size[perm2]; + + array *c=new array(sizep0); + for(size_t i=0; i < sizep0; ++i) { + array *ci=new array(sizep1); + (*c)[i]=ci; + for(size_t j=0; j < sizep1; ++j) { + array *cij=new array(sizep2); + (*ci)[j]=cij; + } + } + + size_t* i=new size_t[DIM]; + + for(i[0]=0; i[0] < size[0]; ++i[0]) { + array *a0=read<array*>(a,i[0]); + for(i[1]=0; i[1] < size[1]; ++i[1]) { + array *a1=read<array*>(a0,i[1]); + for(i[2]=0; i[2] < size[2]; ++i[2]) { + array *c0=read<array*>(c,i[perm0]); + array *c1=read<array*>(c0,i[perm1]); + (*c1)[i[perm2]]=read<real>(a1,i[2]); + } + } + } + + delete [] i; + delete [] size; + + {Stack->push<array*>(c); return;} +} + +// In a boolean array, find the index of the nth true value or -1 if not found +// If n is negative, search backwards. +#line 4737 "runtime.in" +// Int find(boolarray *a, Int n=1); +void gen460(stack *Stack) +{ + Int n=vm::pop<Int>(Stack,1); + boolarray * a=vm::pop<boolarray *>(Stack); +#line 4738 "runtime.in" + + size_t size=checkArray(a); + Int j=-1; + if(n > 0) + for(size_t i=0; i < size; i++) + if(read<bool>(a,i)) { + n--; if(n == 0) {j=(Int) i; break;} + } + if(n < 0) + for(size_t i=size; i > 0;) + if(read<bool>(a,--i)) { + n++; if(n == 0) {j=(Int) i; break;} + } + {Stack->push<Int>(j); return;} +} + +#line 4755 "runtime.in" +// bool ==(realarray2 *a, realarray2 *b); +void gen461(stack *Stack) +{ + realarray2 * b=vm::pop<realarray2 *>(Stack); + realarray2 * a=vm::pop<realarray2 *>(Stack); +#line 4756 "runtime.in" + size_t n=checkArray(a); + if(n != checkArray(b)) {Stack->push<bool>(false); return;} + + size_t n0=n == 0 ? 0 : checkArray(read<array*>(a,0)); + if(n0 != checkArray(read<array*>(b,0))) {Stack->push<bool>(false); return;} + + for(size_t i=0; i < n; ++i) { + array *ai=read<array*>(a,i); + array *bi=read<array*>(b,i); + for(size_t j=0; j < n0; ++j) { + if(read<real>(ai,j) != read<real>(bi,j)) + {Stack->push<bool>(false); return;} + } + } + {Stack->push<bool>(true); return;} +} + +// construct vector obtained by replacing those elements of b for which the +// corresponding elements of a are false by the corresponding element of c. +#line 4776 "runtime.in" +void arrayConditional(stack *Stack) +{ + array * c=vm::pop<array *>(Stack); + array * b=vm::pop<array *>(Stack); + array * a=vm::pop<array *>(Stack); +#line 4777 "runtime.in" + size_t size=checkArray(a); + array *r=new array(size); + if(b && c) { + checkArrays(a,b); + checkArrays(b,c); + for(size_t i=0; i < size; i++) + (*r)[i]=read<bool>(a,i) ? (*b)[i] : (*c)[i]; + } else { + r->clear(); + if(b) { + checkArrays(a,b); + for(size_t i=0; i < size; i++) + if(read<bool>(a,i)) r->push((*b)[i]); + } else if(c) { + checkArrays(a,c); + for(size_t i=0; i < size; i++) + if(!read<bool>(a,i)) r->push((*c)[i]); + } + } + {Stack->push<array*>(r); return;} +} + +// Return an n x n identity matrix. +#line 4801 "runtime.in" +// realarray2* identity(Int n); +void gen463(stack *Stack) +{ + Int n=vm::pop<Int>(Stack); +#line 4802 "runtime.in" + {Stack->push<realarray2*>(Identity(n)); return;} +} + +// Return the diagonal matrix with diagonal entries given by a. +#line 4807 "runtime.in" +void diagonal(stack *Stack) +{ + realarray * a=vm::pop<realarray *>(Stack); +#line 4808 "runtime.in" + size_t n=checkArray(a); + array *c=new array(n); + for(size_t i=0; i < n; ++i) { + array *ci=new array(n); + (*c)[i]=ci; + for(size_t j=0; j < i; ++j) + (*ci)[j]=0.0; + (*ci)[i]=read<real>(a,i); + for(size_t j=i+1; j < n; ++j) + (*ci)[j]=0.0; + } + {Stack->push<realarray2*>(c); return;} +} + +// Return the inverse of an n x n matrix a using Gauss-Jordan elimination. +#line 4824 "runtime.in" +// realarray2* inverse(realarray2 *a); +void gen465(stack *Stack) +{ + realarray2 * a=vm::pop<realarray2 *>(Stack); +#line 4825 "runtime.in" + a=copyArray2(a); + size_t n=checkArray(a); + checkSquare(a); + + inverseAllocate(n); + + for(size_t i=0; i < n; i++) + pivot[i]=0; + + size_t col=0, row=0; + // This is the main loop over the columns to be reduced. + for(size_t i=0; i < n; i++) { + real big=0.0; + // This is the outer loop of the search for a pivot element. + for(size_t j=0; j < n; j++) { + array *aj=read<array*>(a,j); + if(pivot[j] != 1) { + for(size_t k=0; k < n; k++) { + if(pivot[k] == 0) { + real temp=fabs(read<real>(aj,k)); + if(temp >= big) { + big=temp; + row=j; + col=k; + } + } else if(pivot[k] > 1) { + inverseDeallocate(); + error(singular); + } + } + } + } + ++(pivot[col]); + + // Interchange rows, if needed, to put the pivot element on the diagonal. + array *acol=read<array*>(a,col); + if(row != col) { + array *arow=read<array*>(a,row); + for(size_t l=0; l < n; l++) { + real temp=read<real>(arow,l); + (*arow)[l]=read<real>(acol,l); + (*acol)[l]=temp; + } + } + + Row[i]=row; + Col[i]=col; + + // Divide the pivot row by the pivot element. + real denom=read<real>(acol,col); + if(denom == 0.0) { + inverseDeallocate(); + error(singular); + } + real pivinv=1.0/denom; + (*acol)[col]=1.0; + for(size_t l=0; l < n; l++) + (*acol)[l]=read<real>(acol,l)*pivinv; + + // Reduce all rows except for the pivoted one. + for(size_t k=0; k < n; k++) { + if(k != col) { + array *ak=read<array*>(a,k); + real akcol=read<real>(ak,col); + (*ak)[col]=0.0; + for(size_t l=0; l < n; l++) + (*ak)[l]=read<real>(ak,l)-read<real>(acol,l)*akcol; + } + } + } + + // Unscramble the inverse matrix in view of the column interchanges. + for(size_t l=n; l > 0;) { + l--; + size_t r=Row[l]; + size_t c=Col[l]; + if(r != c) { + for(size_t k=0; k < n; k++) { + array *ak=read<array*>(a,k); + real temp=read<real>(ak,r); + (*ak)[r]=read<real>(ak,c); + (*ak)[c]=temp; + } + } + } + inverseDeallocate(); + {Stack->push<realarray2*>(a); return;} +} + +// Solve the linear equation ax=b by LU decomposition, returning the +// solution x, where a is an n x n matrix and b is an array of length n. +// If no solution exists, return an empty array. +#line 4918 "runtime.in" +// realarray* solve(realarray2 *a, realarray *b, bool warn=true); +void gen466(stack *Stack) +{ + bool warn=vm::pop<bool>(Stack,true); + realarray * b=vm::pop<realarray *>(Stack); + realarray2 * a=vm::pop<realarray2 *>(Stack); +#line 4919 "runtime.in" + size_t n=checkArray(a); + + if(n == 0) {Stack->push<realarray*>(new array(0)); return;} + + size_t m=checkArray(b); + if(m != n) error(incommensurate); + + real *A=copyArray2C(a); + size_t *index=new size_t[n]; + + if(LUdecompose(A,n,index,warn) == 0) + {Stack->push<realarray*>(new array(0)); return;} + + array *x=new array(n); + + real *B=copyArrayC(b); + + for(size_t i=0; i < n; ++i) { + size_t ip=index[i]; + real sum=B[ip]; + B[ip]=B[i]; + real *Ai=A+i*n; + for(size_t j=0; j < i; ++j) + sum -= Ai[j]*B[j]; + B[i]=sum; + } + + for(size_t i=n; i > 0;) { + --i; + real sum=B[i]; + real *Ai=A+i*n; + for(size_t j=i+1; j < n; ++j) + sum -= Ai[j]*B[j]; + B[i]=sum/Ai[i]; + } + + for(size_t i=0; i < n; ++i) + (*x)[i]=B[i]; + + delete[] index; + delete[] B; + delete[] A; + + {Stack->push<realarray*>(x); return;} +} + +// Solve the linear equation ax=b by LU decomposition, returning the +// solution x, where a is an n x n matrix and b is an n x m matrix. +// If no solution exists, return an empty array. +#line 4969 "runtime.in" +// realarray2* solve(realarray2 *a, realarray2 *b, bool warn=true); +void gen467(stack *Stack) +{ + bool warn=vm::pop<bool>(Stack,true); + realarray2 * b=vm::pop<realarray2 *>(Stack); + realarray2 * a=vm::pop<realarray2 *>(Stack); +#line 4970 "runtime.in" + size_t n=checkArray(a); + + if(n == 0) {Stack->push<realarray2*>(new array(0)); return;} + + if(checkArray(b) != n) error(incommensurate); + size_t m=checkArray(read<array*>(b,0)); + + real *A=copyArray2C(a); + real *B=copyArray2C(b,false); + + size_t *index=new size_t[n]; + + if(LUdecompose(A,n,index,warn) == 0) + {Stack->push<realarray2*>(new array(0)); return;} + + array *x=new array(n); + + for(size_t i=0; i < n; ++i) { + real *Ai=A+i*n; + real *Bi=B+i*m; + real *Bip=B+index[i]*m; + for(size_t k=0; k < m; ++k) { + real sum=Bip[k]; + Bip[k]=Bi[k]; + size_t jk=k; + for(size_t j=0; j < i; ++j, jk += m) + sum -= Ai[j]*B[jk]; + Bi[k]=sum; + } + } + + for(size_t i=n; i > 0;) { + --i; + real *Ai=A+i*n; + real *Bi=B+i*m; + for(size_t k=0; k < m; ++k) { + real sum=Bi[k]; + size_t jk=(i+1)*m+k; + for(size_t j=i+1; j < n; ++j, jk += m) + sum -= Ai[j]*B[jk]; + Bi[k]=sum/Ai[i]; + } + } + + for(size_t i=0; i < n; ++i) { + real *Bi=B+i*m; + array *xi=new array(m); + (*x)[i]=xi; + for(size_t j=0; j < m; ++j) + (*xi)[j]=Bi[j]; + } + + delete[] index; + delete[] B; + delete[] A; + + {Stack->push<realarray2*>(x); return;} +} + +// Compute the determinant of an n x n matrix. +#line 5031 "runtime.in" +// real determinant(realarray2 *a); +void gen468(stack *Stack) +{ + realarray2 * a=vm::pop<realarray2 *>(Stack); +#line 5032 "runtime.in" + real *A=copyArray2C(a); + size_t n=checkArray(a); + + real det=LUdecompose(A,n,NULL,false); + size_t n1=n+1; + for(size_t i=0; i < n; ++i) + det *= A[i*n1]; + + delete[] A; + + {Stack->push<real>(det); return;} +} + +#line 5046 "runtime.in" +// realarray* *(realarray2 *a, realarray *b); +void gen469(stack *Stack) +{ + realarray * b=vm::pop<realarray *>(Stack); + realarray2 * a=vm::pop<realarray2 *>(Stack); +#line 5047 "runtime.in" + size_t n=checkArray(a); + size_t m=checkArray(b); + array *c=new array(n); + real *B=copyArrayC(b); + for(size_t i=0; i < n; ++i) { + array *ai=read<array*>(a,i); + if(checkArray(ai) != m) error(incommensurate); + real sum=0.0; + for(size_t j=0; j < m; ++j) + sum += read<real>(ai,j)*B[j]; + (*c)[i]=sum; + } + delete[] B; + {Stack->push<realarray*>(c); return;} +} + +#line 5064 "runtime.in" +// realarray2* *(realarray2 *a, realarray2 *b); +void gen470(stack *Stack) +{ + realarray2 * b=vm::pop<realarray2 *>(Stack); + realarray2 * a=vm::pop<realarray2 *>(Stack); +#line 5065 "runtime.in" + size_t n=checkArray(a); + + size_t nb=checkArray(b); + size_t na0=n == 0 ? 0 : checkArray(read<array*>(a,0)); + if(na0 != nb) + error(incommensurate); + + size_t nb0=nb == 0 ? 0 : checkArray(read<array*>(b,0)); + + array *c=new array(n); + + real *A=copyArray2C(a,false); + real *B=copyArray2C(b,false); + + for(size_t i=0; i < n; ++i) { + real *Ai=A+i*nb; + array *ci=new array(nb0); + (*c)[i]=ci; + for(size_t j=0; j < nb0; ++j) { + real sum=0.0; + size_t kj=j; + for(size_t k=0; k < nb; ++k, kj += nb0) + sum += Ai[k]*B[kj]; + (*ci)[j]=sum; + } + } + + delete[] B; + delete[] A; + + {Stack->push<realarray2*>(c); return;} +} + +#line 5099 "runtime.in" +// triple *(realarray2 *t, triple v); +void gen471(stack *Stack) +{ + triple v=vm::pop<triple>(Stack); + realarray2 * t=vm::pop<realarray2 *>(Stack); +#line 5100 "runtime.in" + {Stack->push<triple>(*t*v); return;} +} + +#line 5104 "runtime.in" +// pair project(triple v, realarray2 *t); +void gen472(stack *Stack) +{ + realarray2 * t=vm::pop<realarray2 *>(Stack); + triple v=vm::pop<triple>(Stack); +#line 5105 "runtime.in" + size_t n=checkArray(t); + if(n != 4) error(incommensurate); + array *t0=read<array*>(t,0); + array *t1=read<array*>(t,1); + array *t3=read<array*>(t,3); + if(checkArray(t0) != 4 || checkArray(t1) != 4 || checkArray(t3) != 4) + error(incommensurate); + + real x=v.getx(); + real y=v.gety(); + real z=v.getz(); + + real f=read<real>(t3,0)*x+read<real>(t3,1)*y+read<real>(t3,2)*z+ + read<real>(t3,3); + if(f == 0.0) dividebyzero(); + f=1.0/f; + + {Stack->push<pair>(pair((read<real>(t0,0)*x+read<real>(t0,1)*y+read<real>(t0,2)*z+ + read<real>(t0,3))*f, + (read<real>(t1,0)*x+read<real>(t1,1)*y+read<real>(t1,2)*z+ + read<real>(t1,3))*f)); return;} +} + +// Compute the dot product of vectors a and b. +#line 5130 "runtime.in" +// real dot(realarray *a, realarray *b); +void gen473(stack *Stack) +{ + realarray * b=vm::pop<realarray *>(Stack); + realarray * a=vm::pop<realarray *>(Stack); +#line 5131 "runtime.in" + size_t n=checkArrays(a,b); + real sum=0.0; + for(size_t i=0; i < n; ++i) + sum += read<real>(a,i)*read<real>(b,i); + {Stack->push<real>(sum); return;} +} + +// Solve the problem L\inv f, where f is an n vector and L is the n x n matrix +// +// [ b[0] c[0] a[0] ] +// [ a[1] b[1] c[1] ] +// [ a[2] b[2] c[2] ] +// [ ... ] +// [ c[n-1] a[n-1] b[n-1] ] +#line 5146 "runtime.in" +// realarray* tridiagonal(realarray *a, realarray *b, realarray *c, realarray *f); +void gen474(stack *Stack) +{ + realarray * f=vm::pop<realarray *>(Stack); + realarray * c=vm::pop<realarray *>(Stack); + realarray * b=vm::pop<realarray *>(Stack); + realarray * a=vm::pop<realarray *>(Stack); +#line 5147 "runtime.in" + size_t n=checkArrays(a,b); + checkEqual(n,checkArray(c)); + checkEqual(n,checkArray(f)); + + array *up=new array(n); + array& u=*up; + + if(n == 0) {Stack->push<realarray*>(up); return;} + + // Special case: zero Dirichlet boundary conditions + if(read<real>(a,0) == 0.0 && read<real>(c,n-1) == 0.0) { + real temp=read<real>(b,0); + if(temp == 0.0) dividebyzero(); + temp=1.0/temp; + + real *work=new real[n]; + u[0]=read<real>(f,0)*temp; + work[0]=-read<real>(c,0)*temp; + + for(size_t i=1; i < n; i++) { + real temp=(read<real>(b,i)+read<real>(a,i)*work[i-1]); + if(temp == 0.0) {delete[] work; dividebyzero();} + temp=1.0/temp; + u[i]=(read<real>(f,i)-read<real>(a,i)*read<real>(u,i-1))*temp; + work[i]=-read<real>(c,i)*temp; + } + + for(size_t i=n-1; i >= 1; i--) + u[i-1]=read<real>(u,i-1)+work[i-1]*read<real>(u,i); + + delete[] work; + {Stack->push<realarray*>(up); return;} + } + + real binv=read<real>(b,0); + if(binv == 0.0) dividebyzero(); + binv=1.0/binv; + + if(n == 1) {u[0]=read<real>(f,0)*binv; {Stack->push<realarray*>(up); return;}} + if(n == 2) { + real factor=(read<real>(b,0)*read<real>(b,1)- + read<real>(a,0)*read<real>(c,1)); + if(factor== 0.0) dividebyzero(); + factor=1.0/factor; + real temp=(read<real>(b,0)*read<real>(f,1)- + read<real>(c,1)*read<real>(f,0))*factor; + u[0]=(read<real>(b,1)*read<real>(f,0)- + read<real>(a,0)*read<real>(f,1))*factor; + u[1]=temp; + {Stack->push<realarray*>(up); return;} + } + + real *gamma=new real[n-2]; + real *delta=new real[n-2]; + + gamma[0]=read<real>(c,0)*binv; + delta[0]=read<real>(a,0)*binv; + u[0]=read<real>(f,0)*binv; + real beta=read<real>(c,n-1); + real fn=read<real>(f,n-1)-beta*read<real>(u,0); + real alpha=read<real>(b,n-1)-beta*delta[0]; + + for(size_t i=1; i <= n-3; i++) { + real alphainv=read<real>(b,i)-read<real>(a,i)*gamma[i-1]; + if(alphainv == 0.0) {delete[] gamma; delete[] delta; dividebyzero();} + alphainv=1.0/alphainv; + beta *= -gamma[i-1]; + gamma[i]=read<real>(c,i)*alphainv; + u[i]=(read<real>(f,i)-read<real>(a,i)*read<real>(u,i-1))*alphainv; + fn -= beta*read<real>(u,i); + delta[i]=-read<real>(a,i)*delta[i-1]*alphainv; + alpha -= beta*delta[i]; + } + + real alphainv=read<real>(b,n-2)-read<real>(a,n-2)*gamma[n-3]; + if(alphainv == 0.0) {delete[] gamma; delete[] delta; dividebyzero();} + alphainv=1.0/alphainv; + u[n-2]=(read<real>(f,n-2)-read<real>(a,n-2)*read<real>(u,n-3)) + *alphainv; + beta=read<real>(a,n-1)-beta*gamma[n-3]; + real dnm1=(read<real>(c,n-2)-read<real>(a,n-2)*delta[n-3])*alphainv; + real temp=alpha-beta*dnm1; + if(temp == 0.0) {delete[] gamma; delete[] delta; dividebyzero();} + u[n-1]=temp=(fn-beta*read<real>(u,n-2))/temp; + u[n-2]=read<real>(u,n-2)-dnm1*temp; + + for(size_t i=n-2; i >= 1; i--) + u[i-1]=read<real>(u,i-1)-gamma[i-1]*read<real>(u,i)-delta[i-1]*temp; + + delete[] delta; + delete[] gamma; + + {Stack->push<realarray*>(up); return;} +} + +// Root solve by Newton-Raphson +#line 5244 "runtime.in" +// real newton(Int iterations=100, callableReal *f, callableReal *fprime, real x, bool verbose=false); +void gen475(stack *Stack) +{ + bool verbose=vm::pop<bool>(Stack,false); + real x=vm::pop<real>(Stack); + callableReal * fprime=vm::pop<callableReal *>(Stack); + callableReal * f=vm::pop<callableReal *>(Stack); + Int iterations=vm::pop<Int>(Stack,100); +#line 5246 "runtime.in" + static const real fuzz=1000.0*DBL_EPSILON; + Int i=0; + size_t oldPrec=0; + if(verbose) + oldPrec=cout.precision(DBL_DIG); + + real diff=DBL_MAX; + real lastdiff; + do { + real x0=x; + + Stack->push(x); + fprime->call(Stack); + real dfdx=pop<real>(Stack); + + if(dfdx == 0.0) { + x=DBL_MAX; + break; + } + + Stack->push(x); + f->call(Stack); + real fx=pop<real>(Stack); + + x -= fx/dfdx; + + lastdiff=diff; + + if(verbose) + cout << "Newton-Raphson: " << x << endl; + + diff=fabs(x-x0); + if(++i == iterations) { + x=DBL_MAX; + break; + } + } while (diff != 0.0 && (diff < lastdiff || diff > fuzz*fabs(x))); + + if(verbose) + cout.precision(oldPrec); + {Stack->push<real>(x); return;} +} + +// Root solve by Newton-Raphson bisection +// cf. routine rtsafe (Press et al., Numerical Recipes, 1991). +#line 5292 "runtime.in" +// real newton(Int iterations=100, callableReal *f, callableReal *fprime, real x1, real x2, bool verbose=false); +void gen476(stack *Stack) +{ + bool verbose=vm::pop<bool>(Stack,false); + real x2=vm::pop<real>(Stack); + real x1=vm::pop<real>(Stack); + callableReal * fprime=vm::pop<callableReal *>(Stack); + callableReal * f=vm::pop<callableReal *>(Stack); + Int iterations=vm::pop<Int>(Stack,100); +#line 5294 "runtime.in" + static const real fuzz=1000.0*DBL_EPSILON; + size_t oldPrec=0; + if(verbose) + oldPrec=cout.precision(DBL_DIG); + + Stack->push(x1); + f->call(Stack); + real f1=pop<real>(Stack); + if(f1 == 0.0) {Stack->push<real>(x1); return;} + + Stack->push(x2); + f->call(Stack); + real f2=pop<real>(Stack); + if(f2 == 0.0) {Stack->push<real>(x2); return;} + + if((f1 > 0.0 && f2 > 0.0) || (f1 < 0.0 && f2 < 0.0)) { + ostringstream buf; + buf << "root not bracketed, f(x1)=" << f1 << ", f(x2)=" << f2 << endl; + error(buf); + } + + real x=0.5*(x1+x2); + real dxold=fabs(x2-x1); + if(f1 > 0.0) { + real temp=x1; + x1=x2; + x2=temp; + } + + if(verbose) + cout << "midpoint: " << x << endl; + + real dx=dxold; + Stack->push(x); + f->call(Stack); + real y=pop<real>(Stack); + + Stack->push(x); + fprime->call(Stack); + real dy=pop<real>(Stack); + + Int j; + for(j=0; j < iterations; j++) { + if(((x-x2)*dy-y)*((x-x1)*dy-y) >= 0.0 || fabs(2.0*y) > fabs(dxold*dy)) { + dxold=dx; + dx=0.5*(x2-x1); + x=x1+dx; + if(verbose) + cout << "bisection: " << x << endl; + if(x1 == x) {Stack->push<real>(x); return;} + } else { + dxold=dx; + dx=y/dy; + real temp=x; + x -= dx; + if(verbose) + cout << "Newton-Raphson: " << x << endl; + if(temp == x) {Stack->push<real>(x); return;} + } + if(fabs(dx) < fuzz*fabs(x)) {Stack->push<real>(x); return;} + + Stack->push(x); + f->call(Stack); + y=pop<real>(Stack); + + Stack->push(x); + fprime->call(Stack); + dy=pop<real>(Stack); + + if(y < 0.0) x1=x; + else x2=x; + } + if(verbose) + cout.precision(oldPrec); + {Stack->push<real>((j == iterations) ? DBL_MAX : x); return;} +} + +#line 5372 "runtime.in" +// real simpson(callableReal *f, real a, real b, real acc=DBL_EPSILON, real dxmax=0); +void gen477(stack *Stack) +{ + real dxmax=vm::pop<real>(Stack,0); + real acc=vm::pop<real>(Stack,DBL_EPSILON); + real b=vm::pop<real>(Stack); + real a=vm::pop<real>(Stack); + callableReal * f=vm::pop<callableReal *>(Stack); +#line 5374 "runtime.in" + real integral; + if(dxmax == 0) dxmax=b-a; + Func=f; + FuncStack=Stack; + if(!simpson(integral,wrapFunction,a,b,acc,dxmax)) + error("nesting capacity exceeded in simpson"); + {Stack->push<real>(integral); return;} +} + +// Compute the fast Fourier transform of a pair array +#line 5385 "runtime.in" +void pairArrayFFT(stack *Stack) +{ + Int sign=vm::pop<Int>(Stack,1); + pairarray * a=vm::pop<pairarray *>(Stack); +#line 5386 "runtime.in" + unsigned n=(unsigned) checkArray(a); +#ifdef HAVE_LIBFFTW3 + array *c=new array(n); + if(n) { + Complex *f=FFTWComplex(n); + fft1d Forward(n,intcast(sign),f); + + for(size_t i=0; i < n; i++) { + pair z=read<pair>(a,i); + f[i]=Complex(z.getx(),z.gety()); + } + Forward.fft(f); + + for(size_t i=0; i < n; i++) { + Complex z=f[i]; + (*c)[i]=pair(z.real(),z.imag()); + } + FFTWdelete(f); + } +#else + unused(&n); + unused(&sign); + array *c=new array(0); +#endif // HAVE_LIBFFTW3 + {Stack->push<pairarray*>(c); return;} +} + +#line 5414 "runtime.in" +// Intarray2* triangulate(pairarray *z); +void gen479(stack *Stack) +{ + pairarray * z=vm::pop<pairarray *>(Stack); +#line 5415 "runtime.in" + size_t nv=checkArray(z); +// Call robust version of Gilles Dumoulin's port of Paul Bourke's +// triangulation code. + + XYZ *pxyz=new XYZ[nv+3]; + ITRIANGLE *V=new ITRIANGLE[4*nv]; + + for(size_t i=0; i < nv; ++i) { + pair w=read<pair>(z,i); + pxyz[i].p[0]=w.getx(); + pxyz[i].p[1]=w.gety(); + pxyz[i].i=(Int) i; + } + + Int ntri; + Triangulate((Int) nv,pxyz,V,ntri,true,false); + + size_t nt=(size_t) ntri; + array *t=new array(nt); + for(size_t i=0; i < nt; ++i) { + array *ti=new array(3); + (*t)[i]=ti; + ITRIANGLE *Vi=V+i; + (*ti)[0]=pxyz[Vi->p1].i; + (*ti)[1]=pxyz[Vi->p2].i; + (*ti)[2]=pxyz[Vi->p3].i; + } + + delete[] V; + delete[] pxyz; + {Stack->push<Intarray2*>(t); return;} +} + + +// File operations +#line 5451 "runtime.in" +// bool ==(file *a, file *b); +void gen480(stack *Stack) +{ + file * b=vm::pop<file *>(Stack); + file * a=vm::pop<file *>(Stack); +#line 5452 "runtime.in" + {Stack->push<bool>(a == b); return;} +} + +#line 5457 "runtime.in" +// bool !=(file *a, file *b); +void gen481(stack *Stack) +{ + file * b=vm::pop<file *>(Stack); + file * a=vm::pop<file *>(Stack); +#line 5458 "runtime.in" + {Stack->push<bool>(a != b); return;} +} + +#line 5462 "runtime.in" +void nullFile(stack *Stack) +{ +#line 5463 "runtime.in" + {Stack->push<file*>(&camp::nullfile); return;} +} + +#line 5467 "runtime.in" +// file* input(string name, bool check=true, string comment=commentchar); +void gen483(stack *Stack) +{ + string comment=vm::pop<string>(Stack,commentchar); + bool check=vm::pop<bool>(Stack,true); + string name=vm::pop<string>(Stack); +#line 5468 "runtime.in" + char c=comment.empty() ? (char) 0 : comment[0]; + file *f=new ifile(name,c,check); + f->open(); + {Stack->push<file*>(f); return;} +} + +#line 5475 "runtime.in" +// file* output(string name, bool update=false, string comment=commentchar); +void gen484(stack *Stack) +{ + string comment=vm::pop<string>(Stack,commentchar); + bool update=vm::pop<bool>(Stack,false); + string name=vm::pop<string>(Stack); +#line 5476 "runtime.in" + file *f; + if(update) { + char c=comment.empty() ? (char) 0 : comment[0]; + f=new iofile(name,c); + } else f=new ofile(name); + f->open(); + if(update) f->seek(0,false); + {Stack->push<file*>(f); return;} +} + +#line 5487 "runtime.in" +// file* xinput(string name, bool check=true); +void gen485(stack *Stack) +{ + bool check=vm::pop<bool>(Stack,true); + string name=vm::pop<string>(Stack); +#line 5488 "runtime.in" +#ifdef HAVE_RPC_RPC_H + file *f=new ixfile(name,check); + f->open(); + {Stack->push<file*>(f); return;} +#else + ostringstream buf; + buf << name << ": XDR read support not enabled"; + error(buf); + unused(&check); // Suppress unused variable warning +#endif +} + +#line 5501 "runtime.in" +// file* xoutput(string name, bool update=false); +void gen486(stack *Stack) +{ + bool update=vm::pop<bool>(Stack,false); + string name=vm::pop<string>(Stack); +#line 5502 "runtime.in" +#ifdef HAVE_RPC_RPC_H + file *f; + if(update) + f=new ioxfile(name); + else f=new oxfile(name); + f->open(); + if(update) f->seek(0,false); + {Stack->push<file*>(f); return;} +#else + ostringstream buf; + buf << name << ": XDR write support not enabled"; + error(buf); + unused(&update); // Suppress unused variable warning +#endif +} + +#line 5519 "runtime.in" +// file* binput(string name, bool check=true); +void gen487(stack *Stack) +{ + bool check=vm::pop<bool>(Stack,true); + string name=vm::pop<string>(Stack); +#line 5520 "runtime.in" + file *f=new ibfile(name,check); + f->open(); + {Stack->push<file*>(f); return;} +} + +#line 5526 "runtime.in" +// file* boutput(string name, bool update=false); +void gen488(stack *Stack) +{ + bool update=vm::pop<bool>(Stack,false); + string name=vm::pop<string>(Stack); +#line 5527 "runtime.in" + file *f; + if(update) f=new iobfile(name); + else f=new obfile(name); + f->open(); + if(update) f->seek(0,false); + {Stack->push<file*>(f); return;} +} + +#line 5536 "runtime.in" +// bool eof(file *File); +void gen489(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5537 "runtime.in" + {Stack->push<bool>(File->eof()); return;} +} + +#line 5541 "runtime.in" +// bool eol(file *File); +void gen490(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5542 "runtime.in" + {Stack->push<bool>(File->eol()); return;} +} + +#line 5546 "runtime.in" +// bool error(file *File); +void gen491(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5547 "runtime.in" + {Stack->push<bool>(File->error()); return;} +} + +#line 5551 "runtime.in" +// void clear(file *File); +void gen492(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5552 "runtime.in" + File->clear(); +} + +#line 5556 "runtime.in" +// void close(file *File); +void gen493(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5557 "runtime.in" + File->close(); +} + +#line 5561 "runtime.in" +// Int precision(file *File=NULL, Int digits=0); +void gen494(stack *Stack) +{ + Int digits=vm::pop<Int>(Stack,0); + file * File=vm::pop<file *>(Stack,NULL); +#line 5562 "runtime.in" + if(File == 0) File=&camp::Stdout; + {Stack->push<Int>(File->precision(digits)); return;} +} + +#line 5567 "runtime.in" +// void flush(file *File); +void gen495(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5568 "runtime.in" + File->flush(); +} + +#line 5572 "runtime.in" +// string getc(file *File); +void gen496(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5573 "runtime.in" + char c=0; + if(File->isOpen()) File->read(c); + static char str[1]; + str[0]=c; + {Stack->push<string>(string(str)); return;} +} + +#line 5581 "runtime.in" +// Int tell(file *File); +void gen497(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5582 "runtime.in" + {Stack->push<Int>(File->tell()); return;} +} + +#line 5586 "runtime.in" +// void seek(file *File, Int pos); +void gen498(stack *Stack) +{ + Int pos=vm::pop<Int>(Stack); + file * File=vm::pop<file *>(Stack); +#line 5587 "runtime.in" + File->seek(pos,pos >= 0); +} + +#line 5591 "runtime.in" +// void seekeof(file *File); +void gen499(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5592 "runtime.in" + File->seek(0,false); +} + +// Set file dimensions +#line 5597 "runtime.in" +// file* dimension(file *File, Int nx); +void gen500(stack *Stack) +{ + Int nx=vm::pop<Int>(Stack); + file * File=vm::pop<file *>(Stack); +#line 5598 "runtime.in" + File->dimension(nx); + {Stack->push<file*>(File); return;} +} + +#line 5603 "runtime.in" +// file* dimension(file *File, Int nx, Int ny); +void gen501(stack *Stack) +{ + Int ny=vm::pop<Int>(Stack); + Int nx=vm::pop<Int>(Stack); + file * File=vm::pop<file *>(Stack); +#line 5604 "runtime.in" + File->dimension(nx,ny); + {Stack->push<file*>(File); return;} +} + +#line 5609 "runtime.in" +// file* dimension(file *File, Int nx, Int ny, Int nz); +void gen502(stack *Stack) +{ + Int nz=vm::pop<Int>(Stack); + Int ny=vm::pop<Int>(Stack); + Int nx=vm::pop<Int>(Stack); + file * File=vm::pop<file *>(Stack); +#line 5610 "runtime.in" + File->dimension(nx,ny,nz); + {Stack->push<file*>(File); return;} +} + +// Set file to read comma-separated values +#line 5616 "runtime.in" +// file* csv(file *File, bool b=true); +void gen503(stack *Stack) +{ + bool b=vm::pop<bool>(Stack,true); + file * File=vm::pop<file *>(Stack); +#line 5617 "runtime.in" + File->CSVMode(b); + {Stack->push<file*>(File); return;} +} + +// Set file to read whitespace-separated values +#line 5623 "runtime.in" +// file* word(file *File, bool b=true); +void gen504(stack *Stack) +{ + bool b=vm::pop<bool>(Stack,true); + file * File=vm::pop<file *>(Stack); +#line 5624 "runtime.in" + File->WordMode(b); + {Stack->push<file*>(File); return;} +} + +// Set file to read arrays in line-at-a-time mode +#line 5630 "runtime.in" +// file* line(file *File, bool b=true); +void gen505(stack *Stack) +{ + bool b=vm::pop<bool>(Stack,true); + file * File=vm::pop<file *>(Stack); +#line 5631 "runtime.in" + File->LineMode(b); + {Stack->push<file*>(File); return;} +} + +// Set file to read/write single-precision XDR values. +#line 5637 "runtime.in" +// file* single(file *File, bool b=true); +void gen506(stack *Stack) +{ + bool b=vm::pop<bool>(Stack,true); + file * File=vm::pop<file *>(Stack); +#line 5638 "runtime.in" + File->SingleReal(b); + File->SingleInt(b); + {Stack->push<file*>(File); return;} +} + +// Set file to read/write single-precision real XDR values. +#line 5645 "runtime.in" +// file* single(file *File, real x, bool b=true); +void gen507(stack *Stack) +{ + bool b=vm::pop<bool>(Stack,true); + real x=vm::pop<real>(Stack); + file * File=vm::pop<file *>(Stack); +#line 5646 "runtime.in" + File->SingleReal(b); + unused(&x); + {Stack->push<file*>(File); return;} +} + +// Set file to read/write single-precision int XDR values. +#line 5653 "runtime.in" +// file* single(file *File, Int x, bool b=true); +void gen508(stack *Stack) +{ + bool b=vm::pop<bool>(Stack,true); + Int x=vm::pop<Int>(Stack); + file * File=vm::pop<file *>(Stack); +#line 5654 "runtime.in" + File->SingleInt(b); + unused(&x); + {Stack->push<file*>(File); return;} +} + +// Set file to read an array1 (1 Int size followed by a 1d array) +#line 5661 "runtime.in" +// file* read1(file *File); +void gen509(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5662 "runtime.in" + File->dimension(-2); + {Stack->push<file*>(File); return;} +} + +// Set file to read an array2 (2 Int sizes followed by a 2d array) +#line 5668 "runtime.in" +// file* read2(file *File); +void gen510(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5669 "runtime.in" + File->dimension(-2,-2); + {Stack->push<file*>(File); return;} +} + +// Set file to read an array3 (3 Int sizes followed by a 3d array) +#line 5675 "runtime.in" +// file* read3(file *File); +void gen511(stack *Stack) +{ + file * File=vm::pop<file *>(Stack); +#line 5676 "runtime.in" + File->dimension(-2,-2,-2); + {Stack->push<file*>(File); return;} +} + +// Return the last n lines of the history named name. +#line 5682 "runtime.in" +// stringarray* history(string name, Int n=1); +void gen512(stack *Stack) +{ + Int n=vm::pop<Int>(Stack,1); + string name=vm::pop<string>(Stack); +#line 5683 "runtime.in" +#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) + bool newhistory=historyMap.find(name) == historyMap.end(); + + string filename; + + if(newhistory) { + filename=historyfilename(name); + std::ifstream exists(filename.c_str()); + if(!exists) {Stack->push<stringarray*>(new array(0)); return;} + } + + store_history(&history_save); + HISTORY_STATE& history=historyMap[name].state; + history_set_history_state(&history); + + if(newhistory) + read_history(filename.c_str()); + + array *a=get_history(n); + + store_history(&history); + history_set_history_state(&history_save); + + {Stack->push<stringarray*>(a); return;} +#else + unused(&n); + {Stack->push<stringarray*>(new array(0)); return;} +#endif +} + +// Return the last n lines of the interactive history. +#line 5715 "runtime.in" +// stringarray* history(Int n=0); +void gen513(stack *Stack) +{ + Int n=vm::pop<Int>(Stack,0); +#line 5716 "runtime.in" +#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) + {Stack->push<stringarray*>(get_history(n)); return;} +#else + unused(&n); + {Stack->push<stringarray*>(new array(0)); return;} +#endif +} + +// Prompt for a string using prompt, the GNU readline library, and a +// local history named name. +#line 5727 "runtime.in" +// string readline(string prompt=emptystring, string name=emptystring, bool tabcompletion=false); +void gen514(stack *Stack) +{ + bool tabcompletion=vm::pop<bool>(Stack,false); + string name=vm::pop<string>(Stack,emptystring); + string prompt=vm::pop<string>(Stack,emptystring); +#line 5729 "runtime.in" + if(!isatty(STDIN_FILENO)) + {Stack->push<string>(emptystring); return;} +#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) + init_readline(tabcompletion); + + store_history(&history_save); + bool newhistory=historyMap.find(name) == historyMap.end(); + historyState& h=historyMap[name]; + HISTORY_STATE& history=h.state; + history_set_history_state(&history); + + if(newhistory) + read_history(historyfilename(name).c_str()); + + static char *line=NULL; + /* Return the memory to the free pool + if the buffer has already been allocated. */ + if(line) { + free(line); + line=NULL; + } + + /* Get a line from the user. */ + line=readline(prompt.c_str()); + + if(!line) cout << endl; + + history_set_history_state(&history_save); + + {Stack->push<string>(line ? string(line) : emptystring); return;} +#else + cout << prompt; + string s; + getline(cin,s); + unused(&tabcompletion); // Avoid unused variable warning message. + {Stack->push<string>(s); return;} +#endif +} + +// Save a string in a local history named name. +// If store=true, store the local history in the file historyfilename(name). +#line 5771 "runtime.in" +// void saveline(string name, string value, bool store=true); +void gen515(stack *Stack) +{ + bool store=vm::pop<bool>(Stack,true); + string value=vm::pop<string>(Stack); + string name=vm::pop<string>(Stack); +#line 5772 "runtime.in" +#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) + store_history(&history_save); + bool newhistory=historyMap.find(name) == historyMap.end(); + historyState& h=historyMap[name]; + h.store=store; + HISTORY_STATE& history=h.state; + history_set_history_state(&history); + + if(newhistory) + read_history(historyfilename(name).c_str()); + + if(value != "") { + add_history(value.c_str()); + if(store) { + std::ofstream hout(historyfilename(name).c_str(),std::ios::app); + hout << value << endl; + } + } + + store_history(&history); + history_set_history_state(&history_save); +#else + unused(&store); +#endif +} + +#line 5799 "runtime.in" +// void generate_random_backtrace(); +void gen516(stack *) +{ +#line 5800 "runtime.in" +#if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE) + GC_generate_random_backtrace(); +#else + error("generate_random_backtrace() requires ./configure --enable-gc-debug"); +#endif +} + +#line 5808 "runtime.in" +// void print_random_addresses(Int n=1); +void gen517(stack *Stack) +{ + Int n=vm::pop<Int>(Stack,1); +#line 5809 "runtime.in" +#if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE) + GC_gcollect(); + for (Int i=0; i < n; ++i) + GC_debug_print_heap_obj_proc(GC_base(GC_generate_random_valid_address())); +#else + error("print_random_addresses() requires ./configure --enable-gc-debug"); + unused(&n); // Avoid unused variable warning message. +#endif +} + +} // namespace run + +namespace trans { + +void gen_base_venv(venv &ve) +{ +#line 1074 "runtime.in" + addFunc(ve, run::gen8, primBoolean(), "!", formal(primBoolean(), "b", false, false)); +#line 1102 "runtime.in" + addFunc(ve, run::gen13, primInt(), "AND", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); +#line 1110 "runtime.in" + addFunc(ve, run::gen14, primInt(), "OR", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); +#line 1115 "runtime.in" + addFunc(ve, run::gen15, primInt(), "XOR", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); +#line 1120 "runtime.in" + addFunc(ve, run::gen16, primInt(), "NOT", formal(primInt(), "a", false, false)); +#line 1151 "runtime.in" + addFunc(ve, run::gen21, primBoolean(), "empty", formal(primPicture(), "f", false, false)); +#line 1156 "runtime.in" + addFunc(ve, run::gen22, primVoid(), "erase", formal(primPicture(), "f", false, false)); +#line 1161 "runtime.in" + addFunc(ve, run::gen23, primPair(), "min", formal(primPicture(), "f", false, false)); +#line 1166 "runtime.in" + addFunc(ve, run::gen24, primPair(), "max", formal(primPicture(), "f", false, false)); +#line 1171 "runtime.in" + addFunc(ve, run::gen25, primVoid(), "label", formal(primPicture(), "f", false, false), formal(primString(), "s", false, false), formal(primString(), "size", false, false), formal(primTransform(), "t", false, false), formal(primPair(), "position", false, false), formal(primPair(), "align", false, false), formal(primPen(), "p", false, false)); +#line 1177 "runtime.in" + addFunc(ve, run::gen26, primBoolean(), "labels", formal(primPicture(), "f", false, false)); +#line 1182 "runtime.in" + addFunc(ve, run::gen27, pathArray() , "_texpath", formal(primString(), "s", false, false), formal(primPen(), "p", true, false)); +#line 1249 "runtime.in" + addFunc(ve, run::gen28, pathArray() , "_strokepath", formal(primPath(), "g", false, false), formal(primPen(), "p", true, false)); +#line 1273 "runtime.in" + addFunc(ve, run::gen29, primVoid(), "_draw", formal(primPicture(), "f", false, false), formal(primPath(), "g", false, false), formal(primPen(), "p", false, false)); +#line 1278 "runtime.in" + addFunc(ve, run::gen30, primVoid(), "fill", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primPen(), "p", true, false), formal(primBoolean(), "copy", true, false)); +#line 1284 "runtime.in" + addFunc(ve, run::gen31, primVoid(), "latticeshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray2() , "p", false, false), formal(primBoolean(), "copy", true, false)); +#line 1291 "runtime.in" + addFunc(ve, run::gen32, primVoid(), "axialshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "pena", false, false), formal(primPair(), "a", false, false), formal(primPen(), "penb", false, false), formal(primPair(), "b", false, false), formal(primBoolean(), "copy", true, false)); +#line 1298 "runtime.in" + addFunc(ve, run::gen33, primVoid(), "radialshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "pena", false, false), formal(primPair(), "a", false, false), formal(primReal(), "ra", false, false), formal(primPen(), "penb", false, false), formal(primPair(), "b", false, false), formal(primReal(), "rb", false, false), formal(primBoolean(), "copy", true, false)); +#line 1305 "runtime.in" + addFunc(ve, run::gen34, primVoid(), "gouraudshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray() , "p", false, false), formal(pairArray(), "z", false, false), formal(IntArray(), "edges", false, false), formal(primBoolean(), "copy", true, false)); +#line 1316 "runtime.in" + addFunc(ve, run::gen35, primVoid(), "gouraudshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray() , "p", false, false), formal(IntArray(), "edges", false, false), formal(primBoolean(), "copy", true, false)); +#line 1340 "runtime.in" + addFunc(ve, run::gen36, primVoid(), "tensorshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray2() , "p", false, false), formal(pathArray() , "b", true, false), formal(pairArray2(), "z", true, false), formal(primBoolean(), "copy", true, false)); +#line 1355 "runtime.in" + addFunc(ve, run::gen37, primVoid(), "functionshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primString() , "shader", true, false), formal(primBoolean(), "copy", true, false)); +#line 1363 "runtime.in" + addFunc(ve, run::gen38, primVoid(), "clip", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primBoolean(), "copy", true, false)); +#line 1373 "runtime.in" + addFunc(ve, run::gen39, primVoid(), "beginclip", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primBoolean(), "copy", true, false)); +#line 1380 "runtime.in" + addFunc(ve, run::gen40, primVoid(), "endclip", formal(primPicture(), "f", false, false)); +#line 1385 "runtime.in" + addFunc(ve, run::gen41, primVoid(), "gsave", formal(primPicture(), "f", false, false)); +#line 1390 "runtime.in" + addFunc(ve, run::gen42, primVoid(), "grestore", formal(primPicture(), "f", false, false)); +#line 1395 "runtime.in" + addFunc(ve, run::gen43, primVoid(), "begingroup", formal(primPicture(), "f", false, false)); +#line 1400 "runtime.in" + addFunc(ve, run::gen44, primVoid(), "endgroup", formal(primPicture(), "f", false, false)); +#line 1405 "runtime.in" + addFunc(ve, run::gen45, primVoid(), "add", formal(primPicture(), "dest", false, false), formal(primPicture(), "src", false, false)); +#line 1410 "runtime.in" + addFunc(ve, run::gen46, primVoid(), "prepend", formal(primPicture(), "dest", false, false), formal(primPicture(), "src", false, false)); +#line 1415 "runtime.in" + addFunc(ve, run::gen47, primVoid(), "postscript", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false)); +#line 1420 "runtime.in" + addFunc(ve, run::gen48, primVoid(), "tex", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false)); +#line 1425 "runtime.in" + addFunc(ve, run::gen49, primVoid(), "postscript", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primPair(), "min", false, false), formal(primPair(), "max", false, false)); +#line 1430 "runtime.in" + addFunc(ve, run::gen50, primVoid(), "tex", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primPair(), "min", false, false), formal(primPair(), "max", false, false)); +#line 1435 "runtime.in" + addFunc(ve, run::gen51, primVoid(), "texpreamble", formal(primString() , "s", false, false)); +#line 1443 "runtime.in" + addFunc(ve, run::gen52, primVoid(), "deletepreamble"); +#line 1450 "runtime.in" + addFunc(ve, run::gen53, primVoid(), "_labelpath", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primString() , "size", false, false), formal(primPath(), "g", false, false), formal(primString() , "justify", false, false), formal(primPair(), "offset", false, false), formal(primPen(), "p", false, false)); +#line 1456 "runtime.in" + addFunc(ve, run::gen54, primVoid(), "texreset"); +#line 1464 "runtime.in" + addFunc(ve, run::gen55, primVoid(), "layer", formal(primPicture(), "f", false, false)); +#line 1469 "runtime.in" + addFunc(ve, run::gen56, primVoid(), "newpage", formal(primPicture(), "f", false, false)); +#line 1474 "runtime.in" + addFunc(ve, run::gen57, primVoid(), "_image", formal(primPicture(), "f", false, false), formal(realArray2(), "data", false, false), formal(primPair(), "initial", false, false), formal(primPair(), "final", false, false), formal(penArray() , "palette", true, false), formal(primTransform(), "t", true, false), formal(primBoolean(), "copy", true, false), formal(primBoolean(), "antialias", true, false)); +#line 1484 "runtime.in" + addFunc(ve, run::gen58, primVoid(), "_image", formal(primPicture(), "f", false, false), formal(penArray2() , "data", false, false), formal(primPair(), "initial", false, false), formal(primPair(), "final", false, false), formal(primTransform(), "t", true, false), formal(primBoolean(), "copy", true, false), formal(primBoolean(), "antialias", true, false)); +#line 1491 "runtime.in" + addFunc(ve, run::gen59, primString() , "nativeformat"); +#line 1496 "runtime.in" + addFunc(ve, run::gen60, primBoolean(), "latex"); +#line 1501 "runtime.in" + addFunc(ve, run::gen61, primBoolean(), "pdf"); +#line 1506 "runtime.in" + addFunc(ve, run::gen62, primVoid(), "shipout", formal(primString() , "prefix", true, false), formal(primPicture(), "f", false, false), formal(primPicture(), "preamble", true, false), formal(primString() , "format", true, false), formal(primBoolean(), "wait", true, false), formal(primBoolean(), "view", true, false), formal(transformFunction(), "xform", false, false)); +#line 1552 "runtime.in" + addFunc(ve, run::gen63, primVoid(), "shipout3", formal(primString() , "prefix", false, false), formal(primPicture(), "f", false, false), formal(primString() , "format", true, false), formal(primReal(), "width", false, false), formal(primReal(), "height", false, false), formal(primReal(), "angle", false, false), formal(primTriple(), "m", false, false), formal(primTriple(), "m", false, false), formal(realArray2(), "t", false, false), formal(tripleArray(), "lights", false, false), formal(realArray2(), "diffuse", false, false), formal(realArray2(), "ambient", false, false), formal(realArray2(), "specular", false, false), formal(primBoolean(), "viewportlighting", false, false), formal(primBoolean(), "view", true, false)); +#line 1568 "runtime.in" + addFunc(ve, run::gen64, primVoid(), "shipout3", formal(primString() , "prefix", false, false), formal(primPicture(), "f", false, false)); +#line 1573 "runtime.in" + addFunc(ve, run::gen65, primVoid(), "deconstruct", formal(primPicture(), "f", false, false), formal(primPicture(), "preamble", true, false), formal(primReal(), "magnification", true, false), formal(transformFunction(), "xform", false, false)); +#line 1706 "runtime.in" + addFunc(ve, run::gen66, primVoid(), "purge", formal(primInt(), "divisor", true, false)); +#line 1719 "runtime.in" + addFunc(ve, run::gen68, primBoolean(), "==", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false)); +#line 1724 "runtime.in" + addFunc(ve, run::gen69, primBoolean(), "!=", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false)); +#line 1729 "runtime.in" + addFunc(ve, run::gen70, primPen(), "+", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false)); +#line 1734 "runtime.in" + addFunc(ve, run::gen71, primPen(), "*", formal(primReal(), "a", false, false), formal(primPen(), "b", false, false)); +#line 1739 "runtime.in" + addFunc(ve, run::gen72, primPen(), "*", formal(primPen(), "a", false, false), formal(primReal(), "b", false, false)); +#line 1744 "runtime.in" + addFunc(ve, run::gen73, primPair(), "max", formal(primPen(), "p", false, false)); +#line 1749 "runtime.in" + addFunc(ve, run::gen74, primPair(), "min", formal(primPen(), "p", false, false)); +#line 1754 "runtime.in" + addFunc(ve, run::gen75, primVoid(), "resetdefaultpen"); +#line 1760 "runtime.in" + addFunc(ve, run::gen76, primVoid(), "defaultpen", formal(primPen(), "p", false, false)); +#line 1765 "runtime.in" + addFunc(ve, run::gen77, primPen(), "defaultpen"); +#line 1770 "runtime.in" + addFunc(ve, run::gen78, primBoolean(), "invisible", formal(primPen(), "p", false, false)); +#line 1775 "runtime.in" + addFunc(ve, run::gen79, primPen(), "invisible"); +#line 1780 "runtime.in" + addFunc(ve, run::gen80, primPen(), "gray", formal(primPen(), "p", false, false)); +#line 1786 "runtime.in" + addFunc(ve, run::gen81, primPen(), "rgb", formal(primPen(), "p", false, false)); +#line 1792 "runtime.in" + addFunc(ve, run::gen82, primPen(), "cmyk", formal(primPen(), "p", false, false)); +#line 1798 "runtime.in" + addFunc(ve, run::gen83, primPen(), "interp", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false), formal(primReal(), "t", false, false)); +#line 1803 "runtime.in" + addFunc(ve, run::gen84, primPen(), "rgb", formal(primReal(), "r", false, false), formal(primReal(), "g", false, false), formal(primReal(), "b", false, false)); +#line 1808 "runtime.in" + addFunc(ve, run::gen85, primPen(), "cmyk", formal(primReal(), "c", false, false), formal(primReal(), "m", false, false), formal(primReal(), "y", false, false), formal(primReal(), "k", false, false)); +#line 1813 "runtime.in" + addFunc(ve, run::gen86, primPen(), "gray", formal(primReal(), "gray", false, false)); +#line 1818 "runtime.in" + addFunc(ve, run::gen87, realArray(), "colors", formal(primPen(), "p", false, false)); +#line 1846 "runtime.in" + addFunc(ve, run::gen88, primString() , "colorspace", formal(primPen(), "p", false, false)); +#line 1853 "runtime.in" + addFunc(ve, run::gen89, primPen(), "pattern", formal(primString(), "s", false, false)); +#line 1858 "runtime.in" + addFunc(ve, run::gen90, primString() , "pattern", formal(primPen(), "p", false, false)); +#line 1863 "runtime.in" + addFunc(ve, run::gen91, primPen(), "fillrule", formal(primInt(), "n", false, false)); +#line 1868 "runtime.in" + addFunc(ve, run::gen92, primInt(), "fillrule", formal(primPen(), "p", false, false)); +#line 1873 "runtime.in" + addFunc(ve, run::gen93, primPen(), "opacity", formal(primReal(), "opacity", true, false), formal(primString() , "blend", true, false)); +#line 1883 "runtime.in" + addFunc(ve, run::gen94, primReal(), "opacity", formal(primPen(), "p", false, false)); +#line 1888 "runtime.in" + addFunc(ve, run::gen95, primString() , "blend", formal(primPen(), "p", false, false)); +#line 1893 "runtime.in" + addFunc(ve, run::gen96, primPen(), "linetype", formal(primString(), "s", false, false), formal(primReal(), "offset", true, false), formal(primBoolean(), "scale", true, false), formal(primBoolean(), "adjust", true, false)); +#line 1898 "runtime.in" + addFunc(ve, run::gen97, primString() , "linetype", formal(primPen(), "p", true, false)); +#line 1903 "runtime.in" + addFunc(ve, run::gen98, primReal(), "offset", formal(primPen(), "p", false, false)); +#line 1908 "runtime.in" + addFunc(ve, run::gen99, primBoolean(), "scale", formal(primPen(), "p", false, false)); +#line 1913 "runtime.in" + addFunc(ve, run::gen100, primBoolean(), "adjust", formal(primPen(), "p", false, false)); +#line 1918 "runtime.in" + addFunc(ve, run::gen101, primPen(), "adjust", formal(primPen(), "p", false, false), formal(primReal(), "arclength", false, false), formal(primBoolean(), "cyclic", false, false)); +#line 1923 "runtime.in" + addFunc(ve, run::gen102, primPen(), "linecap", formal(primInt(), "n", false, false)); +#line 1928 "runtime.in" + addFunc(ve, run::gen103, primInt(), "linecap", formal(primPen(), "p", true, false)); +#line 1933 "runtime.in" + addFunc(ve, run::gen104, primPen(), "linejoin", formal(primInt(), "n", false, false)); +#line 1938 "runtime.in" + addFunc(ve, run::gen105, primInt(), "linejoin", formal(primPen(), "p", true, false)); +#line 1943 "runtime.in" + addFunc(ve, run::gen106, primPen(), "miterlimit", formal(primReal(), "x", false, false)); +#line 1948 "runtime.in" + addFunc(ve, run::gen107, primReal(), "miterlimit", formal(primPen(), "p", true, false)); +#line 1953 "runtime.in" + addFunc(ve, run::gen108, primPen(), "linewidth", formal(primReal(), "x", false, false)); +#line 1958 "runtime.in" + addFunc(ve, run::gen109, primReal(), "linewidth", formal(primPen(), "p", true, false)); +#line 1963 "runtime.in" + addFunc(ve, run::gen110, primPen(), "fontcommand", formal(primString(), "s", false, false)); +#line 1968 "runtime.in" + addFunc(ve, run::gen111, primString() , "font", formal(primPen(), "p", true, false)); +#line 1973 "runtime.in" + addFunc(ve, run::gen112, primPen(), "fontsize", formal(primReal(), "size", false, false), formal(primReal(), "lineskip", false, false)); +#line 1979 "runtime.in" + addFunc(ve, run::gen113, primReal(), "fontsize", formal(primPen(), "p", true, false)); +#line 1984 "runtime.in" + addFunc(ve, run::gen114, primReal(), "lineskip", formal(primPen(), "p", true, false)); +#line 1989 "runtime.in" + addFunc(ve, run::gen115, primPen(), "overwrite", formal(primInt(), "n", false, false)); +#line 1995 "runtime.in" + addFunc(ve, run::gen116, primInt(), "overwrite", formal(primPen(), "p", true, false)); +#line 2000 "runtime.in" + addFunc(ve, run::gen117, primPen(), "basealign", formal(primInt(), "n", false, false)); +#line 2005 "runtime.in" + addFunc(ve, run::gen118, primInt(), "basealign", formal(primPen(), "p", true, false)); +#line 2010 "runtime.in" + addFunc(ve, run::gen119, primTransform(), "transform", formal(primPen(), "p", false, false)); +#line 2015 "runtime.in" + addFunc(ve, run::gen120, primPath(), "nib", formal(primPen(), "p", false, false)); +#line 2020 "runtime.in" + addFunc(ve, run::gen121, primPen(), "makepen", formal(primPath(), "p", false, false)); +#line 2025 "runtime.in" + addFunc(ve, run::gen122, primPen(), "colorless", formal(primPen(), "p", false, false)); +#line 2031 "runtime.in" + addFunc(ve, run::gen123, primBoolean(), "interactive"); +#line 2038 "runtime.in" + addFunc(ve, run::gen124, primBoolean(), "uptodate"); +#line 2043 "runtime.in" + addFunc(ve, run::gen125, primInt(), "system", formal(primString() , "s", false, false)); +#line 2053 "runtime.in" + addFunc(ve, run::gen126, primBoolean(), "view"); +#line 2058 "runtime.in" + addFunc(ve, run::gen127, primString() , "asydir"); +#line 2063 "runtime.in" + addFunc(ve, run::gen128, primString() , "locale", formal(primString() , "s", true, false)); +#line 2069 "runtime.in" + addFunc(ve, run::gen129, primVoid(), "abort", formal(primString() , "s", true, false)); +#line 2075 "runtime.in" + addFunc(ve, run::gen130, primVoid(), "exit"); +#line 2080 "runtime.in" + addFunc(ve, run::gen131, primVoid(), "assert", formal(primBoolean(), "b", false, false), formal(primString() , "s", true, false)); +#line 2091 "runtime.in" + addFunc(ve, run::gen132, primVoid(), "sleep", formal(primInt(), "seconds", false, false)); +#line 2097 "runtime.in" + addFunc(ve, run::gen133, primVoid(), "usleep", formal(primInt(), "microseconds", false, false)); +#line 2103 "runtime.in" + addFunc(ve, run::gen134, primVoid(), "_eval", formal(primString(), "s", false, false), formal(primBoolean(), "embedded", false, false), formal(primBoolean(), "interactivewrite", true, false)); +#line 2118 "runtime.in" + addFunc(ve, run::gen135, primVoid(), "_eval", formal(primCode(), "s", false, false), formal(primBoolean(), "embedded", false, false)); +#line 2136 "runtime.in" + addFunc(ve, run::gen136, primString() , "location"); +#line 2148 "runtime.in" + addFunc(ve, run::gen138, primString() , "cd", formal(primString() , "s", true, false)); +#line 2154 "runtime.in" + addFunc(ve, run::gen139, primVoid(), "list", formal(primString(), "s", false, false), formal(primBoolean(), "imports", true, false)); +#line 2171 "runtime.in" + addFunc(ve, run::gen141, primBoolean(), "==", formal(primPath(), "a", false, false), formal(primPath(), "b", false, false)); +#line 2176 "runtime.in" + addFunc(ve, run::gen142, primBoolean(), "!=", formal(primPath(), "a", false, false), formal(primPath(), "b", false, false)); +#line 2181 "runtime.in" + addFunc(ve, run::gen143, primPair(), "point", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2186 "runtime.in" + addFunc(ve, run::gen144, primPair(), "point", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2191 "runtime.in" + addFunc(ve, run::gen145, primPair(), "precontrol", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2196 "runtime.in" + addFunc(ve, run::gen146, primPair(), "precontrol", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2201 "runtime.in" + addFunc(ve, run::gen147, primPair(), "postcontrol", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2206 "runtime.in" + addFunc(ve, run::gen148, primPair(), "postcontrol", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2211 "runtime.in" + addFunc(ve, run::gen149, primPair(), "dir", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false), formal(primBoolean(), "normalize", true, false)); +#line 2216 "runtime.in" + addFunc(ve, run::gen150, primPair(), "dir", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "normalize", true, false)); +#line 2221 "runtime.in" + addFunc(ve, run::gen151, primPair(), "accel", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false)); +#line 2226 "runtime.in" + addFunc(ve, run::gen152, primPair(), "accel", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2231 "runtime.in" + addFunc(ve, run::gen153, primReal(), "radius", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2243 "runtime.in" + addFunc(ve, run::gen154, primPath(), "reverse", formal(primPath(), "p", false, false)); +#line 2248 "runtime.in" + addFunc(ve, run::gen155, primPath(), "subpath", formal(primPath(), "p", false, false), formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); +#line 2253 "runtime.in" + addFunc(ve, run::gen156, primPath(), "subpath", formal(primPath(), "p", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false)); +#line 2258 "runtime.in" + addFunc(ve, run::gen157, primPath(), "nurb", formal(primPair(), "z0", false, false), formal(primPair(), "z1", false, false), formal(primPair(), "z2", false, false), formal(primPair(), "z3", false, false), formal(primReal(), "w0", false, false), formal(primReal(), "w1", false, false), formal(primReal(), "w2", false, false), formal(primReal(), "w3", false, false), formal(primInt(), "m", false, false)); +#line 2264 "runtime.in" + addFunc(ve, run::gen158, primInt(), "length", formal(primPath(), "p", false, false)); +#line 2269 "runtime.in" + addFunc(ve, run::gen159, primBoolean(), "cyclic", formal(primPath(), "p", false, false)); +#line 2274 "runtime.in" + addFunc(ve, run::gen160, primBoolean(), "straight", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2279 "runtime.in" + addFunc(ve, run::gen161, primPath(), "unstraighten", formal(primPath(), "p", false, false)); +#line 2284 "runtime.in" + addFunc(ve, run::gen162, primBoolean(), "piecewisestraight", formal(primPath(), "p", false, false)); +#line 2289 "runtime.in" + addFunc(ve, run::gen163, primReal(), "arclength", formal(primPath(), "p", false, false)); +#line 2294 "runtime.in" + addFunc(ve, run::gen164, primReal(), "arctime", formal(primPath(), "p", false, false), formal(primReal(), "dval", false, false)); +#line 2299 "runtime.in" + addFunc(ve, run::gen165, primReal(), "dirtime", formal(primPath(), "p", false, false), formal(primPair(), "z", false, false)); +#line 2304 "runtime.in" + addFunc(ve, run::gen166, realArray(), "intersect", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false), formal(primReal(), "fuzz", true, false)); +#line 2321 "runtime.in" + addFunc(ve, run::gen167, realArray2(), "intersections", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false), formal(primReal(), "fuzz", true, false)); +#line 2352 "runtime.in" + addFunc(ve, run::gen168, realArray(), "intersections", formal(primPath(), "p", false, false), formal(primPair(), "a", false, true), formal(primPair(), "b", false, true), formal(primReal(), "fuzz", true, false)); +#line 2367 "runtime.in" + addFunc(ve, run::gen169, primPair(), "extension", formal(primPair(), "p", false, false), formal(primPair(), "q", false, false), formal(primPair(), "p", false, false), formal(primPair(), "q", false, false)); +#line 2378 "runtime.in" + addFunc(ve, run::gen170, primInt(), "size", formal(primPath(), "p", false, false)); +#line 2383 "runtime.in" + addFunc(ve, run::gen171, primPath(), "&", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false)); +#line 2388 "runtime.in" + addFunc(ve, run::gen172, primPair(), "min", formal(primPath(), "p", false, false)); +#line 2393 "runtime.in" + addFunc(ve, run::gen173, primPair(), "max", formal(primPath(), "p", false, false)); +#line 2398 "runtime.in" + addFunc(ve, run::gen174, realArray(), "mintimes", formal(primPath(), "p", false, false)); +#line 2407 "runtime.in" + addFunc(ve, run::gen175, realArray(), "maxtimes", formal(primPath(), "p", false, false)); +#line 2416 "runtime.in" + addFunc(ve, run::gen176, primReal(), "relativedistance", formal(primReal(), "theta", false, false), formal(primReal(), "phi", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "atleast", false, false)); +#line 2421 "runtime.in" + addFunc(ve, run::gen177, primInt(), "windingnumber", formal(pathArray() , "p", false, false), formal(primPair(), "z", false, false)); +#line 2426 "runtime.in" + addFunc(ve, run::gen178, primBoolean(), "inside", formal(pathArray() , "g", false, true), formal(primPair(), "z", false, false), formal(primPen(), "fillrule", true, false)); +#line 2431 "runtime.in" + addFunc(ve, run::gen179, primBoolean(), "inside", formal(primPath(), "g", false, false), formal(primPair(), "z", false, false), formal(primPen(), "fillrule", true, false)); +#line 2436 "runtime.in" + addFunc(ve, run::gen180, primReal(), "side", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false)); +#line 2443 "runtime.in" + addFunc(ve, run::gen181, primReal(), "incircle", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false)); +#line 2451 "runtime.in" + addFunc(ve, run::gen182, primPath3(), "path3", formal(tripleArray(), "pre", false, false), formal(tripleArray(), "point", false, false), formal(tripleArray(), "post", false, false), formal(boolArray(), "straight", false, false), formal(primBoolean(), "cyclic", false, false)); +#line 2476 "runtime.in" + addFunc(ve, run::gen184, primBoolean(), "==", formal(primPath3(), "a", false, false), formal(primPath3(), "b", false, false)); +#line 2481 "runtime.in" + addFunc(ve, run::gen185, primBoolean(), "!=", formal(primPath3(), "a", false, false), formal(primPath3(), "b", false, false)); +#line 2486 "runtime.in" + addFunc(ve, run::gen186, primTriple(), "point", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2491 "runtime.in" + addFunc(ve, run::gen187, primTriple(), "point", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2496 "runtime.in" + addFunc(ve, run::gen188, primTriple(), "precontrol", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2501 "runtime.in" + addFunc(ve, run::gen189, primTriple(), "precontrol", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2506 "runtime.in" + addFunc(ve, run::gen190, primTriple(), "postcontrol", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2511 "runtime.in" + addFunc(ve, run::gen191, primTriple(), "postcontrol", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2516 "runtime.in" + addFunc(ve, run::gen192, primTriple(), "dir", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false), formal(primBoolean(), "normalize", true, false)); +#line 2521 "runtime.in" + addFunc(ve, run::gen193, primTriple(), "dir", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "normalize", true, false)); +#line 2526 "runtime.in" + addFunc(ve, run::gen194, primTriple(), "accel", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false)); +#line 2531 "runtime.in" + addFunc(ve, run::gen195, primTriple(), "accel", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2536 "runtime.in" + addFunc(ve, run::gen196, primReal(), "radius", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false)); +#line 2548 "runtime.in" + addFunc(ve, run::gen197, primReal(), "radius", formal(primTriple(), "z0", false, false), formal(primTriple(), "c0", false, false), formal(primTriple(), "c1", false, false), formal(primTriple(), "z1", false, false), formal(primReal(), "t", false, false)); +#line 2560 "runtime.in" + addFunc(ve, run::gen198, primPath3(), "reverse", formal(primPath3(), "p", false, false)); +#line 2565 "runtime.in" + addFunc(ve, run::gen199, primPath3(), "subpath", formal(primPath3(), "p", false, false), formal(primInt(), "a", false, false), formal(primInt(), "b", false, false)); +#line 2570 "runtime.in" + addFunc(ve, run::gen200, primPath3(), "subpath", formal(primPath3(), "p", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false)); +#line 2575 "runtime.in" + addFunc(ve, run::gen201, primInt(), "length", formal(primPath3(), "p", false, false)); +#line 2580 "runtime.in" + addFunc(ve, run::gen202, primBoolean(), "cyclic", formal(primPath3(), "p", false, false)); +#line 2585 "runtime.in" + addFunc(ve, run::gen203, primBoolean(), "straight", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2590 "runtime.in" + addFunc(ve, run::gen204, primTriple(), "perp", formal(primTriple(), "v", false, false), formal(primTriple(), "u", false, false)); +#line 2596 "runtime.in" + addFunc(ve, run::gen205, primReal(), "straightness", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false)); +#line 2607 "runtime.in" + addFunc(ve, run::gen206, primReal(), "straightness", formal(primTriple(), "z0", false, false), formal(primTriple(), "c0", false, false), formal(primTriple(), "c1", false, false), formal(primTriple(), "z1", false, false)); +#line 2615 "runtime.in" + addFunc(ve, run::gen207, primBoolean(), "piecewisestraight", formal(primPath3(), "p", false, false)); +#line 2620 "runtime.in" + addFunc(ve, run::gen208, primReal(), "arclength", formal(primPath3(), "p", false, false)); +#line 2625 "runtime.in" + addFunc(ve, run::gen209, primReal(), "arctime", formal(primPath3(), "p", false, false), formal(primReal(), "dval", false, false)); +#line 2630 "runtime.in" + addFunc(ve, run::gen210, realArray(), "intersect", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false), formal(primReal(), "fuzz", true, false)); +#line 2648 "runtime.in" + addFunc(ve, run::gen211, realArray2(), "intersections", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false), formal(primReal(), "fuzz", true, false)); +#line 2681 "runtime.in" + addFunc(ve, run::gen212, primInt(), "size", formal(primPath3(), "p", false, false)); +#line 2686 "runtime.in" + addFunc(ve, run::gen213, primPath3(), "&", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false)); +#line 2691 "runtime.in" + addFunc(ve, run::gen214, primTriple(), "min", formal(primPath3(), "p", false, false)); +#line 2696 "runtime.in" + addFunc(ve, run::gen215, primTriple(), "max", formal(primPath3(), "p", false, false)); +#line 2701 "runtime.in" + addFunc(ve, run::gen216, realArray(), "mintimes", formal(primPath3(), "p", false, false)); +#line 2711 "runtime.in" + addFunc(ve, run::gen217, realArray(), "maxtimes", formal(primPath3(), "p", false, false)); +#line 2721 "runtime.in" + addFunc(ve, run::gen218, primPath3(), "*", formal(realArray2(), "t", false, false), formal(primPath3(), "g", false, false)); +#line 2776 "runtime.in" + addFunc(ve, run::gen223, primGuide(), "operator cast", formal(primCycleToken(), "tok", false, false)); +#line 2783 "runtime.in" + addFunc(ve, run::gen224, primGuide(), "operator spec", formal(primPair(), "z", false, false), formal(primInt(), "p", false, false)); +#line 2791 "runtime.in" + addFunc(ve, run::gen225, primCurlSpecifier(), "operator curl", formal(primReal(), "gamma", false, false), formal(primInt(), "p", false, false)); +#line 2807 "runtime.in" + addFunc(ve, run::gen228, primGuide(), "operator cast", formal(primCurlSpecifier(), "spec", false, false)); +#line 2812 "runtime.in" + addFunc(ve, run::gen229, primTensionSpecifier(), "operator tension", formal(primReal(), "tout", false, false), formal(primReal(), "tin", false, false), formal(primBoolean(), "atleast", false, false)); +#line 2832 "runtime.in" + addFunc(ve, run::gen233, primGuide(), "operator cast", formal(primTensionSpecifier(), "t", false, false)); +#line 2837 "runtime.in" + addFunc(ve, run::gen234, primGuide(), "operator controls", formal(primPair(), "zout", false, false), formal(primPair(), "zin", false, false)); +#line 2842 "runtime.in" + addFunc(ve, run::gen235, primInt(), "size", formal(primGuide(), "g", false, false)); +#line 2849 "runtime.in" + addFunc(ve, run::gen236, primInt(), "length", formal(primGuide(), "g", false, false)); +#line 2856 "runtime.in" + addFunc(ve, run::gen237, primBoolean(), "cyclic", formal(primGuide(), "g", false, false)); +#line 2863 "runtime.in" + addFunc(ve, run::gen238, primPair(), "point", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); +#line 2870 "runtime.in" + addFunc(ve, run::gen239, pairArray(), "dirSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); +#line 2882 "runtime.in" + addFunc(ve, run::gen240, pairArray(), "controlSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); +#line 2899 "runtime.in" + addFunc(ve, run::gen241, primTensionSpecifier(), "tensionSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); +#line 2909 "runtime.in" + addFunc(ve, run::gen242, realArray(), "curlSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false)); +#line 2923 "runtime.in" + addFunc(ve, run::gen243, primGuide(), "reverse", formal(primGuide(), "g", false, false)); +#line 2977 "runtime.in" + addFunc(ve, run::gen244, primVoid(), "_draw", formal(primPicture(), "f", false, false), formal(primPath3(), "g", false, false), formal(primPen(), "p", false, false)); +#line 2985 "runtime.in" + addFunc(ve, run::gen245, primVoid(), "draw", formal(primPicture(), "f", false, false), formal(tripleArray2(), "g", false, false), formal(primBoolean(), "straight", false, false), formal(penArray() , "p", false, false), formal(primReal(), "opacity", false, false), formal(primReal(), "shininess", false, false), formal(primReal(), "granularity", false, false), formal(primTriple(), "normal", false, false), formal(primBoolean(), "lighton", false, false), formal(penArray() , "colors", false, false)); +#line 2993 "runtime.in" + addFunc(ve, run::gen246, primTriple(), "min3", formal(primPicture(), "f", false, false)); +#line 2998 "runtime.in" + addFunc(ve, run::gen247, primTriple(), "max3", formal(primPicture(), "f", false, false)); +#line 3003 "runtime.in" + addFunc(ve, run::gen248, primPair(), "min", formal(primPicture(), "f", false, false), formal(realArray2(), "t", false, false)); +#line 3011 "runtime.in" + addFunc(ve, run::gen249, primPair(), "max", formal(primPicture(), "f", false, false), formal(realArray2(), "t", false, false)); +#line 3019 "runtime.in" + addFunc(ve, run::gen250, primPair(), "minratio", formal(primPicture(), "f", false, false)); +#line 3024 "runtime.in" + addFunc(ve, run::gen251, primPair(), "maxratio", formal(primPicture(), "f", false, false)); +#line 3029 "runtime.in" + addFunc(ve, run::gen252, primReal(), "minbound", formal(realArray(), "a", false, false), formal(primReal(), "b", false, false)); +#line 3037 "runtime.in" + addFunc(ve, run::gen253, primReal(), "maxbound", formal(realArray(), "a", false, false), formal(primReal(), "b", false, false)); +#line 3045 "runtime.in" + addFunc(ve, run::gen254, primPair(), "minbound", formal(tripleArray(), "a", false, false), formal(realArray2(), "t", false, false), formal(primPair(), "b", false, false)); +#line 3056 "runtime.in" + addFunc(ve, run::gen255, primPair(), "maxbound", formal(tripleArray(), "a", false, false), formal(realArray2(), "t", false, false), formal(primPair(), "b", false, false)); +#line 3067 "runtime.in" + addFunc(ve, run::gen256, primPair(), "max", formal(primPath3(), "g", false, false), formal(realArray2(), "t", false, false)); +#line 3075 "runtime.in" + addFunc(ve, run::gen257, primPair(), "min", formal(primPath3(), "g", false, false), formal(realArray2(), "t", false, false)); +#line 3083 "runtime.in" + addFunc(ve, run::gen258, primReal(), "change2", formal(tripleArray2(), "a", false, false)); +#line 3105 "runtime.in" + addFunc(ve, run::gen259, primBoolean(), "is3D", formal(primPicture(), "f", false, false)); +#line 3110 "runtime.in" + addFunc(ve, run::gen260, primPair(), "bezier", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false)); +#line 3117 "runtime.in" + addFunc(ve, run::gen261, primPair(), "bezierP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false)); +#line 3122 "runtime.in" + addFunc(ve, run::gen262, primPair(), "bezierPP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false)); +#line 3127 "runtime.in" + addFunc(ve, run::gen263, primPair(), "bezierPPP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false)); +#line 3132 "runtime.in" + addFunc(ve, run::gen264, primTriple(), "bezier", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false)); +#line 3139 "runtime.in" + addFunc(ve, run::gen265, primTriple(), "bezierP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false)); +#line 3144 "runtime.in" + addFunc(ve, run::gen266, primTriple(), "bezierPP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false)); +#line 3149 "runtime.in" + addFunc(ve, run::gen267, primTriple(), "bezierPPP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false)); +#line 3162 "runtime.in" + addFunc(ve, run::gen269, primInt(), "length", formal(primString(), "s", false, false)); +#line 3167 "runtime.in" + addFunc(ve, run::gen270, primInt(), "find", formal(primString(), "s", false, false), formal(primString() , "t", false, false), formal(primInt(), "pos", true, false)); +#line 3173 "runtime.in" + addFunc(ve, run::gen271, primInt(), "rfind", formal(primString(), "s", false, false), formal(primString() , "t", false, false), formal(primInt(), "pos", true, false)); +#line 3179 "runtime.in" + addFunc(ve, run::gen272, primString() , "reverse", formal(primString() , "s", false, false)); +#line 3185 "runtime.in" + addFunc(ve, run::gen273, primString() , "insert", formal(primString() , "s", false, false), formal(primInt(), "pos", false, false), formal(primString() , "t", false, false)); +#line 3192 "runtime.in" + addFunc(ve, run::gen274, primString() , "substr", formal(primString(), "s", false, false), formal(primInt(), "pos", false, false), formal(primInt(), "n", true, false)); +#line 3199 "runtime.in" + addFunc(ve, run::gen275, primString() , "erase", formal(primString() , "s", false, false), formal(primInt(), "pos", false, false), formal(primInt(), "n", false, false)); +#line 3206 "runtime.in" + addFunc(ve, run::gen276, primString() , "downcase", formal(primString() , "s", false, false)); +#line 3212 "runtime.in" + addFunc(ve, run::gen277, primString() , "upcase", formal(primString() , "s", false, false)); +#line 3218 "runtime.in" + addFunc(ve, run::gen278, primString() , "replace", formal(primString(), "s", false, false), formal(stringArray2(), "translate", false, false)); +#line 3245 "runtime.in" + addFunc(ve, run::gen279, primString() , "format", formal(primString(), "format", false, false), formal(primInt(), "x", false, false)); +#line 3260 "runtime.in" + addFunc(ve, run::gen280, primString() , "format", formal(primString(), "format", false, false), formal(primReal(), "x", false, false), formal(primString() , "locale", true, false)); +#line 3378 "runtime.in" + addFunc(ve, run::gen281, primInt(), "hex", formal(primString() , "s", false, false)); +#line 3389 "runtime.in" + addFunc(ve, run::gen282, primString() , "string", formal(primInt(), "x", false, false)); +#line 3396 "runtime.in" + addFunc(ve, run::gen283, primString() , "string", formal(primReal(), "x", false, false), formal(primInt(), "digits", true, false)); +#line 3404 "runtime.in" + addFunc(ve, run::gen284, primString() , "time", formal(primString() , "format", true, false)); +#line 3415 "runtime.in" + addFunc(ve, run::gen285, primString() , "time", formal(primInt(), "seconds", false, false), formal(primString() , "format", true, false)); +#line 3428 "runtime.in" + addFunc(ve, run::gen286, primInt(), "seconds", formal(primString() , "t", true, false), formal(primString() , "format", true, false)); +#line 3440 "runtime.in" + addFunc(ve, run::gen287, realArray(), "_cputime"); +#line 3454 "runtime.in" + addFunc(ve, run::gen288, primReal(), "^", formal(primReal(), "x", false, false), formal(primInt(), "y", false, false)); +#line 3462 "runtime.in" + addFunc(ve, run::gen289, primPair(), "^", formal(primPair(), "z", false, false), formal(primInt(), "y", false, false)); +#line 3467 "runtime.in" + addFunc(ve, run::gen290, primInt(), "quotient", formal(primInt(), "x", false, false), formal(primInt(), "y", false, false)); +#line 3475 "runtime.in" + addFunc(ve, run::gen291, primInt(), "abs", formal(primInt(), "x", false, false)); +#line 3480 "runtime.in" + addFunc(ve, run::gen292, primInt(), "sgn", formal(primReal(), "x", false, false)); +#line 3485 "runtime.in" + addFunc(ve, run::gen293, primInt(), "rand"); +#line 3490 "runtime.in" + addFunc(ve, run::gen294, primVoid(), "srand", formal(primInt(), "seed", false, false)); +#line 3495 "runtime.in" + addFunc(ve, run::gen295, primReal(), "unitrand"); +#line 3501 "runtime.in" + addFunc(ve, run::gen296, primInt(), "ceil", formal(primReal(), "x", false, false)); +#line 3506 "runtime.in" + addFunc(ve, run::gen297, primInt(), "floor", formal(primReal(), "x", false, false)); +#line 3511 "runtime.in" + addFunc(ve, run::gen298, primInt(), "round", formal(primReal(), "x", false, false)); +#line 3517 "runtime.in" + addFunc(ve, run::gen299, primInt(), "Ceil", formal(primReal(), "x", false, false)); +#line 3522 "runtime.in" + addFunc(ve, run::gen300, primInt(), "Floor", formal(primReal(), "x", false, false)); +#line 3527 "runtime.in" + addFunc(ve, run::gen301, primInt(), "Round", formal(primReal(), "x", false, false)); +#line 3532 "runtime.in" + addFunc(ve, run::gen302, primReal(), "fmod", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); +#line 3538 "runtime.in" + addFunc(ve, run::gen303, primReal(), "atan2", formal(primReal(), "y", false, false), formal(primReal(), "x", false, false)); +#line 3543 "runtime.in" + addFunc(ve, run::gen304, primReal(), "hypot", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); +#line 3548 "runtime.in" + addFunc(ve, run::gen305, primReal(), "remainder", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); +#line 3553 "runtime.in" + addFunc(ve, run::gen306, primReal(), "J", formal(primInt(), "n", false, false), formal(primReal(), "x", false, false)); +#line 3558 "runtime.in" + addFunc(ve, run::gen307, primReal(), "Y", formal(primInt(), "n", false, false), formal(primReal(), "x", false, false)); +#line 3563 "runtime.in" + addFunc(ve, run::gen308, primReal(), "erf", formal(primReal(), "x", false, false)); +#line 3568 "runtime.in" + addFunc(ve, run::gen309, primReal(), "erfc", formal(primReal(), "x", false, false)); +#line 3573 "runtime.in" + addFunc(ve, run::gen310, primInt(), "factorial", formal(primInt(), "n", false, false)); +#line 3578 "runtime.in" + addFunc(ve, run::gen311, primInt(), "choose", formal(primInt(), "n", false, false), formal(primInt(), "k", false, false)); +#line 3589 "runtime.in" + addFunc(ve, run::gen312, primReal(), "gamma", formal(primReal(), "x", false, false)); +#line 3599 "runtime.in" + addFunc(ve, run::gen313, primPair(), "gamma", formal(primPair(), "z", false, true)); +#line 3605 "runtime.in" + addFunc(ve, run::gen314, realArray(), "quadraticroots", formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "c", false, false)); +#line 3614 "runtime.in" + addFunc(ve, run::gen315, pairArray(), "quadraticroots", formal(primPair(), "a", false, true), formal(primPair(), "b", false, true), formal(primPair(), "c", false, true)); +#line 3623 "runtime.in" + addFunc(ve, run::gen316, realArray(), "cubicroots", formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "c", false, false), formal(primReal(), "d", false, false)); +#line 3633 "runtime.in" + addFunc(ve, run::gen317, primBoolean(), "==", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false)); +#line 3641 "runtime.in" + addFunc(ve, run::gen318, primBoolean(), "!=", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false)); +#line 3646 "runtime.in" + addFunc(ve, run::gen319, primTransform(), "+", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false)); +#line 3651 "runtime.in" + addFunc(ve, run::gen320, primTransform(), "*", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false)); +#line 3656 "runtime.in" + addFunc(ve, run::gen321, primPair(), "*", formal(primTransform(), "t", false, false), formal(primPair(), "z", false, false)); +#line 3661 "runtime.in" + addFunc(ve, run::gen322, primPath(), "*", formal(primTransform(), "t", false, false), formal(primPath(), "g", false, false)); +#line 3666 "runtime.in" + addFunc(ve, run::gen323, primPen(), "*", formal(primTransform(), "t", false, false), formal(primPen(), "p", false, false)); +#line 3671 "runtime.in" + addFunc(ve, run::gen324, primPicture(), "*", formal(primTransform(), "t", false, false), formal(primPicture(), "f", false, false)); +#line 3676 "runtime.in" + addFunc(ve, run::gen325, primPicture(), "*", formal(realArray2(), "t", false, false), formal(primPicture(), "f", false, false)); +#line 3681 "runtime.in" + addFunc(ve, run::gen326, primTransform(), "^", formal(primTransform(), "t", false, false), formal(primInt(), "n", false, false)); +#line 3728 "runtime.in" + addFunc(ve, run::gen334, primTransform(), "shift", formal(primTransform(), "t", false, false)); +#line 3733 "runtime.in" + addFunc(ve, run::gen335, primTransform(), "shiftless", formal(primTransform(), "t", false, false)); +#line 3738 "runtime.in" + addFunc(ve, run::transformIdentity, primTransform(), "identity"); +#line 3743 "runtime.in" + addFunc(ve, run::gen337, primTransform(), "inverse", formal(primTransform(), "t", false, false)); +#line 3748 "runtime.in" + addFunc(ve, run::gen338, primTransform(), "shift", formal(primPair(), "z", false, false)); +#line 3753 "runtime.in" + addFunc(ve, run::gen339, primTransform(), "shift", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); +#line 3758 "runtime.in" + addFunc(ve, run::gen340, primTransform(), "xscale", formal(primReal(), "x", false, false)); +#line 3763 "runtime.in" + addFunc(ve, run::gen341, primTransform(), "yscale", formal(primReal(), "y", false, false)); +#line 3768 "runtime.in" + addFunc(ve, run::gen342, primTransform(), "scale", formal(primReal(), "x", false, false)); +#line 3773 "runtime.in" + addFunc(ve, run::gen343, primTransform(), "scale", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false)); +#line 3778 "runtime.in" + addFunc(ve, run::gen344, primTransform(), "slant", formal(primReal(), "s", false, false)); +#line 3783 "runtime.in" + addFunc(ve, run::gen345, primTransform(), "rotate", formal(primReal(), "angle", false, false), formal(primPair(), "z", true, false)); +#line 3788 "runtime.in" + addFunc(ve, run::gen346, primTransform(), "reflect", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false)); +#line 3811 "runtime.in" + addFunc(ve, run::pairXPart, primReal(), "xpart", formal(primPair(), "z", false, false)); +#line 3816 "runtime.in" + addFunc(ve, run::pairYPart, primReal(), "ypart", formal(primPair(), "z", false, false)); +#line 3821 "runtime.in" + addFunc(ve, run::gen352, primReal(), "length", formal(primPair(), "z", false, false)); +#line 3826 "runtime.in" + addFunc(ve, run::gen353, primReal(), "abs", formal(primPair(), "z", false, false)); +#line 3831 "runtime.in" + addFunc(ve, run::gen354, primPair(), "sqrt", formal(primPair(), "z", false, true)); +#line 3836 "runtime.in" + addFunc(ve, run::gen355, primReal(), "angle", formal(primPair(), "z", false, false), formal(primBoolean(), "warn", true, false)); +#line 3843 "runtime.in" + addFunc(ve, run::gen356, primReal(), "degrees", formal(primPair(), "z", false, false), formal(primBoolean(), "warn", true, false)); +#line 3850 "runtime.in" + addFunc(ve, run::gen357, primReal(), "radians", formal(primReal(), "degrees", false, false)); +#line 3856 "runtime.in" + addFunc(ve, run::gen358, primReal(), "degrees", formal(primReal(), "radians", false, false)); +#line 3862 "runtime.in" + addFunc(ve, run::gen359, primReal(), "Degrees", formal(primReal(), "radians", false, false)); +#line 3868 "runtime.in" + addFunc(ve, run::gen360, primReal(), "Sin", formal(primReal(), "deg", false, false)); +#line 3873 "runtime.in" + addFunc(ve, run::gen361, primReal(), "Cos", formal(primReal(), "deg", false, false)); +#line 3878 "runtime.in" + addFunc(ve, run::gen362, primReal(), "Tan", formal(primReal(), "deg", false, false)); +#line 3883 "runtime.in" + addFunc(ve, run::gen363, primReal(), "aSin", formal(primReal(), "x", false, false)); +#line 3888 "runtime.in" + addFunc(ve, run::gen364, primReal(), "aCos", formal(primReal(), "x", false, false)); +#line 3893 "runtime.in" + addFunc(ve, run::gen365, primReal(), "aTan", formal(primReal(), "x", false, false)); +#line 3898 "runtime.in" + addFunc(ve, run::gen366, primPair(), "unit", formal(primPair(), "z", false, false)); +#line 3903 "runtime.in" + addFunc(ve, run::gen367, primPair(), "dir", formal(primReal(), "degrees", false, false)); +#line 3908 "runtime.in" + addFunc(ve, run::gen368, primPair(), "dir", formal(primPair(), "z", false, true)); +#line 3913 "runtime.in" + addFunc(ve, run::gen369, primPair(), "expi", formal(primReal(), "angle", false, false)); +#line 3918 "runtime.in" + addFunc(ve, run::gen370, primPair(), "exp", formal(primPair(), "z", false, true)); +#line 3923 "runtime.in" + addFunc(ve, run::gen371, primPair(), "log", formal(primPair(), "z", false, true)); +#line 3928 "runtime.in" + addFunc(ve, run::gen372, primPair(), "sin", formal(primPair(), "z", false, true)); +#line 3933 "runtime.in" + addFunc(ve, run::gen373, primPair(), "cos", formal(primPair(), "z", false, true)); +#line 3938 "runtime.in" + addFunc(ve, run::gen374, primPair(), "conj", formal(primPair(), "z", false, false)); +#line 3943 "runtime.in" + addFunc(ve, run::gen375, primPair(), "realmult", formal(primPair(), "z", false, false), formal(primPair(), "w", false, false)); +#line 3948 "runtime.in" + addFunc(ve, run::gen376, primTriple(), "realmult", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false)); +#line 3953 "runtime.in" + addFunc(ve, run::gen377, primReal(), "dot", formal(primPair(), "z", false, true), formal(primPair(), "w", false, true)); +#line 3973 "runtime.in" + addFunc(ve, run::tripleXPart, primReal(), "xpart", formal(primTriple(), "v", false, false)); +#line 3978 "runtime.in" + addFunc(ve, run::tripleYPart, primReal(), "ypart", formal(primTriple(), "v", false, false)); +#line 3983 "runtime.in" + addFunc(ve, run::tripleZPart, primReal(), "zpart", formal(primTriple(), "v", false, false)); +#line 3988 "runtime.in" + addFunc(ve, run::gen383, primTriple(), "*", formal(primReal(), "x", false, false), formal(primTriple(), "v", false, false)); +#line 3993 "runtime.in" + addFunc(ve, run::gen384, primTriple(), "*", formal(primTriple(), "v", false, false), formal(primReal(), "x", false, false)); +#line 3998 "runtime.in" + addFunc(ve, run::gen385, primTriple(), "/", formal(primTriple(), "v", false, false), formal(primReal(), "x", false, false)); +#line 4003 "runtime.in" + addFunc(ve, run::gen386, primReal(), "length", formal(primTriple(), "v", false, false)); +#line 4008 "runtime.in" + addFunc(ve, run::gen387, primReal(), "abs", formal(primTriple(), "v", false, false)); +#line 4013 "runtime.in" + addFunc(ve, run::gen388, primReal(), "polar", formal(primTriple(), "v", false, false)); +#line 4018 "runtime.in" + addFunc(ve, run::gen389, primReal(), "azimuth", formal(primTriple(), "v", false, false)); +#line 4023 "runtime.in" + addFunc(ve, run::gen390, primReal(), "colatitude", formal(primTriple(), "v", false, false)); +#line 4028 "runtime.in" + addFunc(ve, run::gen391, primReal(), "latitude", formal(primTriple(), "v", false, false)); +#line 4033 "runtime.in" + addFunc(ve, run::gen392, primReal(), "longitude", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false)); +#line 4040 "runtime.in" + addFunc(ve, run::gen393, primTriple(), "unit", formal(primTriple(), "v", false, false)); +#line 4045 "runtime.in" + addFunc(ve, run::gen394, primReal(), "dot", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false)); +#line 4050 "runtime.in" + addFunc(ve, run::gen395, primTriple(), "cross", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false)); +#line 4055 "runtime.in" + addFunc(ve, run::gen396, primTriple(), "expi", formal(primReal(), "polar", false, false), formal(primReal(), "azimuth", false, false)); +#line 4060 "runtime.in" + addFunc(ve, run::gen397, primTriple(), "dir", formal(primReal(), "colatitude", false, false), formal(primReal(), "longitude", false, false)); +#line 4065 "runtime.in" + addFunc(ve, run::gen398, primVoid(), "atupdate", formal(voidFunction(), "f", false, false)); +#line 4073 "runtime.in" + addFunc(ve, run::gen399, voidFunction(), "atupdate"); +#line 4078 "runtime.in" + addFunc(ve, run::gen400, primVoid(), "atexit", formal(voidFunction(), "f", false, false)); +#line 4083 "runtime.in" + addFunc(ve, run::gen401, voidFunction(), "atexit"); +#line 4088 "runtime.in" + addFunc(ve, run::gen402, primVoid(), "atbreakpoint", formal(breakpointFunction(), "f", false, false)); +#line 4093 "runtime.in" + addFunc(ve, run::gen403, primVoid(), "breakpoint", formal(primCode(), "s", true, false)); +#line 4098 "runtime.in" + addFunc(ve, run::gen404, primString() , "locatefile", formal(primString() , "file", false, false)); +#line 4103 "runtime.in" + addFunc(ve, run::gen405, primVoid(), "stop", formal(primString() , "file", false, false), formal(primInt(), "line", false, false), formal(primCode(), "s", true, false)); +#line 4111 "runtime.in" + addFunc(ve, run::gen406, primVoid(), "breakpoints"); +#line 4117 "runtime.in" + addFunc(ve, run::gen407, primVoid(), "clear", formal(primString() , "file", false, false), formal(primInt(), "line", false, false)); +#line 4123 "runtime.in" + addFunc(ve, run::gen408, primVoid(), "clear"); +#line 4128 "runtime.in" + addFunc(ve, run::gen409, primString() , "stripdirectory", formal(primString(), "s", false, false)); +#line 4134 "runtime.in" + addFunc(ve, run::gen410, primString() , "stripfile", formal(primString(), "s", false, false)); +#line 4140 "runtime.in" + addFunc(ve, run::gen411, primString() , "stripextension", formal(primString(), "s", false, false)); +#line 4146 "runtime.in" + addFunc(ve, run::gen412, primInt(), "convert", formal(primString() , "args", true, false), formal(primString() , "file", true, false), formal(primString() , "format", true, false)); +#line 4164 "runtime.in" + addFunc(ve, run::gen413, primInt(), "animate", formal(primString() , "args", true, false), formal(primString() , "file", true, false), formal(primString() , "format", true, false)); +#line 4180 "runtime.in" + addFunc(ve, run::gen414, primInt(), "delete", formal(primString(), "s", false, false)); +#line 4190 "runtime.in" + addFunc(ve, run::gen415, primInt(), "rename", formal(primString(), "from", false, false), formal(primString(), "to", false, false)); +#line 4489 "runtime.in" + addFunc(ve, run::gen446, IntArray(), "complement", formal(IntArray(), "a", false, false), formal(primInt(), "n", false, false)); +#line 4521 "runtime.in" + addFunc(ve, run::gen448, IntArray(), "sequence", formal(primInt(), "n", false, false)); +#line 4554 "runtime.in" + addFunc(ve, run::gen451, primBoolean(), "all", formal(boolArray(), "a", false, false)); +#line 4563 "runtime.in" + addFunc(ve, run::gen452, boolArray(), "!", formal(boolArray(), "a", false, false)); +#line 4572 "runtime.in" + addFunc(ve, run::gen453, primInt(), "sum", formal(boolArray(), "a", false, false)); +#line 4735 "runtime.in" + addFunc(ve, run::gen460, primInt(), "find", formal(boolArray(), "a", false, false), formal(primInt(), "n", true, false)); +#line 4755 "runtime.in" + addFunc(ve, run::gen461, primBoolean(), "==", formal(realArray2(), "a", false, false), formal(realArray2(), "b", false, false)); +#line 4800 "runtime.in" + addFunc(ve, run::gen463, realArray2(), "identity", formal(primInt(), "n", false, false)); +#line 4823 "runtime.in" + addFunc(ve, run::gen465, realArray2(), "inverse", formal(realArray2(), "a", false, false)); +#line 4915 "runtime.in" + addFunc(ve, run::gen466, realArray(), "solve", formal(realArray2(), "a", false, false), formal(realArray(), "b", false, false), formal(primBoolean(), "warn", true, false)); +#line 4966 "runtime.in" + addFunc(ve, run::gen467, realArray2(), "solve", formal(realArray2(), "a", false, false), formal(realArray2(), "b", false, false), formal(primBoolean(), "warn", true, false)); +#line 5030 "runtime.in" + addFunc(ve, run::gen468, primReal(), "determinant", formal(realArray2(), "a", false, false)); +#line 5046 "runtime.in" + addFunc(ve, run::gen469, realArray(), "*", formal(realArray2(), "a", false, false), formal(realArray(), "b", false, false)); +#line 5064 "runtime.in" + addFunc(ve, run::gen470, realArray2(), "*", formal(realArray2(), "a", false, false), formal(realArray2(), "b", false, false)); +#line 5099 "runtime.in" + addFunc(ve, run::gen471, primTriple(), "*", formal(realArray2(), "t", false, false), formal(primTriple(), "v", false, false)); +#line 5104 "runtime.in" + addFunc(ve, run::gen472, primPair(), "project", formal(primTriple(), "v", false, false), formal(realArray2(), "t", false, false)); +#line 5129 "runtime.in" + addFunc(ve, run::gen473, primReal(), "dot", formal(realArray(), "a", false, false), formal(realArray(), "b", false, false)); +#line 5139 "runtime.in" + addFunc(ve, run::gen474, realArray(), "tridiagonal", formal(realArray(), "a", false, false), formal(realArray(), "b", false, false), formal(realArray(), "c", false, false), formal(realArray(), "f", false, false)); +#line 5243 "runtime.in" + addFunc(ve, run::gen475, primReal(), "newton", formal(primInt(), "iterations", true, false), formal(realRealFunction(), "f", false, false), formal(realRealFunction(), "fprime", false, false), formal(primReal(), "x", false, false), formal(primBoolean(), "verbose", true, false)); +#line 5290 "runtime.in" + addFunc(ve, run::gen476, primReal(), "newton", formal(primInt(), "iterations", true, false), formal(realRealFunction(), "f", false, false), formal(realRealFunction(), "fprime", false, false), formal(primReal(), "x1", false, false), formal(primReal(), "x2", false, false), formal(primBoolean(), "verbose", true, false)); +#line 5372 "runtime.in" + addFunc(ve, run::gen477, primReal(), "simpson", formal(realRealFunction(), "f", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "acc", true, false), formal(primReal(), "dxmax", true, false)); +#line 5414 "runtime.in" + addFunc(ve, run::gen479, IntArray2(), "triangulate", formal(pairArray(), "z", false, false)); +#line 5449 "runtime.in" + addFunc(ve, run::gen480, primBoolean(), "==", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false)); +#line 5457 "runtime.in" + addFunc(ve, run::gen481, primBoolean(), "!=", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false)); +#line 5467 "runtime.in" + addFunc(ve, run::gen483, primFile(), "input", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false), formal(primString() , "comment", true, false)); +#line 5475 "runtime.in" + addFunc(ve, run::gen484, primFile(), "output", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false), formal(primString() , "comment", true, false)); +#line 5487 "runtime.in" + addFunc(ve, run::gen485, primFile(), "xinput", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false)); +#line 5501 "runtime.in" + addFunc(ve, run::gen486, primFile(), "xoutput", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false)); +#line 5519 "runtime.in" + addFunc(ve, run::gen487, primFile(), "binput", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false)); +#line 5526 "runtime.in" + addFunc(ve, run::gen488, primFile(), "boutput", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false)); +#line 5536 "runtime.in" + addFunc(ve, run::gen489, primBoolean(), "eof", formal(primFile(), "file", false, false)); +#line 5541 "runtime.in" + addFunc(ve, run::gen490, primBoolean(), "eol", formal(primFile(), "file", false, false)); +#line 5546 "runtime.in" + addFunc(ve, run::gen491, primBoolean(), "error", formal(primFile(), "file", false, false)); +#line 5551 "runtime.in" + addFunc(ve, run::gen492, primVoid(), "clear", formal(primFile(), "file", false, false)); +#line 5556 "runtime.in" + addFunc(ve, run::gen493, primVoid(), "close", formal(primFile(), "file", false, false)); +#line 5561 "runtime.in" + addFunc(ve, run::gen494, primInt(), "precision", formal(primFile(), "file", true, false), formal(primInt(), "digits", true, false)); +#line 5567 "runtime.in" + addFunc(ve, run::gen495, primVoid(), "flush", formal(primFile(), "file", false, false)); +#line 5572 "runtime.in" + addFunc(ve, run::gen496, primString() , "getc", formal(primFile(), "file", false, false)); +#line 5581 "runtime.in" + addFunc(ve, run::gen497, primInt(), "tell", formal(primFile(), "file", false, false)); +#line 5586 "runtime.in" + addFunc(ve, run::gen498, primVoid(), "seek", formal(primFile(), "file", false, false), formal(primInt(), "pos", false, false)); +#line 5591 "runtime.in" + addFunc(ve, run::gen499, primVoid(), "seekeof", formal(primFile(), "file", false, false)); +#line 5596 "runtime.in" + addFunc(ve, run::gen500, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false)); +#line 5603 "runtime.in" + addFunc(ve, run::gen501, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false), formal(primInt(), "ny", false, false)); +#line 5609 "runtime.in" + addFunc(ve, run::gen502, primFile(), "dimension", formal(primFile(), "file", false, false), formal(primInt(), "nx", false, false), formal(primInt(), "ny", false, false), formal(primInt(), "nz", false, false)); +#line 5615 "runtime.in" + addFunc(ve, run::gen503, primFile(), "csv", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false)); +#line 5622 "runtime.in" + addFunc(ve, run::gen504, primFile(), "word", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false)); +#line 5629 "runtime.in" + addFunc(ve, run::gen505, primFile(), "line", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false)); +#line 5636 "runtime.in" + addFunc(ve, run::gen506, primFile(), "single", formal(primFile(), "file", false, false), formal(primBoolean(), "b", true, false)); +#line 5644 "runtime.in" + addFunc(ve, run::gen507, primFile(), "single", formal(primFile(), "file", false, false), formal(primReal(), "x", false, false), formal(primBoolean(), "b", true, false)); +#line 5652 "runtime.in" + addFunc(ve, run::gen508, primFile(), "single", formal(primFile(), "file", false, false), formal(primInt(), "x", false, false), formal(primBoolean(), "b", true, false)); +#line 5660 "runtime.in" + addFunc(ve, run::gen509, primFile(), "read1", formal(primFile(), "file", false, false)); +#line 5667 "runtime.in" + addFunc(ve, run::gen510, primFile(), "read2", formal(primFile(), "file", false, false)); +#line 5674 "runtime.in" + addFunc(ve, run::gen511, primFile(), "read3", formal(primFile(), "file", false, false)); +#line 5681 "runtime.in" + addFunc(ve, run::gen512, stringArray(), "history", formal(primString() , "name", false, false), formal(primInt(), "n", true, false)); +#line 5714 "runtime.in" + addFunc(ve, run::gen513, stringArray(), "history", formal(primInt(), "n", true, false)); +#line 5725 "runtime.in" + addFunc(ve, run::gen514, primString() , "readline", formal(primString() , "prompt", true, false), formal(primString() , "name", true, false), formal(primBoolean(), "tabcompletion", true, false)); +#line 5769 "runtime.in" + addFunc(ve, run::gen515, primVoid(), "saveline", formal(primString() , "name", false, false), formal(primString() , "value", false, false), formal(primBoolean(), "store", true, false)); +#line 5799 "runtime.in" + addFunc(ve, run::gen516, primVoid(), "generate_random_backtrace"); +#line 5808 "runtime.in" + addFunc(ve, run::gen517, primVoid(), "print_random_addresses", formal(primInt(), "n", true, false)); +} + +} // namespace trans |