Wooo actual scoping and better C interop
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
|
||||
__if_comp__ __C__ __simple_passthrough__ """
|
||||
__if_comp__ __C__ simple_passthrough """
|
||||
#include <stdio.h>
|
||||
int diff = 7;
|
||||
"""
|
||||
|
||||
|void| print_it() {
|
||||
__if_comp__ __C__ __simple_passthrough__ """
|
||||
__if_comp__ __C__ simple_passthrough """
|
||||
printf("diff_file: %d\n", diff);
|
||||
"""
|
||||
}
|
||||
|
||||
|void| print_it(|int| i) {
|
||||
__if_comp__ __C__ simple_passthrough(i = i::) """
|
||||
printf("diff_file: %d\n", i);
|
||||
"""
|
||||
}
|
||||
|
||||
7
tests/sameNameOne.krak
Normal file
7
tests/sameNameOne.krak
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|int| sameVar;
|
||||
|int| sameFun() { return 5; }
|
||||
typedef classTester {
|
||||
|int| method() { return 8; }
|
||||
}
|
||||
|
||||
6
tests/sameNameTwo.krak
Normal file
6
tests/sameNameTwo.krak
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
|int| sameVar;
|
||||
|int| sameFun() { return 6; }
|
||||
typedef classTester {
|
||||
|int| method() { return 9; }
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
same_file: 5
|
||||
diff_file: 7
|
||||
diff_file: 13
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
import c_passthrough_diff
|
||||
|
||||
|
||||
__if_comp__ __C__ __simple_passthrough__ """
|
||||
__if_comp__ __C__ simple_passthrough """
|
||||
#include <stdio.h>
|
||||
int same = 5;
|
||||
"""
|
||||
|
||||
|int| main() {
|
||||
|
||||
__if_comp__ __C__ __simple_passthrough__ """
|
||||
__if_comp__ __C__ simple_passthrough """
|
||||
printf("same_file: %d\n", same);
|
||||
"""
|
||||
c_passthrough_diff::print_it()
|
||||
|
||||
c_passthrough_diff::print_it();
|
||||
|int| i = 7;
|
||||
|int| j = 6;
|
||||
__if_comp__ __C__ simple_passthrough(i = i, j = j : j = j:) """
|
||||
j = i + j;
|
||||
"""
|
||||
c_passthrough_diff::print_it(j)
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import io:*
|
||||
|
||||
|int| main() {
|
||||
|int| a = -1
|
||||
println(a)
|
||||
println(-a)
|
||||
println(+a); // this is still -1! (as C has it, anyway) (darn comment/semicolon interaction)
|
||||
|
||||
|int| b = 7
|
||||
println(b)
|
||||
println(-b)
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "test_negative_number_unary.krak.h"
|
||||
|
||||
/**
|
||||
* Variable Declarations
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function Definitions
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
/**
|
||||
* Plain Typedefs
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import Includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Top Level C Passthrough
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extern Variable Declarations
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Structs
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function Prototypes
|
||||
*/
|
||||
|
||||
2
tests/test_negative_number_unary.krak/test_negative_number_unary.krak.sh
Executable file
2
tests/test_negative_number_unary.krak/test_negative_number_unary.krak.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
cc -std=c99 test_negative_number_unary.krak.c -o test_negative_number_unary.krak
|
||||
9
tests/test_sameName.expected_results
Normal file
9
tests/test_sameName.expected_results
Normal file
@@ -0,0 +1,9 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
36
tests/test_sameName.krak
Normal file
36
tests/test_sameName.krak
Normal file
@@ -0,0 +1,36 @@
|
||||
import io:*
|
||||
import sameNameOne
|
||||
import sameNameTwo
|
||||
|
||||
|int| sameVar;
|
||||
|int| sameFun() { return 4; }
|
||||
|
||||
typedef classTester {
|
||||
|int| method() {
|
||||
return 7
|
||||
}
|
||||
}
|
||||
|
||||
|int| main() {
|
||||
sameVar = 1
|
||||
sameNameOne::sameVar = 2
|
||||
sameNameTwo::sameVar = 3
|
||||
|
||||
|classTester| class1;
|
||||
|sameNameOne::classTester| class2;
|
||||
|sameNameTwo::classTester| class3;
|
||||
|
||||
println(sameVar)
|
||||
println(sameNameOne::sameVar)
|
||||
println(sameNameTwo::sameVar)
|
||||
|
||||
println(sameFun())
|
||||
println(sameNameOne::sameFun())
|
||||
println(sameNameTwo::sameFun())
|
||||
|
||||
println(class1.method())
|
||||
println(class2.method())
|
||||
println(class3.method())
|
||||
|
||||
return 0
|
||||
}
|
||||
1
tests/test_trigTest.expected_results
Normal file
1
tests/test_trigTest.expected_results
Normal file
@@ -0,0 +1 @@
|
||||
3.141593
|
||||
40
tests/test_trigTest.krak
Normal file
40
tests/test_trigTest.krak
Normal file
@@ -0,0 +1,40 @@
|
||||
import io:*;
|
||||
import math:*;
|
||||
|
||||
|int| main()
|
||||
{
|
||||
|double| ans;
|
||||
|double| STD_PI = 4.0*atan(1.0);
|
||||
println(STD_PI);
|
||||
|
||||
/*
|
||||
ans = 4.0*atan(1.0);
|
||||
print("atan = ");
|
||||
println(ans);
|
||||
|
||||
ans = atan2(0.0,1.0);
|
||||
print("atan2 = ");
|
||||
println(ans);
|
||||
|
||||
ans = acos(1.0);
|
||||
print("acos = ");
|
||||
println(ans);
|
||||
|
||||
ans = 2.0 * asin(1.0);
|
||||
print("asin = ");
|
||||
println(ans);
|
||||
|
||||
ans = tan(STD_PI / 4.0);
|
||||
print("tan = ");
|
||||
println(ans);
|
||||
|
||||
ans = cos(0.0);
|
||||
print("cos = ");
|
||||
println(ans);
|
||||
|
||||
ans = sin(0.0);
|
||||
print("sin = ");
|
||||
println(ans);
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user