-
Notifications
You must be signed in to change notification settings - Fork 228
Expand file tree
/
Copy pathNTupleType.java
More file actions
81 lines (66 loc) · 1.83 KB
/
NTupleType.java
File metadata and controls
81 lines (66 loc) · 1.83 KB
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
/**
* Copyright 2009, Google Inc. All rights reserved.
* Licensed to PSF under a Contributor Agreement.
*/
package org.python.indexer.types;
import org.python.indexer.Indexer;
import org.python.indexer.NBinding;
import org.python.indexer.ast.NUrl;
import java.util.ArrayList;
import java.util.List;
public class NTupleType extends NType {
private List<NType> eltTypes;
public NTupleType() {
this.eltTypes = new ArrayList<NType>();
getTable().addSuper(Indexer.idx.builtins.BaseTuple.getTable());
getTable().setPath(Indexer.idx.builtins.BaseTuple.getTable().getPath());
}
public NTupleType(List<NType> eltTypes) {
this();
this.eltTypes = eltTypes;
}
public NTupleType(NType elt0) {
this();
this.eltTypes.add(elt0);
}
public NTupleType(NType elt0, NType elt1) {
this();
this.eltTypes.add(elt0);
this.eltTypes.add(elt1);
}
public NTupleType(NType... types) {
this();
for (NType type : types) {
this.eltTypes.add(type);
}
}
public void setElementTypes(List<NType> eltTypes) {
this.eltTypes = eltTypes;
}
public List<NType> getElementTypes() {
return eltTypes;
}
public void add(NType elt) {
eltTypes.add(elt);
}
public NType get(int i) {
return eltTypes.get(i);
}
public NListType toListType() {
NListType t = new NListType();
for (NType e : eltTypes) {
t.add(e);
}
return t;
}
@Override
public void printKids(CyclicTypeRecorder ctr, StringBuilder sb) {
sb.append("[");
for (NType elt : eltTypes) {
elt.print(ctr, sb);
sb.append(",");
}
sb.setLength(sb.length() - 1); // pop last comma
sb.append("]");
}
}