Turns out it works now, added more to the test and some comments explaining why
This commit is contained in:
@@ -1013,12 +1013,14 @@ NodeTree<ASTData>* ASTTransformation::templateClassLookup(NodeTree<ASTData>* sco
|
||||
void ASTTransformation::unifyType(NodeTree<Symbol> *syntaxType, Type type, std::map<std::string, Type>* templateTypeMap) {
|
||||
// Ok, 3 options for syntaxType here.
|
||||
// 1) This a basic type. (int, or object, etc)
|
||||
// then check to see if it's the same as our type
|
||||
// THIS ONE will fall through and get put in the map, but it
|
||||
// doesn't matter b/c it'll get filterd out in unifyTemplateFunction
|
||||
// 2) This is a template type type (i.e. T)
|
||||
// match! set up templateTypeMap[T] -> type
|
||||
// 3) This some sort of instantiated template
|
||||
// a) instantiated with some other type (i.e. vector<int>)
|
||||
// this will be a bit of a pain
|
||||
// THIS ONE will fall through and get put in the map, but it
|
||||
// doesn't matter b/c it'll get filterd out in unifyTemplateFunction
|
||||
// b) instantiated with a template type type (i.e. vector<T>)
|
||||
// this will be a bit of a pain too
|
||||
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
11
|
||||
12
|
||||
9
|
||||
13.880000
|
||||
test string
|
||||
|
||||
@@ -2,8 +2,18 @@ import io:*
|
||||
import mem:*
|
||||
import vector:*
|
||||
|
||||
typedef pair<T, U> {
|
||||
var first: T
|
||||
var second: U
|
||||
}
|
||||
|
||||
fun id<T>(in: T): T { return in; }
|
||||
fun idVec<T>(in: vector<T>): T { return in.get(0); }
|
||||
fun pairFun<T>(in: pair<T, int>, another:double): T {
|
||||
println(in.second)
|
||||
println(another)
|
||||
return in.first;
|
||||
}
|
||||
|
||||
fun main():int {
|
||||
var fromTemplateFun = id(11)
|
||||
@@ -11,6 +21,10 @@ fun main():int {
|
||||
aVec.addEnd(12)
|
||||
println(fromTemplateFun)
|
||||
println(idVec(aVec))
|
||||
//println(idVec<int>(aVec))
|
||||
var testPair: pair<char*, int>
|
||||
testPair.first = "test string"
|
||||
testPair.second = 9
|
||||
var someFloat = 13.88
|
||||
println(pairFun(testPair, someFloat))
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user