blob: d38d47755a3ff902fbe7730a8d0d54ad29c0721b (
plain) (
blame)
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
|
/**
* <copyright>
*
* Copyright (c) 2002-2007 itemis AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* itemis AG - Initial API and implementation
*
* </copyright>
*
*/
package org.eclipse.xand3.analyzation.typesystem;
import java.util.Arrays;
import java.util.List;
import org.eclipse.xand3.analyzation.DeclarationsContributor;
import org.eclipse.xand3.analyzation.TypeSystem;
import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
import org.eclipse.xpand3.staticTypesystem.DeclaredType;
import org.eclipse.xpand3.staticTypesystem.FunctionType;
import org.eclipse.xpand3.staticTypesystem.Type;
/**
* @author Sven Efftinge
*
*/
public class TypeSystemImpl extends AbstractTypeSystemImpl implements TypeSystem {
private DeclarationsContributor contr = null;
/**
*
*/
public TypeSystemImpl(DeclarationsContributor contributor) {
if (contributor==null)
throw new NullPointerException("contributor was null");
this.contr = contributor;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.xand3.analyzation.TypeSystem#typeForName(java.lang.String,
* org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
*/
public Type typeForName(String name, AbstractTypeReference... typeArguments) {
DeclaredType dt = contr.typeForName(name);
if (dt == null) {
//TODO CACHING
Type t = FACTORY.createType();
t.setDeclaredType(dt);
t.getActualTypeArguments().addAll(Arrays.asList(typeArguments));
return t;
}
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.xand3.analyzation.TypeSystem#functionForName(java.lang.String,
* java.util.List,
* org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
*/
public FunctionType functionForName(String name,
List<AbstractTypeReference> parameterTypes,
AbstractTypeReference... typeArguments) {
DeclaredFunction func = contr.functionForName(name, parameterTypes.toArray(new AbstractTypeReference[parameterTypes.size()]));
if (func == null) {
//TODO CACHING
FunctionType funcType = FACTORY.createFunctionType();
funcType.setDeclaredFunction(func);
funcType.getActualTypeArguments().addAll(Arrays.asList(typeArguments));
return funcType;
}
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.xand3.analyzation.TypeSystem#functionForNameAndParameterTypes(java.lang.String,
* org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
*/
public FunctionType functionForNameAndParameterTypes(String name,
AbstractTypeReference... parameterTypes) {
return functionForName(name, Arrays.asList(parameterTypes));
}
}
|