-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcast.js
More file actions
25 lines (24 loc) · 774 Bytes
/
Copy pathcast.js
File metadata and controls
25 lines (24 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var lib = require('./common.js');
var tmpls=[
"int tag{{2}}=Ti({{2}});",
"if(x->t=={{x0}}&&(typenum=={{y0}}||typetag==tag{{y2}})) { // {{x2}} -> {{y2}} \n" +
" {{x3}} from;{{y3}} to; res=xalloc({{y0}},x->n); \n"+
" FOR(0,x->n,{from=AS_{{x1}}(x,_i);\n" +
" to=from; \n"+
" appendbuf(res,(buf_t)&to,1); }); }\n"
];
console.log(lib.prelude);
lib.each(lib.types,function(tx) {
console.log(lib.exhaust(lib.projr(lib.repl,tx),tmpls[0]));
});
lib.each(lib.types,function(tx) {
if(lib.dontcast.indexOf(tx[1])!=-1)return;
lib.each(lib.types,function(ty) {
if(lib.dontcast.indexOf(ty[1])!=-1)return;
var a=[];
tmpl=tmpls[1];
for(var i in tx)a["x"+i]=tx[i];
for(var i in ty)a["y"+i]=ty[i];
console.log(lib.exhaust(lib.projr(lib.repl,a),tmpl));
});
});