Mostly implemented Simultaneous Declaration, only template instantation during pass 2 remains to be implemented
This commit is contained in:
1
tests/functionOrderingTest.expected_results
Normal file
1
tests/functionOrderingTest.expected_results
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
17
tests/functionOrderingTest.krak
Normal file
17
tests/functionOrderingTest.krak
Normal file
@@ -0,0 +1,17 @@
|
||||
import io;
|
||||
|
||||
int ret1() {
|
||||
return ret2() / 2;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
print(ret1());
|
||||
print(ret2());
|
||||
print("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret2() {
|
||||
return 2;
|
||||
}
|
||||
1
tests/moreObjectTemplateTest.expected_results
Normal file
1
tests/moreObjectTemplateTest.expected_results
Normal file
@@ -0,0 +1 @@
|
||||
345Hello!Hello!Hello!
|
||||
41
tests/moreObjectTemplateTest.krak
Normal file
41
tests/moreObjectTemplateTest.krak
Normal file
@@ -0,0 +1,41 @@
|
||||
import io;
|
||||
import trivial_container;
|
||||
|
||||
typedef RegularObject {
|
||||
MyInt num;
|
||||
trivialContainer<char*> innerContainer;
|
||||
void set(char* message, int number) {
|
||||
innerContainer.data = message;
|
||||
num = number;
|
||||
}
|
||||
char* get() {
|
||||
return innerContainer.data;
|
||||
}
|
||||
void print() {
|
||||
print(num);
|
||||
innerContainer.print();
|
||||
}
|
||||
};
|
||||
|
||||
typedef MyIntContainer trivialContainer<int>;
|
||||
typedef MyInt int;
|
||||
MyInt c;
|
||||
MyIntContainer roundabout;
|
||||
RegularObject outsideDec;
|
||||
|
||||
void print(trivialContainer<char*> toPrint) {
|
||||
print(toPrint.data);
|
||||
}
|
||||
|
||||
int main() {
|
||||
c = 3;
|
||||
roundabout.data = 4;
|
||||
outsideDec.set("Hello!", 5);
|
||||
print(c);
|
||||
roundabout.print();
|
||||
outsideDec.print();
|
||||
print(outsideDec.get());
|
||||
print(outsideDec.innerContainer);
|
||||
print("\n");
|
||||
return 0;
|
||||
}
|
||||
4
tests/simpleObjectTemplateTest.expected_results
Normal file
4
tests/simpleObjectTemplateTest.expected_results
Normal file
@@ -0,0 +1,4 @@
|
||||
a: 5
|
||||
b: 7
|
||||
a: 9
|
||||
b: Hello Templates!
|
||||
30
tests/simpleObjectTemplateTest.krak
Normal file
30
tests/simpleObjectTemplateTest.krak
Normal file
@@ -0,0 +1,30 @@
|
||||
import io;
|
||||
|
||||
|
||||
typedef template <T> TemplateTest {
|
||||
int a;
|
||||
T b;
|
||||
void print() {
|
||||
print("a: ");
|
||||
print(a);
|
||||
print("\n");
|
||||
print("b: ");
|
||||
print(b);
|
||||
print("\n");
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
TemplateTest<int> test;
|
||||
TemplateTest<char*> test2;
|
||||
test.a = 5;
|
||||
test.b = 7;
|
||||
test2.a = 9;
|
||||
test2.b = "Hello Templates!";
|
||||
|
||||
test.print();
|
||||
test2.print();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user