mirah 0.0.4-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -0
- data/README.txt +51 -0
- data/Rakefile +86 -0
- data/bin/duby +10 -0
- data/bin/dubyc +10 -0
- data/bin/dubyp +10 -0
- data/bin/jrubyp +36 -0
- data/bin/mirah +9 -0
- data/bin/mirah.cmd +1 -0
- data/bin/mirahc +9 -0
- data/bin/mirahc.cmd +1 -0
- data/bin/mirahp +9 -0
- data/bin/mirahp.cmd +1 -0
- data/examples/ant/example-build.xml +7 -0
- data/examples/appengine/Rakefile +19 -0
- data/examples/appengine/Readme +29 -0
- data/examples/appengine/src/org/mirah/MirahApp.mirah +57 -0
- data/examples/appengine/src/org/mirah/list.dhtml +15 -0
- data/examples/appengine/war/WEB-INF/lib/dubydatastore.jar +0 -0
- data/examples/bintrees.mirah +66 -0
- data/examples/construction.mirah +8 -0
- data/examples/dynamic.mirah +17 -0
- data/examples/edb.mirah +3 -0
- data/examples/fib.mirah +16 -0
- data/examples/fields.mirah +22 -0
- data/examples/fractal.mirah +55 -0
- data/examples/java_thing.mirah +13 -0
- data/examples/plugins/appengine/Rakefile +55 -0
- data/examples/plugins/appengine/lib/com/google/appengine/ext/duby/db/datastore.rb +375 -0
- data/examples/plugins/appengine/src/com/google/appengine/ext/duby/db/Model.duby +336 -0
- data/examples/plugins/appengine/test/com/google/appengine/ext/duby/db/ModelTest.duby +113 -0
- data/examples/simple_class.mirah +12 -0
- data/examples/sort_closure.mirah +7 -0
- data/examples/swing.mirah +20 -0
- data/examples/tak.mirah +15 -0
- data/examples/test.edb +9 -0
- data/examples/wiki/Rakefile +18 -0
- data/examples/wiki/src/org/mirah/wiki/MirahWiki.duby +324 -0
- data/examples/wiki/src/org/mirah/wiki/edit.eduby.html +42 -0
- data/examples/wiki/src/org/mirah/wiki/error.eduby.html +2 -0
- data/examples/wiki/src/org/mirah/wiki/layout.eduby.html +69 -0
- data/examples/wiki/src/org/mirah/wiki/parser.eduby.html +7 -0
- data/examples/wiki/src/org/mirah/wiki/view.eduby.html +15 -0
- data/examples/wiki/war/WEB-INF/classes/test/HeredocContext.class +0 -0
- data/examples/wiki/war/WEB-INF/classes/test/MirahParser.class +0 -0
- data/examples/wiki/war/WEB-INF/lib/appengine-api.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/dubydatastore.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/jmeta-runtime.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/pegdown-stubs.jar +0 -0
- data/examples/wiki/war/WEB-INF/pegdown.jar +0 -0
- data/examples/wiki/war/app.yaml +21 -0
- data/examples/wiki/war/public/favicon.ico +0 -0
- data/examples/wiki/war/public/images/appengine_duby.png +0 -0
- data/examples/wiki/war/public/images/back.gif +0 -0
- data/examples/wiki/war/public/images/dir.gif +0 -0
- data/examples/wiki/war/public/images/file.gif +0 -0
- data/examples/wiki/war/public/javascripts/prettify.js +61 -0
- data/examples/wiki/war/public/robots.txt +0 -0
- data/examples/wiki/war/public/stylesheets/main.css +156 -0
- data/examples/wiki/war/public/stylesheets/prettify.css +1 -0
- data/examples/wiki/war/public/stylesheets/sh_style.css +66 -0
- data/examples/wiki/war/public/stylesheets/source.css +21 -0
- data/examples/wiki/war/public/wmd/images/bg-fill.png +0 -0
- data/examples/wiki/war/public/wmd/images/bg.png +0 -0
- data/examples/wiki/war/public/wmd/images/blockquote.png +0 -0
- data/examples/wiki/war/public/wmd/images/bold.png +0 -0
- data/examples/wiki/war/public/wmd/images/code.png +0 -0
- data/examples/wiki/war/public/wmd/images/h1.png +0 -0
- data/examples/wiki/war/public/wmd/images/hr.png +0 -0
- data/examples/wiki/war/public/wmd/images/img.png +0 -0
- data/examples/wiki/war/public/wmd/images/italic.png +0 -0
- data/examples/wiki/war/public/wmd/images/link.png +0 -0
- data/examples/wiki/war/public/wmd/images/ol.png +0 -0
- data/examples/wiki/war/public/wmd/images/redo.png +0 -0
- data/examples/wiki/war/public/wmd/images/separator.png +0 -0
- data/examples/wiki/war/public/wmd/images/ul.png +0 -0
- data/examples/wiki/war/public/wmd/images/undo.png +0 -0
- data/examples/wiki/war/public/wmd/images/wmd-on.png +0 -0
- data/examples/wiki/war/public/wmd/images/wmd.png +0 -0
- data/examples/wiki/war/public/wmd/showdown.js +421 -0
- data/examples/wiki/war/public/wmd/wmd-base.js +1799 -0
- data/examples/wiki/war/public/wmd/wmd-plus.js +311 -0
- data/examples/wiki/war/public/wmd/wmd.js +73 -0
- data/javalib/JRubyParser.jar +0 -0
- data/javalib/dynalang-invoke-0.1.jar +0 -0
- data/javalib/mirah-bootstrap.jar +0 -0
- data/javalib/mirah-parser.jar +0 -0
- data/lib/duby.rb +2 -0
- data/lib/mirah.rb +338 -0
- data/lib/mirah/appengine_tasks.rb +146 -0
- data/lib/mirah/ast.rb +615 -0
- data/lib/mirah/ast/call.rb +307 -0
- data/lib/mirah/ast/class.rb +311 -0
- data/lib/mirah/ast/flow.rb +364 -0
- data/lib/mirah/ast/intrinsics.rb +470 -0
- data/lib/mirah/ast/literal.rb +154 -0
- data/lib/mirah/ast/local.rb +89 -0
- data/lib/mirah/ast/method.rb +360 -0
- data/lib/mirah/ast/scope.rb +208 -0
- data/lib/mirah/ast/structure.rb +226 -0
- data/lib/mirah/ast/type.rb +130 -0
- data/lib/mirah/compiler.rb +341 -0
- data/lib/mirah/env.rb +33 -0
- data/lib/mirah/jvm/base.rb +258 -0
- data/lib/mirah/jvm/compiler.rb +885 -0
- data/lib/mirah/jvm/method_lookup.rb +203 -0
- data/lib/mirah/jvm/source_compiler.rb +737 -0
- data/lib/mirah/jvm/source_generator/builder.rb +444 -0
- data/lib/mirah/jvm/source_generator/loops.rb +110 -0
- data/lib/mirah/jvm/source_generator/precompile.rb +188 -0
- data/lib/mirah/jvm/source_generator/typer.rb +11 -0
- data/lib/mirah/jvm/typer.rb +151 -0
- data/lib/mirah/jvm/types.rb +416 -0
- data/lib/mirah/jvm/types/basic_types.rb +33 -0
- data/lib/mirah/jvm/types/boolean.rb +17 -0
- data/lib/mirah/jvm/types/enumerable.rb +65 -0
- data/lib/mirah/jvm/types/extensions.rb +86 -0
- data/lib/mirah/jvm/types/factory.rb +186 -0
- data/lib/mirah/jvm/types/floats.rb +86 -0
- data/lib/mirah/jvm/types/integers.rb +171 -0
- data/lib/mirah/jvm/types/intrinsics.rb +376 -0
- data/lib/mirah/jvm/types/literals.rb +74 -0
- data/lib/mirah/jvm/types/methods.rb +614 -0
- data/lib/mirah/jvm/types/number.rb +143 -0
- data/lib/mirah/nbcompiler.rb +29 -0
- data/lib/mirah/plugin/edb.rb +29 -0
- data/lib/mirah/plugin/gwt.rb +173 -0
- data/lib/mirah/plugin/java.rb +55 -0
- data/lib/mirah/transform.rb +266 -0
- data/lib/mirah/transform2.rb +728 -0
- data/lib/mirah/typer.rb +407 -0
- data/lib/mirah_task.rb +107 -0
- data/test/test_ast.rb +359 -0
- data/test/test_compilation.rb +112 -0
- data/test/test_env.rb +42 -0
- data/test/test_gwt.rb +58 -0
- data/test/test_java_typer.rb +183 -0
- data/test/test_javac_compiler.rb +63 -0
- data/test/test_jvm_compiler.rb +2607 -0
- data/test/test_typer.rb +221 -0
- metadata +235 -0
@@ -0,0 +1,311 @@
|
|
1
|
+
var Attacklab=Attacklab||{};
|
2
|
+
Attacklab.wmdPlus=function(){
|
3
|
+
this.symboltable;
|
4
|
+
var _1=top;
|
5
|
+
var _2=_1["Attacklab"];
|
6
|
+
var _3=_1["document"];
|
7
|
+
var _4=_1["RegExp"];
|
8
|
+
var _5=_1["navigator"];
|
9
|
+
var _6=_2.Util;
|
10
|
+
var _7=_2.Position;
|
11
|
+
var _8=_2.Command;
|
12
|
+
_8.doAutoindent=function(_9){
|
13
|
+
_9.before=_9.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/,"\n\n");
|
14
|
+
_9.before=_9.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/,"\n\n");
|
15
|
+
_9.before=_9.before.replace(/(\n|^)[ \t]+\n$/,"\n\n");
|
16
|
+
if(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]+.*\n$/.test(_9.before)){
|
17
|
+
if(_8.doList){
|
18
|
+
_8.doList(_9);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
if(/(\n|^)[ ]{0,3}>[ \t]+.*\n$/.test(_9.before)){
|
22
|
+
if(_8.doBlockquote){
|
23
|
+
_8.doBlockquote(_9);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
if(/(\n|^)(\t|[ ]{4,}).*\n$/.test(_9.before)){
|
27
|
+
if(_8.doCode){
|
28
|
+
_8.doCode(_9);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
};
|
32
|
+
_8.doBlockquote=function(_a){
|
33
|
+
_a.selection=_a.selection.replace(/^(\n*)([^\r]+?)(\n*)$/,function(_b,_c,_d,_e){
|
34
|
+
_a.before+=_c;
|
35
|
+
_a.after=_e+_a.after;
|
36
|
+
return _d;
|
37
|
+
});
|
38
|
+
_a.before=_a.before.replace(/(>[ \t]*)$/,function(_f,_10){
|
39
|
+
_a.selection=_10+_a.selection;
|
40
|
+
return "";
|
41
|
+
});
|
42
|
+
_a.selection=_a.selection.replace(/^(\s|>)+$/,"");
|
43
|
+
_a.selection=_a.selection||"Blockquote";
|
44
|
+
if(_a.before){
|
45
|
+
_a.before=_a.before.replace(/\n?$/,"\n");
|
46
|
+
}
|
47
|
+
if(_a.after){
|
48
|
+
_a.after=_a.after.replace(/^\n?/,"\n");
|
49
|
+
}
|
50
|
+
_a.before=_a.before.replace(/(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*$)/,function(_11){
|
51
|
+
_a.startTag=_11;
|
52
|
+
return "";
|
53
|
+
});
|
54
|
+
_a.after=_a.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/,function(_12){
|
55
|
+
_a.endTag=_12;
|
56
|
+
return "";
|
57
|
+
});
|
58
|
+
var _13=function(_14){
|
59
|
+
var _15=_14?"> ":"";
|
60
|
+
if(_a.startTag){
|
61
|
+
_a.startTag=_a.startTag.replace(/\n((>|\s)*)\n$/,function(_16,_17){
|
62
|
+
return "\n"+_17.replace(/^[ ]{0,3}>?[ \t]*$/gm,_15)+"\n";
|
63
|
+
});
|
64
|
+
}
|
65
|
+
if(_a.endTag){
|
66
|
+
_a.endTag=_a.endTag.replace(/^\n((>|\s)*)\n/,function(_18,_19){
|
67
|
+
return "\n"+_19.replace(/^[ ]{0,3}>?[ \t]*$/gm,_15)+"\n";
|
68
|
+
});
|
69
|
+
}
|
70
|
+
};
|
71
|
+
if(/^(?![ ]{0,3}>)/m.test(_a.selection)){
|
72
|
+
_8.wrap(_a,_2.wmd_env.lineLength-2);
|
73
|
+
_a.selection=_a.selection.replace(/^/gm,"> ");
|
74
|
+
_13(true);
|
75
|
+
_a.skipLines();
|
76
|
+
}else{
|
77
|
+
_a.selection=_a.selection.replace(/^[ ]{0,3}> ?/gm,"");
|
78
|
+
_8.unwrap(_a);
|
79
|
+
_13(false);
|
80
|
+
if(!/^(\n|^)[ ]{0,3}>/.test(_a.selection)){
|
81
|
+
if(_a.startTag){
|
82
|
+
_a.startTag=_a.startTag.replace(/\n{0,2}$/,"\n\n");
|
83
|
+
}
|
84
|
+
}
|
85
|
+
if(!/(\n|^)[ ]{0,3}>.*$/.test(_a.selection)){
|
86
|
+
if(_a.endTag){
|
87
|
+
_a.endTag=_a.endTag.replace(/^\n{0,2}/,"\n\n");
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
if(!/\n/.test(_a.selection)){
|
92
|
+
_a.selection=_a.selection.replace(/^(> *)/,function(_1a,_1b){
|
93
|
+
_a.startTag+=_1b;
|
94
|
+
return "";
|
95
|
+
});
|
96
|
+
}
|
97
|
+
};
|
98
|
+
_8.doCode=function(_1c){
|
99
|
+
var _1d=/\S[ ]*$/.test(_1c.before);
|
100
|
+
var _1e=/^[ ]*\S/.test(_1c.after);
|
101
|
+
if((!_1e&&!_1d)||/\n/.test(_1c.selection)){
|
102
|
+
_1c.before=_1c.before.replace(/[ ]{4}$/,function(_1f){
|
103
|
+
_1c.selection=_1f+_1c.selection;
|
104
|
+
return "";
|
105
|
+
});
|
106
|
+
var _20=1;
|
107
|
+
var _21=1;
|
108
|
+
if(/\n(\t|[ ]{4,}).*\n$/.test(_1c.before)){
|
109
|
+
_20=0;
|
110
|
+
}
|
111
|
+
if(/^\n(\t|[ ]{4,})/.test(_1c.after)){
|
112
|
+
_21=0;
|
113
|
+
}
|
114
|
+
_1c.skipLines(_20,_21);
|
115
|
+
if(!_1c.selection){
|
116
|
+
_1c.startTag=" ";
|
117
|
+
_1c.selection="print(\"code sample\");";
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
if(/^[ ]{0,3}\S/m.test(_1c.selection)){
|
121
|
+
_1c.selection=_1c.selection.replace(/^/gm," ");
|
122
|
+
}else{
|
123
|
+
_1c.selection=_1c.selection.replace(/^[ ]{4}/gm,"");
|
124
|
+
}
|
125
|
+
}else{
|
126
|
+
_1c.trimWhitespace();
|
127
|
+
_1c.findTags(/`/,/`/);
|
128
|
+
if(!_1c.startTag&&!_1c.endTag){
|
129
|
+
_1c.startTag=_1c.endTag="`";
|
130
|
+
if(!_1c.selection){
|
131
|
+
_1c.selection="print(\"code sample\");";
|
132
|
+
}
|
133
|
+
}else{
|
134
|
+
if(_1c.endTag&&!_1c.startTag){
|
135
|
+
_1c.before+=_1c.endTag;
|
136
|
+
_1c.endTag="";
|
137
|
+
}else{
|
138
|
+
_1c.startTag=_1c.endTag="";
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
};
|
143
|
+
_8.autoindent={};
|
144
|
+
_8.autoindent.textOp=_8.doAutoindent;
|
145
|
+
_8.blockquote={};
|
146
|
+
_8.blockquote.description="Blockquote <blockquote>";
|
147
|
+
_8.blockquote.image="images/blockquote.png";
|
148
|
+
_8.blockquote.key=".";
|
149
|
+
_8.blockquote.keyCode=190;
|
150
|
+
_8.blockquote.textOp=function(_22){
|
151
|
+
return _8.doBlockquote(_22);
|
152
|
+
};
|
153
|
+
_8.code={};
|
154
|
+
_8.code.description="Code Sample <pre><code>";
|
155
|
+
_8.code.image="images/code.png";
|
156
|
+
_8.code.key="k";
|
157
|
+
_8.code.textOp=_8.doCode;
|
158
|
+
_8.img={};
|
159
|
+
_8.img.description="Image <img>";
|
160
|
+
_8.img.image="images/img.png";
|
161
|
+
_8.img.key="g";
|
162
|
+
_8.img.textOp=function(_23,_24){
|
163
|
+
return _8.doLinkOrImage(_23,true,_24);
|
164
|
+
};
|
165
|
+
_8.doList=function(_25,_26){
|
166
|
+
var _27=/(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/;
|
167
|
+
var _28="";
|
168
|
+
var _29=1;
|
169
|
+
var _2a=function(){
|
170
|
+
if(_26){
|
171
|
+
var _2b=" "+_29+". ";
|
172
|
+
_29++;
|
173
|
+
return _2b;
|
174
|
+
}
|
175
|
+
var _2c=_28||"-";
|
176
|
+
return " "+_2c+" ";
|
177
|
+
};
|
178
|
+
var _2d=function(_2e){
|
179
|
+
if(_26==undefined){
|
180
|
+
_26=/^\s*\d/.test(_2e);
|
181
|
+
}
|
182
|
+
_2e=_2e.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm,function(_2f){
|
183
|
+
return _2a();
|
184
|
+
});
|
185
|
+
return _2e;
|
186
|
+
};
|
187
|
+
var _30=function(){
|
188
|
+
_31=_6.regexToString(_27);
|
189
|
+
_31.expression="^\n*"+_31.expression;
|
190
|
+
var _32=_6.stringToRegex(_31);
|
191
|
+
_25.after=_25.after.replace(_32,_2d);
|
192
|
+
};
|
193
|
+
_25.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/,null);
|
194
|
+
var _33=/^\n/;
|
195
|
+
if(_25.before&&!/\n$/.test(_25.before)&&!_33.test(_25.startTag)){
|
196
|
+
_25.before+=_25.startTag;
|
197
|
+
_25.startTag="";
|
198
|
+
}
|
199
|
+
if(_25.startTag){
|
200
|
+
var _34=/\d+[.]/.test(_25.startTag);
|
201
|
+
_25.startTag="";
|
202
|
+
_25.selection=_25.selection.replace(/\n[ ]{4}/g,"\n");
|
203
|
+
_8.unwrap(_25);
|
204
|
+
_25.skipLines();
|
205
|
+
if(_34){
|
206
|
+
_30();
|
207
|
+
}
|
208
|
+
if(_26==_34){
|
209
|
+
return;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
var _35=1;
|
213
|
+
var _31=_6.regexToString(_27);
|
214
|
+
_31.expression="(\\n|^)"+_31.expression+"$";
|
215
|
+
var _36=_6.stringToRegex(_31);
|
216
|
+
_25.before=_25.before.replace(_36,function(_37){
|
217
|
+
if(/^\s*([*+-])/.test(_37)){
|
218
|
+
_28=_4.$1;
|
219
|
+
}
|
220
|
+
_35=/[^\n]\n\n[^\n]/.test(_37)?1:0;
|
221
|
+
return _2d(_37);
|
222
|
+
});
|
223
|
+
if(!_25.selection){
|
224
|
+
_25.selection="List item";
|
225
|
+
}
|
226
|
+
var _38=_2a();
|
227
|
+
var _39=1;
|
228
|
+
_31=_6.regexToString(_27);
|
229
|
+
_31.expression="^\n*"+_31.expression;
|
230
|
+
_36=_6.stringToRegex(_31);
|
231
|
+
_25.after=_25.after.replace(_36,function(_3a){
|
232
|
+
_39=/[^\n]\n\n[^\n]/.test(_3a)?1:0;
|
233
|
+
return _2d(_3a);
|
234
|
+
});
|
235
|
+
_25.trimWhitespace(true);
|
236
|
+
_25.skipLines(_35,_39,true);
|
237
|
+
_25.startTag=_38;
|
238
|
+
var _3b=_38.replace(/./g," ");
|
239
|
+
_8.wrap(_25,_2.wmd_env.lineLength-_3b.length);
|
240
|
+
_25.selection=_25.selection.replace(/\n/g,"\n"+_3b);
|
241
|
+
};
|
242
|
+
_8.doHeading=function(_3c){
|
243
|
+
_3c.selection=_3c.selection.replace(/\s+/g," ");
|
244
|
+
_3c.selection=_3c.selection.replace(/(^\s+|\s+$)/g,"");
|
245
|
+
var _3d=0;
|
246
|
+
_3c.findTags(/#+[ ]*/,/[ ]*#+/);
|
247
|
+
if(/#+/.test(_3c.startTag)){
|
248
|
+
_3d=_4.lastMatch.length;
|
249
|
+
}
|
250
|
+
_3c.startTag=_3c.endTag="";
|
251
|
+
_3c.findTags(null,/\s?(-+|=+)/);
|
252
|
+
if(/=+/.test(_3c.endTag)){
|
253
|
+
_3d=1;
|
254
|
+
}
|
255
|
+
if(/-+/.test(_3c.endTag)){
|
256
|
+
_3d=2;
|
257
|
+
}
|
258
|
+
_3c.startTag=_3c.endTag="";
|
259
|
+
_3c.skipLines(1,1);
|
260
|
+
if(!_3c.selection){
|
261
|
+
_3c.startTag="## ";
|
262
|
+
_3c.selection="Heading";
|
263
|
+
_3c.endTag=" ##";
|
264
|
+
return;
|
265
|
+
}
|
266
|
+
var _3e=_3d==0?2:_3d-1;
|
267
|
+
if(_3e){
|
268
|
+
var _3f=_3e>=2?"-":"=";
|
269
|
+
var _40=_3c.selection.length;
|
270
|
+
if(_40>_2.wmd_env.lineLength){
|
271
|
+
_40=_2.wmd_env.lineLength;
|
272
|
+
}
|
273
|
+
_3c.endTag="\n";
|
274
|
+
while(_40--){
|
275
|
+
_3c.endTag+=_3f;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
};
|
279
|
+
_8.ol={};
|
280
|
+
_8.ol.description="Numbered List <ol>";
|
281
|
+
_8.ol.image="images/ol.png";
|
282
|
+
_8.ol.key="o";
|
283
|
+
_8.ol.textOp=function(_41){
|
284
|
+
_8.doList(_41,true);
|
285
|
+
};
|
286
|
+
_8.ul={};
|
287
|
+
_8.ul.description="Bulleted List <ul>";
|
288
|
+
_8.ul.image="images/ul.png";
|
289
|
+
_8.ul.key="u";
|
290
|
+
_8.ul.textOp=function(_42){
|
291
|
+
_8.doList(_42,false);
|
292
|
+
};
|
293
|
+
_8.h1={};
|
294
|
+
_8.h1.description="Heading <h1>/<h2>";
|
295
|
+
_8.h1.image="images/h1.png";
|
296
|
+
_8.h1.key="h";
|
297
|
+
_8.h1.textOp=_8.doHeading;
|
298
|
+
_8.hr={};
|
299
|
+
_8.hr.description="Horizontal Rule <hr>";
|
300
|
+
_8.hr.image="images/hr.png";
|
301
|
+
_8.hr.key="r";
|
302
|
+
_8.hr.textOp=function(_43){
|
303
|
+
_43.startTag="----------\n";
|
304
|
+
_43.selection="";
|
305
|
+
_43.skipLines(2,1,true);
|
306
|
+
};
|
307
|
+
};
|
308
|
+
if(Attacklab.fileLoaded){
|
309
|
+
Attacklab.fileLoaded("wmd-plus.js");
|
310
|
+
}
|
311
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
var Attacklab=Attacklab||{};
|
2
|
+
Attacklab.wmd_env={};
|
3
|
+
Attacklab.account_options={};
|
4
|
+
Attacklab.wmd_defaults={version:1,output:"HTML",lineLength:40,delayLoad:false};
|
5
|
+
if(!Attacklab.wmd){
|
6
|
+
Attacklab.wmd=function(){
|
7
|
+
Attacklab.loadEnv=function(){
|
8
|
+
var _1=function(_2){
|
9
|
+
if(!_2){
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
for(var _3 in _2){
|
13
|
+
Attacklab.wmd_env[_3]=_2[_3];
|
14
|
+
}
|
15
|
+
};
|
16
|
+
_1(Attacklab.wmd_defaults);
|
17
|
+
_1(Attacklab.account_options);
|
18
|
+
_1(top["wmd_options"]);
|
19
|
+
Attacklab.full=true;
|
20
|
+
var _4="bold italic | link blockquote code image | ol ul heading hr";
|
21
|
+
Attacklab.wmd_env.buttons=Attacklab.wmd_env.buttons||_4;
|
22
|
+
};
|
23
|
+
Attacklab.loadEnv();
|
24
|
+
var _5=["showdown.js","wmd-base.js","wmd-plus.js"];
|
25
|
+
var _6=function(_7){
|
26
|
+
};
|
27
|
+
Attacklab.fileLoaded=function(_8){
|
28
|
+
arguments.callee.count=arguments.callee.count||0;
|
29
|
+
if(++arguments.callee.count>=_5.length){
|
30
|
+
var go=function(){
|
31
|
+
Attacklab.wmdBase();
|
32
|
+
Attacklab.Util.startEditor();
|
33
|
+
};
|
34
|
+
if(Attacklab.wmd_env.delayLoad){
|
35
|
+
window.setTimeout(go,0);
|
36
|
+
}else{
|
37
|
+
go();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
};
|
41
|
+
Attacklab.editorInit=function(){
|
42
|
+
Attacklab.wmdPlus();
|
43
|
+
};
|
44
|
+
var _a=function(_b,_c){
|
45
|
+
var _d=Attacklab.basePath+_b;
|
46
|
+
if(_c){
|
47
|
+
_d+="?nocache="+(new Date()).getTime();
|
48
|
+
}
|
49
|
+
var _e=document.createElement("script");
|
50
|
+
_e.src=_d;
|
51
|
+
top.document.documentElement.firstChild.appendChild(_e);
|
52
|
+
};
|
53
|
+
var _f=function(_10){
|
54
|
+
var _11=RegExp("(.*)"+_10+"(\\?(.+))?$","g");
|
55
|
+
var _12=document.getElementsByTagName("script");
|
56
|
+
for(var i=0;i<_12.length;i++){
|
57
|
+
if(_11.test(_12[i].src)){
|
58
|
+
var _14=RegExp.$1;
|
59
|
+
if(/wmd-editor.com/.test(_12[i].src)){
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
return _14;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
};
|
66
|
+
Attacklab.basePath=_f("wmd.js")||"http://static.wmd-editor.com/v2/";
|
67
|
+
for(var f,i=0;f=_5[i];i++){
|
68
|
+
_a(f,false);
|
69
|
+
}
|
70
|
+
};
|
71
|
+
Attacklab.wmd();
|
72
|
+
}
|
73
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/duby.rb
ADDED
data/lib/mirah.rb
ADDED
@@ -0,0 +1,338 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rbconfig'
|
3
|
+
require 'mirah/transform'
|
4
|
+
require 'mirah/ast'
|
5
|
+
require 'mirah/typer'
|
6
|
+
require 'mirah/compiler'
|
7
|
+
require 'mirah/env'
|
8
|
+
begin
|
9
|
+
require 'bitescript'
|
10
|
+
rescue LoadError
|
11
|
+
$: << File.dirname(__FILE__) + '/../../bitescript/lib'
|
12
|
+
require 'bitescript'
|
13
|
+
end
|
14
|
+
require 'mirah/jvm/compiler'
|
15
|
+
require 'mirah/jvm/typer'
|
16
|
+
Dir[File.dirname(__FILE__) + "/mirah/plugin/*"].each {|file| require "#{file}" if file =~ /\.rb$/}
|
17
|
+
require 'jruby'
|
18
|
+
|
19
|
+
module Duby
|
20
|
+
def self.run(*args)
|
21
|
+
DubyImpl.new.run(*args)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.compile(*args)
|
25
|
+
DubyImpl.new.compile(*args)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse(*args)
|
29
|
+
DubyImpl.new.parse(*args)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.plugins
|
33
|
+
@plugins ||= []
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.reset
|
37
|
+
plugins.each {|x| x.reset if x.respond_to?(:reset)}
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.print_error(message, position)
|
41
|
+
puts "#{position.file}:#{position.start_line}: #{message}"
|
42
|
+
file_offset = 0
|
43
|
+
startline = position.start_line - 1
|
44
|
+
endline = position.end_line - 1
|
45
|
+
start_col = position.start_col - 1
|
46
|
+
end_col = position.end_col - 1
|
47
|
+
# don't try to search dash_e
|
48
|
+
# TODO: show dash_e source the same way
|
49
|
+
if File.exist? position.file
|
50
|
+
File.open(position.file).each_with_index do |line, lineno|
|
51
|
+
if lineno >= startline && lineno <= endline
|
52
|
+
puts line.chomp
|
53
|
+
if lineno == startline
|
54
|
+
print ' ' * start_col
|
55
|
+
else
|
56
|
+
start_col = 0
|
57
|
+
end
|
58
|
+
if lineno < endline
|
59
|
+
puts '^' * (line.size - start_col)
|
60
|
+
else
|
61
|
+
puts '^' * [end_col - start_col, 1].max
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class CompilationState
|
69
|
+
attr_accessor :verbose, :destination
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# This is a custom classloader impl to allow loading classes with
|
74
|
+
# interdependencies by having findClass retrieve classes as needed from the
|
75
|
+
# collection of all classes generated by the target script.
|
76
|
+
class DubyClassLoader < java::security::SecureClassLoader
|
77
|
+
def initialize(parent, class_map)
|
78
|
+
super(parent)
|
79
|
+
@class_map = class_map
|
80
|
+
end
|
81
|
+
|
82
|
+
def findClass(name)
|
83
|
+
if @class_map[name]
|
84
|
+
bytes = @class_map[name].to_java_bytes
|
85
|
+
defineClass(name, bytes, 0, bytes.length)
|
86
|
+
else
|
87
|
+
raise java.lang.ClassNotFoundException.new(name)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def loadClass(name, resolve)
|
92
|
+
cls = findLoadedClass(name)
|
93
|
+
if cls == nil
|
94
|
+
if @class_map[name]
|
95
|
+
cls = findClass(name)
|
96
|
+
else
|
97
|
+
cls = super(name, false)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
resolveClass(cls) if resolve
|
102
|
+
|
103
|
+
cls
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class DubyImpl
|
108
|
+
def initialize
|
109
|
+
Duby::AST.type_factory = Duby::JVM::Types::TypeFactory.new
|
110
|
+
end
|
111
|
+
|
112
|
+
def run(*args)
|
113
|
+
main = nil
|
114
|
+
class_map = {}
|
115
|
+
|
116
|
+
# generate all bytes for all classes
|
117
|
+
generate(args) do |outfile, builder|
|
118
|
+
bytes = builder.generate
|
119
|
+
name = builder.class_name.gsub(/\//, '.')
|
120
|
+
class_map[name] = bytes
|
121
|
+
end
|
122
|
+
|
123
|
+
# load all classes
|
124
|
+
dcl = DubyClassLoader.new(java.lang.ClassLoader.system_class_loader, class_map)
|
125
|
+
class_map.each do |name,|
|
126
|
+
cls = dcl.load_class(name)
|
127
|
+
# TODO: using first main; find correct one
|
128
|
+
main ||= cls.get_method("main", java::lang::String[].java_class) #rescue nil
|
129
|
+
end
|
130
|
+
|
131
|
+
# run the main method we found
|
132
|
+
if main
|
133
|
+
begin
|
134
|
+
main.invoke(nil, [args.to_java(:string)].to_java)
|
135
|
+
rescue java.lang.Exception => e
|
136
|
+
e = e.cause if e.cause
|
137
|
+
raise e
|
138
|
+
end
|
139
|
+
else
|
140
|
+
puts "No main found"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def compile(*args)
|
145
|
+
generate(args) do |filename, builder|
|
146
|
+
filename = "#{@state.destination}#{filename}"
|
147
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
148
|
+
bytes = builder.generate
|
149
|
+
File.open(filename, 'wb') {|f| f.write(bytes)}
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def generate(args, &block)
|
154
|
+
process_flags!(args)
|
155
|
+
|
156
|
+
# collect all ASTs from all files
|
157
|
+
all_nodes = []
|
158
|
+
expand_files(args).each do |duby_file|
|
159
|
+
if duby_file == '-e'
|
160
|
+
@filename = '-e'
|
161
|
+
next
|
162
|
+
elsif @filename == '-e'
|
163
|
+
all_nodes << parse('-e', duby_file)
|
164
|
+
else
|
165
|
+
all_nodes << parse(duby_file)
|
166
|
+
end
|
167
|
+
@filename = nil
|
168
|
+
exit 1 if @error
|
169
|
+
end
|
170
|
+
|
171
|
+
# enter all ASTs into inference engine
|
172
|
+
infer_asts(all_nodes)
|
173
|
+
|
174
|
+
# compile each AST in turn
|
175
|
+
all_nodes.each do |ast|
|
176
|
+
compile_ast(ast, &block)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def parse(*args)
|
181
|
+
process_flags!(args)
|
182
|
+
@filename = args.shift
|
183
|
+
|
184
|
+
if @filename
|
185
|
+
if @filename == '-e'
|
186
|
+
@filename = 'DashE'
|
187
|
+
src = args[0]
|
188
|
+
else
|
189
|
+
src = File.read(@filename)
|
190
|
+
end
|
191
|
+
else
|
192
|
+
print_help
|
193
|
+
exit(1)
|
194
|
+
end
|
195
|
+
begin
|
196
|
+
ast = Duby::AST.parse_ruby(src, @filename)
|
197
|
+
# rescue org.jrubyparser.lexer.SyntaxException => ex
|
198
|
+
# Duby.print_error(ex.message, ex.position)
|
199
|
+
# raise ex if @state.verbose
|
200
|
+
end
|
201
|
+
@transformer = Duby::Transform::Transformer.new(@state)
|
202
|
+
Java::MirahImpl::Builtin.initialize_builtins(@transformer)
|
203
|
+
@transformer.filename = @filename
|
204
|
+
ast = @transformer.transform(ast, nil)
|
205
|
+
@transformer.errors.each do |ex|
|
206
|
+
Duby.print_error(ex.message, ex.position)
|
207
|
+
raise ex.cause || ex if @state.verbose
|
208
|
+
end
|
209
|
+
@error = @transformer.errors.size > 0
|
210
|
+
|
211
|
+
ast
|
212
|
+
end
|
213
|
+
|
214
|
+
def infer_asts(asts)
|
215
|
+
typer = Duby::Typer::JVM.new(@transformer)
|
216
|
+
asts.each {|ast| typer.infer(ast) }
|
217
|
+
begin
|
218
|
+
typer.resolve(false)
|
219
|
+
ensure
|
220
|
+
puts asts.inspect if @state.verbose
|
221
|
+
|
222
|
+
failed = !typer.errors.empty?
|
223
|
+
if failed
|
224
|
+
puts "Inference Error:"
|
225
|
+
typer.errors.each do |ex|
|
226
|
+
if ex.node
|
227
|
+
Duby.print_error(ex.message, ex.node.position)
|
228
|
+
else
|
229
|
+
puts ex.message
|
230
|
+
end
|
231
|
+
puts ex.backtrace if @state.verbose
|
232
|
+
end
|
233
|
+
exit 1
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def compile_ast(ast, &block)
|
239
|
+
begin
|
240
|
+
compiler = @compiler_class.new
|
241
|
+
ast.compile(compiler, false)
|
242
|
+
compiler.generate(&block)
|
243
|
+
rescue Exception => ex
|
244
|
+
if ex.respond_to? :node
|
245
|
+
Duby.print_error(ex.message, ex.node.position)
|
246
|
+
puts ex.backtrace if @state.verbose
|
247
|
+
exit 1
|
248
|
+
else
|
249
|
+
raise ex
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
def process_flags!(args)
|
256
|
+
@state ||= Duby::CompilationState.new
|
257
|
+
while args.length > 0 && args[0] =~ /^-/
|
258
|
+
case args[0]
|
259
|
+
when '--verbose', '-V'
|
260
|
+
Duby::Typer.verbose = true
|
261
|
+
Duby::AST.verbose = true
|
262
|
+
Duby::Compiler::JVM.verbose = true
|
263
|
+
@state.verbose = true
|
264
|
+
args.shift
|
265
|
+
when '--java', '-j'
|
266
|
+
require 'mirah/jvm/source_compiler'
|
267
|
+
@compiler_class = Duby::Compiler::JavaSource
|
268
|
+
args.shift
|
269
|
+
when '--dest', '-d'
|
270
|
+
args.shift
|
271
|
+
@state.destination = File.join(File.expand_path(args.shift), '')
|
272
|
+
when '--cd'
|
273
|
+
args.shift
|
274
|
+
Dir.chdir(args.shift)
|
275
|
+
when '--plugin', '-p'
|
276
|
+
args.shift
|
277
|
+
plugin = args.shift
|
278
|
+
require "mirah/plugin/#{plugin}"
|
279
|
+
when '-I'
|
280
|
+
args.shift
|
281
|
+
$: << args.shift
|
282
|
+
when '--classpath', '-c'
|
283
|
+
args.shift
|
284
|
+
Duby::Env.decode_paths(args.shift, $CLASSPATH)
|
285
|
+
when '--explicit-packages'
|
286
|
+
args.shift
|
287
|
+
Duby::AST::Script.explicit_packages = true
|
288
|
+
when '--help', '-h'
|
289
|
+
print_help
|
290
|
+
exit(0)
|
291
|
+
when '-e'
|
292
|
+
break
|
293
|
+
else
|
294
|
+
puts "unrecognized flag: " + args[0]
|
295
|
+
print_help
|
296
|
+
exit(1)
|
297
|
+
end
|
298
|
+
end
|
299
|
+
@state.destination ||= File.join(File.expand_path('.'), '')
|
300
|
+
@compiler_class ||= Duby::Compiler::JVM
|
301
|
+
end
|
302
|
+
|
303
|
+
def print_help
|
304
|
+
$stdout.puts "#{$0} [flags] <files or \"-e SCRIPT\">
|
305
|
+
-V, --verbose\t\tVerbose logging
|
306
|
+
-j, --java\t\tOutput .java source (jrubyc only)
|
307
|
+
-d, --dir DIR\t\tUse DIR as the base dir for compilation, packages
|
308
|
+
-p, --plugin PLUGIN\tLoad and use plugin during compilation
|
309
|
+
-c, --classpath PATH\tAdd PATH to the Java classpath for compilation
|
310
|
+
--explicit-packages\tDisable guessing the package from the filename
|
311
|
+
-h, --help\t\tPrint this help message
|
312
|
+
-e\t\t\tCompile or run the script following -e (naming it \"DashE\")"
|
313
|
+
end
|
314
|
+
|
315
|
+
def expand_files(files)
|
316
|
+
expanded = []
|
317
|
+
files.each do |filename|
|
318
|
+
if File.directory?(filename)
|
319
|
+
Dir[File.join(filename, '*')].each do |child|
|
320
|
+
if File.directory?(child)
|
321
|
+
files << child
|
322
|
+
elsif child =~ /\.(duby|mirah)$/
|
323
|
+
expanded << child
|
324
|
+
end
|
325
|
+
end
|
326
|
+
else
|
327
|
+
expanded << filename
|
328
|
+
end
|
329
|
+
end
|
330
|
+
expanded
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
Mirah = Duby
|
335
|
+
|
336
|
+
if __FILE__ == $0
|
337
|
+
Duby.run(ARGV[0], *ARGV[1..-1])
|
338
|
+
end
|