Skip to content

Commit

Permalink
csimlab
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmarkarl committed Feb 25, 2022
1 parent 46f50d3 commit c37c691
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
28 changes: 23 additions & 5 deletions csimlab/arith.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ template <typename T, typename K> void t_copy( T buffer, int length, K value, in
}

template <typename T, typename K> void t_add( T buffer, int length, K value, int vallen ) {
println("lllalalal\n");
if( vallen < length ) {
for( int i = 0; i < length; i++ ) {
buffer[i] += value[i%vallen];
Expand Down Expand Up @@ -546,9 +547,18 @@ template<template<typename T, typename V> class c_func, typename K> void specari
}

template<template<typename T, typename V> class c_func, typename K> void subarith( K kbuf, long klen ) {
//printf("subarith\n");
printf("subarith\n");
if( data.length == -1 ) {

if( data.type == -66 ) c_func< c_simlab<double&>&,K >( *(c_simlab<double&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -65 ) c_func< c_simlab<long long&>&,K >( *(c_simlab<long long&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -64 ) c_func< c_simlab<unsigned long long&>&,K >( *(c_simlab<unsigned long long&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -34 ) c_func< c_simlab<float&>&,K >( *(c_simlab<float&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -33 ) c_func< c_simlab<int&>&,K >( *(c_simlab<int&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -32 ) {
printf("yes2! %lld\n", klen);
c_func< c_simlab<unsigned int&>&,K >( *(c_simlab<unsigned int&>*)data.buffer, data.length, kbuf, klen );
}
else if( data.type == -16 ) c_func< c_simlab<short&>&,K >( *(c_simlab<short&>*)data.buffer, data.length, kbuf, klen );
} else if( data.length == 0 ) {
if( data.type == 66 ) c_func<double*,K>( (double*)&data.buffer, 1, kbuf, klen );
else if( data.type == 65 ) {
Expand All @@ -564,10 +574,16 @@ template<template<typename T, typename V> class c_func, typename K> void subarit
} else if( data.type < 0 ) {
if( data.type == -66 ) c_func< c_simlab<double&>&,K >( *(c_simlab<double&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -65 ) c_func< c_simlab<long long&>&,K >( *(c_simlab<long long&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -64 ) c_func< c_simlab<unsigned long long&>&,K >( *(c_simlab<unsigned long long&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -64 ) {
printf("lala\n");
c_func< c_simlab<unsigned long long&>&,K >( *(c_simlab<unsigned long long&>*)data.buffer, data.length, kbuf, klen );
}
else if( data.type == -34 ) c_func< c_simlab<float&>&,K >( *(c_simlab<float&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -33 ) c_func< c_simlab<int&>&,K >( *(c_simlab<int&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -32 ) c_func< c_simlab<unsigned int&>&,K >( *(c_simlab<unsigned int&>*)data.buffer, data.length, kbuf, klen );
else if( data.type == -32 ) {
printf("yes!\n");
c_func< c_simlab<unsigned int&>&,K >( *(c_simlab<unsigned int&>*)data.buffer, data.length, kbuf, klen );
}
else if( data.type == -16 ) c_func< c_simlab<short&>&,K >( *(c_simlab<short&>*)data.buffer, data.length, kbuf, klen );
} else {
if( data.type == 66 ) c_func<double*,K>( (double*)data.buffer, data.length, kbuf, klen );
Expand All @@ -592,12 +608,14 @@ template<template<typename T, typename K> class c_func> void specarith( simlab &
}

template<template<typename T, typename K> class c_func> void arith( simlab & value ) {
//printf("arith\n");
printf("arith %lld %lld %lld\n",value.length,value.buffer,value.type);
if( value.length == 0 ) {
if( value.type == 32 ) {
printf("heyhey\n");
c_const<unsigned int> sl( *(unsigned int*)&value.buffer );
subarith< c_func, c_simlab<unsigned int>& >( sl, 1 );
} else if( value.type == 33 ) {
printf("heyhey2\n");
c_const<int> sl( *(int*)&value.buffer );
subarith< c_func, c_simlab<int>& >( sl, 1 );
} else if( value.type == 34 ) {
Expand Down
4 changes: 2 additions & 2 deletions csimlab/printers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ JNIEXPORT int printi( simlab sl ) {
va_end( args );
//printf("%d %d %d\n", (int)val.length, (int)val.type, (int)val.buffer );*/

printf( "%d %d %d\n", (int)sl.buffer, (int)sl.type, (int)sl.length );
printf( "%d %d %d\n", (int)data.buffer, (int)data.type, (int)data.length );
//printf( "%d %d %d\n", (int)sl.buffer, (int)sl.type, (int)sl.length );
//printf( "%d %d %d\n", (int)data.buffer, (int)data.type, (int)data.length );
passnext.dw = sl;
return print( "%d\t", "\n", passnext );
}
Expand Down
28 changes: 14 additions & 14 deletions csimlab/stuff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4251,7 +4251,7 @@ JNIEXPORT int lg10( simlab wh ) {
func.type = 32;
func.length = 0;

func.buffer = (long)log10;
func.buffer = (long)(double (*)(double))log10;
dfunc( func, wh );

return current;
Expand All @@ -4262,7 +4262,7 @@ JNIEXPORT int simlab_log2( simlab wh ) {
func.type = 32;
func.length = 0;

func.buffer = (long)log2;
func.buffer = (long)(double (*)(double))log2;
dfunc( func, wh );

return 1;
Expand All @@ -4273,7 +4273,7 @@ JNIEXPORT int simlab_ln( simlab wh ) {
func.type = 32;
func.length = 0;

func.buffer = (long)log;
func.buffer = (long)(double (*)(double))log;
dfunc( func, wh );

return 1;
Expand All @@ -4284,7 +4284,7 @@ JNIEXPORT int simlab_log10( simlab wh ) {
func.type = 32;
func.length = 0;

func.buffer = (long)log10;
func.buffer = (long)(double (*)(double))log10;
dfunc( func, wh );

return 1;
Expand All @@ -4296,11 +4296,11 @@ JNIEXPORT int simlab_cos( simlab wh ) {
func.length = 0;

if( data.type == 34 ) {
func.buffer = (long)cos;
dfunc( func, wh );
} else {
func.buffer = (long)cosf;
func.buffer = (long)(float (*)(float))cosf;
ffunc( func, wh );
} else {
func.buffer = (long)(double (*)(double))cos;
dfunc( func, wh );
}

return current;
Expand All @@ -4327,10 +4327,10 @@ JNIEXPORT int simlab_sin( simlab wh ) {
func.length = 0;

if( data.type == 34 ) {
func.buffer = (long)sinf;
func.buffer = (long)(float (*)(float))sinf;
ffunc( func, wh );
} else {
func.buffer = (long)sin;
func.buffer = (long)(double (*)(double))sin;
dfunc( func, wh );
}
return 1;
Expand All @@ -4342,11 +4342,11 @@ JNIEXPORT int simlab_asin( simlab wh ) {
func.length = 0;

if( data.type == 34 ) {
func.buffer = (long)asin;
dfunc( func, wh );
} else {
func.buffer = (long)acosf;
func.buffer = (long)(float (*)(float))asinf;
ffunc( func, wh );
} else {
func.buffer = (long)(double (*)(double))acos;
dfunc( func, wh );
}
return current;
}
Expand Down

0 comments on commit c37c691

Please sign in to comment.