Source Code Cross Referenced for YARVMachine.java in  » Scripting » jruby » org » jruby » ast » executable » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » jruby » org.jruby.ast.executable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jruby.ast.executable;
002:
003:        import org.jruby.Ruby;
004:        import org.jruby.RubyHash;
005:        import org.jruby.RubyModule;
006:        import org.jruby.RubyString;
007:        import org.jruby.MetaClass;
008:        import org.jruby.parser.StaticScope;
009:        import org.jruby.parser.LocalStaticScope;
010:        import org.jruby.runtime.CallType;
011:        import org.jruby.runtime.DynamicScope;
012:        import org.jruby.runtime.ThreadContext;
013:        import org.jruby.runtime.Visibility;
014:        import org.jruby.runtime.builtin.IRubyObject;
015:        import org.jruby.internal.runtime.methods.YARVMethod;
016:        import org.jruby.internal.runtime.methods.WrapperMethod;
017:        import org.jruby.runtime.MethodIndex;
018:
019:        public class YARVMachine {
020:            private static final boolean TAILCALL_OPT = Boolean
021:                    .getBoolean("jruby.tailcall.enabled");
022:
023:            public static final YARVMachine INSTANCE = new YARVMachine();
024:
025:            public static int instruction(String name) {
026:                return YARVInstructions.instruction(name);
027:            }
028:
029:            public static class InstructionSequence {
030:                public String magic;
031:                public int major;
032:                public int minor;
033:                public int format_type;
034:                public Object misc;
035:                public String name;
036:                public String filename;
037:                public Object[] line;
038:                public String type;
039:
040:                public String[] locals;
041:
042:                public int args_argc;
043:                public int args_arg_opts;
044:                public String[] args_opt_labels;
045:                public int args_rest;
046:                public int args_block;
047:
048:                public Object[] exception;
049:
050:                public Instruction[] body;
051:
052:                public InstructionSequence(Ruby runtime, String name,
053:                        String file, String type) {
054:                    magic = "YARVInstructionSimpledataFormat";
055:                    major = 1;
056:                    minor = 1;
057:                    format_type = 1;
058:                    misc = runtime.getNil();
059:                    this .name = name;
060:                    this .filename = file;
061:                    this .line = new Object[0];
062:                    this .type = type;
063:                    this .locals = new String[0];
064:                    this .args_argc = 0;
065:                    this .args_arg_opts = 0;
066:                    this .exception = new Object[0];
067:                }
068:            }
069:
070:            public static class Instruction {
071:                final public int bytecode;
072:                public int line_no;
073:                public String s_op0;
074:                public IRubyObject o_op0;
075:                public Object _tmp;
076:                public long l_op0;
077:                public long l_op1;
078:                public int i_op1;
079:                public InstructionSequence iseq_op;
080:                public Instruction[] ins_op;
081:                public int i_op3;
082:
083:                public int index;
084:
085:                public Instruction(int bytecode) {
086:                    this .bytecode = bytecode;
087:                }
088:
089:                public Instruction(int bytecode, String op) {
090:                    this .bytecode = bytecode;
091:                    this .s_op0 = op;
092:                }
093:
094:                public Instruction(int bytecode, String op,
095:                        InstructionSequence op1) {
096:                    this .bytecode = bytecode;
097:                    this .s_op0 = op;
098:                    this .iseq_op = op1;
099:                }
100:
101:                public Instruction(int bytecode, long op) {
102:                    this .bytecode = bytecode;
103:                    this .l_op0 = op;
104:                }
105:
106:                public Instruction(int bytecode, IRubyObject op) {
107:                    this .bytecode = bytecode;
108:                    this .o_op0 = op;
109:                }
110:
111:                public Instruction(int bytecode, String op, int op1,
112:                        Instruction[] op2, int op3) {
113:                    this .bytecode = bytecode;
114:                    this .s_op0 = op;
115:                    this .i_op1 = op1;
116:                    this .ins_op = op2;
117:                    this .i_op3 = op3;
118:                }
119:
120:                public String toString() {
121:                    return "[:"
122:                            + YARVInstructions.name(bytecode)
123:                            + ", "
124:                            + (s_op0 != null ? s_op0 : (o_op0 != null ? o_op0
125:                                    .toString() : ("" + l_op0))) + "]";
126:                }
127:            }
128:
129:            public IRubyObject exec(ThreadContext context, IRubyObject self,
130:                    StaticScope scope, Instruction[] bytecodes) {
131:                return exec(context, self, new DynamicScope(scope), bytecodes);
132:            }
133:
134:            public IRubyObject exec(ThreadContext context, IRubyObject self,
135:                    DynamicScope scope, Instruction[] bytecodes) {
136:                IRubyObject[] stack = new IRubyObject[255];
137:                int stackTop = 0;
138:                stack[stackTop] = context.getRuntime().getNil();
139:                int ip = 0;
140:                Ruby runtime = context.getRuntime();
141:                context.preRootNode(scope);
142:                IRubyObject recv;
143:                IRubyObject other;
144:
145:                yarvloop: while (ip < bytecodes.length) {
146:                    //System.err.println("Executing: " + YARVInstructions.name(bytecodes[ip].bytecode));
147:                    switch (bytecodes[ip].bytecode) {
148:                    case YARVInstructions.NOP:
149:                        break;
150:                    case YARVInstructions.GETLOCAL:
151:                        stack[++stackTop] = context.getCurrentScope().getValue(
152:                                (int) bytecodes[ip].l_op0, 0);
153:                        break;
154:                    case YARVInstructions.SETLOCAL:
155:                        context.getCurrentScope()
156:                                .setValue((int) bytecodes[ip].l_op0,
157:                                        stack[stackTop--], 0);
158:                        break;
159:                    case YARVInstructions.GETSPECIAL:
160:                        System.err
161:                                .println("Not implemented, YARVMachine."
162:                                        + YARVInstructions
163:                                                .name(bytecodes[ip].bytecode));
164:                        break;
165:                    case YARVInstructions.SETSPECIAL:
166:                        System.err
167:                                .println("Not implemented, YARVMachine."
168:                                        + YARVInstructions
169:                                                .name(bytecodes[ip].bytecode));
170:                        break;
171:                    case YARVInstructions.GETDYNAMIC:
172:                        System.err
173:                                .println("Not implemented, YARVMachine."
174:                                        + YARVInstructions
175:                                                .name(bytecodes[ip].bytecode));
176:                        break;
177:                    case YARVInstructions.SETDYNAMIC:
178:                        System.err
179:                                .println("Not implemented, YARVMachine."
180:                                        + YARVInstructions
181:                                                .name(bytecodes[ip].bytecode));
182:                        break;
183:                    case YARVInstructions.GETINSTANCEVARIABLE:
184:                        stack[++stackTop] = self
185:                                .getInstanceVariable(bytecodes[ip].s_op0);
186:                        break;
187:                    case YARVInstructions.SETINSTANCEVARIABLE:
188:                        self.setInstanceVariable(bytecodes[ip].s_op0,
189:                                stack[stackTop--]);
190:                        break;
191:                    case YARVInstructions.GETCLASSVARIABLE: {
192:                        RubyModule rubyClass = context.getRubyClass();
193:                        String name = bytecodes[ip].s_op0;
194:
195:                        if (rubyClass == null) {
196:                            stack[++stackTop] = self.getMetaClass()
197:                                    .getClassVar(name);
198:                        } else if (!rubyClass.isSingleton()) {
199:                            stack[++stackTop] = rubyClass.getClassVar(name);
200:                        } else {
201:                            RubyModule module = (RubyModule) rubyClass
202:                                    .getInstanceVariable("__attached__");
203:
204:                            if (module != null) {
205:                                stack[++stackTop] = module.getClassVar(name);
206:                            } else {
207:                                stack[++stackTop] = context.getRuntime()
208:                                        .getNil();
209:                            }
210:                        }
211:                        break;
212:                    }
213:                    case YARVInstructions.SETCLASSVARIABLE: {
214:                        RubyModule rubyClass = (RubyModule) context.peekCRef()
215:                                .getValue();
216:
217:                        if (rubyClass == null) {
218:                            rubyClass = self.getMetaClass();
219:                        } else if (rubyClass.isSingleton()) {
220:                            rubyClass = (RubyModule) rubyClass
221:                                    .getInstanceVariable("__attached__");
222:                        }
223:
224:                        rubyClass.setClassVar(bytecodes[ip].s_op0,
225:                                stack[stackTop--]);
226:                        break;
227:                    }
228:                    case YARVInstructions.GETCONSTANT:
229:                        IRubyObject cls = stack[stackTop--];
230:                        stack[++stackTop] = context
231:                                .getConstant(bytecodes[ip].s_op0);
232:                        break;
233:                    case YARVInstructions.SETCONSTANT:
234:                        RubyModule module = (RubyModule) context.peekCRef()
235:                                .getValue();
236:                        module.setConstant(bytecodes[ip].s_op0,
237:                                stack[stackTop--]);
238:                        runtime.incGlobalState();
239:                        break;
240:                    case YARVInstructions.GETGLOBAL:
241:                        System.err
242:                                .println("Not implemented, YARVMachine."
243:                                        + YARVInstructions
244:                                                .name(bytecodes[ip].bytecode));
245:                        break;
246:                    case YARVInstructions.SETGLOBAL:
247:                        System.err
248:                                .println("Not implemented, YARVMachine."
249:                                        + YARVInstructions
250:                                                .name(bytecodes[ip].bytecode));
251:                        break;
252:                    case YARVInstructions.PUTNIL:
253:                        stack[++stackTop] = context.getRuntime().getNil();
254:                        break;
255:                    case YARVInstructions.PUTSELF:
256:                        stack[++stackTop] = self;
257:                        break;
258:                    case YARVInstructions.PUTUNDEF:
259:                        // ko1 said this is going away
260:                        System.err
261:                                .println("Not implemented, YARVMachine."
262:                                        + YARVInstructions
263:                                                .name(bytecodes[ip].bytecode));
264:                        break;
265:                    case YARVInstructions.PUTOBJECT:
266:                        stack[++stackTop] = bytecodes[ip].o_op0;
267:                        break;
268:                    case YARVInstructions.PUTSTRING:
269:                        stack[++stackTop] = context.getRuntime().newString(
270:                                bytecodes[ip].s_op0);
271:                        break;
272:                    case YARVInstructions.CONCATSTRINGS: {
273:                        StringBuffer concatter = new StringBuffer();
274:                        for (int i = 0; i < bytecodes[ip].l_op0; i++) {
275:                            concatter.append(stack[stackTop--].toString());
276:                        }
277:                        stack[++stackTop] = context.getRuntime().newString(
278:                                concatter.toString());
279:                        break;
280:                    }
281:                    case YARVInstructions.TOSTRING:
282:                        if (!(stack[stackTop] instanceof  RubyString)) {
283:                            stack[stackTop] = (stack[stackTop]).callMethod(
284:                                    context, MethodIndex.TO_S, "to_s");
285:                        }
286:                        break;
287:                    case YARVInstructions.TOREGEXP:
288:                        System.err
289:                                .println("Not implemented, YARVMachine."
290:                                        + YARVInstructions
291:                                                .name(bytecodes[ip].bytecode));
292:                        break;
293:                    case YARVInstructions.NEWARRAY: {
294:                        int size = (int) bytecodes[ip].l_op0;
295:                        IRubyObject[] arr = new IRubyObject[size];
296:                        for (int i = size - 1; i >= 0; i--) {
297:                            arr[i] = stack[stackTop--];
298:                        }
299:                        stack[++stackTop] = context.getRuntime()
300:                                .newArrayNoCopy(arr);
301:                        break;
302:                    }
303:                    case YARVInstructions.DUPARRAY:
304:                        stack[++stackTop] = bytecodes[ip].o_op0.dup();
305:                        break;
306:                    case YARVInstructions.EXPANDARRAY:
307:                        // masgn array to values
308:                        System.err
309:                                .println("Not implemented, YARVMachine."
310:                                        + YARVInstructions
311:                                                .name(bytecodes[ip].bytecode));
312:                        break;
313:                    case YARVInstructions.CONCATARRAY:
314:                        System.err
315:                                .println("Not implemented, YARVMachine."
316:                                        + YARVInstructions
317:                                                .name(bytecodes[ip].bytecode));
318:                        break;
319:                    case YARVInstructions.SPLATARRAY:
320:                        System.err
321:                                .println("Not implemented, YARVMachine."
322:                                        + YARVInstructions
323:                                                .name(bytecodes[ip].bytecode));
324:                        break;
325:                    case YARVInstructions.CHECKINCLUDEARRAY:
326:                        System.err
327:                                .println("Not implemented, YARVMachine."
328:                                        + YARVInstructions
329:                                                .name(bytecodes[ip].bytecode));
330:                        break;
331:                    case YARVInstructions.NEWHASH:
332:                        int hsize = (int) bytecodes[ip].l_op0;
333:                        RubyHash h = RubyHash.newHash(runtime);
334:                        IRubyObject v,
335:                        k;
336:                        for (int i = hsize; i > 0; i -= 2) {
337:                            v = stack[stackTop--];
338:                            k = stack[stackTop--];
339:                            h.aset(k, v);
340:                        }
341:                        stack[++stackTop] = h;
342:                        break;
343:                    case YARVInstructions.NEWRANGE:
344:                        System.err
345:                                .println("Not implemented, YARVMachine."
346:                                        + YARVInstructions
347:                                                .name(bytecodes[ip].bytecode));
348:                        break;
349:                    case YARVInstructions.PUTNOT:
350:                        stack[stackTop + 1] = stack[stackTop].isTrue() ? runtime
351:                                .getFalse()
352:                                : runtime.getTrue();
353:                        stackTop++;
354:                        break;
355:                    case YARVInstructions.POP:
356:                        stackTop--;
357:                        break;
358:                    case YARVInstructions.DUP:
359:                        stack[stackTop + 1] = stack[stackTop];
360:                        stackTop++;
361:                        break;
362:                    case YARVInstructions.DUPN: {
363:                        int size = (int) bytecodes[ip].l_op0;
364:                        for (int i = 0; i < size; i++) {
365:                            stack[stackTop + 1] = stack[stackTop - size];
366:                            stackTop++;
367:                        }
368:                        break;
369:                    }
370:                    case YARVInstructions.SWAP:
371:                        stack[stackTop + 1] = stack[stackTop];
372:                        stack[stackTop] = stack[stackTop - 1];
373:                        stack[stackTop - 1] = stack[stackTop + 1];
374:                    case YARVInstructions.REPUT:
375:                        System.err
376:                                .println("Not implemented, YARVMachine."
377:                                        + YARVInstructions
378:                                                .name(bytecodes[ip].bytecode));
379:                        break;
380:                    case YARVInstructions.TOPN: {
381:                        int n = (int) bytecodes[ip].l_op0;
382:                        other = stack[stackTop - n];
383:                        stack[++stackTop] = other;
384:                        break;
385:                    }
386:                    case YARVInstructions.SETN: {
387:                        int n = (int) bytecodes[ip].l_op0;
388:                        stack[stackTop - n] = stack[stackTop];
389:                        break;
390:                    }
391:                    case YARVInstructions.EMPTSTACK:
392:                        stackTop = 0;
393:                        break;
394:                    case YARVInstructions.DEFINEMETHOD:
395:                        RubyModule containingClass = context.getRubyClass();
396:
397:                        if (containingClass == null) {
398:                            throw runtime
399:                                    .newTypeError("No class to add method.");
400:                        }
401:
402:                        String mname = bytecodes[ip].iseq_op.name;
403:                        if (containingClass == runtime.getObject()
404:                                && mname == "initialize") {
405:                            runtime
406:                                    .getWarnings()
407:                                    .warn(
408:                                            "redefining Object#initialize may cause infinite loop");
409:                        }
410:
411:                        Visibility visibility = context.getCurrentVisibility();
412:                        if (mname == "initialize"
413:                                || visibility.isModuleFunction()
414:                                || context.isTopLevel()) {
415:                            visibility = Visibility.PRIVATE;
416:                        }
417:
418:                        if (containingClass.isSingleton()) {
419:                            IRubyObject attachedObject = ((MetaClass) containingClass)
420:                                    .getAttachedObject();
421:
422:                            if (attachedObject.getMetaClass() == runtime
423:                                    .getFixnum()
424:                                    || attachedObject.getMetaClass() == runtime
425:                                            .getClass("Symbol")) {
426:                                throw runtime
427:                                        .newTypeError("can't define singleton method \""
428:                                                + mname
429:                                                + "\" for "
430:                                                + attachedObject.getType());
431:                            }
432:                        }
433:
434:                        StaticScope sco = new LocalStaticScope(null);
435:                        sco.setVariables(bytecodes[ip].iseq_op.locals);
436:                        YARVMethod newMethod = new YARVMethod(containingClass,
437:                                bytecodes[ip].iseq_op, sco, visibility, context
438:                                        .peekCRef());
439:
440:                        containingClass.addMethod(mname, newMethod);
441:
442:                        if (context.getCurrentVisibility().isModuleFunction()) {
443:                            containingClass.getSingletonClass().addMethod(
444:                                    mname,
445:                                    new WrapperMethod(containingClass
446:                                            .getSingletonClass(), newMethod,
447:                                            Visibility.PUBLIC));
448:                            containingClass.callMethod(context,
449:                                    "singleton_method_added", runtime
450:                                            .newSymbol(mname));
451:                        }
452:
453:                        // 'class << state.self' and 'class << obj' uses defn as opposed to defs
454:                        if (containingClass.isSingleton()) {
455:                            ((MetaClass) containingClass).getAttachedObject()
456:                                    .callMethod(context,
457:                                            "singleton_method_added",
458:                                            runtime.newSymbol(mname));
459:                        } else {
460:                            containingClass.callMethod(context, "method_added",
461:                                    runtime.newSymbol(mname));
462:                        }
463:                        stack[++stackTop] = runtime.getNil();
464:                        runtime.incGlobalState();
465:                        break;
466:                    case YARVInstructions.ALIAS:
467:                        System.err
468:                                .println("Not implemented, YARVMachine."
469:                                        + YARVInstructions
470:                                                .name(bytecodes[ip].bytecode));
471:                        break;
472:                    case YARVInstructions.UNDEF:
473:                        System.err
474:                                .println("Not implemented, YARVMachine."
475:                                        + YARVInstructions
476:                                                .name(bytecodes[ip].bytecode));
477:                        runtime.incGlobalState();
478:                        break;
479:                    case YARVInstructions.DEFINED:
480:                        System.err
481:                                .println("Not implemented, YARVMachine."
482:                                        + YARVInstructions
483:                                                .name(bytecodes[ip].bytecode));
484:                        break;
485:                    case YARVInstructions.POSTEXE:
486:                        System.err
487:                                .println("Not implemented, YARVMachine."
488:                                        + YARVInstructions
489:                                                .name(bytecodes[ip].bytecode));
490:                        break;
491:                    case YARVInstructions.TRACE:
492:                        System.err
493:                                .println("Not implemented, YARVMachine."
494:                                        + YARVInstructions
495:                                                .name(bytecodes[ip].bytecode));
496:                        break;
497:                    case YARVInstructions.DEFINECLASS:
498:                        System.err
499:                                .println("Not implemented, YARVMachine."
500:                                        + YARVInstructions
501:                                                .name(bytecodes[ip].bytecode));
502:                        break;
503:                    case YARVInstructions.SEND: {
504:                        String name = bytecodes[ip].s_op0;
505:                        IRubyObject[] args = new IRubyObject[bytecodes[ip].i_op1];
506:
507:                        Instruction[] blockBytecodes = bytecodes[ip].ins_op;
508:                        // TODO: block stuff
509:                        int flags = bytecodes[ip].i_op3;
510:                        CallType callType;
511:
512:                        for (int i = args.length; i > 0; i--) {
513:                            args[i - 1] = stack[stackTop--];
514:                        }
515:
516:                        if ((flags & YARVInstructions.VCALL_FLAG) == 0) {
517:                            if ((flags & YARVInstructions.FCALL_FLAG) == 0) {
518:                                recv = stack[stackTop--];
519:                                callType = CallType.NORMAL;
520:                            } else {
521:                                stackTop--;
522:                                recv = self;
523:                                callType = CallType.FUNCTIONAL;
524:                            }
525:                        } else {
526:                            recv = self;
527:                            callType = CallType.VARIABLE;
528:                        }
529:                        assert recv.getMetaClass() != null : recv.getClass()
530:                                .getName();
531:
532:                        if (TAILCALL_OPT
533:                                && (bytecodes[ip + 1].bytecode == YARVInstructions.LEAVE || (flags & YARVInstructions.TAILCALL_FLAG) == YARVInstructions.TAILCALL_FLAG)
534:                                && recv == self
535:                                && name.equals(context.getFrameName())) {
536:                            stackTop = 0;
537:                            ip = -1;
538:
539:                            for (int i = 0; i < args.length; i++) {
540:                                context.getCurrentScope().getValues()[i] = args[i];
541:                            }
542:                        } else {
543:                            stack[++stackTop] = recv.callMethod(context, name,
544:                                    args, callType);
545:                        }
546:                        break;
547:                    }
548:                    case YARVInstructions.INVOKESUPER:
549:                        System.err
550:                                .println("Not implemented, YARVMachine."
551:                                        + YARVInstructions
552:                                                .name(bytecodes[ip].bytecode));
553:                        break;
554:                    case YARVInstructions.INVOKEBLOCK:
555:                        System.err
556:                                .println("Not implemented, YARVMachine."
557:                                        + YARVInstructions
558:                                                .name(bytecodes[ip].bytecode));
559:                        break;
560:                    case YARVInstructions.LEAVE:
561:                        break yarvloop;
562:                    case YARVInstructions.FINISH:
563:                        System.err
564:                                .println("Not implemented, YARVMachine."
565:                                        + YARVInstructions
566:                                                .name(bytecodes[ip].bytecode));
567:                        break;
568:                    case YARVInstructions.THROW:
569:                        System.err
570:                                .println("Not implemented, YARVMachine."
571:                                        + YARVInstructions
572:                                                .name(bytecodes[ip].bytecode));
573:                        break;
574:                    case YARVInstructions.JUMP:
575:                        ip = (int) bytecodes[ip].l_op0;
576:                        continue yarvloop;
577:                    case YARVInstructions.BRANCHIF:
578:                        if (stack[stackTop--].isTrue()) {
579:                            ip = (int) bytecodes[ip].l_op0;
580:                        } else {
581:                            ip++;
582:                        }
583:                        continue yarvloop;
584:                    case YARVInstructions.BRANCHUNLESS:
585:                        if (!stack[stackTop--].isTrue()) {
586:                            ip = (int) bytecodes[ip].l_op0;
587:                        } else {
588:                            ip++;
589:                        }
590:                        continue yarvloop;
591:                    case YARVInstructions.GETINLINECACHE:
592:                        if (bytecodes[ip].l_op1 == runtime.getGlobalState()) {
593:                            stack[++stackTop] = bytecodes[ip].o_op0;
594:                            ip = (int) bytecodes[ip].l_op0;
595:                            continue yarvloop;
596:                        }
597:                        break;
598:                    case YARVInstructions.ONCEINLINECACHE:
599:                        if (bytecodes[ip].l_op1 > 0) {
600:                            stack[++stackTop] = bytecodes[ip].o_op0;
601:                            ip = (int) bytecodes[ip].l_op0;
602:                            continue yarvloop;
603:                        }
604:                        break;
605:                    case YARVInstructions.SETINLINECACHE:
606:                        int we = (int) bytecodes[ip].l_op0;
607:                        bytecodes[we].o_op0 = stack[stackTop];
608:                        bytecodes[we].l_op1 = runtime.getGlobalState();
609:                        break;
610:                    case YARVInstructions.OPT_CASE_DISPATCH:
611:                        System.err
612:                                .println("Not implemented, YARVMachine."
613:                                        + YARVInstructions
614:                                                .name(bytecodes[ip].bytecode));
615:                        break;
616:                    case YARVInstructions.OPT_CHECKENV:
617:                        System.err
618:                                .println("Not implemented, YARVMachine."
619:                                        + YARVInstructions
620:                                                .name(bytecodes[ip].bytecode));
621:                        break;
622:                    case YARVInstructions.OPT_PLUS:
623:                        other = stack[stackTop--];
624:                        recv = stack[stackTop--];
625:                        stack[++stackTop] = recv.callMethod(context,
626:                                MethodIndex.OP_PLUS, "+", other);
627:                        break;
628:                    case YARVInstructions.OPT_MINUS:
629:                        other = stack[stackTop--];
630:                        recv = stack[stackTop--];
631:                        stack[++stackTop] = recv.callMethod(context,
632:                                MethodIndex.OP_MINUS, "-", other);
633:                        break;
634:                    case YARVInstructions.OPT_MULT:
635:                        other = stack[stackTop--];
636:                        recv = stack[stackTop--];
637:                        stack[++stackTop] = recv.callMethod(context,
638:                                MethodIndex.OP_TIMES, "*", other);
639:                        break;
640:                    case YARVInstructions.OPT_DIV:
641:                        other = stack[stackTop--];
642:                        recv = stack[stackTop--];
643:                        stack[++stackTop] = recv
644:                                .callMethod(context, "/", other);
645:                        break;
646:                    case YARVInstructions.OPT_MOD:
647:                        other = stack[stackTop--];
648:                        recv = stack[stackTop--];
649:                        stack[++stackTop] = recv
650:                                .callMethod(context, "%", other);
651:                        break;
652:                    case YARVInstructions.OPT_EQ:
653:                        other = stack[stackTop--];
654:                        recv = stack[stackTop--];
655:                        stack[++stackTop] = recv.callMethod(context,
656:                                MethodIndex.EQUALEQUAL, "==", other);
657:                        break;
658:                    case YARVInstructions.OPT_LT:
659:                        other = stack[stackTop--];
660:                        recv = stack[stackTop--];
661:                        stack[++stackTop] = recv.callMethod(context,
662:                                MethodIndex.OP_LT, "<", other);
663:                        break;
664:                    case YARVInstructions.OPT_LE:
665:                        other = stack[stackTop--];
666:                        recv = stack[stackTop--];
667:                        stack[++stackTop] = recv.callMethod(context,
668:                                MethodIndex.OP_LE, "<=", other);
669:                        break;
670:                    case YARVInstructions.OPT_LTLT:
671:                        other = stack[stackTop--];
672:                        recv = stack[stackTop--];
673:                        stack[++stackTop] = recv.callMethod(context,
674:                                MethodIndex.OP_LSHIFT, "<<", other);
675:                        break;
676:                    case YARVInstructions.OPT_AREF:
677:                        other = stack[stackTop--];
678:                        recv = stack[stackTop--];
679:                        stack[++stackTop] = recv.callMethod(context,
680:                                MethodIndex.AREF, "[]", other);
681:                        break;
682:                    case YARVInstructions.OPT_ASET:
683:                        //YARV will never emit this, for some reason.
684:                        IRubyObject value = stack[stackTop--];
685:                        other = stack[stackTop--];
686:                        recv = stack[stackTop--];
687:                        stack[++stackTop] = recv.callMethod(context,
688:                                MethodIndex.ASET, "[]=", new IRubyObject[] {
689:                                        other, value });
690:                        break;
691:                    case YARVInstructions.OPT_LENGTH:
692:                        recv = stack[stackTop--];
693:                        stack[++stackTop] = recv.callMethod(context, "length");
694:                        break;
695:                    case YARVInstructions.OPT_SUCC:
696:                        recv = stack[stackTop--];
697:                        stack[++stackTop] = recv.callMethod(context, "succ");
698:                        break;
699:                    case YARVInstructions.OPT_REGEXPMATCH1:
700:                        stack[stackTop] = bytecodes[ip].o_op0.callMethod(
701:                                context, "=~", stack[stackTop]);
702:                        break;
703:                    case YARVInstructions.OPT_REGEXPMATCH2:
704:                        other = stack[stackTop--];
705:                        recv = stack[stackTop--];
706:                        stack[++stackTop] = recv.callMethod(context, "=~",
707:                                other);
708:                        break;
709:                    case YARVInstructions.OPT_CALL_NATIVE_COMPILED:
710:                        System.err
711:                                .println("Not implemented, YARVMachine."
712:                                        + YARVInstructions
713:                                                .name(bytecodes[ip].bytecode));
714:                        break;
715:                    case YARVInstructions.BITBLT:
716:                        System.err
717:                                .println("Not implemented, YARVMachine."
718:                                        + YARVInstructions
719:                                                .name(bytecodes[ip].bytecode));
720:                        break;
721:                    case YARVInstructions.ANSWER:
722:                        stack[++stackTop] = runtime.newFixnum(42);
723:                        break;
724:                    case YARVInstructions.GETLOCAL_OP_2:
725:                        System.err
726:                                .println("Not implemented, YARVMachine."
727:                                        + YARVInstructions
728:                                                .name(bytecodes[ip].bytecode));
729:                        break;
730:                    case YARVInstructions.GETLOCAL_OP_3:
731:                        System.err
732:                                .println("Not implemented, YARVMachine."
733:                                        + YARVInstructions
734:                                                .name(bytecodes[ip].bytecode));
735:                        break;
736:                    case YARVInstructions.GETLOCAL_OP_4:
737:                        System.err
738:                                .println("Not implemented, YARVMachine."
739:                                        + YARVInstructions
740:                                                .name(bytecodes[ip].bytecode));
741:                        break;
742:                    case YARVInstructions.SETLOCAL_OP_2:
743:                        System.err
744:                                .println("Not implemented, YARVMachine."
745:                                        + YARVInstructions
746:                                                .name(bytecodes[ip].bytecode));
747:                        break;
748:                    case YARVInstructions.SETLOCAL_OP_3:
749:                        System.err
750:                                .println("Not implemented, YARVMachine."
751:                                        + YARVInstructions
752:                                                .name(bytecodes[ip].bytecode));
753:                        break;
754:                    case YARVInstructions.SETLOCAL_OP_4:
755:                        System.err
756:                                .println("Not implemented, YARVMachine."
757:                                        + YARVInstructions
758:                                                .name(bytecodes[ip].bytecode));
759:                        break;
760:                    case YARVInstructions.GETDYNAMIC_OP__WC__0:
761:                        System.err
762:                                .println("Not implemented, YARVMachine."
763:                                        + YARVInstructions
764:                                                .name(bytecodes[ip].bytecode));
765:                        break;
766:                    case YARVInstructions.GETDYNAMIC_OP_1_0:
767:                        System.err
768:                                .println("Not implemented, YARVMachine."
769:                                        + YARVInstructions
770:                                                .name(bytecodes[ip].bytecode));
771:                        break;
772:                    case YARVInstructions.GETDYNAMIC_OP_2_0:
773:                        System.err
774:                                .println("Not implemented, YARVMachine."
775:                                        + YARVInstructions
776:                                                .name(bytecodes[ip].bytecode));
777:                        break;
778:                    case YARVInstructions.GETDYNAMIC_OP_3_0:
779:                        System.err
780:                                .println("Not implemented, YARVMachine."
781:                                        + YARVInstructions
782:                                                .name(bytecodes[ip].bytecode));
783:                        break;
784:                    case YARVInstructions.GETDYNAMIC_OP_4_0:
785:                        System.err
786:                                .println("Not implemented, YARVMachine."
787:                                        + YARVInstructions
788:                                                .name(bytecodes[ip].bytecode));
789:                        break;
790:                    case YARVInstructions.SETDYNAMIC_OP__WC__0:
791:                        System.err
792:                                .println("Not implemented, YARVMachine."
793:                                        + YARVInstructions
794:                                                .name(bytecodes[ip].bytecode));
795:                        break;
796:                    case YARVInstructions.SETDYNAMIC_OP_1_0:
797:                        System.err
798:                                .println("Not implemented, YARVMachine."
799:                                        + YARVInstructions
800:                                                .name(bytecodes[ip].bytecode));
801:                        break;
802:                    case YARVInstructions.SETDYNAMIC_OP_2_0:
803:                        System.err
804:                                .println("Not implemented, YARVMachine."
805:                                        + YARVInstructions
806:                                                .name(bytecodes[ip].bytecode));
807:                        break;
808:                    case YARVInstructions.SETDYNAMIC_OP_3_0:
809:                        System.err
810:                                .println("Not implemented, YARVMachine."
811:                                        + YARVInstructions
812:                                                .name(bytecodes[ip].bytecode));
813:                        break;
814:                    case YARVInstructions.SETDYNAMIC_OP_4_0:
815:                        System.err
816:                                .println("Not implemented, YARVMachine."
817:                                        + YARVInstructions
818:                                                .name(bytecodes[ip].bytecode));
819:                        break;
820:                    case YARVInstructions.PUTOBJECT_OP_INT2FIX_0_0_C_:
821:                        System.err
822:                                .println("Not implemented, YARVMachine."
823:                                        + YARVInstructions
824:                                                .name(bytecodes[ip].bytecode));
825:                        break;
826:                    case YARVInstructions.PUTOBJECT_OP_INT2FIX_0_1_C_:
827:                        System.err
828:                                .println("Not implemented, YARVMachine."
829:                                        + YARVInstructions
830:                                                .name(bytecodes[ip].bytecode));
831:                        break;
832:                    case YARVInstructions.PUTOBJECT_OP_QTRUE:
833:                        System.err
834:                                .println("Not implemented, YARVMachine."
835:                                        + YARVInstructions
836:                                                .name(bytecodes[ip].bytecode));
837:                        break;
838:                    case YARVInstructions.PUTOBJECT_OP_QFALSE:
839:                        System.err
840:                                .println("Not implemented, YARVMachine."
841:                                        + YARVInstructions
842:                                                .name(bytecodes[ip].bytecode));
843:                        break;
844:                    case YARVInstructions.SEND_OP__WC___WC__QFALSE_0__WC_:
845:                        System.err
846:                                .println("Not implemented, YARVMachine."
847:                                        + YARVInstructions
848:                                                .name(bytecodes[ip].bytecode));
849:                        break;
850:                    case YARVInstructions.SEND_OP__WC__0_QFALSE_0__WC_:
851:                        System.err
852:                                .println("Not implemented, YARVMachine."
853:                                        + YARVInstructions
854:                                                .name(bytecodes[ip].bytecode));
855:                        break;
856:                    case YARVInstructions.SEND_OP__WC__1_QFALSE_0__WC_:
857:                        System.err
858:                                .println("Not implemented, YARVMachine."
859:                                        + YARVInstructions
860:                                                .name(bytecodes[ip].bytecode));
861:                        break;
862:                    case YARVInstructions.SEND_OP__WC__2_QFALSE_0__WC_:
863:                        System.err
864:                                .println("Not implemented, YARVMachine."
865:                                        + YARVInstructions
866:                                                .name(bytecodes[ip].bytecode));
867:                        break;
868:                    case YARVInstructions.SEND_OP__WC__3_QFALSE_0__WC_:
869:                        System.err
870:                                .println("Not implemented, YARVMachine."
871:                                        + YARVInstructions
872:                                                .name(bytecodes[ip].bytecode));
873:                        break;
874:                    case YARVInstructions.SEND_OP__WC___WC__QFALSE_0X04__WC_:
875:                        System.err
876:                                .println("Not implemented, YARVMachine."
877:                                        + YARVInstructions
878:                                                .name(bytecodes[ip].bytecode));
879:                        break;
880:                    case YARVInstructions.SEND_OP__WC__0_QFALSE_0X04__WC_:
881:                        System.err
882:                                .println("Not implemented, YARVMachine."
883:                                        + YARVInstructions
884:                                                .name(bytecodes[ip].bytecode));
885:                        break;
886:                    case YARVInstructions.SEND_OP__WC__1_QFALSE_0X04__WC_:
887:                        System.err
888:                                .println("Not implemented, YARVMachine."
889:                                        + YARVInstructions
890:                                                .name(bytecodes[ip].bytecode));
891:                        break;
892:                    case YARVInstructions.SEND_OP__WC__2_QFALSE_0X04__WC_:
893:                        System.err
894:                                .println("Not implemented, YARVMachine."
895:                                        + YARVInstructions
896:                                                .name(bytecodes[ip].bytecode));
897:                        break;
898:                    case YARVInstructions.SEND_OP__WC__3_QFALSE_0X04__WC_:
899:                        System.err
900:                                .println("Not implemented, YARVMachine."
901:                                        + YARVInstructions
902:                                                .name(bytecodes[ip].bytecode));
903:                        break;
904:                    case YARVInstructions.SEND_OP__WC__0_QFALSE_0X0C__WC_:
905:                        System.err
906:                                .println("Not implemented, YARVMachine."
907:                                        + YARVInstructions
908:                                                .name(bytecodes[ip].bytecode));
909:                        break;
910:                    case YARVInstructions.UNIFIED_PUTOBJECT_PUTOBJECT:
911:                        System.err
912:                                .println("Not implemented, YARVMachine."
913:                                        + YARVInstructions
914:                                                .name(bytecodes[ip].bytecode));
915:                        break;
916:                    case YARVInstructions.UNIFIED_PUTOBJECT_PUTSTRING:
917:                        System.err
918:                                .println("Not implemented, YARVMachine."
919:                                        + YARVInstructions
920:                                                .name(bytecodes[ip].bytecode));
921:                        break;
922:                    case YARVInstructions.UNIFIED_PUTOBJECT_SETLOCAL:
923:                        System.err
924:                                .println("Not implemented, YARVMachine."
925:                                        + YARVInstructions
926:                                                .name(bytecodes[ip].bytecode));
927:                        break;
928:                    case YARVInstructions.UNIFIED_PUTOBJECT_SETDYNAMIC:
929:                        System.err
930:                                .println("Not implemented, YARVMachine."
931:                                        + YARVInstructions
932:                                                .name(bytecodes[ip].bytecode));
933:                        break;
934:                    case YARVInstructions.UNIFIED_PUTSTRING_PUTSTRING:
935:                        System.err
936:                                .println("Not implemented, YARVMachine."
937:                                        + YARVInstructions
938:                                                .name(bytecodes[ip].bytecode));
939:                        break;
940:                    case YARVInstructions.UNIFIED_PUTSTRING_PUTOBJECT:
941:                        System.err
942:                                .println("Not implemented, YARVMachine."
943:                                        + YARVInstructions
944:                                                .name(bytecodes[ip].bytecode));
945:                        break;
946:                    case YARVInstructions.UNIFIED_PUTSTRING_SETLOCAL:
947:                        System.err
948:                                .println("Not implemented, YARVMachine."
949:                                        + YARVInstructions
950:                                                .name(bytecodes[ip].bytecode));
951:                        break;
952:                    case YARVInstructions.UNIFIED_PUTSTRING_SETDYNAMIC:
953:                        System.err
954:                                .println("Not implemented, YARVMachine."
955:                                        + YARVInstructions
956:                                                .name(bytecodes[ip].bytecode));
957:                        break;
958:                    case YARVInstructions.UNIFIED_DUP_SETLOCAL:
959:                        System.err
960:                                .println("Not implemented, YARVMachine."
961:                                        + YARVInstructions
962:                                                .name(bytecodes[ip].bytecode));
963:                        break;
964:                    case YARVInstructions.UNIFIED_GETLOCAL_GETLOCAL:
965:                        System.err
966:                                .println("Not implemented, YARVMachine."
967:                                        + YARVInstructions
968:                                                .name(bytecodes[ip].bytecode));
969:                        break;
970:                    case YARVInstructions.UNIFIED_GETLOCAL_PUTOBJECT:
971:                        System.err
972:                                .println("Not implemented, YARVMachine."
973:                                        + YARVInstructions
974:                                                .name(bytecodes[ip].bytecode));
975:                        break;
976:                    }
977:                    ip++;
978:                }
979:
980:                context.postRootNode();
981:                return stack[stackTop];
982:            }
983:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.