-
Notifications
You must be signed in to change notification settings - Fork 228
Expand file tree
/
Copy pathNListType.java
More file actions
53 lines (43 loc) · 1.29 KB
/
NListType.java
File metadata and controls
53 lines (43 loc) · 1.29 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
/**
* 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;
public class NListType extends NType {
private NType eltType;
public NListType() {
this(new NUnknownType());
}
public NListType(NType elt0) {
eltType = elt0;
getTable().addSuper(Indexer.idx.builtins.BaseList.getTable());
getTable().setPath(Indexer.idx.builtins.BaseList.getTable().getPath());
}
public void setElementType(NType eltType) {
this.eltType = eltType;
}
/**
* Returns the type of the elements. You should wrap the result
* with {@link NUnknownType#follow} to get to the actual type.
*/
public NType getElementType() {
return eltType;
}
public void add(NType another) {
eltType = NUnionType.union(eltType, another);
}
public NTupleType toTupleType(int n) {
NTupleType ret = new NTupleType();
for (int i = 0; i < n; i++) {
ret.add(eltType);
}
return ret;
}
@Override
public void printKids(CyclicTypeRecorder ctr, StringBuilder sb) {
eltType.print(ctr, sb);
}
}