~ubuntu-branches/ubuntu/vivid/nqp/vivid-proposed

« back to all changes in this revision

Viewing changes to src/vm/jvm/runtime/org/perl6/nqp/sixmodel/REPRRegistry.java

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2013-11-01 12:09:18 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20131101120918-kx51sl0sxl3exsxi
Tags: 2013.10-1
* New upstream release
* Bump versioned (Build-)Depends on parrot
* Update patches
* Install new README.pod
* Fix vcs-field-not-canonical
* Do not install rubyish examples
* Do not Depends on parrot-devel anymore
* Add 07_disable-serialization-tests.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.perl6.nqp.sixmodel;
 
2
 
 
3
import java.util.ArrayList;
 
4
import java.util.HashMap;
 
5
 
 
6
import org.perl6.nqp.sixmodel.reprs.CallCapture;
 
7
import org.perl6.nqp.sixmodel.reprs.CodeRefREPR;
 
8
import org.perl6.nqp.sixmodel.reprs.ContextRef;
 
9
import org.perl6.nqp.sixmodel.reprs.Continuation;
 
10
import org.perl6.nqp.sixmodel.reprs.CArray;
 
11
import org.perl6.nqp.sixmodel.reprs.CPointer;
 
12
import org.perl6.nqp.sixmodel.reprs.CStr;
 
13
import org.perl6.nqp.sixmodel.reprs.IOHandle;
 
14
import org.perl6.nqp.sixmodel.reprs.JavaWrap;
 
15
import org.perl6.nqp.sixmodel.reprs.KnowHOWAttribute;
 
16
import org.perl6.nqp.sixmodel.reprs.KnowHOWREPR;
 
17
import org.perl6.nqp.sixmodel.reprs.Lexotic;
 
18
import org.perl6.nqp.sixmodel.reprs.MultiCache;
 
19
import org.perl6.nqp.sixmodel.reprs.NativeCall;
 
20
import org.perl6.nqp.sixmodel.reprs.NFA;
 
21
import org.perl6.nqp.sixmodel.reprs.P6Opaque;
 
22
import org.perl6.nqp.sixmodel.reprs.P6bigint;
 
23
import org.perl6.nqp.sixmodel.reprs.P6int;
 
24
import org.perl6.nqp.sixmodel.reprs.P6num;
 
25
import org.perl6.nqp.sixmodel.reprs.P6str;
 
26
import org.perl6.nqp.sixmodel.reprs.SCRef;
 
27
import org.perl6.nqp.sixmodel.reprs.Uninstantiable;
 
28
import org.perl6.nqp.sixmodel.reprs.VMArray;
 
29
import org.perl6.nqp.sixmodel.reprs.VMException;
 
30
import org.perl6.nqp.sixmodel.reprs.VMHash;
 
31
import org.perl6.nqp.sixmodel.reprs.VMIter;
 
32
 
 
33
public class REPRRegistry {
 
34
    private static HashMap<String, Integer> reprIdMap = new HashMap<String, Integer>();
 
35
    private static ArrayList<REPR> reprs = new ArrayList<REPR>();
 
36
    
 
37
    public static REPR getByName(String name) {
 
38
        Integer idx = reprIdMap.get(name);
 
39
        if (idx == null)
 
40
            throw new RuntimeException("No REPR " + name);
 
41
        return getById(idx);
 
42
    }
 
43
    
 
44
    public static REPR getById(int id) {
 
45
        if (id < reprs.size())
 
46
            return reprs.get(id);
 
47
        else
 
48
            throw new RuntimeException("No REPR " + new Integer(id).toString());
 
49
    }
 
50
    
 
51
    private static void addREPR(String name, REPR REPR) {
 
52
        REPR.ID = reprs.size();
 
53
        REPR.name = name;
 
54
        reprIdMap.put(name, reprs.size());
 
55
        reprs.add(REPR);
 
56
    }
 
57
    
 
58
    static {
 
59
        addREPR("KnowHOWREPR", new KnowHOWREPR());
 
60
        addREPR("KnowHOWAttribute", new KnowHOWAttribute());
 
61
        addREPR("P6opaque", new P6Opaque());
 
62
        addREPR("VMHash", new VMHash());
 
63
        addREPR("VMArray", new VMArray());
 
64
        addREPR("VMIter", new VMIter());
 
65
        addREPR("P6str", new P6str());
 
66
        addREPR("P6int", new P6int());
 
67
        addREPR("P6num", new P6num());
 
68
        addREPR("Uninstantiable", new Uninstantiable());
 
69
        addREPR("SCRef", new SCRef());
 
70
        addREPR("JavaWrap", new JavaWrap());
 
71
        addREPR("ContextRef", new ContextRef());
 
72
        addREPR("Continuation", new Continuation());
 
73
        addREPR("Lexotic", new Lexotic());
 
74
        addREPR("CodeRef", new CodeRefREPR());
 
75
        addREPR("CallCapture", new CallCapture());
 
76
        addREPR("NFA", new NFA());
 
77
        addREPR("VMException", new VMException());
 
78
        addREPR("IOHandle", new IOHandle());
 
79
        addREPR("P6bigint", new P6bigint());
 
80
        addREPR("MultiCache", new MultiCache());
 
81
        addREPR("NativeCall", new NativeCall());
 
82
        addREPR("CPointer", new CPointer());
 
83
        addREPR("CArray", new CArray());
 
84
        addREPR("CStr", new CStr());
 
85
    }
 
86
}