summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/runtime.cc
blob: 85a951807715c31b5a8178b7f3609c8282aac49e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
/***** Autogenerated from runtime.in; changes will be overwritten *****/

#line 1 "runtimebase.in"
/*****
 * runtimebase.in
 * Andy Hammerlindl  2009/07/28
 *
 * Common declarations needed for all code-generating .in files.
 *
 *****/


#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 1 "runtimebase.in"
#include "stack.h"
#include "types.h"
#include "builtin.h"
#include "entry.h"
#include "errormsg.h"
#include "array.h"
#include "triple.h"
#include "callable.h"
#include "opsymbols.h"

using vm::stack;
using vm::error;
using vm::array;
using vm::read;
using vm::callable;
using types::formal;
using types::function;
using camp::triple;

#define PRIMITIVE(name,Name,asyName) using types::prim##Name;
#include <primitives.h>
#undef PRIMITIVE

typedef double real;

void unused(void *);

namespace run {
array *copyArray(array *a);
array *copyArray2(array *a);
array *copyArray3(array *a);

inline size_t checkdimension(const array *a, size_t dim)
{
  size_t size=checkArray(a);
  if(dim && size != dim) {
    ostringstream buf;
    buf << "array of length " << dim << " expected";
    error(buf);
  }
  return size;
}

template<class T>
void copyArrayC(T* &dest, const array *a, size_t dim=0,
                GCPlacement placement=NoGC)
{
  size_t size=checkdimension(a,dim);
  dest=(placement == NoGC) ? new T[size] : new(placement) T[size];
  for(size_t i=0; i < size; i++) 
    dest[i]=read<T>(a,i);
}

template<class T>
void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0,
                 GCPlacement placement=NoGC)
{
  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;
    error(buf);
  }
  
  dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m];
  for(size_t i=0; i < n; i++) {
    array *ai=read<array*>(a,i);
    size_t aisize=checkArray(ai);
    if(aisize == m) {
      T *desti=dest+i*m;
      for(size_t j=0; j < m; j++) 
        desti[j]=read<T>(ai,j);
    } else
      error(square ? "matrix must be square" : "matrix must be rectangular");
  }
}

double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0,
                                   GCPlacement placement=NoGC);
}

function *realRealFunction();

#define CURRENTPEN processData().currentpen

#line 55 "runtime.in"
#include <cfloat>
#include <iostream>
#include <fstream>
#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 "drawpath.h"
#include "guide.h"
#include "picture.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"
   
#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 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::booleanArray;
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 *realRealFunction()
{
  return new function(primReal(),primReal());
}

function *realTripleFunction()
{
  return new function(primReal(),primTriple());
}

const size_t camp::ColorComponents[]={0,0,1,3,4,0};

namespace vm {
#if COMPACT
const Int DefaultValue=0x7fffffffffffffffLL;
const Int Undefined=0x7ffffffffffffffeLL;

const item Default=DefaultValue;
#else
const item Default=item(default_t());
#endif
}

namespace run {
  
const char *arrayempty="cannot take min or max of empty array";
const char *noruntime="no runtime environment for embedded eval";

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();
  }
}

string emptystring;
pair zero;

}

static string defaulttransparency=string("Compatible");

void unused(void *)
{
}

// Autogenerated routines:



#include "runtime.symbols.h"

namespace run {

// Initializers
#line 217 "runtime.in"
void IntZero(stack *Stack)
{
#line 218 "runtime.in"
  {Stack->push<Int>(0); return;}
}

#line 223 "runtime.in"
void realZero(stack *Stack)
{
#line 224 "runtime.in"
  {Stack->push<real>(0.0); return;}
}

#line 228 "runtime.in"
void boolFalse(stack *Stack)
{
#line 229 "runtime.in"
  {Stack->push<bool>(false); return;}
}

#line 233 "runtime.in"
void pushNullArray(stack *Stack)
{
#line 234 "runtime.in"
  {Stack->push<array*>(0); return;}
}

#line 238 "runtime.in"
void pushNullRecord(stack *Stack)
{
#line 239 "runtime.in"
  {Stack->push<frame*>(0); return;}
}

#line 243 "runtime.in"
void pushNullFunction(stack *Stack)
{
#line 244 "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 253 "runtime.in"
void pushDefault(stack *Stack)
{
#line 254 "runtime.in"
  {Stack->push(Default); return;}
}


// Test if the value on the stack is the default value token.
#line 260 "runtime.in"
void isDefault(stack *Stack)
{
  item i=vm::pop(Stack);
#line 261 "runtime.in"
  {Stack->push<bool>(isdefault(i)); return;}
}


// Casts
#line 267 "runtime.in"
void pairToGuide(stack *Stack)
{
  pair z=vm::pop<pair>(Stack);
#line 268 "runtime.in"
  {Stack->push<guide*>(new pairguide(z)); return;}
}

#line 273 "runtime.in"
void pathToGuide(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 274 "runtime.in"
  {Stack->push<guide*>(new pathguide(p)); return;}
}

#line 278 "runtime.in"
void guideToPath(stack *Stack)
{
  guide * g=vm::pop<guide *>(Stack);
#line 279 "runtime.in"
  {Stack->push<path>(g->solve()); return;}
}


// Pen operations
#line 285 "runtime.in"
void newPen(stack *Stack)
{
#line 286 "runtime.in"
  {Stack->push<pen>(pen()); return;}
}

#line 291 "runtime.in"
// bool ==(pen a, pen b);
void gen_runtime12(stack *Stack)
{
  pen b=vm::pop<pen>(Stack);
  pen a=vm::pop<pen>(Stack);
#line 292 "runtime.in"
  {Stack->push<bool>(a == b); return;}
}

#line 296 "runtime.in"
// bool !=(pen a, pen b);
void gen_runtime13(stack *Stack)
{
  pen b=vm::pop<pen>(Stack);
  pen a=vm::pop<pen>(Stack);
#line 297 "runtime.in"
  {Stack->push<bool>(a != b); return;}
}

#line 301 "runtime.in"
// pen +(pen a, pen b);
void gen_runtime14(stack *Stack)
{
  pen b=vm::pop<pen>(Stack);
  pen a=vm::pop<pen>(Stack);
#line 302 "runtime.in"
  {Stack->push<pen>(a+b); return;}
}

#line 306 "runtime.in"
// pen *(real a, pen b);
void gen_runtime15(stack *Stack)
{
  pen b=vm::pop<pen>(Stack);
  real a=vm::pop<real>(Stack);
#line 307 "runtime.in"
  {Stack->push<pen>(a*b); return;}
}

#line 311 "runtime.in"
// pen *(pen a, real b);
void gen_runtime16(stack *Stack)
{
  real b=vm::pop<real>(Stack);
  pen a=vm::pop<pen>(Stack);
#line 312 "runtime.in"
  {Stack->push<pen>(b*a); return;}
}

#line 316 "runtime.in"
// pair max(pen p);
void gen_runtime17(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 317 "runtime.in"
  {Stack->push<pair>(p.bounds().Max()); return;}
}

#line 321 "runtime.in"
// pair min(pen p);
void gen_runtime18(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 322 "runtime.in"
  {Stack->push<pair>(p.bounds().Min()); return;}
}

// Reset the meaning of pen default attributes.
#line 327 "runtime.in"
// void resetdefaultpen();
void gen_runtime19(stack *)
{
#line 328 "runtime.in"
  processData().defaultpen=camp::pen::initialpen();
}

#line 332 "runtime.in"
// void defaultpen(pen p);
void gen_runtime20(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 333 "runtime.in"
  processData().defaultpen=pen(resolvepen,p);
}

#line 337 "runtime.in"
// pen defaultpen();
void gen_runtime21(stack *Stack)
{
#line 338 "runtime.in"
  {Stack->push<pen>(processData().defaultpen); return;}
}

#line 342 "runtime.in"
// bool invisible(pen p);
void gen_runtime22(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 343 "runtime.in"
  {Stack->push<bool>(p.invisible()); return;}
}

#line 347 "runtime.in"
// pen invisible();
void gen_runtime23(stack *Stack)
{
#line 348 "runtime.in"
  {Stack->push<pen>(pen(invisiblepen)); return;}
}

#line 352 "runtime.in"
// pen gray(pen p);
void gen_runtime24(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 353 "runtime.in"
  p.togrey();
  {Stack->push<pen>(p); return;}
}

#line 358 "runtime.in"
// pen rgb(pen p);
void gen_runtime25(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 359 "runtime.in"
  p.torgb();
  {Stack->push<pen>(p); return;}
}

#line 364 "runtime.in"
// pen cmyk(pen p);
void gen_runtime26(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 365 "runtime.in"
  p.tocmyk();
  {Stack->push<pen>(p); return;}
}

#line 370 "runtime.in"
// pen interp(pen a, pen b, real t);
void gen_runtime27(stack *Stack)
{
  real t=vm::pop<real>(Stack);
  pen b=vm::pop<pen>(Stack);
  pen a=vm::pop<pen>(Stack);
#line 371 "runtime.in"
  {Stack->push<pen>(interpolate(a,b,t)); return;}
}

#line 375 "runtime.in"
// pen rgb(real r, real g, real b);
void gen_runtime28(stack *Stack)
{
  real b=vm::pop<real>(Stack);
  real g=vm::pop<real>(Stack);
  real r=vm::pop<real>(Stack);
#line 376 "runtime.in"
  {Stack->push<pen>(pen(r,g,b)); return;}
}

#line 380 "runtime.in"
// pen cmyk(real c, real m, real y, real k);
void gen_runtime29(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 381 "runtime.in"
  {Stack->push<pen>(pen(c,m,y,k)); return;}  
}

#line 385 "runtime.in"
// pen gray(real gray);
void gen_runtime30(stack *Stack)
{
  real gray=vm::pop<real>(Stack);
#line 386 "runtime.in"
  {Stack->push<pen>(pen(gray)); return;}
}

#line 390 "runtime.in"
// realarray* colors(pen p);
void gen_runtime31(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 391 "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 418 "runtime.in"
// string hex(pen p);
void gen_runtime32(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 419 "runtime.in"  
  {Stack->push<string>(p.hex()); return;}
}

#line 423 "runtime.in"
// Int byte(real x);
void gen_runtime33(stack *Stack)
{
  real x=vm::pop<real>(Stack);
#line 424 "runtime.in"
  {Stack->push<Int>(byte(x)); return;}
}

#line 428 "runtime.in"
// string colorspace(pen p);
void gen_runtime34(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 429 "runtime.in"
  string s=ColorDeviceSuffix[p.colorspace()];
  std::transform(s.begin(),s.end(),s.begin(),tolower);
  {Stack->push<string>(s); return;}
}

#line 435 "runtime.in"
// pen pattern(string *s);
void gen_runtime35(stack *Stack)
{
  string * s=vm::pop<string *>(Stack);
#line 436 "runtime.in"
  {Stack->push<pen>(pen(setpattern,*s)); return;}
}

#line 440 "runtime.in"
// string pattern(pen p);
void gen_runtime36(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 441 "runtime.in"
  {Stack->push<string>(p.fillpattern()); return;}  
}

#line 445 "runtime.in"
// pen fillrule(Int n);
void gen_runtime37(stack *Stack)
{
  Int n=vm::pop<Int>(Stack);
#line 446 "runtime.in"
  {Stack->push<pen>(pen(n >= 0 && n < nFill ? (FillRule) n : DEFFILL)); return;}
}

#line 450 "runtime.in"
// Int fillrule(pen p);
void gen_runtime38(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 451 "runtime.in"
  {Stack->push<Int>(p.Fillrule()); return;}  
}

#line 455 "runtime.in"
// pen opacity(real opacity=1.0, string blend=defaulttransparency);
void gen_runtime39(stack *Stack)
{
  string blend=vm::pop<string>(Stack,defaulttransparency);
  real opacity=vm::pop<real>(Stack,1.0);
#line 456 "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 465 "runtime.in"
// real opacity(pen p);
void gen_runtime40(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 466 "runtime.in"
  {Stack->push<real>(p.opacity()); return;}
}

#line 470 "runtime.in"
// string blend(pen p);
void gen_runtime41(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 471 "runtime.in"
  {Stack->push<string>(p.blend()); return;}
}

#line 475 "runtime.in"
// pen linetype(realarray *pattern, real offset=0, bool scale=true,             bool adjust=true);
void gen_runtime42(stack *Stack)
{
  bool adjust=vm::pop<bool>(Stack,true);
  bool scale=vm::pop<bool>(Stack,true);
  real offset=vm::pop<real>(Stack,0);
  realarray * pattern=vm::pop<realarray *>(Stack);
#line 477 "runtime.in"
  size_t size=checkArray(pattern);
  array *a=new array(size);
  for(size_t i=0; i < size; ++i) 
    (*a)[i]=::max(vm::read<double>(pattern,i),0.0);

  {Stack->push<pen>(pen(LineType(*a,offset,scale,adjust))); return;} 
}

#line 486 "runtime.in"
// realarray* linetype(pen p=CURRENTPEN);
void gen_runtime43(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 487 "runtime.in"
  array a=p.linetype()->pattern;
  {Stack->push<realarray*>(copyArray(&a)); return;}
}

#line 492 "runtime.in"
// real offset(pen p);
void gen_runtime44(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 493 "runtime.in"
  {Stack->push<real>(p.linetype()->offset); return;}
}

#line 497 "runtime.in"
// bool scale(pen p);
void gen_runtime45(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 498 "runtime.in"
  {Stack->push<bool>(p.linetype()->scale); return;}
}

#line 502 "runtime.in"
// bool adjust(pen p);
void gen_runtime46(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 503 "runtime.in"
  {Stack->push<bool>(p.linetype()->adjust); return;}
}

#line 507 "runtime.in"
// pen adjust(pen p, real arclength, bool cyclic);
void gen_runtime47(stack *Stack)
{
  bool cyclic=vm::pop<bool>(Stack);
  real arclength=vm::pop<real>(Stack);
  pen p=vm::pop<pen>(Stack);
#line 508 "runtime.in"
  {Stack->push<pen>(adjustdash(p,arclength,cyclic)); return;}
}

#line 512 "runtime.in"
// pen linecap(Int n);
void gen_runtime48(stack *Stack)
{
  Int n=vm::pop<Int>(Stack);
#line 513 "runtime.in"
  {Stack->push<pen>(pen(setlinecap,n >= 0 && n < nCap ? n : DEFCAP)); return;}
}

#line 517 "runtime.in"
// Int linecap(pen p=CURRENTPEN);
void gen_runtime49(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 518 "runtime.in"
  {Stack->push<Int>(p.cap()); return;}  
}

#line 522 "runtime.in"
// pen linejoin(Int n);
void gen_runtime50(stack *Stack)
{
  Int n=vm::pop<Int>(Stack);
#line 523 "runtime.in"
  {Stack->push<pen>(pen(setlinejoin,n >= 0 && n < nJoin ? n : DEFJOIN)); return;}
}

#line 527 "runtime.in"
// Int linejoin(pen p=CURRENTPEN);
void gen_runtime51(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 528 "runtime.in"
  {Stack->push<Int>(p.join()); return;}  
}

#line 532 "runtime.in"
// pen miterlimit(real x);
void gen_runtime52(stack *Stack)
{
  real x=vm::pop<real>(Stack);
#line 533 "runtime.in"
  {Stack->push<pen>(pen(setmiterlimit,x >= 1.0 ? x : DEFJOIN)); return;}
}

#line 537 "runtime.in"
// real miterlimit(pen p=CURRENTPEN);
void gen_runtime53(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 538 "runtime.in"
  {Stack->push<real>(p.miter()); return;}  
}

#line 542 "runtime.in"
// pen linewidth(real x);
void gen_runtime54(stack *Stack)
{
  real x=vm::pop<real>(Stack);
#line 543 "runtime.in"
  {Stack->push<pen>(pen(setlinewidth,x >= 0.0 ? x : DEFWIDTH)); return;}
}

#line 547 "runtime.in"
// real linewidth(pen p=CURRENTPEN);
void gen_runtime55(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 548 "runtime.in"
  {Stack->push<real>(p.width()); return;}  
}

#line 552 "runtime.in"
// pen fontcommand(string *s);
void gen_runtime56(stack *Stack)
{
  string * s=vm::pop<string *>(Stack);
#line 553 "runtime.in"
  {Stack->push<pen>(pen(setfont,*s)); return;}
}

#line 557 "runtime.in"
// string font(pen p=CURRENTPEN);
void gen_runtime57(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 558 "runtime.in"
  {Stack->push<string>(p.Font()); return;}
}

#line 562 "runtime.in"
// pen fontsize(real size, real lineskip);
void gen_runtime58(stack *Stack)
{
  real lineskip=vm::pop<real>(Stack);
  real size=vm::pop<real>(Stack);
#line 563 "runtime.in"
  {Stack->push<pen>(pen(setfontsize,size > 0.0 ? size : 0.0,
             lineskip > 0.0 ? lineskip : 0.0)); return;}
}

#line 568 "runtime.in"
// real fontsize(pen p=CURRENTPEN);
void gen_runtime59(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 569 "runtime.in"
  {Stack->push<real>(p.size()); return;}
}

#line 573 "runtime.in"
// real lineskip(pen p=CURRENTPEN);
void gen_runtime60(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 574 "runtime.in"
  {Stack->push<real>(p.Lineskip()); return;}  
}

#line 578 "runtime.in"
// pen overwrite(Int n);
void gen_runtime61(stack *Stack)
{
  Int n=vm::pop<Int>(Stack);
#line 579 "runtime.in"
  {Stack->push<pen>(pen(setoverwrite,n >= 0 && n < nOverwrite ? (overwrite_t) n :
             DEFWRITE)); return;}
}

#line 584 "runtime.in"
// Int overwrite(pen p=CURRENTPEN);
void gen_runtime62(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 585 "runtime.in"
  {Stack->push<Int>(p.Overwrite()); return;}  
}

#line 589 "runtime.in"
// pen basealign(Int n);
void gen_runtime63(stack *Stack)
{
  Int n=vm::pop<Int>(Stack);
#line 590 "runtime.in"
  {Stack->push<pen>(pen(n >= 0 && n < nBaseLine ? (BaseLine) n : DEFBASE)); return;}
}

#line 594 "runtime.in"
// Int basealign(pen p=CURRENTPEN);
void gen_runtime64(stack *Stack)
{
  pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 595 "runtime.in"
  {Stack->push<Int>(p.Baseline()); return;}
}

#line 599 "runtime.in"
// transform transform(pen p);
void gen_runtime65(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 600 "runtime.in"
  {Stack->push<transform>(p.getTransform()); return;}
}

#line 604 "runtime.in"
// path nib(pen p);
void gen_runtime66(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 605 "runtime.in"
  {Stack->push<path>(p.Path()); return;}
}

#line 609 "runtime.in"
// pen makepen(path p);
void gen_runtime67(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 610 "runtime.in"
  {Stack->push<pen>(pen(p)); return;}
}

#line 614 "runtime.in"
// pen colorless(pen p);
void gen_runtime68(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
#line 615 "runtime.in"
  p.colorless();
  {Stack->push<pen>(p); return;}
}

// Interactive mode
#line 621 "runtime.in"
// bool interactive();
void gen_runtime69(stack *Stack)
{
#line 622 "runtime.in"
  {Stack->push<bool>(interact::interactive); return;}
}

#line 627 "runtime.in"
// bool uptodate();
void gen_runtime70(stack *Stack)
{
#line 628 "runtime.in"
  {Stack->push<bool>(interact::uptodate); return;}
}


// System commands
#line 634 "runtime.in"
// Int system(stringarray *s);
void gen_runtime71(stack *Stack)
{
  stringarray * s=vm::pop<stringarray *>(Stack);
#line 635 "runtime.in"
  if(safe) error("system() call disabled; override with option -nosafe");
  size_t size=checkArray(s);
  if(size == 0) {Stack->push<Int>(0); return;}
  mem::vector<string> cmd;
  for(size_t i=0; i < size; ++i)
    cmd.push_back(read<string>(s,i));
  {Stack->push<Int>(System(cmd)); return;}
}

#line 646 "runtime.in"
// bool view();
void gen_runtime72(stack *Stack)
{
#line 647 "runtime.in"
  {Stack->push<bool>(view()); return;}
}

#line 651 "runtime.in"
// string asydir();
void gen_runtime73(stack *Stack)
{
#line 652 "runtime.in"
  {Stack->push<string>(systemDir); return;}
}

#line 656 "runtime.in"
// string locale(string s=emptystring);
void gen_runtime74(stack *Stack)
{
  string s=vm::pop<string>(Stack,emptystring);
#line 657 "runtime.in"
  char *L=setlocale(LC_ALL,s.empty() ? NULL : s.c_str());
  {Stack->push<string>(L != NULL ? string(L) : ""); return;}
}

#line 662 "runtime.in"
// void abort(string s=emptystring);
void gen_runtime75(stack *Stack)
{
  string s=vm::pop<string>(Stack,emptystring);
#line 663 "runtime.in"
  if(s.empty()) throw handled_error();
  error(s.c_str());
}

#line 668 "runtime.in"
// void exit();
void gen_runtime76(stack *)
{
#line 669 "runtime.in"
  throw quit();
}

#line 673 "runtime.in"
// void assert(bool b, string s=emptystring);
void gen_runtime77(stack *Stack)
{
  string s=vm::pop<string>(Stack,emptystring);
  bool b=vm::pop<bool>(Stack);
#line 674 "runtime.in"
  flush(cout);
  if(!b) {
    ostringstream buf;
    buf << "assert FAILED";
    if(s != "") buf << ": " << s;
    error(buf);
  }
}

#line 684 "runtime.in"
// void sleep(Int seconds);
void gen_runtime78(stack *Stack)
{
  Int seconds=vm::pop<Int>(Stack);
#line 685 "runtime.in"
  if(seconds <= 0) return;      
  sleep(seconds);
}

#line 690 "runtime.in"
// void usleep(Int microseconds);
void gen_runtime79(stack *Stack)
{
  Int microseconds=vm::pop<Int>(Stack);
#line 691 "runtime.in"
  if(microseconds <= 0) return; 
  usleep((unsigned long) microseconds); 
}

#line 696 "runtime.in"
// void _eval(string *s, bool embedded, bool interactiveWrite=false);
void gen_runtime80(stack *Stack)
{
  bool interactiveWrite=vm::pop<bool>(Stack,false);
  bool embedded=vm::pop<bool>(Stack);
  string * s=vm::pop<string *>(Stack);
#line 697 "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
      error(noruntime);
  } else
    runString(*s,interactiveWrite);
}

#line 709 "runtime.in"
// void _eval(runnable *s, bool embedded);
void gen_runtime81(stack *Stack)
{
  bool embedded=vm::pop<bool>(Stack);
  runnable * s=vm::pop<runnable *>(Stack);
#line 710 "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
      error(noruntime);
  } else
    runCode(ast);
}

#line 725 "runtime.in"
// string location();
void gen_runtime82(stack *Stack)
{
#line 726 "runtime.in"
  ostringstream buf;
  buf << getPos();
  {Stack->push<string>(buf.str()); return;}
}

// Wrapper for the stack::load() method.
#line 732 "runtime.in"
void loadModule(stack *Stack)
{
  string * index=vm::pop<string *>(Stack);
#line 733 "runtime.in"
  Stack->load(*index);
}

#line 737 "runtime.in"
// string cd(string s=emptystring);
void gen_runtime84(stack *Stack)
{
  string s=vm::pop<string>(Stack,emptystring);
#line 738 "runtime.in"
  if(!s.empty() && !globalwrite()) {
    string outname=getSetting<string>("outname");
    string dir=stripDir(outname);
    if(dir.empty()) Setting("outname")=getPath()+dirsep+outname;
  }
  {Stack->push<string>(setPath(s.c_str())); return;}
}

#line 747 "runtime.in"
// void list(string *s, bool imports=false);
void gen_runtime85(stack *Stack)
{
  bool imports=vm::pop<bool>(Stack,false);
  string * s=vm::pop<string *>(Stack);
#line 748 "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);
}


// Guide operations
#line 758 "runtime.in"
void nullGuide(stack *Stack)
{
#line 759 "runtime.in"
  {Stack->push<guide*>(new pathguide(path())); return;}
}

#line 764 "runtime.in"
void dotsGuide(stack *Stack)
{
  guidearray * a=vm::pop<guidearray *>(Stack);
#line 765 "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 774 "runtime.in"
void dashesGuide(stack *Stack)
{
  guidearray * a=vm::pop<guidearray *>(Stack);
#line 775 "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 801 "runtime.in"
void newCycleToken(stack *Stack)
{
#line 802 "runtime.in"
  {Stack->push<cycleToken>(cycleToken()); return;}
}

#line 806 "runtime.in"
// guide* operator cast(cycleToken tok);
void gen_runtime90(stack *Stack)
{
  cycleToken tok=vm::pop<cycleToken>(Stack);
#line 807 "runtime.in"
// Avoid unused variable warning messages.
  unused(&tok);
  {Stack->push<guide*>(new cycletokguide()); return;}
}

#line 813 "runtime.in"
// guide* operator spec(pair z, Int p);
void gen_runtime91(stack *Stack)
{
  Int p=vm::pop<Int>(Stack);
  pair z=vm::pop<pair>(Stack);
#line 814 "runtime.in"
  camp::side d=(camp::side) p;
  camp::dirSpec *sp=new camp::dirSpec(z);

  {Stack->push<guide*>(new specguide(sp,d)); return;}
}

#line 821 "runtime.in"
// curlSpecifier operator curl(real gamma, Int p);
void gen_runtime92(stack *Stack)
{
  Int p=vm::pop<Int>(Stack);
  real gamma=vm::pop<real>(Stack);
#line 822 "runtime.in"
  camp::side s=(camp::side) p;
  {Stack->push<curlSpecifier>(curlSpecifier(gamma,s)); return;}
}

#line 827 "runtime.in"
void curlSpecifierValuePart(stack *Stack)
{
  curlSpecifier spec=vm::pop<curlSpecifier>(Stack);
#line 828 "runtime.in"
  {Stack->push<real>(spec.getValue()); return;}
}

#line 832 "runtime.in"
void curlSpecifierSidePart(stack *Stack)
{
  curlSpecifier spec=vm::pop<curlSpecifier>(Stack);
#line 833 "runtime.in"
  {Stack->push<Int>(spec.getSide()); return;}
}

#line 837 "runtime.in"
// guide* operator cast(curlSpecifier spec);
void gen_runtime95(stack *Stack)
{
  curlSpecifier spec=vm::pop<curlSpecifier>(Stack);
#line 838 "runtime.in"
  {Stack->push<guide*>(new specguide(spec)); return;}
}

#line 842 "runtime.in"
// tensionSpecifier operator tension(real tout, real tin, bool atleast);
void gen_runtime96(stack *Stack)
{
  bool atleast=vm::pop<bool>(Stack);
  real tin=vm::pop<real>(Stack);
  real tout=vm::pop<real>(Stack);
#line 843 "runtime.in"
  {Stack->push<tensionSpecifier>(tensionSpecifier(tout, tin, atleast)); return;}
}

#line 847 "runtime.in"
void tensionSpecifierOutPart(stack *Stack)
{
  tensionSpecifier t=vm::pop<tensionSpecifier>(Stack);
#line 848 "runtime.in"
  {Stack->push<real>(t.getOut()); return;}
}

#line 852 "runtime.in"
void tensionSpecifierInPart(stack *Stack)
{
  tensionSpecifier t=vm::pop<tensionSpecifier>(Stack);
#line 853 "runtime.in"
  {Stack->push<real>(t.getIn()); return;}
}

#line 857 "runtime.in"
void tensionSpecifierAtleastPart(stack *Stack)
{
  tensionSpecifier t=vm::pop<tensionSpecifier>(Stack);
#line 858 "runtime.in"
  {Stack->push<bool>(t.getAtleast()); return;}
}

#line 862 "runtime.in"
// guide* operator cast(tensionSpecifier t);
void gen_runtime100(stack *Stack)
{
  tensionSpecifier t=vm::pop<tensionSpecifier>(Stack);
#line 863 "runtime.in"
  {Stack->push<guide*>(new tensionguide(t)); return;}
}

#line 867 "runtime.in"
// guide* operator controls(pair zout, pair zin);
void gen_runtime101(stack *Stack)
{
  pair zin=vm::pop<pair>(Stack);
  pair zout=vm::pop<pair>(Stack);
#line 868 "runtime.in"
  {Stack->push<guide*>(new controlguide(zout, zin)); return;}
}

#line 872 "runtime.in"
// Int size(guide *g);
void gen_runtime102(stack *Stack)
{
  guide * g=vm::pop<guide *>(Stack);
#line 873 "runtime.in"
  flatguide f;
  g->flatten(f,false);
  {Stack->push<Int>(f.size()); return;}
}

#line 879 "runtime.in"
// Int length(guide *g);
void gen_runtime103(stack *Stack)
{
  guide * g=vm::pop<guide *>(Stack);
#line 880 "runtime.in"
  flatguide f;
  g->flatten(f,false);
  {Stack->push<Int>(g->cyclic() ? f.size() : f.size()-1); return;}
}

#line 886 "runtime.in"
// bool cyclic(guide *g);
void gen_runtime104(stack *Stack)
{
  guide * g=vm::pop<guide *>(Stack);
#line 887 "runtime.in"
  flatguide f;
  g->flatten(f,false);
  {Stack->push<bool>(g->cyclic()); return;}
}

#line 893 "runtime.in"
// pair point(guide *g, Int t);
void gen_runtime105(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  guide * g=vm::pop<guide *>(Stack);
#line 894 "runtime.in"
  flatguide f;
  g->flatten(f,false);
  {Stack->push<pair>(f.Nodes(adjustedIndex(t,f.size(),g->cyclic())).z); return;}
}

#line 900 "runtime.in"
// pairarray* dirSpecifier(guide *g, Int t);
void gen_runtime106(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  guide * g=vm::pop<guide *>(Stack);
#line 901 "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 912 "runtime.in"
// pairarray* controlSpecifier(guide *g, Int t);
void gen_runtime107(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  guide * g=vm::pop<guide *>(Stack);
#line 913 "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 929 "runtime.in"
// tensionSpecifier tensionSpecifier(guide *g, Int t);
void gen_runtime108(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  guide * g=vm::pop<guide *>(Stack);
#line 930 "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 939 "runtime.in"
// realarray* curlSpecifier(guide *g, Int t);
void gen_runtime109(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  guide * g=vm::pop<guide *>(Stack);
#line 940 "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 953 "runtime.in"
// guide* reverse(guide *g);
void gen_runtime110(stack *Stack)
{
  guide * g=vm::pop<guide *>(Stack);
#line 954 "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;}
}

#line 1008 "runtime.in"
// realarray* _cputime();
void gen_runtime111(stack *Stack)
{
#line 1009 "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;}
}


// Transforms
#line 1024 "runtime.in"
// bool ==(transform a, transform b);
void gen_runtime112(stack *Stack)
{
  transform b=vm::pop<transform>(Stack);
  transform a=vm::pop<transform>(Stack);
#line 1025 "runtime.in"
  {Stack->push<bool>(a == b); return;}
}

#line 1030 "runtime.in"
// bool !=(transform a, transform b);
void gen_runtime113(stack *Stack)
{
  transform b=vm::pop<transform>(Stack);
  transform a=vm::pop<transform>(Stack);
#line 1031 "runtime.in"
  {Stack->push<bool>(a != b); return;}
}

#line 1035 "runtime.in"
// transform +(transform a, transform b);
void gen_runtime114(stack *Stack)
{
  transform b=vm::pop<transform>(Stack);
  transform a=vm::pop<transform>(Stack);
#line 1036 "runtime.in"
  {Stack->push<transform>(a+b); return;}
}

#line 1040 "runtime.in"
// transform *(transform a, transform b);
void gen_runtime115(stack *Stack)
{
  transform b=vm::pop<transform>(Stack);
  transform a=vm::pop<transform>(Stack);
#line 1041 "runtime.in"
  {Stack->push<transform>(a*b); return;}
}

#line 1045 "runtime.in"
// pair *(transform t, pair z);
void gen_runtime116(stack *Stack)
{
  pair z=vm::pop<pair>(Stack);
  transform t=vm::pop<transform>(Stack);
#line 1046 "runtime.in"
  {Stack->push<pair>(t*z); return;}
}

#line 1050 "runtime.in"
// path *(transform t, path g);
void gen_runtime117(stack *Stack)
{
  path g=vm::pop<path>(Stack);
  transform t=vm::pop<transform>(Stack);
#line 1051 "runtime.in"
  {Stack->push<path>(transformed(t,g)); return;}
}

#line 1055 "runtime.in"
// pen *(transform t, pen p);
void gen_runtime118(stack *Stack)
{
  pen p=vm::pop<pen>(Stack);
  transform t=vm::pop<transform>(Stack);
#line 1056 "runtime.in"
  {Stack->push<pen>(transformed(t,p)); return;}
}

#line 1060 "runtime.in"
// picture* *(transform t, picture *f);
void gen_runtime119(stack *Stack)
{
  picture * f=vm::pop<picture *>(Stack);
  transform t=vm::pop<transform>(Stack);
#line 1061 "runtime.in"
  {Stack->push<picture*>(transformed(t,f)); return;}
}

#line 1065 "runtime.in"
// picture* *(realarray2 *t, picture *f);
void gen_runtime120(stack *Stack)
{
  picture * f=vm::pop<picture *>(Stack);
  realarray2 * t=vm::pop<realarray2 *>(Stack);
#line 1066 "runtime.in"
  {Stack->push<picture*>(transformed(*t,f)); return;}
}

#line 1070 "runtime.in"
// transform ^(transform t, Int n);
void gen_runtime121(stack *Stack)
{
  Int n=vm::pop<Int>(Stack);
  transform t=vm::pop<transform>(Stack);
#line 1071 "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 1081 "runtime.in"
void transformXPart(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1082 "runtime.in"
  {Stack->push<real>(t.getx()); return;}
}

#line 1086 "runtime.in"
void transformYPart(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1087 "runtime.in"
  {Stack->push<real>(t.gety()); return;}
}

#line 1091 "runtime.in"
void transformXXPart(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1092 "runtime.in"
  {Stack->push<real>(t.getxx()); return;}
}

#line 1096 "runtime.in"
void transformXYPart(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1097 "runtime.in"
  {Stack->push<real>(t.getxy()); return;}
}

#line 1101 "runtime.in"
void transformYXPart(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1102 "runtime.in"
  {Stack->push<real>(t.getyx()); return;}
}

#line 1106 "runtime.in"
void transformYYPart(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1107 "runtime.in"
  {Stack->push<real>(t.getyy()); return;}
}

#line 1111 "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 1113 "runtime.in"
  {Stack->push<transform>(transform(x,y,xx,xy,yx,yy)); return;}
}

#line 1117 "runtime.in"
// transform shift(transform t);
void gen_runtime129(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1118 "runtime.in"
  {Stack->push<transform>(transform(t.getx(),t.gety(),0,0,0,0)); return;}
}

#line 1122 "runtime.in"
// transform shiftless(transform t);
void gen_runtime130(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1123 "runtime.in"
  {Stack->push<transform>(transform(0,0,t.getxx(),t.getxy(),t.getyx(),t.getyy())); return;}
}

#line 1127 "runtime.in"
// transform identity();
void transformIdentity(stack *Stack)
{
#line 1128 "runtime.in"
  {Stack->push<transform>(identity); return;}
}

#line 1132 "runtime.in"
// transform inverse(transform t);
void gen_runtime132(stack *Stack)
{
  transform t=vm::pop<transform>(Stack);
#line 1133 "runtime.in"
  {Stack->push<transform>(inverse(t)); return;}
}

#line 1137 "runtime.in"
// transform shift(pair z);
void gen_runtime133(stack *Stack)
{
  pair z=vm::pop<pair>(Stack);
#line 1138 "runtime.in"
  {Stack->push<transform>(shift(z)); return;}
}

#line 1142 "runtime.in"
// transform shift(real x, real y);
void gen_runtime134(stack *Stack)
{
  real y=vm::pop<real>(Stack);
  real x=vm::pop<real>(Stack);
#line 1143 "runtime.in"
  {Stack->push<transform>(shift(pair(x,y))); return;}
}

#line 1147 "runtime.in"
// transform xscale(real x);
void gen_runtime135(stack *Stack)
{
  real x=vm::pop<real>(Stack);
#line 1148 "runtime.in"
  {Stack->push<transform>(xscale(x)); return;}
}

#line 1152 "runtime.in"
// transform yscale(real y);
void gen_runtime136(stack *Stack)
{
  real y=vm::pop<real>(Stack);
#line 1153 "runtime.in"
  {Stack->push<transform>(yscale(y)); return;}
}

#line 1157 "runtime.in"
// transform scale(real x);
void gen_runtime137(stack *Stack)
{
  real x=vm::pop<real>(Stack);
#line 1158 "runtime.in"
  {Stack->push<transform>(scale(x)); return;}
}

#line 1162 "runtime.in"
// transform scale(real x, real y);
void gen_runtime138(stack *Stack)
{
  real y=vm::pop<real>(Stack);
  real x=vm::pop<real>(Stack);
#line 1163 "runtime.in"
  {Stack->push<transform>(scale(x,y)); return;}
}

#line 1167 "runtime.in"
// transform slant(real s);
void gen_runtime139(stack *Stack)
{
  real s=vm::pop<real>(Stack);
#line 1168 "runtime.in"
  {Stack->push<transform>(slant(s)); return;}
}

#line 1172 "runtime.in"
// transform rotate(real angle, pair z=0);
void gen_runtime140(stack *Stack)
{
  pair z=vm::pop<pair>(Stack,0);
  real angle=vm::pop<real>(Stack);
#line 1173 "runtime.in"
  {Stack->push<transform>(rotatearound(z,radians(angle))); return;}
}

#line 1177 "runtime.in"
// transform reflect(pair a, pair b);
void gen_runtime141(stack *Stack)
{
  pair b=vm::pop<pair>(Stack);
  pair a=vm::pop<pair>(Stack);
#line 1178 "runtime.in"
  {Stack->push<transform>(reflectabout(a,b)); return;}
}

} // namespace run

namespace trans {

void gen_runtime_venv(venv &ve)
{
#line 215 "runtime.in"
  REGISTER_BLTIN(run::IntZero,"IntZero");
#line 223 "runtime.in"
  REGISTER_BLTIN(run::realZero,"realZero");
#line 228 "runtime.in"
  REGISTER_BLTIN(run::boolFalse,"boolFalse");
#line 233 "runtime.in"
  REGISTER_BLTIN(run::pushNullArray,"pushNullArray");
#line 238 "runtime.in"
  REGISTER_BLTIN(run::pushNullRecord,"pushNullRecord");
#line 243 "runtime.in"
  REGISTER_BLTIN(run::pushNullFunction,"pushNullFunction");
#line 248 "runtime.in"
  REGISTER_BLTIN(run::pushDefault,"pushDefault");
#line 258 "runtime.in"
  REGISTER_BLTIN(run::isDefault,"isDefault");
#line 265 "runtime.in"
  REGISTER_BLTIN(run::pairToGuide,"pairToGuide");
#line 273 "runtime.in"
  REGISTER_BLTIN(run::pathToGuide,"pathToGuide");
#line 278 "runtime.in"
  REGISTER_BLTIN(run::guideToPath,"guideToPath");
#line 283 "runtime.in"
  REGISTER_BLTIN(run::newPen,"newPen");
#line 291 "runtime.in"
  addFunc(ve, run::gen_runtime12, primBoolean(), SYM_EQ, formal(primPen(), SYM(a), false, false), formal(primPen(), SYM(b), false, false));
#line 296 "runtime.in"
  addFunc(ve, run::gen_runtime13, primBoolean(), SYM_NEQ, formal(primPen(), SYM(a), false, false), formal(primPen(), SYM(b), false, false));
#line 301 "runtime.in"
  addFunc(ve, run::gen_runtime14, primPen(), SYM_PLUS, formal(primPen(), SYM(a), false, false), formal(primPen(), SYM(b), false, false));
#line 306 "runtime.in"
  addFunc(ve, run::gen_runtime15, primPen(), SYM_TIMES, formal(primReal(), SYM(a), false, false), formal(primPen(), SYM(b), false, false));
#line 311 "runtime.in"
  addFunc(ve, run::gen_runtime16, primPen(), SYM_TIMES, formal(primPen(), SYM(a), false, false), formal(primReal(), SYM(b), false, false));
#line 316 "runtime.in"
  addFunc(ve, run::gen_runtime17, primPair(), SYM(max), formal(primPen(), SYM(p), false, false));
#line 321 "runtime.in"
  addFunc(ve, run::gen_runtime18, primPair(), SYM(min), formal(primPen(), SYM(p), false, false));
#line 326 "runtime.in"
  addFunc(ve, run::gen_runtime19, primVoid(), SYM(resetdefaultpen));
#line 332 "runtime.in"
  addFunc(ve, run::gen_runtime20, primVoid(), SYM(defaultpen), formal(primPen(), SYM(p), false, false));
#line 337 "runtime.in"
  addFunc(ve, run::gen_runtime21, primPen(), SYM(defaultpen));
#line 342 "runtime.in"
  addFunc(ve, run::gen_runtime22, primBoolean(), SYM(invisible), formal(primPen(), SYM(p), false, false));
#line 347 "runtime.in"
  addFunc(ve, run::gen_runtime23, primPen(), SYM(invisible));
#line 352 "runtime.in"
  addFunc(ve, run::gen_runtime24, primPen(), SYM(gray), formal(primPen(), SYM(p), false, false));
#line 358 "runtime.in"
  addFunc(ve, run::gen_runtime25, primPen(), SYM(rgb), formal(primPen(), SYM(p), false, false));
#line 364 "runtime.in"
  addFunc(ve, run::gen_runtime26, primPen(), SYM(cmyk), formal(primPen(), SYM(p), false, false));
#line 370 "runtime.in"
  addFunc(ve, run::gen_runtime27, primPen(), SYM(interp), formal(primPen(), SYM(a), false, false), formal(primPen(), SYM(b), false, false), formal(primReal(), SYM(t), false, false));
#line 375 "runtime.in"
  addFunc(ve, run::gen_runtime28, primPen(), SYM(rgb), formal(primReal(), SYM(r), false, false), formal(primReal(), SYM(g), false, false), formal(primReal(), SYM(b), false, false));
#line 380 "runtime.in"
  addFunc(ve, run::gen_runtime29, primPen(), SYM(cmyk), formal(primReal(), SYM(c), false, false), formal(primReal(), SYM(m), false, false), formal(primReal(), SYM(y), false, false), formal(primReal(), SYM(k), false, false));
#line 385 "runtime.in"
  addFunc(ve, run::gen_runtime30, primPen(), SYM(gray), formal(primReal(), SYM(gray), false, false));
#line 390 "runtime.in"
  addFunc(ve, run::gen_runtime31, realArray(), SYM(colors), formal(primPen(), SYM(p), false, false));
#line 418 "runtime.in"
  addFunc(ve, run::gen_runtime32, primString() , SYM(hex), formal(primPen(), SYM(p), false, false));
#line 423 "runtime.in"
  addFunc(ve, run::gen_runtime33, primInt(), SYM(byte), formal(primReal(), SYM(x), false, false));
#line 428 "runtime.in"
  addFunc(ve, run::gen_runtime34, primString() , SYM(colorspace), formal(primPen(), SYM(p), false, false));
#line 435 "runtime.in"
  addFunc(ve, run::gen_runtime35, primPen(), SYM(pattern), formal(primString(), SYM(s), false, false));
#line 440 "runtime.in"
  addFunc(ve, run::gen_runtime36, primString() , SYM(pattern), formal(primPen(), SYM(p), false, false));
#line 445 "runtime.in"
  addFunc(ve, run::gen_runtime37, primPen(), SYM(fillrule), formal(primInt(), SYM(n), false, false));
#line 450 "runtime.in"
  addFunc(ve, run::gen_runtime38, primInt(), SYM(fillrule), formal(primPen(), SYM(p), false, false));
#line 455 "runtime.in"
  addFunc(ve, run::gen_runtime39, primPen(), SYM(opacity), formal(primReal(), SYM(opacity), true, false), formal(primString() , SYM(blend), true, false));
#line 465 "runtime.in"
  addFunc(ve, run::gen_runtime40, primReal(), SYM(opacity), formal(primPen(), SYM(p), false, false));
#line 470 "runtime.in"
  addFunc(ve, run::gen_runtime41, primString() , SYM(blend), formal(primPen(), SYM(p), false, false));
#line 475 "runtime.in"
  addFunc(ve, run::gen_runtime42, primPen(), SYM(linetype), formal(realArray(), SYM(pattern), false, false), formal(primReal(), SYM(offset), true, false), formal(primBoolean(), SYM(scale), true, false), formal(primBoolean(), SYM(adjust), true, false));
#line 486 "runtime.in"
  addFunc(ve, run::gen_runtime43, realArray(), SYM(linetype), formal(primPen(), SYM(p), true, false));
#line 492 "runtime.in"
  addFunc(ve, run::gen_runtime44, primReal(), SYM(offset), formal(primPen(), SYM(p), false, false));
#line 497 "runtime.in"
  addFunc(ve, run::gen_runtime45, primBoolean(), SYM(scale), formal(primPen(), SYM(p), false, false));
#line 502 "runtime.in"
  addFunc(ve, run::gen_runtime46, primBoolean(), SYM(adjust), formal(primPen(), SYM(p), false, false));
#line 507 "runtime.in"
  addFunc(ve, run::gen_runtime47, primPen(), SYM(adjust), formal(primPen(), SYM(p), false, false), formal(primReal(), SYM(arclength), false, false), formal(primBoolean(), SYM(cyclic), false, false));
#line 512 "runtime.in"
  addFunc(ve, run::gen_runtime48, primPen(), SYM(linecap), formal(primInt(), SYM(n), false, false));
#line 517 "runtime.in"
  addFunc(ve, run::gen_runtime49, primInt(), SYM(linecap), formal(primPen(), SYM(p), true, false));
#line 522 "runtime.in"
  addFunc(ve, run::gen_runtime50, primPen(), SYM(linejoin), formal(primInt(), SYM(n), false, false));
#line 527 "runtime.in"
  addFunc(ve, run::gen_runtime51, primInt(), SYM(linejoin), formal(primPen(), SYM(p), true, false));
#line 532 "runtime.in"
  addFunc(ve, run::gen_runtime52, primPen(), SYM(miterlimit), formal(primReal(), SYM(x), false, false));
#line 537 "runtime.in"
  addFunc(ve, run::gen_runtime53, primReal(), SYM(miterlimit), formal(primPen(), SYM(p), true, false));
#line 542 "runtime.in"
  addFunc(ve, run::gen_runtime54, primPen(), SYM(linewidth), formal(primReal(), SYM(x), false, false));
#line 547 "runtime.in"
  addFunc(ve, run::gen_runtime55, primReal(), SYM(linewidth), formal(primPen(), SYM(p), true, false));
#line 552 "runtime.in"
  addFunc(ve, run::gen_runtime56, primPen(), SYM(fontcommand), formal(primString(), SYM(s), false, false));
#line 557 "runtime.in"
  addFunc(ve, run::gen_runtime57, primString() , SYM(font), formal(primPen(), SYM(p), true, false));
#line 562 "runtime.in"
  addFunc(ve, run::gen_runtime58, primPen(), SYM(fontsize), formal(primReal(), SYM(size), false, false), formal(primReal(), SYM(lineskip), false, false));
#line 568 "runtime.in"
  addFunc(ve, run::gen_runtime59, primReal(), SYM(fontsize), formal(primPen(), SYM(p), true, false));
#line 573 "runtime.in"
  addFunc(ve, run::gen_runtime60, primReal(), SYM(lineskip), formal(primPen(), SYM(p), true, false));
#line 578 "runtime.in"
  addFunc(ve, run::gen_runtime61, primPen(), SYM(overwrite), formal(primInt(), SYM(n), false, false));
#line 584 "runtime.in"
  addFunc(ve, run::gen_runtime62, primInt(), SYM(overwrite), formal(primPen(), SYM(p), true, false));
#line 589 "runtime.in"
  addFunc(ve, run::gen_runtime63, primPen(), SYM(basealign), formal(primInt(), SYM(n), false, false));
#line 594 "runtime.in"
  addFunc(ve, run::gen_runtime64, primInt(), SYM(basealign), formal(primPen(), SYM(p), true, false));
#line 599 "runtime.in"
  addFunc(ve, run::gen_runtime65, primTransform(), SYM(transform), formal(primPen(), SYM(p), false, false));
#line 604 "runtime.in"
  addFunc(ve, run::gen_runtime66, primPath(), SYM(nib), formal(primPen(), SYM(p), false, false));
#line 609 "runtime.in"
  addFunc(ve, run::gen_runtime67, primPen(), SYM(makepen), formal(primPath(), SYM(p), false, false));
#line 614 "runtime.in"
  addFunc(ve, run::gen_runtime68, primPen(), SYM(colorless), formal(primPen(), SYM(p), false, false));
#line 620 "runtime.in"
  addFunc(ve, run::gen_runtime69, primBoolean(), SYM(interactive));
#line 627 "runtime.in"
  addFunc(ve, run::gen_runtime70, primBoolean(), SYM(uptodate));
#line 632 "runtime.in"
  addFunc(ve, run::gen_runtime71, primInt(), SYM(system), formal(stringArray(), SYM(s), false, false));
#line 646 "runtime.in"
  addFunc(ve, run::gen_runtime72, primBoolean(), SYM(view));
#line 651 "runtime.in"
  addFunc(ve, run::gen_runtime73, primString() , SYM(asydir));
#line 656 "runtime.in"
  addFunc(ve, run::gen_runtime74, primString() , SYM(locale), formal(primString() , SYM(s), true, false));
#line 662 "runtime.in"
  addFunc(ve, run::gen_runtime75, primVoid(), SYM(abort), formal(primString() , SYM(s), true, false));
#line 668 "runtime.in"
  addFunc(ve, run::gen_runtime76, primVoid(), SYM(exit));
#line 673 "runtime.in"
  addFunc(ve, run::gen_runtime77, primVoid(), SYM(assert), formal(primBoolean(), SYM(b), false, false), formal(primString() , SYM(s), true, false));
#line 684 "runtime.in"
  addFunc(ve, run::gen_runtime78, primVoid(), SYM(sleep), formal(primInt(), SYM(seconds), false, false));
#line 690 "runtime.in"
  addFunc(ve, run::gen_runtime79, primVoid(), SYM(usleep), formal(primInt(), SYM(microseconds), false, false));
#line 696 "runtime.in"
  addFunc(ve, run::gen_runtime80, primVoid(), SYM(_eval), formal(primString(), SYM(s), false, false), formal(primBoolean(), SYM(embedded), false, false), formal(primBoolean(), SYM(interactivewrite), true, false));
#line 709 "runtime.in"
  addFunc(ve, run::gen_runtime81, primVoid(), SYM(_eval), formal(primCode(), SYM(s), false, false), formal(primBoolean(), SYM(embedded), false, false));
#line 725 "runtime.in"
  addFunc(ve, run::gen_runtime82, primString() , SYM(location));
#line 731 "runtime.in"
  REGISTER_BLTIN(run::loadModule,"loadModule");
#line 737 "runtime.in"
  addFunc(ve, run::gen_runtime84, primString() , SYM(cd), formal(primString() , SYM(s), true, false));
#line 747 "runtime.in"
  addFunc(ve, run::gen_runtime85, primVoid(), SYM(list), formal(primString(), SYM(s), false, false), formal(primBoolean(), SYM(imports), true, false));
#line 756 "runtime.in"
  REGISTER_BLTIN(run::nullGuide,"nullGuide");
#line 764 "runtime.in"
  REGISTER_BLTIN(run::dotsGuide,"dotsGuide");
#line 774 "runtime.in"
  REGISTER_BLTIN(run::dashesGuide,"dashesGuide");
#line 801 "runtime.in"
  REGISTER_BLTIN(run::newCycleToken,"newCycleToken");
#line 806 "runtime.in"
  addFunc(ve, run::gen_runtime90, primGuide(), symbol::trans("operator cast"), formal(primCycleToken(), SYM(tok), false, false));
#line 813 "runtime.in"
  addFunc(ve, run::gen_runtime91, primGuide(), symbol::trans("operator spec"), formal(primPair(), SYM(z), false, false), formal(primInt(), SYM(p), false, false));
#line 821 "runtime.in"
  addFunc(ve, run::gen_runtime92, primCurlSpecifier(), SYM_CURL, formal(primReal(), SYM(gamma), false, false), formal(primInt(), SYM(p), false, false));
#line 827 "runtime.in"
  REGISTER_BLTIN(run::curlSpecifierValuePart,"curlSpecifierValuePart");
#line 832 "runtime.in"
  REGISTER_BLTIN(run::curlSpecifierSidePart,"curlSpecifierSidePart");
#line 837 "runtime.in"
  addFunc(ve, run::gen_runtime95, primGuide(), symbol::trans("operator cast"), formal(primCurlSpecifier(), SYM(spec), false, false));
#line 842 "runtime.in"
  addFunc(ve, run::gen_runtime96, primTensionSpecifier(), SYM_TENSION, formal(primReal(), SYM(tout), false, false), formal(primReal(), SYM(tin), false, false), formal(primBoolean(), SYM(atleast), false, false));
#line 847 "runtime.in"
  REGISTER_BLTIN(run::tensionSpecifierOutPart,"tensionSpecifierOutPart");
#line 852 "runtime.in"
  REGISTER_BLTIN(run::tensionSpecifierInPart,"tensionSpecifierInPart");
#line 857 "runtime.in"
  REGISTER_BLTIN(run::tensionSpecifierAtleastPart,"tensionSpecifierAtleastPart");
#line 862 "runtime.in"
  addFunc(ve, run::gen_runtime100, primGuide(), symbol::trans("operator cast"), formal(primTensionSpecifier(), SYM(t), false, false));
#line 867 "runtime.in"
  addFunc(ve, run::gen_runtime101, primGuide(), SYM_CONTROLS, formal(primPair(), SYM(zout), false, false), formal(primPair(), SYM(zin), false, false));
#line 872 "runtime.in"
  addFunc(ve, run::gen_runtime102, primInt(), SYM(size), formal(primGuide(), SYM(g), false, false));
#line 879 "runtime.in"
  addFunc(ve, run::gen_runtime103, primInt(), SYM(length), formal(primGuide(), SYM(g), false, false));
#line 886 "runtime.in"
  addFunc(ve, run::gen_runtime104, primBoolean(), SYM(cyclic), formal(primGuide(), SYM(g), false, false));
#line 893 "runtime.in"
  addFunc(ve, run::gen_runtime105, primPair(), SYM(point), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false));
#line 900 "runtime.in"
  addFunc(ve, run::gen_runtime106, pairArray(), SYM(dirSpecifier), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false));
#line 912 "runtime.in"
  addFunc(ve, run::gen_runtime107, pairArray(), SYM(controlSpecifier), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false));
#line 929 "runtime.in"
  addFunc(ve, run::gen_runtime108, primTensionSpecifier(), SYM(tensionSpecifier), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false));
#line 939 "runtime.in"
  addFunc(ve, run::gen_runtime109, realArray(), SYM(curlSpecifier), formal(primGuide(), SYM(g), false, false), formal(primInt(), SYM(t), false, false));
#line 953 "runtime.in"
  addFunc(ve, run::gen_runtime110, primGuide(), SYM(reverse), formal(primGuide(), SYM(g), false, false));
#line 1008 "runtime.in"
  addFunc(ve, run::gen_runtime111, realArray(), SYM(_cputime));
#line 1022 "runtime.in"
  addFunc(ve, run::gen_runtime112, primBoolean(), SYM_EQ, formal(primTransform(), SYM(a), false, false), formal(primTransform(), SYM(b), false, false));
#line 1030 "runtime.in"
  addFunc(ve, run::gen_runtime113, primBoolean(), SYM_NEQ, formal(primTransform(), SYM(a), false, false), formal(primTransform(), SYM(b), false, false));
#line 1035 "runtime.in"
  addFunc(ve, run::gen_runtime114, primTransform(), SYM_PLUS, formal(primTransform(), SYM(a), false, false), formal(primTransform(), SYM(b), false, false));
#line 1040 "runtime.in"
  addFunc(ve, run::gen_runtime115, primTransform(), SYM_TIMES, formal(primTransform(), SYM(a), false, false), formal(primTransform(), SYM(b), false, false));
#line 1045 "runtime.in"
  addFunc(ve, run::gen_runtime116, primPair(), SYM_TIMES, formal(primTransform(), SYM(t), false, false), formal(primPair(), SYM(z), false, false));
#line 1050 "runtime.in"
  addFunc(ve, run::gen_runtime117, primPath(), SYM_TIMES, formal(primTransform(), SYM(t), false, false), formal(primPath(), SYM(g), false, false));
#line 1055 "runtime.in"
  addFunc(ve, run::gen_runtime118, primPen(), SYM_TIMES, formal(primTransform(), SYM(t), false, false), formal(primPen(), SYM(p), false, false));
#line 1060 "runtime.in"
  addFunc(ve, run::gen_runtime119, primPicture(), SYM_TIMES, formal(primTransform(), SYM(t), false, false), formal(primPicture(), SYM(f), false, false));
#line 1065 "runtime.in"
  addFunc(ve, run::gen_runtime120, primPicture(), SYM_TIMES, formal(realArray2(), SYM(t), false, false), formal(primPicture(), SYM(f), false, false));
#line 1070 "runtime.in"
  addFunc(ve, run::gen_runtime121, primTransform(), SYM_CARET, formal(primTransform(), SYM(t), false, false), formal(primInt(), SYM(n), false, false));
#line 1081 "runtime.in"
  REGISTER_BLTIN(run::transformXPart,"transformXPart");
#line 1086 "runtime.in"
  REGISTER_BLTIN(run::transformYPart,"transformYPart");
#line 1091 "runtime.in"
  REGISTER_BLTIN(run::transformXXPart,"transformXXPart");
#line 1096 "runtime.in"
  REGISTER_BLTIN(run::transformXYPart,"transformXYPart");
#line 1101 "runtime.in"
  REGISTER_BLTIN(run::transformYXPart,"transformYXPart");
#line 1106 "runtime.in"
  REGISTER_BLTIN(run::transformYYPart,"transformYYPart");
#line 1111 "runtime.in"
  REGISTER_BLTIN(run::real6ToTransform,"real6ToTransform");
#line 1117 "runtime.in"
  addFunc(ve, run::gen_runtime129, primTransform(), SYM(shift), formal(primTransform(), SYM(t), false, false));
#line 1122 "runtime.in"
  addFunc(ve, run::gen_runtime130, primTransform(), SYM(shiftless), formal(primTransform(), SYM(t), false, false));
#line 1127 "runtime.in"
  addFunc(ve, run::transformIdentity, primTransform(), SYM(identity));
#line 1132 "runtime.in"
  addFunc(ve, run::gen_runtime132, primTransform(), SYM(inverse), formal(primTransform(), SYM(t), false, false));
#line 1137 "runtime.in"
  addFunc(ve, run::gen_runtime133, primTransform(), SYM(shift), formal(primPair(), SYM(z), false, false));
#line 1142 "runtime.in"
  addFunc(ve, run::gen_runtime134, primTransform(), SYM(shift), formal(primReal(), SYM(x), false, false), formal(primReal(), SYM(y), false, false));
#line 1147 "runtime.in"
  addFunc(ve, run::gen_runtime135, primTransform(), SYM(xscale), formal(primReal(), SYM(x), false, false));
#line 1152 "runtime.in"
  addFunc(ve, run::gen_runtime136, primTransform(), SYM(yscale), formal(primReal(), SYM(y), false, false));
#line 1157 "runtime.in"
  addFunc(ve, run::gen_runtime137, primTransform(), SYM(scale), formal(primReal(), SYM(x), false, false));
#line 1162 "runtime.in"
  addFunc(ve, run::gen_runtime138, primTransform(), SYM(scale), formal(primReal(), SYM(x), false, false), formal(primReal(), SYM(y), false, false));
#line 1167 "runtime.in"
  addFunc(ve, run::gen_runtime139, primTransform(), SYM(slant), formal(primReal(), SYM(s), false, false));
#line 1172 "runtime.in"
  addFunc(ve, run::gen_runtime140, primTransform(), SYM(rotate), formal(primReal(), SYM(angle), false, false), formal(primPair(), SYM(z), true, false));
#line 1177 "runtime.in"
  addFunc(ve, run::gen_runtime141, primTransform(), SYM(reflect), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false));
}

} // namespace trans