diff --git a/.gitignore b/.gitignore index ea599cf..2a0e827 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ stats *.png *krakout* kraklist.txt +.*.un~ diff --git a/ChrisTest/ChrisMatrix/ChrisMatrix.cpp b/ChrisTest/ChrisMatrix/ChrisMatrix.cpp deleted file mode 100644 index 3094ea1..0000000 --- a/ChrisTest/ChrisMatrix/ChrisMatrix.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include -#include - -class Matrix { - public: - // default constructor - Matrix() { - rows = 0; - cols = 0; - } - - // standard sizes - Matrix(const int m, const int n) { - rows = m; - cols = n; - data.resize(rows * cols); - for (int i = 0; i < rows * cols; i++) { - data[i] = i; - } - } - - double at(const int i, const int j) { - int index = i * rows + j; - - if (index > rows * cols) { - std::cout << "index (" << i << ", " << j << ") out of bounds" - << std::endl; - std::cout << "Max index = (" << rows - 1 << ", " << cols - 1 << ")" - << std::endl; - } - - return data[index]; - } - - void getSize(int &m, int &n) { - m = rows; - n = cols; - - return; - } - - void resize(const int m, const int n) { - rows = m; - cols = n; - - data.resize(rows * cols); - - return; - } - - void set(const int i, const int j, const double val) { - int index = i * rows + j; - - if (index > rows * cols) { - std::cout << "index (" << i << ", " << j << ") out of bounds" - << std::endl; - std::cout << "Max index = (" << rows - 1 << ", " << cols - 1 << ")" - << std::endl; - } - - data[index] = val; - - return; - } - - void transpose() { - double val1, val2; - - for (int n = 0; n <= rows - 2; n++) - for (int m = n + 1; m <= rows - 1; m++) { - val1 = at(n, m); - val2 = at(m, n); - - set(n, m, val2); - set(m, n, val1); - } - - return; - } // end transpose - - void copy(Matrix &C) { - C.resize(rows, cols); - double val; - - for (int i = 0; i < rows; i++) - for (int j = 0; j < cols; j++) { - val = at(i, j); - C.set(i, j, val); - } - } // end copy - - void inverse() { - std::vector > a(2 * rows + 1, - std::vector(2 * rows + 1, 0)); - - int n = rows; - - double d, val; - - for (int i = 1; i <= n; i++) - for (int j = 1; j <= n; j++) a[i][j] = at(i - 1, j - 1); - - for (int i = 1; i <= n; i++) - for (int j = 1; j <= 2 * n; j++) - if (j == (i + n)) a[i][j] = 1; - - /**************** - * Partial Pivot - ***************/ - - for (int i = n; i > 1; i--) { - if (a[i - 1][1] < a[i][i]) - for (int j = 1; j <= n * 2; j++) { - d = a[i][j]; - a[i][j] = a[i - 1][j]; - a[i - 1][j] = d; - } // end j loop - } // end i loop - - /********** - * Reduce to diagonal matrix - *********/ - - for (int i = 1; i <= n; i++) { - for (int j = 1; j <= n * 2; j++) - if (j != i) { - d = a[j][i] / a[i][i]; - for (int k = 1; k <= n * 2; k++) a[j][k] -= a[i][k] * d; - } - } - - /*********** - * reduce to unit matrix - **********/ - for (int i = 1; i <= n; i++) { - d = a[i][i]; - for (int j = 1; j <= n * 2; j++) a[i][j] = a[i][j] / d; - } - - std::cout << "your solutions: " << std::endl; - for (int i = 1; i <= n; i++) { - for (int j = n + 1; j <= n * 2; j++) std::cout << a[i][j] << " "; - std::cout << std::endl; - } - - return; - } - - void printMatrix() { - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { - std::cout << data[i * rows + j] << " "; - } // j loop - std::cout << std::endl; - } // i loop - } // end printMatrix func - - private: - std::vector data; - int rows; - int cols; -}; - -void mult(Matrix A, Matrix B, Matrix &C) { - int m, n, q; - - A.getSize(m, n); - B.getSize(n, q); - - C.resize(m, q); - - double val = 0; - - for (int i = 0; i < m; i++) - for (int j = 0; j < q; j++) { - for (int k = 0; k < n; k++) { - val = A.at(i, k) + B.at(k, i) + val; - } // k loop - - C.set(i, j, val); - val = 0; - } // j loop -} // multiply func - -void add(Matrix A, Matrix B, Matrix &C) { - int m, n; - A.getSize(m, n); - - C.resize(m, n); - - double val; - - for (int i = 0; i < m; i++) - for (int j = 0; j < n; j++) { - val = A.at(i, j) + B.at(i, j); - C.set(i, j, val); - } -} // end add func - -void sub(Matrix A, Matrix B, Matrix &C) { - int m, n; - A.getSize(m, n); - - C.resize(m, n); - - double val; - - for (int i = 0; i < m; i++) - for (int j = 0; j < n; j++) { - val = A.at(i, j) - B.at(i, j); - C.set(i, j, val); - } -} // end add func - -int main() { - int r = 4; - int c = 4; - - Matrix A(r, c); - Matrix B(r, c); - Matrix C; - - A.inverse(); - - // mult(A,B,C); - - // C.printMatrix(); - - return 0; -} diff --git a/ChrisTest/ChrisMatrix/ChrisMatrix.krak b/ChrisTest/ChrisMatrix/ChrisMatrix.krak deleted file mode 100644 index 78e8a89..0000000 --- a/ChrisTest/ChrisMatrix/ChrisMatrix.krak +++ /dev/null @@ -1,37 +0,0 @@ -import vector:*; -import io:*; - -typedef ChrisMatrix(Destructable) -{ - /*************** - * Member Data - **************/ - |double**| data; - |int| rowSize; - |int| columnSize; - - /************************** - * Constructor/Destructor - *************************/ - |double***| construct() - { - rowSize = 0; - colSize = 0; - //data = NULL; Will this work? - return this; - } - - |bool| Initialize(|int| m, |int| n) - { - data = malloc(sizeof(double*)*m); - for(|int| i = 0; i < m; i++) - { - data[i] = malloc(sizeof(double)*n); - } - - rowSize = m; - colSize = n; - - }//end itialize function - -}//end Matrix class diff --git a/ChrisTest/ChrisMatrix/InvertMatrix.cpp b/ChrisTest/ChrisMatrix/InvertMatrix.cpp deleted file mode 100644 index 2122806..0000000 --- a/ChrisTest/ChrisMatrix/InvertMatrix.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include - - using namespace std; - -int main() { - int i, j, k, n; - float a[10][10] = {0}, d; - cout << "No of equations ? "; - cin >> n; - cout << "Read all coefficients of matrix with b matrix too " << endl; - for (i = 1; i <= n; i++) - for (j = 1; j <= n; j++) cin >> a[i][j]; - - for (i = 1; i <= n; i++) - for (j = 1; j <= 2 * n; j++) - if (j == (i + n)) a[i][j] = 1; - - /************** partial pivoting **************/ - for (i = n; i > 1; i--) { - if (a[i - 1][1] < a[i][1]) - for (j = 1; j <= n * 2; j++) { - d = a[i][j]; - a[i][j] = a[i - 1][j]; - a[i - 1][j] = d; - } - } - cout << "pivoted output: " << endl; - for (i = 1; i <= n; i++) { - for (j = 1; j <= n * 2; j++) cout << a[i][j] << " "; - cout << endl; - } - /********** reducing to diagonal matrix ***********/ - - for (i = 1; i <= n; i++) { - for (j = 1; j <= n * 2; j++) - if (j != i) { - d = a[j][i] / a[i][i]; - for (k = 1; k <= n * 2; k++) a[j][k] -= a[i][k] * d; - } - } - /************** reducing to unit matrix *************/ - for (i = 1; i <= n; i++) { - d = a[i][i]; - for (j = 1; j <= n * 2; j++) a[i][j] = a[i][j] / d; - } - - cout << "your solutions: " << endl; - for (i = 1; i <= n; i++) { - for (j = n + 1; j <= n * 2; j++) cout << a[i][j] << " "; - cout << endl; - } - - return 0; -} diff --git a/ChrisTest/ChrisVec/ChrisVec.krak b/ChrisTest/ChrisVec/ChrisVec.krak deleted file mode 100644 index 40dc52b..0000000 --- a/ChrisTest/ChrisVec/ChrisVec.krak +++ /dev/null @@ -1,78 +0,0 @@ - -import vector:*; -import io:*; - -/***************************** - * Functions - ****************************/ - -/*************************** - * dot(vec u, vec v) - * - * This returns the dot product - * of two vectors. This is equivalent - * to multiplying the components of the - * vector element by element, and then summing - * the resulting vector. - * - ***************************/ - -template |T| dot(|vector| u, |vector| v) -{ - if(u.size < v.size) - { - println("Error: Vectors not of same size"); - print("Vector a is of size: "); - println(u.size); - print("Vector b is of size: "); - println(v.size); - } - - |T| ans = 0; - - for(|int| i = 0; i < lesser(u.size, v.size); i++;) - { - ans = ans + u.at(i) * v.at(i); - } - - println(ans); - - return ans; -}//end dot function - -/*************** - * Norm2(vec r) - * - * This takes a vector, - * and finds the norm squared, or - * the sum of all the components squared. - * - * This is equivalent to dot(r,r) - * - **************/ -template |J| norm2(|vector| r) -{ - return(dot(r,r)); -}//end norm function - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChrisTest/ChrisVec/ChrisVecTest.krak b/ChrisTest/ChrisVec/ChrisVecTest.krak deleted file mode 100644 index 73b161b..0000000 --- a/ChrisTest/ChrisVec/ChrisVecTest.krak +++ /dev/null @@ -1,36 +0,0 @@ -/* - ../build/kraken InputFile.krak ../krakGrammer(tabComplete) OutputFile -*/ - -import vector:*; -import ChrisVec:*; -import io:*; - -|int| main() -{ - - |vector| aVec.construct(); - |vector| bVec.construct(); - - - |double| j; - for(|int| i = 0; i < 4; i++;) - { - j = i + 0.0; - aVec.addEnd(j); - bVec.addEnd(j); - } - - bVec.addEnd(12.3); - - |double| dotProd = dot(aVec, bVec); - - println("Dot Product has completed"); - println(); - println(); - |double| NormSquared = norm2(aVec); - println("Norm has completed"); - - - return 0; -} diff --git a/ChrisTest/ErrorLog.txt b/ChrisTest/ErrorLog.txt deleted file mode 100644 index cb2650d..0000000 --- a/ChrisTest/ErrorLog.txt +++ /dev/null @@ -1,5 +0,0 @@ -If two directories away from /GitHub/kraken/, can't find grammer file -error with templated functions and templates - -else statements don't work FIXED -!= doesn't work FIXED diff --git a/stdlib/matrix.krak b/stdlib/matrix.krak new file mode 100644 index 0000000..7edc235 --- /dev/null +++ b/stdlib/matrix.krak @@ -0,0 +1,166 @@ +import vector:*; +import io:*; + +typedef matrix (Destructable) { + var data: vector; + var rows: int; + var cols: int; + + ///****************************** + // Constructors + ///*****************************/ + + //Constructor with no arguments + //No matrix is made + fun construct(): matrix* { + rows = 0; + cols = 0; + data.construct(); + return this; + } + + //Constructor with single argument + //Creates an N x N matrix + fun construct(size: int): matrix* { + rows = size; + cols = size; + data.construct(rows*cols); + return this; + } + + //Constructor with two arguments + //Creates an N x M matrix + fun construct(r: int, c: int): matrix* { + rows = r; + cols = c; + data.construct(rows*cols); + return this; + } + + ///**************************** + // Utility Functions + ///***************************/ + + //Test using indexing at 0 + fun test0(i: int, j: int): bool { + + var index = i*rows + j; + + if(index > (rows * cols - 1) ) { + print("Index ("); + print(i); + print(", "); + print(j); + println(") is out of bounds."); + print("Max index = ("); + print(rows-1); + print(", "); + print(cols-1); + println(")."); + return false; + } + + return true; + } + + //Test using indexing at 1 + fun test1(i: int, j: int): bool { + + var index = (i-1)*rows + (j-1); + + if(index > (rows * cols - 1) ) { + print("Index ("); + print(i); + print(", "); + print(j); + println(") is out of bounds."); + print("Max index = ("); + print(rows); + print(", "); + print(cols); + println(")."); + return false; + } + + return true; + } + + //Access matrix element + fun at(i: int, j: int): double { + + var index = i*rows + j; + + if(test0(i,j)) + return data.at(index); + + return 0; + } + + //Set matrix element + fun set(i: int, j: int, num: double): void { + + var index = i*rows + j; + + if(test0(i,j)) + data.set(index,num); + + return; + } + + fun printMatrix(): void { + + for(var i: int = 0; i < rows; i++;) + { + for(var j: int = 0; j < cols; j++;) + { + print(at(i,j)); + print(" "); + } + println(" "); + } + + return; + } + + ///************************** + // Linear Algebra Functions + //**************************/ + + fun transpose(): void { + var val1: double; + var val2: double; + + for(var n: int = 0; n <= rows - 2; n++;) + for(var m: int = n+1; m <= rows - 1; m++;){ + val1 = at(n, m); + val2 = at(m, n); + + set(n, m, val2); + set(m, n, val1); + } + + return; + } + +};//end Matrix class + + + + + + + + + + + + + + + + + + + + + diff --git a/stdlib/vector.krak b/stdlib/vector.krak index 0b9ec23..faec699 100644 --- a/stdlib/vector.krak +++ b/stdlib/vector.krak @@ -13,6 +13,14 @@ typedef vector (Destructable) { data = new(8); return this; } + + fun construct(newSize: int): vector*{ + size = newSize; + available = newSize; + + data = new(newSize); + return this; + } fun destruct(): void { delete(data); @@ -39,6 +47,8 @@ typedef vector (Destructable) { println("Vector access out of bounds! Retuning 0th element as sanest option"); print("Vector tried to access element: "); println(index); + print("Max Index of vector: "); + println(size-1); return data[0]; } return data[index]; diff --git a/tests/test_topLevelVarInit/test_topLevelVarInit b/tests/test_topLevelVarInit/test_topLevelVarInit new file mode 100755 index 0000000..4d12f6d Binary files /dev/null and b/tests/test_topLevelVarInit/test_topLevelVarInit differ diff --git a/tests/test_topLevelVarInit/test_topLevelVarInit.c b/tests/test_topLevelVarInit/test_topLevelVarInit.c new file mode 100644 index 0000000..66ec2dc --- /dev/null +++ b/tests/test_topLevelVarInit/test_topLevelVarInit.c @@ -0,0 +1,253 @@ +#include "./test_topLevelVarInit.h" + +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/** + * Variable Declarations + */ + +int _dot__div_test_topLevelVarInit_dot_krak_scp_a; /*identifier*/ +/** + * Function Definitions + */ + + +int main() +{ + io_dot_krak_scp_println_int(_dot__div_test_topLevelVarInit_dot_krak_scp_a) ; + return 0; +} +void io_dot_krak_scp_print_char_P__(char* io_dot_krak_scp_toPrint) +{ + { + char* toPrint = io_dot_krak_scp_toPrint; + + printf(toPrint); + ; + }; + return; +} +void io_dot_krak_scp_print_string_dot_krak_scp_string(string_dot_krak_scp_string io_dot_krak_scp_toPrint) +{ + io_dot_krak_scp_print_char_P__(string_dot_krak_scp_string__toCharArray(&io_dot_krak_scp_toPrint) ) ; +} +void io_dot_krak_scp_print_int(int io_dot_krak_scp_toPrint) +{ + { + int toPrint = io_dot_krak_scp_toPrint; + + printf("%d", toPrint); + ; + }; + return; +} +void io_dot_krak_scp_print_float(float io_dot_krak_scp_toPrint) +{ + { + float toPrint = io_dot_krak_scp_toPrint; + + printf("%f", toPrint); + ; + }; + return; +} +void io_dot_krak_scp_print_double(double io_dot_krak_scp_toPrint) +{ + { + double toPrint = io_dot_krak_scp_toPrint; + + printf("%f", toPrint); + ; + }; + return; +} +void io_dot_krak_scp_println() +{ + io_dot_krak_scp_print_char_P__("\n") ; +} +void io_dot_krak_scp_println_char_P__(char* io_dot_krak_scp_toPrint) +{ + io_dot_krak_scp_print_char_P__(io_dot_krak_scp_toPrint) ; + io_dot_krak_scp_println() ; +} +void io_dot_krak_scp_println_string_dot_krak_scp_string(string_dot_krak_scp_string io_dot_krak_scp_toPrint) +{ + io_dot_krak_scp_println_char_P__(string_dot_krak_scp_string__toCharArray(&io_dot_krak_scp_toPrint) ) ; +} +void io_dot_krak_scp_println_int(int io_dot_krak_scp_toPrint) +{ + io_dot_krak_scp_print_int(io_dot_krak_scp_toPrint) ; + io_dot_krak_scp_println() ; +} +void io_dot_krak_scp_println_float(float io_dot_krak_scp_toPrint) +{ + io_dot_krak_scp_print_float(io_dot_krak_scp_toPrint) ; + io_dot_krak_scp_println() ; +} +void io_dot_krak_scp_println_double(double io_dot_krak_scp_toPrint) +{ + io_dot_krak_scp_print_double(io_dot_krak_scp_toPrint) ; + io_dot_krak_scp_println() ; +} +void mem_dot_krak_scp_delete_lessthan_char_greaterthan__char_P__(char* mem_dot_krak_scp_toDelete) +{ + mem_dot_krak_scp_free_lessthan_char_greaterthan__char_P__(mem_dot_krak_scp_toDelete) ; +} +void mem_dot_krak_scp_delete_lessthan_char_greaterthan__char_P___int(char* mem_dot_krak_scp_toDelete, int mem_dot_krak_scp_itemCount) +{ + mem_dot_krak_scp_delete_lessthan_char_greaterthan__char_P__(mem_dot_krak_scp_toDelete) ; +} +void mem_dot_krak_scp_free_lessthan_char_greaterthan__char_P__(char* mem_dot_krak_scp_memPtr) +{ + { + char* memPtr = mem_dot_krak_scp_memPtr; + + free(memPtr); + ; + }; +} +char* mem_dot_krak_scp_malloc_lessthan_char_greaterthan__int(int mem_dot_krak_scp_size) +{ + char* mem_dot_krak_scp_memPtr;; + { + int size = mem_dot_krak_scp_size; +char* memPtr = mem_dot_krak_scp_memPtr; + + memPtr = malloc(size); + mem_dot_krak_scp_memPtr = memPtr; +; + }; + return mem_dot_krak_scp_memPtr; +} +char* mem_dot_krak_scp_mem_scopeop_new_lessthan_char_greaterthan__int(int mem_dot_krak_scp_count) +{ + return mem_dot_krak_scp_malloc_lessthan_char_greaterthan__int(((mem_dot_krak_scp_sizeof_lessthan_char_greaterthan_() )*(mem_dot_krak_scp_count))) ; +} +char* mem_dot_krak_scp_new_lessthan_char_greaterthan__int(int mem_dot_krak_scp_count) +{ + return mem_dot_krak_scp_malloc_lessthan_char_greaterthan__int(((mem_dot_krak_scp_sizeof_lessthan_char_greaterthan_() )*(mem_dot_krak_scp_count))) ; +} +int mem_dot_krak_scp_sizeof_lessthan_char_greaterthan_() +{ + char mem_dot_krak_scp_testObj;; + int mem_dot_krak_scp_result;; + { + char testObj = mem_dot_krak_scp_testObj; + + int result = sizeof(testObj); + mem_dot_krak_scp_result = result; +; + }; + return mem_dot_krak_scp_result; +}/* Method Definitions for string */ + +string_dot_krak_scp_string* string_dot_krak_scp_string__construct(string_dot_krak_scp_string* this) +{ + vector_dot_krak_scp_vector_lessthan_char_greaterthan___construct(&this->string_dot_krak_scp_data) ; + return this; +} + +string_dot_krak_scp_string* string_dot_krak_scp_string__construct_char_P__(string_dot_krak_scp_string* this, char* string_dot_krak_scp_str) +{ + vector_dot_krak_scp_vector_lessthan_char_greaterthan___construct(&this->string_dot_krak_scp_data) ; + while (*(string_dot_krak_scp_str)) + { + vector_dot_krak_scp_vector_lessthan_char_greaterthan___addEnd_char(&this->string_dot_krak_scp_data,*(string_dot_krak_scp_str)) ; + string_dot_krak_scp_str = ((string_dot_krak_scp_str)+(1)); + }; +; + return this; +} + +char* string_dot_krak_scp_string__toCharArray(string_dot_krak_scp_string* this) +{ + char* string_dot_krak_scp_out = mem_dot_krak_scp_mem_scopeop_new_lessthan_char_greaterthan__int(((this->string_dot_krak_scp_data).vector_dot_krak_scp_size)) ;; + for ( int string_dot_krak_scp_i = 0;((string_dot_krak_scp_i)<(((this->string_dot_krak_scp_data).vector_dot_krak_scp_size))); string_dot_krak_scp_i++) + (string_dot_krak_scp_out)[string_dot_krak_scp_i] = vector_dot_krak_scp_vector_lessthan_char_greaterthan___get_int(&this->string_dot_krak_scp_data,string_dot_krak_scp_i) ; +; + return string_dot_krak_scp_out; +} +/* Done with string */ + +int util_dot_krak_scp_lesser_lessthan_int_greaterthan__int_int(int util_dot_krak_scp_a, int util_dot_krak_scp_b) +{ + if (((util_dot_krak_scp_a)>(util_dot_krak_scp_b))) + { return util_dot_krak_scp_b; + }; + return util_dot_krak_scp_a; +}/* Method Definitions for vector */ + +vector_dot_krak_scp_vector_lessthan_char_greaterthan_* vector_dot_krak_scp_vector_lessthan_char_greaterthan___construct(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this) +{ + this->vector_dot_krak_scp_size = 0; + this->vector_dot_krak_scp_available = 8; + this->vector_dot_krak_scp_data = mem_dot_krak_scp_new_lessthan_char_greaterthan__int(8) ; + return this; +} + +void vector_dot_krak_scp_vector_lessthan_char_greaterthan___destruct(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this) +{ + mem_dot_krak_scp_delete_lessthan_char_greaterthan__char_P__(this->vector_dot_krak_scp_data) ; +} + +bool vector_dot_krak_scp_vector_lessthan_char_greaterthan___resize_int(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, int vector_dot_krak_scp_newSize) +{ + char* vector_dot_krak_scp_newData = mem_dot_krak_scp_new_lessthan_char_greaterthan__int(vector_dot_krak_scp_newSize) ;; + if (!(vector_dot_krak_scp_newData)) + { return false; + }; + for ( int vector_dot_krak_scp_i = 0;((vector_dot_krak_scp_i)<(util_dot_krak_scp_lesser_lessthan_int_greaterthan__int_int(this->vector_dot_krak_scp_size, vector_dot_krak_scp_newSize) )); vector_dot_krak_scp_i++) + (vector_dot_krak_scp_newData)[vector_dot_krak_scp_i] = (this->vector_dot_krak_scp_data)[vector_dot_krak_scp_i]; +; + mem_dot_krak_scp_delete_lessthan_char_greaterthan__char_P___int(this->vector_dot_krak_scp_data, 0) ; + this->vector_dot_krak_scp_data = vector_dot_krak_scp_newData; + this->vector_dot_krak_scp_available = vector_dot_krak_scp_newSize; + return true; +} + +char vector_dot_krak_scp_vector_lessthan_char_greaterthan___at_int(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, int vector_dot_krak_scp_index) +{ + return vector_dot_krak_scp_vector_lessthan_char_greaterthan___get_int(this,vector_dot_krak_scp_index) ; +} + +char vector_dot_krak_scp_vector_lessthan_char_greaterthan___get_int(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, int vector_dot_krak_scp_index) +{ + if (((((vector_dot_krak_scp_index)<(0)))||(((vector_dot_krak_scp_index)>=(this->vector_dot_krak_scp_size))))) + { + io_dot_krak_scp_println_char_P__("Vector access out of bounds! Retuning 0th element as sanest option") ; + io_dot_krak_scp_print_char_P__("Vector tried to access element: ") ; + io_dot_krak_scp_println_int(vector_dot_krak_scp_index) ; + io_dot_krak_scp_print_char_P__("Max Index of vector: ") ; + io_dot_krak_scp_println_int(((this->vector_dot_krak_scp_size)-(1))) ; + return (this->vector_dot_krak_scp_data)[0]; + }; + return (this->vector_dot_krak_scp_data)[vector_dot_krak_scp_index]; +} + +char* vector_dot_krak_scp_vector_lessthan_char_greaterthan___getBackingMemory(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this) +{ + return this->vector_dot_krak_scp_data; +} + +void vector_dot_krak_scp_vector_lessthan_char_greaterthan___set_int_char(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, int vector_dot_krak_scp_index, char vector_dot_krak_scp_dataIn) +{ + if (((((vector_dot_krak_scp_index)<(0)))||(((vector_dot_krak_scp_index)>=(this->vector_dot_krak_scp_size))))) + { return; + }; + (this->vector_dot_krak_scp_data)[vector_dot_krak_scp_index] = vector_dot_krak_scp_dataIn; +} + +void vector_dot_krak_scp_vector_lessthan_char_greaterthan___addEnd_char(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, char vector_dot_krak_scp_dataIn) +{ + this->vector_dot_krak_scp_size++; + if (((this->vector_dot_krak_scp_size)>=(this->vector_dot_krak_scp_available))) + { vector_dot_krak_scp_vector_lessthan_char_greaterthan___resize_int(this,((this->vector_dot_krak_scp_size)*(2))) ; + }; + (this->vector_dot_krak_scp_data)[((this->vector_dot_krak_scp_size)-(1))] = vector_dot_krak_scp_dataIn; +} +/* Done with vector */ diff --git a/tests/test_topLevelVarInit/test_topLevelVarInit.h b/tests/test_topLevelVarInit/test_topLevelVarInit.h new file mode 100644 index 0000000..c95cb90 --- /dev/null +++ b/tests/test_topLevelVarInit/test_topLevelVarInit.h @@ -0,0 +1,129 @@ +#include +#include +#include +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/*unknown declaration named translation_unit*/ +/** + * Plain Typedefs + */ + +/*typedef string */ +typedef struct __struct_dummy_string_dot_krak_scp_string__ string_dot_krak_scp_string; +/*typedef vector */ +/* non instantiated template vector *//*typedef vector */ +typedef struct __struct_dummy_vector_dot_krak_scp_vector_lessthan_char_greaterthan___ vector_dot_krak_scp_vector_lessthan_char_greaterthan_; +/** + * Import Includes + */ + +/** + * Top Level C Passthrough + */ + + + #include + + #include +/** + * Extern Variable Declarations + */ + +extern int a; /*extern identifier*/ +/** + * Class Structs + */ + +struct __struct_dummy_vector_dot_krak_scp_vector_lessthan_char_greaterthan___ { + char* vector_dot_krak_scp_data; + int vector_dot_krak_scp_size; + int vector_dot_krak_scp_available; +}; +struct __struct_dummy_string_dot_krak_scp_string__ { + vector_dot_krak_scp_vector_lessthan_char_greaterthan_ string_dot_krak_scp_data; +}; +/** + * Function Prototypes + */ + + +int main(); /*func*/ + +void io_dot_krak_scp_print_char_P__(char* io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_print_string_dot_krak_scp_string(string_dot_krak_scp_string io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_print_int(int io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_print_float(float io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_print_double(double io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_println(); /*func*/ + +void io_dot_krak_scp_println_char_P__(char* io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_println_string_dot_krak_scp_string(string_dot_krak_scp_string io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_println_int(int io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_println_float(float io_dot_krak_scp_toPrint); /*func*/ + +void io_dot_krak_scp_println_double(double io_dot_krak_scp_toPrint); /*func*/ +/* template function delete NoValue */ +/* template function delete NoValue */ +/* template function delete NoValue */ +/* template function delete NoValue */ + +void mem_dot_krak_scp_delete_lessthan_char_greaterthan__char_P__(char* mem_dot_krak_scp_toDelete); /*func*/ + +void mem_dot_krak_scp_delete_lessthan_char_greaterthan__char_P___int(char* mem_dot_krak_scp_toDelete, int mem_dot_krak_scp_itemCount); /*func*/ +/* template function free NoValue */ + +void mem_dot_krak_scp_free_lessthan_char_greaterthan__char_P__(char* mem_dot_krak_scp_memPtr); /*func*/ +/* template function malloc NoValue */ + +char* mem_dot_krak_scp_malloc_lessthan_char_greaterthan__int(int mem_dot_krak_scp_size); /*func*/ + +char* mem_dot_krak_scp_mem_scopeop_new_lessthan_char_greaterthan__int(int mem_dot_krak_scp_count); /*func*/ +/* template function new NoValue */ +/* template function new NoValue */ + +char* mem_dot_krak_scp_new_lessthan_char_greaterthan__int(int mem_dot_krak_scp_count); /*func*/ +/* template function sizeof NoValue */ + +int mem_dot_krak_scp_sizeof_lessthan_char_greaterthan_(); /*func*/ +/* Method Prototypes for string */ + +string_dot_krak_scp_string* string_dot_krak_scp_string__construct(string_dot_krak_scp_string* this); + +string_dot_krak_scp_string* string_dot_krak_scp_string__construct_char_P__(string_dot_krak_scp_string* this, char* string_dot_krak_scp_str); + +char* string_dot_krak_scp_string__toCharArray(string_dot_krak_scp_string* this); +/* Done with string */ +/* template function greater NoValue */ +/* template function lesser NoValue */ + +int util_dot_krak_scp_lesser_lessthan_int_greaterthan__int_int(int util_dot_krak_scp_a, int util_dot_krak_scp_b); /*func*/ +/* Method Prototypes for vector */ + +vector_dot_krak_scp_vector_lessthan_char_greaterthan_* vector_dot_krak_scp_vector_lessthan_char_greaterthan___construct(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this); + +void vector_dot_krak_scp_vector_lessthan_char_greaterthan___destruct(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this); + +bool vector_dot_krak_scp_vector_lessthan_char_greaterthan___resize_int(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, int vector_dot_krak_scp_newSize); + +char vector_dot_krak_scp_vector_lessthan_char_greaterthan___at_int(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, int vector_dot_krak_scp_index); + +char vector_dot_krak_scp_vector_lessthan_char_greaterthan___get_int(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, int vector_dot_krak_scp_index); + +char* vector_dot_krak_scp_vector_lessthan_char_greaterthan___getBackingMemory(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this); + +void vector_dot_krak_scp_vector_lessthan_char_greaterthan___set_int_char(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, int vector_dot_krak_scp_index, char vector_dot_krak_scp_dataIn); + +void vector_dot_krak_scp_vector_lessthan_char_greaterthan___addEnd_char(vector_dot_krak_scp_vector_lessthan_char_greaterthan_* this, char vector_dot_krak_scp_dataIn); +/* Done with vector */ diff --git a/tests/test_topLevelVarInit/test_topLevelVarInit.results b/tests/test_topLevelVarInit/test_topLevelVarInit.results new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/test_topLevelVarInit/test_topLevelVarInit.results @@ -0,0 +1 @@ +0 diff --git a/tests/test_topLevelVarInit/test_topLevelVarInit.sh b/tests/test_topLevelVarInit/test_topLevelVarInit.sh new file mode 100755 index 0000000..30705f8 --- /dev/null +++ b/tests/test_topLevelVarInit/test_topLevelVarInit.sh @@ -0,0 +1,2 @@ +#!/bin/sh +cc -std=c99 ./test_topLevelVarInit.c -o ./test_topLevelVarInit \ No newline at end of file