/
P6capture.java
128 lines (111 loc) · 4.07 KB
/
P6capture.java
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
package Rakudo.Metamodel.Representations;
import java.util.HashMap;
import Rakudo.Metamodel.RakudoObject;
import Rakudo.Metamodel.Representation;
import Rakudo.Metamodel.SharedTable;
import Rakudo.Metamodel.Hints;
import Rakudo.Serialization.SerializationContext;
/// <summary>
/// A representation that we use (for now) for native captures.
/// </summary>
public final class P6capture implements Representation
{
/// <summary>
/// This is how a Capture looks.
/// </summary>
public final class Instance implements RakudoObject
{
public RakudoObject[] Positionals;
public HashMap<String, RakudoObject> Nameds;
public SharedTable getSTable() {
return new SharedTable(); // TODO
}
public void setSTable(SharedTable st) {
}
public SerializationContext getSC() {
return new SerializationContext(); // TODO
}
public void setSC(SerializationContext sc) {
}
public Instance(SharedTable sharedTable)
{
this.setSTable(sharedTable);
}
}
/// <summary>
/// Create a new type object.
/// </summary>
/// <param name="MetaPackage"></param>
/// <returns></returns>
public RakudoObject type_object_for(RakudoObject MetaPackage)
{
SharedTable STable = new SharedTable();
STable.HOW = MetaPackage;
STable.REPR = this;
STable.WHAT = new Instance(STable);
return STable.WHAT;
}
/// <summary>
/// Creates an instance of the type with the given type object.
/// </summary>
/// <param name="WHAT"></param>
/// <returns></returns>
public RakudoObject instance_of(RakudoObject WHAT)
{
return new Instance(WHAT.getSTable());
}
/// <summary>
/// Determines if the representation is defined or not.
/// </summary>
/// <param name="Obj"></param>
/// <returns></returns>
public boolean defined(RakudoObject O)
{
Instance Obj = (Instance)O;
return Obj.Positionals != null || Obj.Nameds != null;
}
public RakudoObject get_attribute(RakudoObject Object, RakudoObject ClassHandle, String Name)
{
throw new UnsupportedOperationException("Native captures cannot store additional attributes.");
}
public RakudoObject get_attribute_with_hint(RakudoObject Object, RakudoObject ClassHandle, String Name, int Hint)
{
throw new UnsupportedOperationException("Native captures cannot store additional attributes.");
}
public void bind_attribute(RakudoObject Object, RakudoObject ClassHandle, String Name, RakudoObject Value)
{
throw new UnsupportedOperationException("Native captures cannot store additional attributes.");
}
public void bind_attribute_with_hint(RakudoObject Object, RakudoObject ClassHandle, String Name, int Hint, RakudoObject Value)
{
throw new UnsupportedOperationException("Native captures cannot store additional attributes.");
}
public int hint_for(RakudoObject ClassHandle, String Name)
{
return Hints.NO_HINT;
}
public void set_int(RakudoObject Object, int Value)
{
throw new UnsupportedOperationException("This type of representation cannot box a native int");
}
public int get_int(RakudoObject Object)
{
throw new UnsupportedOperationException("This type of representation cannot unbox to a native int");
}
public void set_num(RakudoObject Object, double Value)
{
throw new UnsupportedOperationException("This type of representation cannot box a native num");
}
public double get_num(RakudoObject Object)
{
throw new UnsupportedOperationException("This type of representation cannot unbox to a native num");
}
public void set_str(RakudoObject Object, String Value)
{
throw new UnsupportedOperationException("This type of representation cannot box a native string");
}
public String get_str(RakudoObject Object)
{
throw new UnsupportedOperationException("This type of representation cannot unbox to a native string");
}
}