From 49ef9ee461f08588e9bc7699c9b197add620c582 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 18 Feb 2022 23:50:14 +0100 Subject: [PATCH] gac: remove support for static linking This has virtually no use case anymore since dynamic linking is supported everywhere. At the same time it is an impediment for `make install` support. So it just doesn't seem worth the effort to preserve it. --- Makefile.rules | 2 - cnf/gac.in | 86 +- tst/test-compile/README.md | 2 - tst/test-compile/and_filter.g.static.c | 623 ----- tst/test-compile/assert.g.static.c | 331 --- tst/test-compile/basics.g.static.c | 2935 -------------------- tst/test-compile/callfunc.g.static.c | 1247 --------- tst/test-compile/function_types.g.static.c | 674 ----- tst/test-compile/info.g.static.c | 281 -- tst/test-compile/plus.g.static.c | 139 - tst/test-compile/print_various.g.static.c | 255 -- tst/test-compile/ranges.g.static.c | 454 --- tst/test-compile/run_all.sh | 11 - tst/test-compile/run_compiled_static.sh | 29 - 14 files changed, 6 insertions(+), 7063 deletions(-) delete mode 100644 tst/test-compile/and_filter.g.static.c delete mode 100644 tst/test-compile/assert.g.static.c delete mode 100644 tst/test-compile/basics.g.static.c delete mode 100644 tst/test-compile/callfunc.g.static.c delete mode 100644 tst/test-compile/function_types.g.static.c delete mode 100644 tst/test-compile/info.g.static.c delete mode 100644 tst/test-compile/plus.g.static.c delete mode 100644 tst/test-compile/print_various.g.static.c delete mode 100644 tst/test-compile/ranges.g.static.c delete mode 100755 tst/test-compile/run_compiled_static.sh diff --git a/Makefile.rules b/Makefile.rules index 28a0d05a92..150bc6af09 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -763,8 +763,6 @@ GAP_CPPFLAGS="$(GAP_PKG_CPPFLAGS)" GAP_LDFLAGS="$(GAP_LDFLAGS)" GAP_LIBS="$(GAP_LIBS)" -GAP_OBJS="$(OBJS)" - JULIA="$(JULIA)" JULIA_CPPFLAGS="$(JULIA_CPPFLAGS)" JULIA_LDFLAGS="$(JULIA_LDFLAGS)" diff --git a/cnf/gac.in b/cnf/gac.in index 8ba5cb1ca0..92b78135c5 100644 --- a/cnf/gac.in +++ b/cnf/gac.in @@ -66,7 +66,6 @@ libtool="@SHELL@ ${abs_top_builddir}/libtool" # These three should be filled in by the standard autoconf procedures c_compiler="$libtool --mode=compile $GAP_CC" cxx_compiler="$libtool --mode=compile $GAP_CXX" -c_linker="$libtool --mode=link $GAP_CC -export-dynamic" # These will need special care c_dyn_linker="$libtool --mode=link $GAP_CC -module -avoid-version -rpath $libdir" @@ -134,24 +133,11 @@ c_link_dyn () { } -############################################################################# -## -#F c_link -## -c_link () { - mkdir -p $(dirname $1) - echo ${c_linker} ${GAP_LDFLAGS} -o $1 $2 ${GAP_LIBS} - ${c_linker} ${GAP_LDFLAGS} -o $1 $2 ${GAP_LIBS} || exit 1 -} - ############################################################################# ## #F process_o_file ## ## Compile according to comp_mode and comp_howfar -## -## This does everything except the final link phase in the static case -## in that case it adds the basename and object file path of $names and $objects ## process_o_file () { @@ -171,9 +157,6 @@ process_o_file () { #F process_c_file ## ## Compile according to comp_mode and comp_howfar -## -## This does everything except the final link phase in the static case -## in that case it adds the basename and object file path of $names and $objects ## process_c_file () { @@ -224,9 +207,6 @@ process_cxx_file () { #F process_gap_file ## ## Compile according to comp_mode and comp_howfar -## -## This does everything except the final link phase in the static case -## in that case it adds the basename and object file path of $names and $objects ## process_gap_file () { @@ -329,49 +309,6 @@ if [ "X${inputs}" = "X" ]; then fi - - -############################################################################# -## -#F make_compstat -## - -make_compstat () { - # make 'compstat.c' and compile it - temps_c="${temps_c} ${gactmp}/$$compstat.c" - ( - echo "/* made by 'gac', can be thrown away */" - echo "#include \"compiled.h\"" - - echo "extern StructInitInfo * Init__type1 ( void );" - echo "extern StructInitInfo * Init__oper1( void );" - - for name in ${names}; do - echo "extern StructInitInfo * Init__${name} ( void );" - done - - echo "InitInfoFunc CompInitFuncs[] = {" - echo " Init__type1," - echo " Init__oper1," - - for name in ${names}; do - echo " Init__${name}," - done - echo " 0" - echo "};" - ) > ${gactmp}/$$compstat.c - - temps_o="${gactmp}/$$compstat.lo ${temps_o}" - c_compile ${gactmp}/$$compstat.o ${gactmp}/$$compstat.c "${GAP_CFLAGS}" - if [ "$savetemps" = "true" ]; then - echo "Leaving temp file " ${gactmp}/$$compstat.c - else - echo rm -f ${gactmp}/$$compstat.c - rm -f ${gactmp}/$$compstat.c - fi - objects="${gactmp}/$$compstat.lo ${objects}" -} - make_tmpdir () { if command -v mktemp >/dev/null 2>&1 ; then gactmp=$(mktemp -d -t "gacXXXXXXX") @@ -430,26 +367,15 @@ for input in ${inputs}; do done -# static link phase +# link phase if [ $comp_howfar = "link" ]; then if [ $comp_mode = "comp_static" ]; then - make_compstat - - # link everything together - if [ "X${output}" = "X" ]; then output="gacout"; fi - - for object in $GAP_OBJS; do - if [ ${object} != "build/obj/src/compstat.c.lo" ]; then - objects="${abs_top_builddir}/${object} ${objects}" - fi - done - - c_link ${output} "${objects}" - - else - if [ "X${output}" = "X" ]; then output="${name}.la"; fi - c_link_dyn ${output} "${objects}" + echo "$0: static linking is not supported anymore, use -d / --dynamic" + exit 1 fi + + if [ "X${output}" = "X" ]; then output="${name}.la"; fi + c_link_dyn ${output} "${objects}" if [ "$savetemps" = "true" ]; then echo "Leaving object files " ${temps_o} diff --git a/tst/test-compile/README.md b/tst/test-compile/README.md index 5093dee05a..425c9f4020 100644 --- a/tst/test-compile/README.md +++ b/tst/test-compile/README.md @@ -2,8 +2,6 @@ These tests are designed to check the GAP -> C compiler ./run_compiled_dynamic.sh : Run a single test, after compiling it into a dynamic module and loading it -./run_compiled_static.sh : Run a single test, after compiling it - into a static module and loading it ./run_interpreted.sh : Run a single test without compiling it ./run_all.sh : Run all tests with and without compiling diff --git a/tst/test-compile/and_filter.g.static.c b/tst/test-compile/and_filter.g.static.c deleted file mode 100644 index 65a998febf..0000000000 --- a/tst/test-compile/and_filter.g.static.c +++ /dev/null @@ -1,623 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "-101028112" - -/* global variables used in handlers */ -static GVar G_Print; -static Obj GF_Print; -static GVar G_CALL__WITH__CATCH; -static Obj GF_CALL__WITH__CATCH; -static GVar G_runtest; -static GVar G_IsAssociative; -static Obj GC_IsAssociative; -static GVar G_BreakOnError; -static GVar G_Center; -static Obj GC_Center; - -/* record names used in handlers */ - -/* information for the functions */ -static Obj NameFunc[9]; -static Obj FileName; - -/* handler for function 3 */ -static Obj HdlrFunc3 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return false and 1; */ - t_2 = False; - if ( t_2 == False ) { - t_1 = t_2; - } - else if ( t_2 == True ) { - CHECK_BOOL( INTOBJ_INT(1) ); - t_1 = INTOBJ_INT(1); - } - else if (IS_FILTER( t_2 ) ) { - t_1 = NewAndFilter( t_2, INTOBJ_INT(1) ); - } - else { - RequireArgumentEx(0, t_2, "", - "must be 'true' or 'false' or a filter" ); - } - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 4 */ -static Obj HdlrFunc4 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return true or 1; */ - t_3 = True; - t_2 = (Obj)(UInt)(t_3 != False); - t_1 = (t_2 ? True : False); - if ( t_1 == False ) { - CHECK_BOOL( INTOBJ_INT(1) ); - t_3 = (Obj)(UInt)(INTOBJ_INT(1) != False); - t_1 = (t_3 ? True : False); - } - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 5 */ -static Obj HdlrFunc5 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return Center and IsAssociative; */ - t_2 = GC_Center; - CHECK_BOUND( t_2, "Center" ); - if ( t_2 == False ) { - t_1 = t_2; - } - else if ( t_2 == True ) { - t_3 = GC_IsAssociative; - CHECK_BOUND( t_3, "IsAssociative" ); - CHECK_BOOL( t_3 ); - t_1 = t_3; - } - else if (IS_FILTER( t_2 ) ) { - t_4 = GC_IsAssociative; - CHECK_BOUND( t_4, "IsAssociative" ); - t_1 = NewAndFilter( t_2, t_4 ); - } - else { - RequireArgumentEx(0, t_2, "", - "must be 'true' or 'false' or a filter" ); - } - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 6 */ -static Obj HdlrFunc6 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return IsAssociative and Center; */ - t_2 = GC_IsAssociative; - CHECK_BOUND( t_2, "IsAssociative" ); - if ( t_2 == False ) { - t_1 = t_2; - } - else if ( t_2 == True ) { - t_3 = GC_Center; - CHECK_BOUND( t_3, "Center" ); - CHECK_BOOL( t_3 ); - t_1 = t_3; - } - else if (IS_FILTER( t_2 ) ) { - t_4 = GC_Center; - CHECK_BOUND( t_4, "Center" ); - t_1 = NewAndFilter( t_2, t_4 ); - } - else { - RequireArgumentEx(0, t_2, "", - "must be 'true' or 'false' or a filter" ); - } - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 7 */ -static Obj HdlrFunc7 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return 1 and false; */ - if ( INTOBJ_INT(1) == False ) { - t_1 = INTOBJ_INT(1); - } - else if ( INTOBJ_INT(1) == True ) { - t_2 = False; - t_1 = t_2; - } - else if (IS_FILTER( INTOBJ_INT(1) ) ) { - t_3 = False; - t_1 = NewAndFilter( INTOBJ_INT(1), t_3 ); - } - else { - RequireArgumentEx(0, INTOBJ_INT(1), "", - "must be 'true' or 'false' or a filter" ); - } - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 8 */ -static Obj HdlrFunc8 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return 1 or true; */ - CHECK_BOOL( INTOBJ_INT(1) ); - t_2 = (Obj)(UInt)(INTOBJ_INT(1) != False); - t_1 = (t_2 ? True : False); - if ( t_1 == False ) { - t_4 = True; - t_3 = (Obj)(UInt)(t_4 != False); - t_1 = (t_3 ? True : False); - } - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Obj t_5 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( false and 1, "\n" ); */ - t_1 = GF_Print; - t_3 = False; - if ( t_3 == False ) { - t_2 = t_3; - } - else if ( t_3 == True ) { - CHECK_BOOL( INTOBJ_INT(1) ); - t_2 = INTOBJ_INT(1); - } - else if (IS_FILTER( t_3 ) ) { - t_2 = NewAndFilter( t_3, INTOBJ_INT(1) ); - } - else { - RequireArgumentEx(0, t_3, "", - "must be 'true' or 'false' or a filter" ); - } - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( true or 1, "\n" ); */ - t_1 = GF_Print; - t_4 = True; - t_3 = (Obj)(UInt)(t_4 != False); - t_2 = (t_3 ? True : False); - if ( t_2 == False ) { - CHECK_BOOL( INTOBJ_INT(1) ); - t_4 = (Obj)(UInt)(INTOBJ_INT(1) != False); - t_2 = (t_4 ? True : False); - } - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( function ( ) - return false and 1; - end( ), "\n" ); */ - t_1 = GF_Print; - t_3 = NewFunction( NameFunc[3], 0, 0, HdlrFunc3 ); - SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); - t_4 = NewFunctionBody(); - SET_STARTLINE_BODY(t_4, 5); - SET_ENDLINE_BODY(t_4, 5); - SET_FILENAME_BODY(t_4, FileName); - SET_BODY_FUNC(t_3, t_4); - if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) { - t_2 = CALL_0ARGS( t_3 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( function ( ) - return true or 1; - end( ), "\n" ); */ - t_1 = GF_Print; - t_3 = NewFunction( NameFunc[4], 0, 0, HdlrFunc4 ); - SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); - t_4 = NewFunctionBody(); - SET_STARTLINE_BODY(t_4, 6); - SET_ENDLINE_BODY(t_4, 6); - SET_FILENAME_BODY(t_4, FileName); - SET_BODY_FUNC(t_3, t_4); - if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) { - t_2 = CALL_0ARGS( t_3 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( IsAssociative and IsAssociative, "\n" ); */ - t_1 = GF_Print; - t_3 = GC_IsAssociative; - CHECK_BOUND( t_3, "IsAssociative" ); - if ( t_3 == False ) { - t_2 = t_3; - } - else if ( t_3 == True ) { - t_4 = GC_IsAssociative; - CHECK_BOUND( t_4, "IsAssociative" ); - CHECK_BOOL( t_4 ); - t_2 = t_4; - } - else if (IS_FILTER( t_3 ) ) { - t_5 = GC_IsAssociative; - CHECK_BOUND( t_5, "IsAssociative" ); - t_2 = NewAndFilter( t_3, t_5 ); - } - else { - RequireArgumentEx(0, t_3, "", - "must be 'true' or 'false' or a filter" ); - } - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* BreakOnError := false; */ - t_1 = False; - AssGVar( G_BreakOnError, t_1 ); - - /* CALL_WITH_CATCH( function ( ) - return Center and IsAssociative; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[5], 0, 0, HdlrFunc5 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 13); - SET_ENDLINE_BODY(t_3, 13); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - return IsAssociative and Center; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[6], 0, 0, HdlrFunc6 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 16); - SET_ENDLINE_BODY(t_3, 16); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - return 1 and false; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[7], 0, 0, HdlrFunc7 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 18); - SET_ENDLINE_BODY(t_3, 18); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - return 1 or true; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[8], 0, 0, HdlrFunc8 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 19); - SET_ENDLINE_BODY(t_3, 19); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* runtest := function ( ) - Print( false and 1, "\n" ); - Print( true or 1, "\n" ); - Print( function ( ) - return false and 1; - end( ), "\n" ); - Print( function ( ) - return true or 1; - end( ), "\n" ); - Print( IsAssociative and IsAssociative, "\n" ); - BreakOnError := false; - CALL_WITH_CATCH( function ( ) - return Center and IsAssociative; - end, [ ] ); - CALL_WITH_CATCH( function ( ) - return IsAssociative and Center; - end, [ ] ); - CALL_WITH_CATCH( function ( ) - return 1 and false; - end, [ ] ); - CALL_WITH_CATCH( function ( ) - return 1 or true; - end, [ ] ); - return; - end; */ - t_1 = NewFunction( NameFunc[2], 0, 0, HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 1); - SET_ENDLINE_BODY(t_2, 21); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_Print = GVarName( "Print" ); - G_CALL__WITH__CATCH = GVarName( "CALL_WITH_CATCH" ); - G_runtest = GVarName( "runtest" ); - G_IsAssociative = GVarName( "IsAssociative" ); - G_BreakOnError = GVarName( "BreakOnError" ); - G_Center = GVarName( "Center" ); - - /* record names used in handlers */ - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - NameFunc[3] = 0; - NameFunc[4] = 0; - NameFunc[5] = 0; - NameFunc[6] = 0; - NameFunc[7] = 0; - NameFunc[8] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - InitFopyGVar( "Print", &GF_Print ); - InitFopyGVar( "CALL_WITH_CATCH", &GF_CALL__WITH__CATCH ); - InitCopyGVar( "IsAssociative", &GC_IsAssociative ); - InitCopyGVar( "Center", &GC_Center ); - - /* information for the functions */ - InitGlobalBag( &FileName, "and_filter.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "and_filter.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "and_filter.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "and_filter.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "and_filter.g:NameFunc[2]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc3, "and_filter.g:HdlrFunc3("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[3]), "and_filter.g:NameFunc[3]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc4, "and_filter.g:HdlrFunc4("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[4]), "and_filter.g:NameFunc[4]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc5, "and_filter.g:HdlrFunc5("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[5]), "and_filter.g:NameFunc[5]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc6, "and_filter.g:HdlrFunc6("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[6]), "and_filter.g:NameFunc[6]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc7, "and_filter.g:HdlrFunc7("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[7]), "and_filter.g:NameFunc[7]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc8, "and_filter.g:HdlrFunc8("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[8]), "and_filter.g:NameFunc[8]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "and_filter.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "and_filter.g", - .crc = -101028112, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__and__filter ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/assert.g.static.c b/tst/test-compile/assert.g.static.c deleted file mode 100644 index ebb6804b24..0000000000 --- a/tst/test-compile/assert.g.static.c +++ /dev/null @@ -1,331 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "47091879" - -/* global variables used in handlers */ -static GVar G_Print; -static Obj GF_Print; -static GVar G_SetAssertionLevel; -static Obj GF_SetAssertionLevel; -static GVar G_AssertionLevel; -static Obj GF_AssertionLevel; -static GVar G_runtest; - -/* record names used in handlers */ - -/* information for the functions */ -static Obj NameFunc[3]; -static Obj FileName; - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( AssertionLevel( ), "\n" ); */ - t_1 = GF_Print; - t_3 = GF_AssertionLevel; - if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) { - t_2 = CALL_0ARGS( t_3 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 1 ) { - t_2 = False; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - t_2 = MakeString( "fail-A" ); - if ( t_2 != (Obj)(UInt)0 ){ - if ( IS_STRING_REP ( t_2 ) ) - PrintString1( t_2); - else - PrintObj(t_2); - } - } - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 1 ) { - t_2 = False; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - AssertionFailure(); - } - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 0 ) { - t_2 = True; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - t_2 = MakeString( "fail-B" ); - if ( t_2 != (Obj)(UInt)0 ){ - if ( IS_STRING_REP ( t_2 ) ) - PrintString1( t_2); - else - PrintObj(t_2); - } - } - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 0 ) { - t_2 = True; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - AssertionFailure(); - } - } - - /* SetAssertionLevel( 2 ); */ - t_1 = GF_SetAssertionLevel; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, INTOBJ_INT(2) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(2) ) ); - } - - /* Print( AssertionLevel( ), "\n" ); */ - t_1 = GF_Print; - t_3 = GF_AssertionLevel; - if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) { - t_2 = CALL_0ARGS( t_3 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 3 ) { - t_2 = False; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - t_2 = MakeString( "fail-C" ); - if ( t_2 != (Obj)(UInt)0 ){ - if ( IS_STRING_REP ( t_2 ) ) - PrintString1( t_2); - else - PrintObj(t_2); - } - } - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 3 ) { - t_2 = False; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - AssertionFailure(); - } - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 2 ) { - t_2 = True; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - t_2 = MakeString( "fail-D" ); - if ( t_2 != (Obj)(UInt)0 ){ - if ( IS_STRING_REP ( t_2 ) ) - PrintString1( t_2); - else - PrintObj(t_2); - } - } - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 2 ) { - t_2 = True; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - AssertionFailure(); - } - } - - /* Assert( ... ); */ - if ( STATE(CurrentAssertionLevel) >= 2 ) { - t_2 = False; - t_1 = (Obj)(UInt)(t_2 != False); - if ( ! t_1 ) { - t_2 = MakeString( "pass!\n" ); - if ( t_2 != (Obj)(UInt)0 ){ - if ( IS_STRING_REP ( t_2 ) ) - PrintString1( t_2); - else - PrintObj(t_2); - } - } - } - - /* Print( "end of function\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "end of function\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* runtest := function ( ) - Print( AssertionLevel( ), "\n" ); - Assert( 1, false, "fail-A" ); - Assert( 1, false ); - Assert( 0, true, "fail-B" ); - Assert( 0, true ); - SetAssertionLevel( 2 ); - Print( AssertionLevel( ), "\n" ); - Assert( 3, false, "fail-C" ); - Assert( 3, false ); - Assert( 2, true, "fail-D" ); - Assert( 2, true ); - Assert( 2, false, "pass!\n" ); - Print( "end of function\n" ); - return; - end; */ - t_1 = NewFunction( NameFunc[2], 0, 0, HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 1); - SET_ENDLINE_BODY(t_2, 18); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_Print = GVarName( "Print" ); - G_SetAssertionLevel = GVarName( "SetAssertionLevel" ); - G_AssertionLevel = GVarName( "AssertionLevel" ); - G_runtest = GVarName( "runtest" ); - - /* record names used in handlers */ - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - InitFopyGVar( "Print", &GF_Print ); - InitFopyGVar( "SetAssertionLevel", &GF_SetAssertionLevel ); - InitFopyGVar( "AssertionLevel", &GF_AssertionLevel ); - - /* information for the functions */ - InitGlobalBag( &FileName, "assert.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "assert.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "assert.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "assert.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "assert.g:NameFunc[2]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "assert.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "assert.g", - .crc = 47091879, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__assert ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/basics.g.static.c b/tst/test-compile/basics.g.static.c deleted file mode 100644 index 3c8dd0422f..0000000000 --- a/tst/test-compile/basics.g.static.c +++ /dev/null @@ -1,2935 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "-52605173" - -/* global variables used in handlers */ -static GVar G_PushOptions; -static Obj GF_PushOptions; -static GVar G_PopOptions; -static Obj GF_PopOptions; -static GVar G_Print; -static Obj GF_Print; -static GVar G_test__int__constants; -static Obj GF_test__int__constants; -static GVar G_test__func__calls; -static Obj GF_test__func__calls; -static GVar G_Display; -static Obj GF_Display; -static GVar G_test__cmp__ops; -static Obj GF_test__cmp__ops; -static GVar G_test__arith; -static Obj GF_test__arith; -static GVar G_test__tilde; -static Obj GF_test__tilde; -static GVar G_test__list__rec__exprs; -static Obj GF_test__list__rec__exprs; -static GVar G_myglobal; -static Obj GC_myglobal; -static GVar G_test__IsBound__Unbind; -static Obj GF_test__IsBound__Unbind; -static GVar G_test__loops; -static Obj GF_test__loops; -static GVar G_runtest; - -/* record names used in handlers */ -static RNam R_myopt; -static RNam R_x; -static RNam R_a; -static RNam R_b; -static RNam R_d; - -/* information for the functions */ -static Obj NameFunc[13]; -static Obj FileName; - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self ) -{ - Obj l_x = 0; - Obj l_y = 0; - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - (void)l_x; - (void)l_y; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* x := 10 ^ 5; */ - t_1 = POW( INTOBJ_INT(10), INTOBJ_INT(5) ); - l_x = t_1; - - /* Print( x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_x, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x, t_2 ) ); - } - - /* y := 100000; */ - l_y = INTOBJ_INT(100000); - - /* Print( y, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_y, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_y, t_2 ) ); - } - - /* Print( x = y, "\n" ); */ - t_1 = GF_Print; - t_2 = (EQ( l_x, l_y ) ? True : False); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* x := - 10 ^ 5; */ - t_2 = POW( INTOBJ_INT(10), INTOBJ_INT(5) ); - C_AINV_FIA( t_1, t_2 ) - l_x = t_1; - - /* Print( x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_x, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x, t_2 ) ); - } - - /* y := -100000; */ - l_y = INTOBJ_INT(-100000); - - /* Print( y, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_y, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_y, t_2 ) ); - } - - /* Print( x = y, "\n" ); */ - t_1 = GF_Print; - t_2 = (EQ( l_x, l_y ) ? True : False); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* x := 10 ^ 10; */ - t_1 = POW( INTOBJ_INT(10), INTOBJ_INT(10) ); - l_x = t_1; - - /* Print( x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_x, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x, t_2 ) ); - } - - /* y := 10000000000; */ - l_y = ObjInt_Int8(10000000000); - - /* Print( y, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_y, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_y, t_2 ) ); - } - - /* Print( x = y, "\n" ); */ - t_1 = GF_Print; - t_2 = (EQ( l_x, l_y ) ? True : False); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* x := - 10 ^ 10; */ - t_2 = POW( INTOBJ_INT(10), INTOBJ_INT(10) ); - C_AINV_FIA( t_1, t_2 ) - l_x = t_1; - - /* Print( x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_x, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x, t_2 ) ); - } - - /* y := -10000000000; */ - l_y = ObjInt_Int8(-10000000000); - - /* Print( y, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_y, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_y, t_2 ) ); - } - - /* Print( x = y, "\n" ); */ - t_1 = GF_Print; - t_2 = (EQ( l_x, l_y ) ? True : False); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* x := 10 ^ 20; */ - t_1 = POW( INTOBJ_INT(10), INTOBJ_INT(20) ); - l_x = t_1; - - /* Print( x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_x, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x, t_2 ) ); - } - - /* y := 100000000000000000000; */ - t_1 = NewWordSizedBag(T_INTPOS, 16); - C_SET_LIMB8( t_1, 0, 7766279631452241920LL); - C_SET_LIMB8( t_1, 1, 5LL); - l_y = t_1; - - /* Print( y, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_y, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_y, t_2 ) ); - } - - /* Print( x = y, "\n" ); */ - t_1 = GF_Print; - t_2 = (EQ( l_x, l_y ) ? True : False); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* x := - 10 ^ 20; */ - t_2 = POW( INTOBJ_INT(10), INTOBJ_INT(20) ); - C_AINV_FIA( t_1, t_2 ) - l_x = t_1; - - /* Print( x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_x, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x, t_2 ) ); - } - - /* y := - 100000000000000000000; */ - t_2 = NewWordSizedBag(T_INTPOS, 16); - C_SET_LIMB8( t_2, 0, 7766279631452241920LL); - C_SET_LIMB8( t_2, 1, 5LL); - C_AINV_FIA( t_1, t_2 ) - l_y = t_1; - - /* Print( y, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, l_y, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_y, t_2 ) ); - } - - /* Print( x = y, "\n" ); */ - t_1 = GF_Print; - t_2 = (EQ( l_x, l_y ) ? True : False); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 4 */ -static Obj HdlrFunc4 ( - Obj self, - Obj a_args ) -{ - Obj t_1 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return Length( args ); */ - C_LEN_LIST_FPL( t_1, a_args ) - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 5 */ -static Obj HdlrFunc5 ( - Obj self, - Obj a_args ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Display( Length( args ) ); */ - t_1 = GF_Display; - C_LEN_LIST_FPL( t_2, a_args ) - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 3 */ -static Obj HdlrFunc3 ( - Obj self ) -{ - Obj l_vararg__fun = 0; - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - (void)l_vararg__fun; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* vararg_fun := function ( args... ) - return Length( args ); - end; */ - t_1 = NewFunction( NameFunc[4], -1, ArgStringToList("args"), HdlrFunc4 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 58); - SET_ENDLINE_BODY(t_2, 60); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - l_vararg__fun = t_1; - - /* Print( vararg_fun( ), "\n" ); */ - t_1 = GF_Print; - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_0ARGS( l_vararg__fun ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( 1 ), "\n" ); */ - t_1 = GF_Print; - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_1ARGS( l_vararg__fun, INTOBJ_INT(1) ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1) ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( 1, 2 ), "\n" ); */ - t_1 = GF_Print; - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_2ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2) ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2) ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( 1, 2, 3 ), "\n" ); */ - t_1 = GF_Print; - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_3ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3) ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3) ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( 1, 2, 3, 4 ), "\n" ); */ - t_1 = GF_Print; - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_4ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4) ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4) ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( 1, 2, 3, 4, 5 ), "\n" ); */ - t_1 = GF_Print; - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_5ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4), INTOBJ_INT(5) ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4), INTOBJ_INT(5) ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( 1, 2, 3, 4, 5, 6 ), "\n" ); */ - t_1 = GF_Print; - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_6ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4), INTOBJ_INT(5), INTOBJ_INT(6) ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4), INTOBJ_INT(5), INTOBJ_INT(6) ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( 1, 2, 3, 4, 5, 6, 7 ), "\n" ); */ - t_1 = GF_Print; - t_3 = NEW_PLIST( T_PLIST, 7 ); - SET_LEN_PLIST( t_3, 7 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_3, 3, INTOBJ_INT(3) ); - SET_ELM_PLIST( t_3, 4, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_3, 5, INTOBJ_INT(5) ); - SET_ELM_PLIST( t_3, 6, INTOBJ_INT(6) ); - SET_ELM_PLIST( t_3, 7, INTOBJ_INT(7) ); - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_XARGS( l_vararg__fun, t_3 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, t_3 ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( "x", true, vararg_fun, 4, 5, 6, 7 ), "\n" ); */ - t_1 = GF_Print; - t_3 = NEW_PLIST( T_PLIST, 7 ); - SET_LEN_PLIST( t_3, 7 ); - t_4 = MakeString( "x" ); - SET_ELM_PLIST( t_3, 1, t_4 ); - CHANGED_BAG( t_3 ); - t_4 = True; - SET_ELM_PLIST( t_3, 2, t_4 ); - CHANGED_BAG( t_3 ); - SET_ELM_PLIST( t_3, 3, l_vararg__fun ); - CHANGED_BAG( t_3 ); - SET_ELM_PLIST( t_3, 4, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_3, 5, INTOBJ_INT(5) ); - SET_ELM_PLIST( t_3, 6, INTOBJ_INT(6) ); - SET_ELM_PLIST( t_3, 7, INTOBJ_INT(7) ); - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_XARGS( l_vararg__fun, t_3 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, t_3 ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( : myopt := true ), "\n" ); */ - t_1 = GF_Print; - t_2 = NEW_PREC( 1 ); - t_3 = (Obj)R_myopt; - t_4 = True; - AssPRec( t_2, (UInt)t_3, t_4 ); - SortPRecRNam( t_2, 0 ); - CALL_1ARGS( GF_PushOptions, t_2 ); - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_0ARGS( l_vararg__fun ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_2 ); - CALL_0ARGS( GF_PopOptions ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( vararg_fun( : myopt := "value" ), "\n" ); */ - t_1 = GF_Print; - t_2 = NEW_PREC( 1 ); - t_3 = (Obj)R_myopt; - t_4 = MakeString( "value" ); - AssPRec( t_2, (UInt)t_3, t_4 ); - SortPRecRNam( t_2, 0 ); - CALL_1ARGS( GF_PushOptions, t_2 ); - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - t_2 = CALL_0ARGS( l_vararg__fun ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_2 ); - CALL_0ARGS( GF_PopOptions ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* vararg_fun := function ( args... ) - Display( Length( args ) ); - return; - end; */ - t_1 = NewFunction( NameFunc[5], -1, ArgStringToList("args"), HdlrFunc5 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 89); - SET_ENDLINE_BODY(t_2, 91); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - l_vararg__fun = t_1; - - /* vararg_fun( ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_0ARGS( l_vararg__fun ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( ) ); - } - - /* vararg_fun( 1 ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_1ARGS( l_vararg__fun, INTOBJ_INT(1) ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1) ) ); - } - - /* vararg_fun( 1, 2 ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_2ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2) ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2) ) ); - } - - /* vararg_fun( 1, 2, 3 ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_3ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3) ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3) ) ); - } - - /* vararg_fun( 1, 2, 3, 4 ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_4ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4) ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4) ) ); - } - - /* vararg_fun( 1, 2, 3, 4, 5 ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_5ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4), INTOBJ_INT(5) ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4), INTOBJ_INT(5) ) ); - } - - /* vararg_fun( 1, 2, 3, 4, 5, 6 ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_6ARGS( l_vararg__fun, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4), INTOBJ_INT(5), INTOBJ_INT(6) ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4), INTOBJ_INT(5), INTOBJ_INT(6) ) ); - } - - /* vararg_fun( 1, 2, 3, 4, 5, 6, 7 ); */ - t_1 = NEW_PLIST( T_PLIST, 7 ); - SET_LEN_PLIST( t_1, 7 ); - SET_ELM_PLIST( t_1, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_1, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_1, 3, INTOBJ_INT(3) ); - SET_ELM_PLIST( t_1, 4, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_1, 5, INTOBJ_INT(5) ); - SET_ELM_PLIST( t_1, 6, INTOBJ_INT(6) ); - SET_ELM_PLIST( t_1, 7, INTOBJ_INT(7) ); - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_XARGS( l_vararg__fun, t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, t_1 ); - } - - /* vararg_fun( "x", true, vararg_fun, 4, 5, 6, 7 ); */ - t_1 = NEW_PLIST( T_PLIST, 7 ); - SET_LEN_PLIST( t_1, 7 ); - t_2 = MakeString( "x" ); - SET_ELM_PLIST( t_1, 1, t_2 ); - CHANGED_BAG( t_1 ); - t_2 = True; - SET_ELM_PLIST( t_1, 2, t_2 ); - CHANGED_BAG( t_1 ); - SET_ELM_PLIST( t_1, 3, l_vararg__fun ); - CHANGED_BAG( t_1 ); - SET_ELM_PLIST( t_1, 4, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_1, 5, INTOBJ_INT(5) ); - SET_ELM_PLIST( t_1, 6, INTOBJ_INT(6) ); - SET_ELM_PLIST( t_1, 7, INTOBJ_INT(7) ); - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_XARGS( l_vararg__fun, t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, t_1 ); - } - t_1 = NEW_PREC( 1 ); - t_2 = (Obj)R_myopt; - t_3 = True; - AssPRec( t_1, (UInt)t_2, t_3 ); - SortPRecRNam( t_1, 0 ); - CALL_1ARGS( GF_PushOptions, t_1 ); - - /* vararg_fun( ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_0ARGS( l_vararg__fun ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( ) ); - } - CALL_0ARGS( GF_PopOptions ); - t_1 = NEW_PREC( 1 ); - t_2 = (Obj)R_myopt; - t_3 = MakeString( "value" ); - AssPRec( t_1, (UInt)t_2, t_3 ); - SortPRecRNam( t_1, 0 ); - CALL_1ARGS( GF_PushOptions, t_1 ); - - /* vararg_fun( ); */ - if ( TNUM_OBJ( l_vararg__fun ) == T_FUNCTION ) { - CALL_0ARGS( l_vararg__fun ); - } - else { - DoOperation2Args( CallFuncListOper, l_vararg__fun, NewPlistFromArgs( ) ); - } - CALL_0ARGS( GF_PopOptions ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 6 */ -static Obj HdlrFunc6 ( - Obj self ) -{ - Obj l_x = 0; - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - (void)l_x; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "setting x to 2 ...\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "setting x to 2 ...\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := 2; */ - l_x = INTOBJ_INT(2); - - /* Print( "1 = 2 is ", 1 = 2, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 = 2 is " ); - t_3 = ((((Int)INTOBJ_INT(1)) == ((Int)INTOBJ_INT(2))) ? True : False); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 = x is ", 1 = x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 = x is " ); - t_3 = ((((Int)INTOBJ_INT(1)) == ((Int)l_x)) ? True : False); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 = 2 via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 = 2 via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 = 2 then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(1)) == ((Int)INTOBJ_INT(2))); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 = x via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 = x via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 = x then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(1)) == ((Int)l_x)); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 <> 2 is ", 1 <> 2, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 <> 2 is " ); - t_3 = ((((Int)INTOBJ_INT(1)) == ((Int)INTOBJ_INT(2))) ? False : True); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 <> x is ", 1 <> x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 <> x is " ); - t_3 = ((((Int)INTOBJ_INT(1)) == ((Int)l_x)) ? False : True); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 <> 2 via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 <> 2 via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 <> 2 then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(1)) != ((Int)INTOBJ_INT(2))); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 <> x via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 <> x via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 <> x then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(1)) != ((Int)l_x)); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 < 2 is ", 1 < 2, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 < 2 is " ); - t_3 = ((((Int)INTOBJ_INT(1)) < ((Int)INTOBJ_INT(2))) ? True : False); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 < x is ", 1 < x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 < x is " ); - t_3 = ((((Int)INTOBJ_INT(1)) < ((Int)l_x)) ? True : False); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 < 2 via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 < 2 via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 < 2 then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(1)) < ((Int)INTOBJ_INT(2))); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 < x via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 < x via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 < x then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(1)) < ((Int)l_x)); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 <= 2 is ", 1 <= 2, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 <= 2 is " ); - t_3 = ((((Int)INTOBJ_INT(2)) < ((Int)INTOBJ_INT(1))) ? False : True); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 <= x is ", 1 <= x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 <= x is " ); - t_3 = ((((Int)l_x) < ((Int)INTOBJ_INT(1))) ? False : True); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 <= 2 via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 <= 2 via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 <= 2 then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(2)) >= ((Int)INTOBJ_INT(1))); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 <= x via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 <= x via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 <= x then */ - t_1 = (Obj)(UInt)(((Int)l_x) >= ((Int)INTOBJ_INT(1))); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 > 2 is ", 1 > 2, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 > 2 is " ); - t_3 = ((((Int)INTOBJ_INT(2)) < ((Int)INTOBJ_INT(1))) ? True : False); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 > x is ", 1 > x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 > x is " ); - t_3 = ((((Int)l_x) < ((Int)INTOBJ_INT(1))) ? True : False); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 > 2 via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 > 2 via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 > 2 then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(2)) < ((Int)INTOBJ_INT(1))); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 > x via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 > x via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 > x then */ - t_1 = (Obj)(UInt)(((Int)l_x) < ((Int)INTOBJ_INT(1))); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 >= 2 is ", 1 >= 2, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 >= 2 is " ); - t_3 = ((((Int)INTOBJ_INT(1)) < ((Int)INTOBJ_INT(2))) ? False : True); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 >= x is ", 1 >= x, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 >= x is " ); - t_3 = ((((Int)INTOBJ_INT(1)) < ((Int)l_x)) ? False : True); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "1 >= 2 via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 >= 2 via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 >= 2 then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(1)) >= ((Int)INTOBJ_INT(2))); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* Print( "1 >= x via if is " ); */ - t_1 = GF_Print; - t_2 = MakeString( "1 >= x via if is " ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* if 1 >= x then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(1)) >= ((Int)l_x)); - if ( t_1 ) { - - /* Print( "true\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "true\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - - /* else */ - else { - - /* Print( "false\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "false\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - } - /* fi */ - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 7 */ -static Obj HdlrFunc7 ( - Obj self ) -{ - Obj l_x = 0; - Obj t_1 = 0; - (void)l_x; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* x := 5; */ - l_x = INTOBJ_INT(5); - - /* x := - x; */ - C_AINV_INTOBJS( t_1, l_x ) - l_x = t_1; - - /* x := 1 / 2; */ - t_1 = QUO( INTOBJ_INT(1), INTOBJ_INT(2) ); - l_x = t_1; - - /* x := - x; */ - C_AINV_FIA( t_1, l_x ) - l_x = t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 8 */ -static Obj HdlrFunc8 ( - Obj self ) -{ - Obj l_x = 0; - (void)l_x; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 9 */ -static Obj HdlrFunc9 ( - Obj self ) -{ - Obj l_l = 0; - Obj l_x = 0; - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Obj t_5 = 0; - Obj t_6 = 0; - (void)l_l; - (void)l_x; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Display( [ ] ); */ - t_1 = GF_Display; - t_2 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_2, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Display( [ 1, 2, 3 ] ); */ - t_1 = GF_Display; - t_2 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_2, 3 ); - SET_ELM_PLIST( t_2, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_2, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_2, 3, INTOBJ_INT(3) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Display( [ 1,, 3, [ 4, 5 ], rec( - x := [ 6, rec( - ) ] ) ] ); */ - t_1 = GF_Display; - t_2 = NEW_PLIST( T_PLIST, 5 ); - SET_LEN_PLIST( t_2, 5 ); - SET_ELM_PLIST( t_2, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_2, 3, INTOBJ_INT(3) ); - t_3 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_3, 2 ); - SET_ELM_PLIST( t_2, 4, t_3 ); - CHANGED_BAG( t_2 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(5) ); - t_3 = NEW_PREC( 1 ); - SET_ELM_PLIST( t_2, 5, t_3 ); - CHANGED_BAG( t_2 ); - t_4 = (Obj)R_x; - t_5 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_5, 2 ); - AssPRec( t_3, (UInt)t_4, t_5 ); - SET_ELM_PLIST( t_5, 1, INTOBJ_INT(6) ); - t_6 = NEW_PREC( 0 ); - SET_ELM_PLIST( t_5, 2, t_6 ); - CHANGED_BAG( t_5 ); - SortPRecRNam( t_6, 0 ); - SortPRecRNam( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* l := [ ]; */ - t_1 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_1, 0 ); - l_l = t_1; - - /* l[1] := 1; */ - C_ASS_LIST_FPL_INTOBJ( l_l, INTOBJ_INT(1), INTOBJ_INT(1) ) - - /* l[1 + 1] := 2; */ - C_SUM_INTOBJS( t_1, INTOBJ_INT(1), INTOBJ_INT(1) ) - CHECK_INT_POS( t_1 ); - C_ASS_LIST_FPL_INTOBJ( l_l, t_1, INTOBJ_INT(2) ) - - /* l![3] := 3; */ - AssPosObj( l_l, 3, INTOBJ_INT(3) ); - - /* l![2 + 2] := 4; */ - C_SUM_INTOBJS( t_1, INTOBJ_INT(2), INTOBJ_INT(2) ) - CHECK_INT_SMALL_POS( t_1 ); - AssPosObj( l_l, Int_ObjInt(t_1), INTOBJ_INT(4) ); - - /* Display( l ); */ - t_1 = GF_Display; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_l ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_l ) ); - } - - /* Print( "l[1] = ", l[1], "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "l[1] = " ); - C_ELM_LIST_FPL( t_3, l_l, INTOBJ_INT(1) ) - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "l[2] = ", l[1 + 1], "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "l[2] = " ); - C_SUM_INTOBJS( t_4, INTOBJ_INT(1), INTOBJ_INT(1) ) - CHECK_INT_POS( t_4 ); - C_ELM_LIST_FPL( t_3, l_l, t_4 ) - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "l[3] = ", l![3], "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "l[3] = " ); - t_3 = ElmPosObj( l_l, 3 ); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "l[4] = ", l![2 + 2], "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "l[4] = " ); - C_SUM_INTOBJS( t_4, INTOBJ_INT(2), INTOBJ_INT(2) ) - CHECK_INT_SMALL_POS( t_4 ); - t_3 = ElmPosObj( l_l, Int_ObjInt(t_4) ); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* x := rec( - a := 1 ); */ - t_1 = NEW_PREC( 1 ); - t_2 = (Obj)R_a; - AssPRec( t_1, (UInt)t_2, INTOBJ_INT(1) ); - SortPRecRNam( t_1, 0 ); - l_x = t_1; - - /* x.b := 2; */ - ASS_REC( l_x, R_b, INTOBJ_INT(2) ); - - /* x.("c") := x.a + x.("b"); */ - t_1 = MakeString( "c" ); - t_3 = ELM_REC( l_x, R_a ); - t_5 = MakeString( "b" ); - t_4 = ELM_REC( l_x, RNamObj(t_5) ); - C_SUM_FIA( t_2, t_3, t_4 ) - ASS_REC( l_x, RNamObj(t_1), t_2 ); - - /* x!.d := 42; */ - AssComObj( l_x, R_d, INTOBJ_INT(42) ); - - /* x!.("e") := 23; */ - t_1 = MakeString( "e" ); - AssComObj( l_x, RNamObj(t_1), INTOBJ_INT(23) ); - - /* Display( x ); */ - t_1 = GF_Display; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_x ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x ) ); - } - - /* Print( "x.a = ", x.a, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "x.a = " ); - t_3 = ELM_REC( l_x, R_a ); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "x.b = ", x.("b"), "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "x.b = " ); - t_4 = MakeString( "b" ); - t_3 = ELM_REC( l_x, RNamObj(t_4) ); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "x.d = ", x!.d, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "x.d = " ); - t_3 = ElmComObj( l_x, R_d ); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* Print( "x.e = ", x!.("e"), "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "x.e = " ); - t_4 = MakeString( "e" ); - t_3 = ElmComObj( l_x, RNamObj(t_4) ); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 10 */ -static Obj HdlrFunc10 ( - Obj self ) -{ - Obj l_x = 0; - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - (void)l_x; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "Testing IsBound and Unbind for lvar\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "Testing IsBound and Unbind for lvar\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := 42; */ - l_x = INTOBJ_INT(42); - - /* Display( IsBound( x ) ); */ - t_1 = GF_Display; - t_2 = ((l_x != 0) ? True : False); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Unbind( x ); */ - l_x = 0; - - /* Display( IsBound( x ) ); */ - t_1 = GF_Display; - t_2 = ((l_x != 0) ? True : False); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Print( "Testing IsBound and Unbind for gvar\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "Testing IsBound and Unbind for gvar\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* myglobal := 42; */ - AssGVar( G_myglobal, INTOBJ_INT(42) ); - - /* Display( IsBound( myglobal ) ); */ - t_1 = GF_Display; - t_3 = GC_myglobal; - t_2 = ((t_3 != 0) ? True : False); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Unbind( myglobal ); */ - AssGVar( G_myglobal, 0 ); - - /* Display( IsBound( myglobal ) ); */ - t_1 = GF_Display; - t_3 = GC_myglobal; - t_2 = ((t_3 != 0) ? True : False); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Print( "Testing IsBound and Unbind for list\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "Testing IsBound and Unbind for list\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := [ 1, 2, 3 ]; */ - t_1 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_1, 3 ); - SET_ELM_PLIST( t_1, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_1, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_1, 3, INTOBJ_INT(3) ); - l_x = t_1; - - /* Display( IsBound( x[2] ) ); */ - t_1 = GF_Display; - t_2 = C_ISB_LIST( l_x, INTOBJ_INT(2) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Unbind( x[2] ); */ - C_UNB_LIST( l_x, INTOBJ_INT(2) ); - - /* Display( IsBound( x[2] ) ); */ - t_1 = GF_Display; - t_2 = C_ISB_LIST( l_x, INTOBJ_INT(2) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Print( "Testing IsBound and Unbind for list with bang\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "Testing IsBound and Unbind for list with bang\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := [ 1, 2, 3 ]; */ - t_1 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_1, 3 ); - SET_ELM_PLIST( t_1, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_1, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_1, 3, INTOBJ_INT(3) ); - l_x = t_1; - - /* Display( IsBound( x![2] ) ); */ - t_1 = GF_Display; - t_2 = IsbPosObj( l_x, 2 ) ? True : False; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Unbind( x![2] ); */ - UnbPosObj( l_x, 2 ); - - /* Display( IsBound( x![2] ) ); */ - t_1 = GF_Display; - t_2 = IsbPosObj( l_x, 2 ) ? True : False; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Print( "Testing IsBound and Unbind for record\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "Testing IsBound and Unbind for record\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := rec( - a := 1 ); */ - t_1 = NEW_PREC( 1 ); - t_2 = (Obj)R_a; - AssPRec( t_1, (UInt)t_2, INTOBJ_INT(1) ); - SortPRecRNam( t_1, 0 ); - l_x = t_1; - - /* Display( IsBound( x.a ) ); */ - t_1 = GF_Display; - t_2 = (ISB_REC( l_x, R_a ) ? True : False); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Unbind( x.a ); */ - UNB_REC( l_x, R_a ); - - /* Display( IsBound( x.a ) ); */ - t_1 = GF_Display; - t_2 = (ISB_REC( l_x, R_a ) ? True : False); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Print( "Testing IsBound and Unbind for record with expr\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "Testing IsBound and Unbind for record with expr\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := rec( - a := 1 ); */ - t_1 = NEW_PREC( 1 ); - t_2 = (Obj)R_a; - AssPRec( t_1, (UInt)t_2, INTOBJ_INT(1) ); - SortPRecRNam( t_1, 0 ); - l_x = t_1; - - /* Display( IsBound( x.("a") ) ); */ - t_1 = GF_Display; - t_3 = MakeString( "a" ); - t_2 = (ISB_REC( l_x, RNamObj(t_3) ) ? True : False); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Unbind( x.("a") ); */ - t_1 = MakeString( "a" ); - UNB_REC( l_x, RNamObj(t_1) ); - - /* Display( IsBound( x.("a") ) ); */ - t_1 = GF_Display; - t_3 = MakeString( "a" ); - t_2 = (ISB_REC( l_x, RNamObj(t_3) ) ? True : False); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Print( "Testing IsBound and Unbind for record with bang\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "Testing IsBound and Unbind for record with bang\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := rec( - a := 1 ); */ - t_1 = NEW_PREC( 1 ); - t_2 = (Obj)R_a; - AssPRec( t_1, (UInt)t_2, INTOBJ_INT(1) ); - SortPRecRNam( t_1, 0 ); - l_x = t_1; - - /* Display( IsBound( x!.a ) ); */ - t_1 = GF_Display; - t_2 = IsbComObj( l_x, R_a ) ? True : False; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Unbind( x!.a ); */ - UnbComObj( l_x, R_a ); - - /* Display( IsBound( x!.a ) ); */ - t_1 = GF_Display; - t_2 = IsbComObj( l_x, R_a ) ? True : False; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Print( "Testing IsBound and Unbind for record with bang and expr\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "Testing IsBound and Unbind for record with bang and expr\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := rec( - a := 1 ); */ - t_1 = NEW_PREC( 1 ); - t_2 = (Obj)R_a; - AssPRec( t_1, (UInt)t_2, INTOBJ_INT(1) ); - SortPRecRNam( t_1, 0 ); - l_x = t_1; - - /* Display( IsBound( x!.("a") ) ); */ - t_1 = GF_Display; - t_3 = MakeString( "a" ); - t_2 = IsbComObj( l_x, RNamObj(t_3) ) ? True : False; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Unbind( x!.("a") ); */ - t_1 = MakeString( "a" ); - UnbComObj( l_x, RNamObj(t_1) ); - - /* Display( IsBound( x!.("a") ) ); */ - t_1 = GF_Display; - t_3 = MakeString( "a" ); - t_2 = IsbComObj( l_x, RNamObj(t_3) ) ? True : False; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 11 */ -static Obj HdlrFunc11 ( - Obj self ) -{ - Obj l_x = 0; - Obj t_1 = 0; - Obj t_2 = 0; - (void)l_x; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Display( "testing repeat loop" ); */ - t_1 = GF_Display; - t_2 = MakeString( "testing repeat loop" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := 0; */ - l_x = INTOBJ_INT(0); - - /* repeat */ - do { - - /* x := x + 1; */ - C_SUM_FIA( t_1, l_x, INTOBJ_INT(1) ) - l_x = t_1; - - /* if x = 1 then */ - t_1 = (Obj)(UInt)(EQ( l_x, INTOBJ_INT(1) )); - if ( t_1 ) { - - /* continue; */ - continue; - - } - - /* elif x = 4 then */ - else { - t_1 = (Obj)(UInt)(EQ( l_x, INTOBJ_INT(4) )); - if ( t_1 ) { - - /* break; */ - break; - - } - - /* else */ - else { - - /* Display( x ); */ - t_1 = GF_Display; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_x ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x ) ); - } - - } - } - /* fi */ - - /* until x >= 100 */ - t_1 = (Obj)(UInt)(! LT( l_x, INTOBJ_INT(100) )); - if ( t_1 ) break; - } while ( 1 ); - - /* Display( "testing while loop" ); */ - t_1 = GF_Display; - t_2 = MakeString( "testing while loop" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* x := 0; */ - l_x = INTOBJ_INT(0); - - /* while x < 100 do */ - while ( 1 ) { - t_1 = (Obj)(UInt)(LT( l_x, INTOBJ_INT(100) )); - if ( ! t_1 ) break; - - /* x := x + 1; */ - C_SUM_FIA( t_1, l_x, INTOBJ_INT(1) ) - l_x = t_1; - - /* if x = 1 then */ - t_1 = (Obj)(UInt)(EQ( l_x, INTOBJ_INT(1) )); - if ( t_1 ) { - - /* continue; */ - continue; - - } - - /* elif x = 4 then */ - else { - t_1 = (Obj)(UInt)(EQ( l_x, INTOBJ_INT(4) )); - if ( t_1 ) { - - /* break; */ - break; - - } - - /* else */ - else { - - /* Display( x ); */ - t_1 = GF_Display; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_x ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_x ) ); - } - - } - } - /* fi */ - - } - /* od */ - - /* Display( "testing for loop" ); */ - t_1 = GF_Display; - t_2 = MakeString( "testing for loop" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* for x in [ 1 .. 100 ] do */ - for ( t_1 = INTOBJ_INT(1); - ((Int)t_1) <= ((Int)INTOBJ_INT(100)); - t_1 = (Obj)(((UInt)t_1)+4) ) { - l_x = t_1; - - /* if x = 1 then */ - t_2 = (Obj)(UInt)(((Int)l_x) == ((Int)INTOBJ_INT(1))); - if ( t_2 ) { - - /* continue; */ - continue; - - } - - /* elif x = 4 then */ - else { - t_2 = (Obj)(UInt)(((Int)l_x) == ((Int)INTOBJ_INT(4))); - if ( t_2 ) { - - /* break; */ - break; - - } - - /* else */ - else { - - /* Display( x ); */ - t_2 = GF_Display; - if ( TNUM_OBJ( t_2 ) == T_FUNCTION ) { - CALL_1ARGS( t_2, l_x ); - } - else { - DoOperation2Args( CallFuncListOper, t_2, NewPlistFromArgs( l_x ) ); - } - - } - } - /* fi */ - - } - /* od */ - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 12 */ -static Obj HdlrFunc12 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* test_int_constants( ); */ - t_1 = GF_test__int__constants; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* test_func_calls( ); */ - t_1 = GF_test__func__calls; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* test_cmp_ops( ); */ - t_1 = GF_test__cmp__ops; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* test_arith( ); */ - t_1 = GF_test__arith; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* test_tilde( ); */ - t_1 = GF_test__tilde; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* test_list_rec_exprs( ); */ - t_1 = GF_test__list__rec__exprs; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* test_IsBound_Unbind( ); */ - t_1 = GF_test__IsBound__Unbind; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* test_loops( ); */ - t_1 = GF_test__loops; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* Display( () ); */ - t_1 = GF_Display; - t_2 = IdentityPerm; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* test_int_constants := function ( ) - local x, y; - x := 10 ^ 5; - Print( x, "\n" ); - y := 100000; - Print( y, "\n" ); - Print( x = y, "\n" ); - x := - 10 ^ 5; - Print( x, "\n" ); - y := -100000; - Print( y, "\n" ); - Print( x = y, "\n" ); - x := 10 ^ 10; - Print( x, "\n" ); - y := 10000000000; - Print( y, "\n" ); - Print( x = y, "\n" ); - x := - 10 ^ 10; - Print( x, "\n" ); - y := -10000000000; - Print( y, "\n" ); - Print( x = y, "\n" ); - x := 10 ^ 20; - Print( x, "\n" ); - y := 100000000000000000000; - Print( y, "\n" ); - Print( x = y, "\n" ); - x := - 10 ^ 20; - Print( x, "\n" ); - y := - 100000000000000000000; - Print( y, "\n" ); - Print( x = y, "\n" ); - return; - end; */ - t_1 = NewFunction( NameFunc[2], 0, 0, HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 7); - SET_ENDLINE_BODY(t_2, 48); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_test__int__constants, t_1 ); - - /* test_func_calls := function ( ) - local vararg_fun; - vararg_fun := function ( args... ) - return Length( args ); - end; - Print( vararg_fun( ), "\n" ); - Print( vararg_fun( 1 ), "\n" ); - Print( vararg_fun( 1, 2 ), "\n" ); - Print( vararg_fun( 1, 2, 3 ), "\n" ); - Print( vararg_fun( 1, 2, 3, 4 ), "\n" ); - Print( vararg_fun( 1, 2, 3, 4, 5 ), "\n" ); - Print( vararg_fun( 1, 2, 3, 4, 5, 6 ), "\n" ); - Print( vararg_fun( 1, 2, 3, 4, 5, 6, 7 ), "\n" ); - Print( vararg_fun( "x", true, vararg_fun, 4, 5, 6, 7 ), "\n" ); - Print( vararg_fun( : myopt := true ), "\n" ); - Print( vararg_fun( : myopt := "value" ), "\n" ); - vararg_fun := function ( args... ) - Display( Length( args ) ); - return; - end; - vararg_fun( ); - vararg_fun( 1 ); - vararg_fun( 1, 2 ); - vararg_fun( 1, 2, 3 ); - vararg_fun( 1, 2, 3, 4 ); - vararg_fun( 1, 2, 3, 4, 5 ); - vararg_fun( 1, 2, 3, 4, 5, 6 ); - vararg_fun( 1, 2, 3, 4, 5, 6, 7 ); - vararg_fun( "x", true, vararg_fun, 4, 5, 6, 7 ); - vararg_fun( : myopt := true ); - vararg_fun( : myopt := "value" ); - return; - end; */ - t_1 = NewFunction( NameFunc[3], 0, 0, HdlrFunc3 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 54); - SET_ENDLINE_BODY(t_2, 112); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_test__func__calls, t_1 ); - - /* test_cmp_ops := function ( ) - local x; - Print( "setting x to 2 ...\n" ); - x := 2; - Print( "1 = 2 is ", 1 = 2, "\n" ); - Print( "1 = x is ", 1 = x, "\n" ); - Print( "1 = 2 via if is " ); - if 1 = 2 then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 = x via if is " ); - if 1 = x then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 <> 2 is ", 1 <> 2, "\n" ); - Print( "1 <> x is ", 1 <> x, "\n" ); - Print( "1 <> 2 via if is " ); - if 1 <> 2 then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 <> x via if is " ); - if 1 <> x then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 < 2 is ", 1 < 2, "\n" ); - Print( "1 < x is ", 1 < x, "\n" ); - Print( "1 < 2 via if is " ); - if 1 < 2 then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 < x via if is " ); - if 1 < x then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 <= 2 is ", 1 <= 2, "\n" ); - Print( "1 <= x is ", 1 <= x, "\n" ); - Print( "1 <= 2 via if is " ); - if 1 <= 2 then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 <= x via if is " ); - if 1 <= x then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 > 2 is ", 1 > 2, "\n" ); - Print( "1 > x is ", 1 > x, "\n" ); - Print( "1 > 2 via if is " ); - if 1 > 2 then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 > x via if is " ); - if 1 > x then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 >= 2 is ", 1 >= 2, "\n" ); - Print( "1 >= x is ", 1 >= x, "\n" ); - Print( "1 >= 2 via if is " ); - if 1 >= 2 then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - Print( "1 >= x via if is " ); - if 1 >= x then - Print( "true\n" ); - else - Print( "false\n" ); - fi; - return; - end; */ - t_1 = NewFunction( NameFunc[6], 0, 0, HdlrFunc6 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 122); - SET_ENDLINE_BODY(t_2, 163); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_test__cmp__ops, t_1 ); - - /* test_arith := function ( ) - local x; - x := 5; - x := - x; - x := 1 / 2; - x := - x; - return; - end; */ - t_1 = NewFunction( NameFunc[7], 0, 0, HdlrFunc7 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 169); - SET_ENDLINE_BODY(t_2, 177); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_test__arith, t_1 ); - - /* test_tilde := function ( ) - local x; - return; - end; */ - t_1 = NewFunction( NameFunc[8], 0, 0, HdlrFunc8 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 183); - SET_ENDLINE_BODY(t_2, 199); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_test__tilde, t_1 ); - - /* test_list_rec_exprs := function ( ) - local l, x; - Display( [ ] ); - Display( [ 1, 2, 3 ] ); - Display( [ 1,, 3, [ 4, 5 ], rec( - x := [ 6, rec( - ) ] ) ] ); - l := [ ]; - l[1] := 1; - l[1 + 1] := 2; - l![3] := 3; - l![2 + 2] := 4; - Display( l ); - Print( "l[1] = ", l[1], "\n" ); - Print( "l[2] = ", l[1 + 1], "\n" ); - Print( "l[3] = ", l![3], "\n" ); - Print( "l[4] = ", l![2 + 2], "\n" ); - x := rec( - a := 1 ); - x.b := 2; - x.("c") := x.a + x.("b"); - x!.d := 42; - x!.("e") := 23; - Display( x ); - Print( "x.a = ", x.a, "\n" ); - Print( "x.b = ", x.("b"), "\n" ); - Print( "x.d = ", x!.d, "\n" ); - Print( "x.e = ", x!.("e"), "\n" ); - return; - end; */ - t_1 = NewFunction( NameFunc[9], 0, 0, HdlrFunc9 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 205); - SET_ENDLINE_BODY(t_2, 233); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_test__list__rec__exprs, t_1 ); - - /* myglobal := 1; */ - AssGVar( G_myglobal, INTOBJ_INT(1) ); - - /* test_IsBound_Unbind := function ( ) - local x; - Print( "Testing IsBound and Unbind for lvar\n" ); - x := 42; - Display( IsBound( x ) ); - Unbind( x ); - Display( IsBound( x ) ); - Print( "Testing IsBound and Unbind for gvar\n" ); - myglobal := 42; - Display( IsBound( myglobal ) ); - Unbind( myglobal ); - Display( IsBound( myglobal ) ); - Print( "Testing IsBound and Unbind for list\n" ); - x := [ 1, 2, 3 ]; - Display( IsBound( x[2] ) ); - Unbind( x[2] ); - Display( IsBound( x[2] ) ); - Print( "Testing IsBound and Unbind for list with bang\n" ); - x := [ 1, 2, 3 ]; - Display( IsBound( x![2] ) ); - Unbind( x![2] ); - Display( IsBound( x![2] ) ); - Print( "Testing IsBound and Unbind for record\n" ); - x := rec( - a := 1 ); - Display( IsBound( x.a ) ); - Unbind( x.a ); - Display( IsBound( x.a ) ); - Print( "Testing IsBound and Unbind for record with expr\n" ); - x := rec( - a := 1 ); - Display( IsBound( x.("a") ) ); - Unbind( x.("a") ); - Display( IsBound( x.("a") ) ); - Print( "Testing IsBound and Unbind for record with bang\n" ); - x := rec( - a := 1 ); - Display( IsBound( x!.a ) ); - Unbind( x!.a ); - Display( IsBound( x!.a ) ); - Print( "Testing IsBound and Unbind for record with bang and expr\n" ); - x := rec( - a := 1 ); - Display( IsBound( x!.("a") ) ); - Unbind( x!.("a") ); - Display( IsBound( x!.("a") ) ); - return; - end; */ - t_1 = NewFunction( NameFunc[10], 0, 0, HdlrFunc10 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 240); - SET_ENDLINE_BODY(t_2, 299); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_test__IsBound__Unbind, t_1 ); - - /* test_loops := function ( ) - local x; - Display( "testing repeat loop" ); - x := 0; - repeat - x := x + 1; - if x = 1 then - continue; - elif x = 4 then - break; - else - Display( x ); - fi; - until x >= 100; - Display( "testing while loop" ); - x := 0; - while x < 100 do - x := x + 1; - if x = 1 then - continue; - elif x = 4 then - break; - else - Display( x ); - fi; - od; - Display( "testing for loop" ); - for x in [ 1 .. 100 ] do - if x = 1 then - continue; - elif x = 4 then - break; - else - Display( x ); - fi; - od; - return; - end; */ - t_1 = NewFunction( NameFunc[11], 0, 0, HdlrFunc11 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 305); - SET_ENDLINE_BODY(t_2, 346); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_test__loops, t_1 ); - - /* runtest := function ( ) - test_int_constants( ); - test_func_calls( ); - test_cmp_ops( ); - test_arith( ); - test_tilde( ); - test_list_rec_exprs( ); - test_IsBound_Unbind( ); - test_loops( ); - Display( () ); - return; - end; */ - t_1 = NewFunction( NameFunc[12], 0, 0, HdlrFunc12 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 352); - SET_ENDLINE_BODY(t_2, 364); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_PushOptions = GVarName( "PushOptions" ); - G_PopOptions = GVarName( "PopOptions" ); - G_Print = GVarName( "Print" ); - G_test__int__constants = GVarName( "test_int_constants" ); - G_test__func__calls = GVarName( "test_func_calls" ); - G_Display = GVarName( "Display" ); - G_test__cmp__ops = GVarName( "test_cmp_ops" ); - G_test__arith = GVarName( "test_arith" ); - G_test__tilde = GVarName( "test_tilde" ); - G_test__list__rec__exprs = GVarName( "test_list_rec_exprs" ); - G_myglobal = GVarName( "myglobal" ); - G_test__IsBound__Unbind = GVarName( "test_IsBound_Unbind" ); - G_test__loops = GVarName( "test_loops" ); - G_runtest = GVarName( "runtest" ); - - /* record names used in handlers */ - R_myopt = RNamName( "myopt" ); - R_x = RNamName( "x" ); - R_a = RNamName( "a" ); - R_b = RNamName( "b" ); - R_d = RNamName( "d" ); - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - NameFunc[3] = 0; - NameFunc[4] = 0; - NameFunc[5] = 0; - NameFunc[6] = 0; - NameFunc[7] = 0; - NameFunc[8] = 0; - NameFunc[9] = 0; - NameFunc[10] = 0; - NameFunc[11] = 0; - NameFunc[12] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - InitFopyGVar( "PushOptions", &GF_PushOptions ); - InitFopyGVar( "PopOptions", &GF_PopOptions ); - InitFopyGVar( "Print", &GF_Print ); - InitFopyGVar( "test_int_constants", &GF_test__int__constants ); - InitFopyGVar( "test_func_calls", &GF_test__func__calls ); - InitFopyGVar( "Display", &GF_Display ); - InitFopyGVar( "test_cmp_ops", &GF_test__cmp__ops ); - InitFopyGVar( "test_arith", &GF_test__arith ); - InitFopyGVar( "test_tilde", &GF_test__tilde ); - InitFopyGVar( "test_list_rec_exprs", &GF_test__list__rec__exprs ); - InitCopyGVar( "myglobal", &GC_myglobal ); - InitFopyGVar( "test_IsBound_Unbind", &GF_test__IsBound__Unbind ); - InitFopyGVar( "test_loops", &GF_test__loops ); - - /* information for the functions */ - InitGlobalBag( &FileName, "basics.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "basics.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "basics.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "basics.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "basics.g:NameFunc[2]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc3, "basics.g:HdlrFunc3("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[3]), "basics.g:NameFunc[3]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc4, "basics.g:HdlrFunc4("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[4]), "basics.g:NameFunc[4]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc5, "basics.g:HdlrFunc5("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[5]), "basics.g:NameFunc[5]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc6, "basics.g:HdlrFunc6("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[6]), "basics.g:NameFunc[6]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc7, "basics.g:HdlrFunc7("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[7]), "basics.g:NameFunc[7]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc8, "basics.g:HdlrFunc8("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[8]), "basics.g:NameFunc[8]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc9, "basics.g:HdlrFunc9("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[9]), "basics.g:NameFunc[9]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc10, "basics.g:HdlrFunc10("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[10]), "basics.g:NameFunc[10]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc11, "basics.g:HdlrFunc11("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[11]), "basics.g:NameFunc[11]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc12, "basics.g:HdlrFunc12("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[12]), "basics.g:NameFunc[12]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "basics.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "basics.g", - .crc = -52605173, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__basics ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/callfunc.g.static.c b/tst/test-compile/callfunc.g.static.c deleted file mode 100644 index 4b885a2207..0000000000 --- a/tst/test-compile/callfunc.g.static.c +++ /dev/null @@ -1,1247 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "6760218" - -/* global variables used in handlers */ -static GVar G_ReturnTrue; -static Obj GC_ReturnTrue; -static GVar G_fail; -static Obj GC_fail; -static GVar G_Print; -static Obj GF_Print; -static GVar G_CALL__WITH__CATCH; -static Obj GF_CALL__WITH__CATCH; -static GVar G_p0; -static Obj GF_p0; -static GVar G_p1; -static Obj GF_p1; -static GVar G_p7; -static Obj GF_p7; -static GVar G_f0; -static Obj GF_f0; -static GVar G_Display; -static Obj GF_Display; -static GVar G_f1; -static Obj GF_f1; -static GVar G_f7; -static Obj GF_f7; -static GVar G_runtest; -static GVar G_NewCategory; -static Obj GF_NewCategory; -static GVar G_IsFunction; -static Obj GC_IsFunction; -static GVar G_InstallMethod; -static Obj GF_InstallMethod; -static GVar G_CallFuncList; -static Obj GC_CallFuncList; -static GVar G_IsList; -static Obj GC_IsList; -static GVar G_Objectify; -static Obj GF_Objectify; -static GVar G_NewType; -static Obj GF_NewType; -static GVar G_NewFamily; -static Obj GF_NewFamily; -static GVar G_IsPositionalObjectRep; -static Obj GC_IsPositionalObjectRep; -static GVar G_BreakOnError; - -/* record names used in handlers */ - -/* information for the functions */ -static Obj NameFunc[16]; -static Obj FileName; - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self, - Obj a_f ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "p0\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "p0\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* f( ); */ - if ( TNUM_OBJ( a_f ) == T_FUNCTION ) { - CALL_0ARGS( a_f ); - } - else { - DoOperation2Args( CallFuncListOper, a_f, NewPlistFromArgs( ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 3 */ -static Obj HdlrFunc3 ( - Obj self, - Obj a_f ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "p1\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "p1\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* f( 1 ); */ - if ( TNUM_OBJ( a_f ) == T_FUNCTION ) { - CALL_1ARGS( a_f, INTOBJ_INT(1) ); - } - else { - DoOperation2Args( CallFuncListOper, a_f, NewPlistFromArgs( INTOBJ_INT(1) ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 4 */ -static Obj HdlrFunc4 ( - Obj self, - Obj a_f ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "p7\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "p7\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* f( 1, 2, 3, 4, 5, 6, 7 ); */ - t_1 = NEW_PLIST( T_PLIST, 7 ); - SET_LEN_PLIST( t_1, 7 ); - SET_ELM_PLIST( t_1, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_1, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_1, 3, INTOBJ_INT(3) ); - SET_ELM_PLIST( t_1, 4, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_1, 5, INTOBJ_INT(5) ); - SET_ELM_PLIST( t_1, 6, INTOBJ_INT(6) ); - SET_ELM_PLIST( t_1, 7, INTOBJ_INT(7) ); - if ( TNUM_OBJ( a_f ) == T_FUNCTION ) { - CALL_XARGS( a_f, t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, a_f, t_1 ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 5 */ -static Obj HdlrFunc5 ( - Obj self, - Obj a_f ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "f0\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "f0\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Display( f( ) ); */ - t_1 = GF_Display; - if ( TNUM_OBJ( a_f ) == T_FUNCTION ) { - t_2 = CALL_0ARGS( a_f ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, a_f, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_2 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 6 */ -static Obj HdlrFunc6 ( - Obj self, - Obj a_f ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "f1\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "f1\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Display( f( 1 ) ); */ - t_1 = GF_Display; - if ( TNUM_OBJ( a_f ) == T_FUNCTION ) { - t_2 = CALL_1ARGS( a_f, INTOBJ_INT(1) ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, a_f, NewPlistFromArgs( INTOBJ_INT(1) ) ); - } - CHECK_FUNC_RESULT( t_2 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 7 */ -static Obj HdlrFunc7 ( - Obj self, - Obj a_f ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "f7\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "f7\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Display( f( 1, 2, 3, 4, 5, 6, 7 ) ); */ - t_1 = GF_Display; - t_3 = NEW_PLIST( T_PLIST, 7 ); - SET_LEN_PLIST( t_3, 7 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_3, 3, INTOBJ_INT(3) ); - SET_ELM_PLIST( t_3, 4, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_3, 5, INTOBJ_INT(5) ); - SET_ELM_PLIST( t_3, 6, INTOBJ_INT(6) ); - SET_ELM_PLIST( t_3, 7, INTOBJ_INT(7) ); - if ( TNUM_OBJ( a_f ) == T_FUNCTION ) { - t_2 = CALL_XARGS( a_f, t_3 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, a_f, t_3 ); - } - CHECK_FUNC_RESULT( t_2 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 9 */ -static Obj HdlrFunc9 ( - Obj self, - Obj a_func, - Obj a_args ) -{ - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return args; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return a_args; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 10 */ -static Obj HdlrFunc10 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* p0( fail ); */ - t_1 = GF_p0; - t_2 = GC_fail; - CHECK_BOUND( t_2, "fail" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 11 */ -static Obj HdlrFunc11 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* p1( fail ); */ - t_1 = GF_p1; - t_2 = GC_fail; - CHECK_BOUND( t_2, "fail" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 12 */ -static Obj HdlrFunc12 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* p7( fail ); */ - t_1 = GF_p7; - t_2 = GC_fail; - CHECK_BOUND( t_2, "fail" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 13 */ -static Obj HdlrFunc13 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* f0( fail ); */ - t_1 = GF_f0; - t_2 = GC_fail; - CHECK_BOUND( t_2, "fail" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 14 */ -static Obj HdlrFunc14 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* f1( fail ); */ - t_1 = GF_f1; - t_2 = GC_fail; - CHECK_BOUND( t_2, "fail" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 15 */ -static Obj HdlrFunc15 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* f7( fail ); */ - t_1 = GF_f7; - t_2 = GC_fail; - CHECK_BOUND( t_2, "fail" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 8 */ -static Obj HdlrFunc8 ( - Obj self ) -{ - Obj l_IsCustomFunction = 0; - Obj l_f = 0; - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Obj t_5 = 0; - Obj t_6 = 0; - Obj t_7 = 0; - Obj t_8 = 0; - (void)l_IsCustomFunction; - (void)l_f; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "test with a regular function\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "test with a regular function\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* f := ReturnTrue; */ - t_1 = GC_ReturnTrue; - CHECK_BOUND( t_1, "ReturnTrue" ); - l_f = t_1; - - /* p0( f ); */ - t_1 = GF_p0; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* p1( f ); */ - t_1 = GF_p1; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* p7( f ); */ - t_1 = GF_p7; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* f0( f ); */ - t_1 = GF_f0; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* f1( f ); */ - t_1 = GF_f1; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* f7( f ); */ - t_1 = GF_f7; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* Print( "test with a custom function\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "test with a custom function\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* IsCustomFunction := NewCategory( "IsCustomFunction", IsFunction ); */ - t_2 = GF_NewCategory; - t_3 = MakeString( "IsCustomFunction" ); - t_4 = GC_IsFunction; - CHECK_BOUND( t_4, "IsFunction" ); - if ( TNUM_OBJ( t_2 ) == T_FUNCTION ) { - t_1 = CALL_2ARGS( t_2, t_3, t_4 ); - } - else { - t_1 = DoOperation2Args( CallFuncListOper, t_2, NewPlistFromArgs( t_3, t_4 ) ); - } - CHECK_FUNC_RESULT( t_1 ); - l_IsCustomFunction = t_1; - - /* InstallMethod( CallFuncList, [ IsCustomFunction, IsList ], function ( func, args ) - return args; - end ); */ - t_1 = GF_InstallMethod; - t_2 = GC_CallFuncList; - CHECK_BOUND( t_2, "CallFuncList" ); - t_3 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_3, 2 ); - SET_ELM_PLIST( t_3, 1, l_IsCustomFunction ); - CHANGED_BAG( t_3 ); - t_4 = GC_IsList; - CHECK_BOUND( t_4, "IsList" ); - SET_ELM_PLIST( t_3, 2, t_4 ); - CHANGED_BAG( t_3 ); - t_4 = NewFunction( NameFunc[9], 2, ArgStringToList("func,args"), HdlrFunc9 ); - SET_ENVI_FUNC( t_4, STATE(CurrLVars) ); - t_5 = NewFunctionBody(); - SET_STARTLINE_BODY(t_5, 49); - SET_ENDLINE_BODY(t_5, 49); - SET_FILENAME_BODY(t_5, FileName); - SET_BODY_FUNC(t_4, t_5); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, t_3, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3, t_4 ) ); - } - - /* f := Objectify( NewType( NewFamily( "CustomFunctionFamily" ), IsCustomFunction and IsPositionalObjectRep ), [ ] ); */ - t_2 = GF_Objectify; - t_4 = GF_NewType; - t_6 = GF_NewFamily; - t_7 = MakeString( "CustomFunctionFamily" ); - if ( TNUM_OBJ( t_6 ) == T_FUNCTION ) { - t_5 = CALL_1ARGS( t_6, t_7 ); - } - else { - t_5 = DoOperation2Args( CallFuncListOper, t_6, NewPlistFromArgs( t_7 ) ); - } - CHECK_FUNC_RESULT( t_5 ); - if ( l_IsCustomFunction == False ) { - t_6 = l_IsCustomFunction; - } - else if ( l_IsCustomFunction == True ) { - t_7 = GC_IsPositionalObjectRep; - CHECK_BOUND( t_7, "IsPositionalObjectRep" ); - CHECK_BOOL( t_7 ); - t_6 = t_7; - } - else if (IS_FILTER( l_IsCustomFunction ) ) { - t_8 = GC_IsPositionalObjectRep; - CHECK_BOUND( t_8, "IsPositionalObjectRep" ); - t_6 = NewAndFilter( l_IsCustomFunction, t_8 ); - } - else { - RequireArgumentEx(0, l_IsCustomFunction, "", - "must be 'true' or 'false' or a filter" ); - } - if ( TNUM_OBJ( t_4 ) == T_FUNCTION ) { - t_3 = CALL_2ARGS( t_4, t_5, t_6 ); - } - else { - t_3 = DoOperation2Args( CallFuncListOper, t_4, NewPlistFromArgs( t_5, t_6 ) ); - } - CHECK_FUNC_RESULT( t_3 ); - t_4 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_4, 0 ); - if ( TNUM_OBJ( t_2 ) == T_FUNCTION ) { - t_1 = CALL_2ARGS( t_2, t_3, t_4 ); - } - else { - t_1 = DoOperation2Args( CallFuncListOper, t_2, NewPlistFromArgs( t_3, t_4 ) ); - } - CHECK_FUNC_RESULT( t_1 ); - l_f = t_1; - - /* p0( f ); */ - t_1 = GF_p0; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* p1( f ); */ - t_1 = GF_p1; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* p7( f ); */ - t_1 = GF_p7; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* f0( f ); */ - t_1 = GF_f0; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* f1( f ); */ - t_1 = GF_f1; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* f7( f ); */ - t_1 = GF_f7; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, l_f ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( l_f ) ); - } - - /* BreakOnError := false; */ - t_1 = False; - AssGVar( G_BreakOnError, t_1 ); - - /* Print( "test with a non-function\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "test with a non-function\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - p0( fail ); - return; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[10], 0, 0, HdlrFunc10 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 64); - SET_ENDLINE_BODY(t_3, 64); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - p1( fail ); - return; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[11], 0, 0, HdlrFunc11 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 65); - SET_ENDLINE_BODY(t_3, 65); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - p7( fail ); - return; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[12], 0, 0, HdlrFunc12 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 66); - SET_ENDLINE_BODY(t_3, 66); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - f0( fail ); - return; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[13], 0, 0, HdlrFunc13 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 68); - SET_ENDLINE_BODY(t_3, 68); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - f1( fail ); - return; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[14], 0, 0, HdlrFunc14 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 69); - SET_ENDLINE_BODY(t_3, 69); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - f7( fail ); - return; - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[15], 0, 0, HdlrFunc15 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 70); - SET_ENDLINE_BODY(t_3, 70); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* p0 := function ( f ) - Print( "p0\n" ); - f( ); - return; - end; */ - t_1 = NewFunction( NameFunc[2], 1, ArgStringToList("f"), HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 2); - SET_ENDLINE_BODY(t_2, 5); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_p0, t_1 ); - - /* p1 := function ( f ) - Print( "p1\n" ); - f( 1 ); - return; - end; */ - t_1 = NewFunction( NameFunc[3], 1, ArgStringToList("f"), HdlrFunc3 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 7); - SET_ENDLINE_BODY(t_2, 10); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_p1, t_1 ); - - /* p7 := function ( f ) - Print( "p7\n" ); - f( 1, 2, 3, 4, 5, 6, 7 ); - return; - end; */ - t_1 = NewFunction( NameFunc[4], 1, ArgStringToList("f"), HdlrFunc4 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 12); - SET_ENDLINE_BODY(t_2, 15); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_p7, t_1 ); - - /* f0 := function ( f ) - Print( "f0\n" ); - Display( f( ) ); - return; - end; */ - t_1 = NewFunction( NameFunc[5], 1, ArgStringToList("f"), HdlrFunc5 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 18); - SET_ENDLINE_BODY(t_2, 21); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_f0, t_1 ); - - /* f1 := function ( f ) - Print( "f1\n" ); - Display( f( 1 ) ); - return; - end; */ - t_1 = NewFunction( NameFunc[6], 1, ArgStringToList("f"), HdlrFunc6 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 23); - SET_ENDLINE_BODY(t_2, 26); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_f1, t_1 ); - - /* f7 := function ( f ) - Print( "f7\n" ); - Display( f( 1, 2, 3, 4, 5, 6, 7 ) ); - return; - end; */ - t_1 = NewFunction( NameFunc[7], 1, ArgStringToList("f"), HdlrFunc7 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 28); - SET_ENDLINE_BODY(t_2, 31); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_f7, t_1 ); - - /* runtest := function ( ) - local IsCustomFunction, f; - Print( "test with a regular function\n" ); - f := ReturnTrue; - p0( f ); - p1( f ); - p7( f ); - f0( f ); - f1( f ); - f7( f ); - Print( "test with a custom function\n" ); - IsCustomFunction := NewCategory( "IsCustomFunction", IsFunction ); - InstallMethod( CallFuncList, [ IsCustomFunction, IsList ], function ( func, args ) - return args; - end ); - f := Objectify( NewType( NewFamily( "CustomFunctionFamily" ), IsCustomFunction and IsPositionalObjectRep ), [ ] ); - p0( f ); - p1( f ); - p7( f ); - f0( f ); - f1( f ); - f7( f ); - BreakOnError := false; - Print( "test with a non-function\n" ); - CALL_WITH_CATCH( function ( ) - p0( fail ); - return; - end, [ ] ); - CALL_WITH_CATCH( function ( ) - p1( fail ); - return; - end, [ ] ); - CALL_WITH_CATCH( function ( ) - p7( fail ); - return; - end, [ ] ); - CALL_WITH_CATCH( function ( ) - f0( fail ); - return; - end, [ ] ); - CALL_WITH_CATCH( function ( ) - f1( fail ); - return; - end, [ ] ); - CALL_WITH_CATCH( function ( ) - f7( fail ); - return; - end, [ ] ); - return; - end; */ - t_1 = NewFunction( NameFunc[8], 0, 0, HdlrFunc8 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 33); - SET_ENDLINE_BODY(t_2, 72); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_ReturnTrue = GVarName( "ReturnTrue" ); - G_fail = GVarName( "fail" ); - G_Print = GVarName( "Print" ); - G_CALL__WITH__CATCH = GVarName( "CALL_WITH_CATCH" ); - G_p0 = GVarName( "p0" ); - G_p1 = GVarName( "p1" ); - G_p7 = GVarName( "p7" ); - G_f0 = GVarName( "f0" ); - G_Display = GVarName( "Display" ); - G_f1 = GVarName( "f1" ); - G_f7 = GVarName( "f7" ); - G_runtest = GVarName( "runtest" ); - G_NewCategory = GVarName( "NewCategory" ); - G_IsFunction = GVarName( "IsFunction" ); - G_InstallMethod = GVarName( "InstallMethod" ); - G_CallFuncList = GVarName( "CallFuncList" ); - G_IsList = GVarName( "IsList" ); - G_Objectify = GVarName( "Objectify" ); - G_NewType = GVarName( "NewType" ); - G_NewFamily = GVarName( "NewFamily" ); - G_IsPositionalObjectRep = GVarName( "IsPositionalObjectRep" ); - G_BreakOnError = GVarName( "BreakOnError" ); - - /* record names used in handlers */ - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - NameFunc[3] = 0; - NameFunc[4] = 0; - NameFunc[5] = 0; - NameFunc[6] = 0; - NameFunc[7] = 0; - NameFunc[8] = 0; - NameFunc[9] = 0; - NameFunc[10] = 0; - NameFunc[11] = 0; - NameFunc[12] = 0; - NameFunc[13] = 0; - NameFunc[14] = 0; - NameFunc[15] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - InitCopyGVar( "ReturnTrue", &GC_ReturnTrue ); - InitCopyGVar( "fail", &GC_fail ); - InitFopyGVar( "Print", &GF_Print ); - InitFopyGVar( "CALL_WITH_CATCH", &GF_CALL__WITH__CATCH ); - InitFopyGVar( "p0", &GF_p0 ); - InitFopyGVar( "p1", &GF_p1 ); - InitFopyGVar( "p7", &GF_p7 ); - InitFopyGVar( "f0", &GF_f0 ); - InitFopyGVar( "Display", &GF_Display ); - InitFopyGVar( "f1", &GF_f1 ); - InitFopyGVar( "f7", &GF_f7 ); - InitFopyGVar( "NewCategory", &GF_NewCategory ); - InitCopyGVar( "IsFunction", &GC_IsFunction ); - InitFopyGVar( "InstallMethod", &GF_InstallMethod ); - InitCopyGVar( "CallFuncList", &GC_CallFuncList ); - InitCopyGVar( "IsList", &GC_IsList ); - InitFopyGVar( "Objectify", &GF_Objectify ); - InitFopyGVar( "NewType", &GF_NewType ); - InitFopyGVar( "NewFamily", &GF_NewFamily ); - InitCopyGVar( "IsPositionalObjectRep", &GC_IsPositionalObjectRep ); - - /* information for the functions */ - InitGlobalBag( &FileName, "callfunc.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "callfunc.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "callfunc.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "callfunc.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "callfunc.g:NameFunc[2]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc3, "callfunc.g:HdlrFunc3("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[3]), "callfunc.g:NameFunc[3]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc4, "callfunc.g:HdlrFunc4("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[4]), "callfunc.g:NameFunc[4]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc5, "callfunc.g:HdlrFunc5("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[5]), "callfunc.g:NameFunc[5]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc6, "callfunc.g:HdlrFunc6("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[6]), "callfunc.g:NameFunc[6]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc7, "callfunc.g:HdlrFunc7("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[7]), "callfunc.g:NameFunc[7]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc8, "callfunc.g:HdlrFunc8("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[8]), "callfunc.g:NameFunc[8]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc9, "callfunc.g:HdlrFunc9("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[9]), "callfunc.g:NameFunc[9]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc10, "callfunc.g:HdlrFunc10("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[10]), "callfunc.g:NameFunc[10]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc11, "callfunc.g:HdlrFunc11("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[11]), "callfunc.g:NameFunc[11]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc12, "callfunc.g:HdlrFunc12("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[12]), "callfunc.g:NameFunc[12]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc13, "callfunc.g:HdlrFunc13("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[13]), "callfunc.g:NameFunc[13]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc14, "callfunc.g:HdlrFunc14("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[14]), "callfunc.g:NameFunc[14]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc15, "callfunc.g:HdlrFunc15("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[15]), "callfunc.g:NameFunc[15]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "callfunc.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "callfunc.g", - .crc = 6760218, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__callfunc ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/function_types.g.static.c b/tst/test-compile/function_types.g.static.c deleted file mode 100644 index e20ee8eed3..0000000000 --- a/tst/test-compile/function_types.g.static.c +++ /dev/null @@ -1,674 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "-15431547" - -/* global variables used in handlers */ -static GVar G_Print; -static Obj GF_Print; -static GVar G_CALL__WITH__CATCH; -static Obj GF_CALL__WITH__CATCH; -static GVar G_f1; -static Obj GF_f1; -static GVar G_f2; -static Obj GF_f2; -static GVar G_f3; -static Obj GF_f3; -static GVar G_f4; -static Obj GF_f4; -static GVar G_runtest; -static GVar G_BreakOnError; - -/* record names used in handlers */ - -/* information for the functions */ -static Obj NameFunc[11]; -static Obj FileName; - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self, - Obj a_a ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "f1:", a, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "f1:" ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, a_a, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, a_a, t_3 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 3 */ -static Obj HdlrFunc3 ( - Obj self, - Obj a_a, - Obj a_b ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "f2:", a, ":", b, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "f2:" ); - t_3 = MakeString( ":" ); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_5ARGS( t_1, t_2, a_a, t_3, a_b, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, a_a, t_3, a_b, t_4 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 4 */ -static Obj HdlrFunc4 ( - Obj self, - Obj a_a ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "f3:", a, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "f3:" ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, t_2, a_a, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, a_a, t_3 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 5 */ -static Obj HdlrFunc5 ( - Obj self, - Obj args ) -{ - Obj a_a; - Obj a_b; - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Bag oldFrame; - CHECK_NR_AT_LEAST_ARGS( 2, args ) - a_a = ELM_PLIST( args, 1 ); - Obj x_temp_range = Range2Check(INTOBJ_INT(2), INTOBJ_INT(LEN_PLIST(args))); - a_b = ELMS_LIST(args , x_temp_range); - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( "f4:", a, ":", b, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "f4:" ); - t_3 = MakeString( ":" ); - t_4 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_5ARGS( t_1, t_2, a_a, t_3, a_b, t_4 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, a_a, t_3, a_b, t_4 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 7 */ -static Obj HdlrFunc7 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return f1( ); */ - t_2 = GF_f1; - if ( TNUM_OBJ( t_2 ) == T_FUNCTION ) { - t_1 = CALL_0ARGS( t_2 ); - } - else { - t_1 = DoOperation2Args( CallFuncListOper, t_2, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_1 ); - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 8 */ -static Obj HdlrFunc8 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return f1( 1, 2 ); */ - t_2 = GF_f1; - if ( TNUM_OBJ( t_2 ) == T_FUNCTION ) { - t_1 = CALL_2ARGS( t_2, INTOBJ_INT(1), INTOBJ_INT(2) ); - } - else { - t_1 = DoOperation2Args( CallFuncListOper, t_2, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2) ) ); - } - CHECK_FUNC_RESULT( t_1 ); - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 9 */ -static Obj HdlrFunc9 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return f2( 1, 2, 3 ); */ - t_2 = GF_f2; - if ( TNUM_OBJ( t_2 ) == T_FUNCTION ) { - t_1 = CALL_3ARGS( t_2, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3) ); - } - else { - t_1 = DoOperation2Args( CallFuncListOper, t_2, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3) ) ); - } - CHECK_FUNC_RESULT( t_1 ); - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 10 */ -static Obj HdlrFunc10 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return f4( ); */ - t_2 = GF_f4; - if ( TNUM_OBJ( t_2 ) == T_FUNCTION ) { - t_1 = CALL_0ARGS( t_2 ); - } - else { - t_1 = DoOperation2Args( CallFuncListOper, t_2, NewPlistFromArgs( ) ); - } - CHECK_FUNC_RESULT( t_1 ); - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 6 */ -static Obj HdlrFunc6 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* f1( 2 ); */ - t_1 = GF_f1; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, INTOBJ_INT(2) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(2) ) ); - } - - /* f2( 2, 3 ); */ - t_1 = GF_f2; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, INTOBJ_INT(2), INTOBJ_INT(3) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(2), INTOBJ_INT(3) ) ); - } - - /* f3( ); */ - t_1 = GF_f3; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_0ARGS( t_1 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( ) ); - } - - /* f3( 2 ); */ - t_1 = GF_f3; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, INTOBJ_INT(2) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(2) ) ); - } - - /* f3( 2, 3, 4 ); */ - t_1 = GF_f3; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(2), INTOBJ_INT(3), INTOBJ_INT(4) ) ); - } - - /* f4( 1 ); */ - t_1 = GF_f4; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, INTOBJ_INT(1) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(1) ) ); - } - - /* f4( 1, 2 ); */ - t_1 = GF_f4; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, INTOBJ_INT(1), INTOBJ_INT(2) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2) ) ); - } - - /* f4( 1, 2, 3 ); */ - t_1 = GF_f4; - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_3ARGS( t_1, INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(3) ) ); - } - - /* BreakOnError := false; */ - t_1 = False; - AssGVar( G_BreakOnError, t_1 ); - - /* CALL_WITH_CATCH( function ( ) - return f1( ); - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[7], 0, 0, HdlrFunc7 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 29); - SET_ENDLINE_BODY(t_3, 29); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - return f1( 1, 2 ); - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[8], 0, 0, HdlrFunc8 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 30); - SET_ENDLINE_BODY(t_3, 30); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - return f2( 1, 2, 3 ); - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[9], 0, 0, HdlrFunc9 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 31); - SET_ENDLINE_BODY(t_3, 31); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( function ( ) - return f4( ); - end, [ ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = NewFunction( NameFunc[10], 0, 0, HdlrFunc10 ); - SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); - t_3 = NewFunctionBody(); - SET_STARTLINE_BODY(t_3, 32); - SET_ENDLINE_BODY(t_3, 32); - SET_FILENAME_BODY(t_3, FileName); - SET_BODY_FUNC(t_2, t_3); - t_3 = NEW_PLIST( T_PLIST, 0 ); - SET_LEN_PLIST( t_3, 0 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* f1 := function ( a ) - Print( "f1:", a, "\n" ); - return; - end; */ - t_1 = NewFunction( NameFunc[2], 1, ArgStringToList("a"), HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 1); - SET_ENDLINE_BODY(t_2, 3); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_f1, t_1 ); - - /* f2 := function ( a, b ) - Print( "f2:", a, ":", b, "\n" ); - return; - end; */ - t_1 = NewFunction( NameFunc[3], 2, ArgStringToList("a,b"), HdlrFunc3 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 5); - SET_ENDLINE_BODY(t_2, 7); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_f2, t_1 ); - - /* f3 := function ( a... ) - Print( "f3:", a, "\n" ); - return; - end; */ - t_1 = NewFunction( NameFunc[4], -1, ArgStringToList("a"), HdlrFunc4 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 9); - SET_ENDLINE_BODY(t_2, 11); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_f3, t_1 ); - - /* f4 := function ( a, b... ) - Print( "f4:", a, ":", b, "\n" ); - return; - end; */ - t_1 = NewFunction( NameFunc[5], -2, ArgStringToList("a,b"), HdlrFunc5 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 13); - SET_ENDLINE_BODY(t_2, 15); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_f4, t_1 ); - - /* runtest := function ( ) - f1( 2 ); - f2( 2, 3 ); - f3( ); - f3( 2 ); - f3( 2, 3, 4 ); - f4( 1 ); - f4( 1, 2 ); - f4( 1, 2, 3 ); - BreakOnError := false; - CALL_WITH_CATCH( function ( ) - return f1( ); - end, [ ] ); - CALL_WITH_CATCH( function ( ) - return f1( 1, 2 ); - end, [ ] ); - CALL_WITH_CATCH( function ( ) - return f2( 1, 2, 3 ); - end, [ ] ); - CALL_WITH_CATCH( function ( ) - return f4( ); - end, [ ] ); - return; - end; */ - t_1 = NewFunction( NameFunc[6], 0, 0, HdlrFunc6 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 17); - SET_ENDLINE_BODY(t_2, 34); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_Print = GVarName( "Print" ); - G_CALL__WITH__CATCH = GVarName( "CALL_WITH_CATCH" ); - G_f1 = GVarName( "f1" ); - G_f2 = GVarName( "f2" ); - G_f3 = GVarName( "f3" ); - G_f4 = GVarName( "f4" ); - G_runtest = GVarName( "runtest" ); - G_BreakOnError = GVarName( "BreakOnError" ); - - /* record names used in handlers */ - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - NameFunc[3] = 0; - NameFunc[4] = 0; - NameFunc[5] = 0; - NameFunc[6] = 0; - NameFunc[7] = 0; - NameFunc[8] = 0; - NameFunc[9] = 0; - NameFunc[10] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - InitFopyGVar( "Print", &GF_Print ); - InitFopyGVar( "CALL_WITH_CATCH", &GF_CALL__WITH__CATCH ); - InitFopyGVar( "f1", &GF_f1 ); - InitFopyGVar( "f2", &GF_f2 ); - InitFopyGVar( "f3", &GF_f3 ); - InitFopyGVar( "f4", &GF_f4 ); - - /* information for the functions */ - InitGlobalBag( &FileName, "function_types.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "function_types.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "function_types.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "function_types.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "function_types.g:NameFunc[2]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc3, "function_types.g:HdlrFunc3("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[3]), "function_types.g:NameFunc[3]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc4, "function_types.g:HdlrFunc4("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[4]), "function_types.g:NameFunc[4]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc5, "function_types.g:HdlrFunc5("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[5]), "function_types.g:NameFunc[5]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc6, "function_types.g:HdlrFunc6("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[6]), "function_types.g:NameFunc[6]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc7, "function_types.g:HdlrFunc7("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[7]), "function_types.g:NameFunc[7]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc8, "function_types.g:HdlrFunc8("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[8]), "function_types.g:NameFunc[8]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc9, "function_types.g:HdlrFunc9("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[9]), "function_types.g:NameFunc[9]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc10, "function_types.g:HdlrFunc10("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[10]), "function_types.g:NameFunc[10]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "function_types.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "function_types.g", - .crc = -15431547, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__function__types ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/info.g.static.c b/tst/test-compile/info.g.static.c deleted file mode 100644 index 661f917384..0000000000 --- a/tst/test-compile/info.g.static.c +++ /dev/null @@ -1,281 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "58141340" - -/* global variables used in handlers */ -static GVar G_Print; -static Obj GF_Print; -static GVar G_runtest; -static GVar G_InfoLevel; -static Obj GF_InfoLevel; -static GVar G_InfoDebug; -static Obj GC_InfoDebug; -static GVar G_SetInfoLevel; -static Obj GF_SetInfoLevel; - -/* record names used in handlers */ - -/* information for the functions */ -static Obj NameFunc[3]; -static Obj FileName; - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( InfoLevel( InfoDebug ), "\n" ); */ - t_1 = GF_Print; - t_3 = GF_InfoLevel; - t_4 = GC_InfoDebug; - CHECK_BOUND( t_4, "InfoDebug" ); - if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) { - t_2 = CALL_1ARGS( t_3, t_4 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( t_4 ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Info( ... ); */ - t_1 = GC_InfoDebug; - CHECK_BOUND( t_1, "InfoDebug" ); - t_3 = InfoCheckLevel( t_1, INTOBJ_INT(2) ); - if ( t_3 == True ) { - t_2 = NEW_PLIST( T_PLIST, 1 ); - SET_LEN_PLIST( t_2, 1 ); - t_3 = MakeString( "Do not print" ); - SET_ELM_PLIST( t_2, 1, t_3 ); - CHANGED_BAG(t_2); - InfoDoPrint( t_1, INTOBJ_INT(2), t_2 ); - } - - /* Info( ... ); */ - t_1 = GC_InfoDebug; - CHECK_BOUND( t_1, "InfoDebug" ); - t_3 = InfoCheckLevel( t_1, INTOBJ_INT(1) ); - if ( t_3 == True ) { - t_2 = NEW_PLIST( T_PLIST, 1 ); - SET_LEN_PLIST( t_2, 1 ); - t_3 = MakeString( "print this A" ); - SET_ELM_PLIST( t_2, 1, t_3 ); - CHANGED_BAG(t_2); - InfoDoPrint( t_1, INTOBJ_INT(1), t_2 ); - } - - /* SetInfoLevel( InfoDebug, 2 ); */ - t_1 = GF_SetInfoLevel; - t_2 = GC_InfoDebug; - CHECK_BOUND( t_2, "InfoDebug" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, INTOBJ_INT(2) ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, INTOBJ_INT(2) ) ); - } - - /* Print( InfoLevel( InfoDebug ), "\n" ); */ - t_1 = GF_Print; - t_3 = GF_InfoLevel; - t_4 = GC_InfoDebug; - CHECK_BOUND( t_4, "InfoDebug" ); - if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) { - t_2 = CALL_1ARGS( t_3, t_4 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( t_4 ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Info( ... ); */ - t_1 = GC_InfoDebug; - CHECK_BOUND( t_1, "InfoDebug" ); - t_3 = InfoCheckLevel( t_1, INTOBJ_INT(3) ); - if ( t_3 == True ) { - t_2 = NEW_PLIST( T_PLIST, 1 ); - SET_LEN_PLIST( t_2, 1 ); - t_3 = MakeString( "Do not print" ); - SET_ELM_PLIST( t_2, 1, t_3 ); - CHANGED_BAG(t_2); - InfoDoPrint( t_1, INTOBJ_INT(3), t_2 ); - } - - /* Info( ... ); */ - t_1 = GC_InfoDebug; - CHECK_BOUND( t_1, "InfoDebug" ); - t_3 = InfoCheckLevel( t_1, INTOBJ_INT(2) ); - if ( t_3 == True ) { - t_2 = NEW_PLIST( T_PLIST, 1 ); - SET_LEN_PLIST( t_2, 1 ); - t_3 = MakeString( "print this B" ); - SET_ELM_PLIST( t_2, 1, t_3 ); - CHANGED_BAG(t_2); - InfoDoPrint( t_1, INTOBJ_INT(2), t_2 ); - } - - /* Info( ... ); */ - t_1 = GC_InfoDebug; - CHECK_BOUND( t_1, "InfoDebug" ); - t_3 = InfoCheckLevel( t_1, INTOBJ_INT(1) ); - if ( t_3 == True ) { - t_2 = NEW_PLIST( T_PLIST, 1 ); - SET_LEN_PLIST( t_2, 1 ); - t_3 = MakeString( "print this C" ); - SET_ELM_PLIST( t_2, 1, t_3 ); - CHANGED_BAG(t_2); - InfoDoPrint( t_1, INTOBJ_INT(1), t_2 ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* runtest := function ( ) - Print( InfoLevel( InfoDebug ), "\n" ); - Info( InfoDebug, 2, "Do not print" ); - Info( InfoDebug, 1, "print this A" ); - SetInfoLevel( InfoDebug, 2 ); - Print( InfoLevel( InfoDebug ), "\n" ); - Info( InfoDebug, 3, "Do not print" ); - Info( InfoDebug, 2, "print this B" ); - Info( InfoDebug, 1, "print this C" ); - return; - end; */ - t_1 = NewFunction( NameFunc[2], 0, 0, HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 1); - SET_ENDLINE_BODY(t_2, 10); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_Print = GVarName( "Print" ); - G_runtest = GVarName( "runtest" ); - G_InfoLevel = GVarName( "InfoLevel" ); - G_InfoDebug = GVarName( "InfoDebug" ); - G_SetInfoLevel = GVarName( "SetInfoLevel" ); - - /* record names used in handlers */ - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - InitFopyGVar( "Print", &GF_Print ); - InitFopyGVar( "InfoLevel", &GF_InfoLevel ); - InitCopyGVar( "InfoDebug", &GC_InfoDebug ); - InitFopyGVar( "SetInfoLevel", &GF_SetInfoLevel ); - - /* information for the functions */ - InitGlobalBag( &FileName, "info.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "info.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "info.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "info.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "info.g:NameFunc[2]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "info.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "info.g", - .crc = 58141340, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__info ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/plus.g.static.c b/tst/test-compile/plus.g.static.c deleted file mode 100644 index 4bf5901547..0000000000 --- a/tst/test-compile/plus.g.static.c +++ /dev/null @@ -1,139 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "5799640" - -/* global variables used in handlers */ -static GVar G_runtest; - -/* record names used in handlers */ - -/* information for the functions */ -static Obj NameFunc[3]; -static Obj FileName; - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self ) -{ - Obj t_1 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return 1 + 2; */ - C_SUM_INTOBJS( t_1, INTOBJ_INT(1), INTOBJ_INT(2) ) - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* runtest := function ( ) - return 1 + 2; - end; */ - t_1 = NewFunction( NameFunc[2], 0, 0, HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 1); - SET_ENDLINE_BODY(t_2, 3); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_runtest = GVarName( "runtest" ); - - /* record names used in handlers */ - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - - /* information for the functions */ - InitGlobalBag( &FileName, "plus.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "plus.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "plus.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "plus.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "plus.g:NameFunc[2]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "plus.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "plus.g", - .crc = 5799640, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__plus ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/print_various.g.static.c b/tst/test-compile/print_various.g.static.c deleted file mode 100644 index 64ccbc30f8..0000000000 --- a/tst/test-compile/print_various.g.static.c +++ /dev/null @@ -1,255 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "71331546" - -/* global variables used in handlers */ -static GVar G_Print; -static Obj GF_Print; -static GVar G_runtest; -static GVar G_Group; -static Obj GF_Group; - -/* record names used in handlers */ - -/* information for the functions */ -static Obj NameFunc[3]; -static Obj FileName; - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Obj t_5 = 0; - Obj t_6 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* Print( 1, "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, INTOBJ_INT(1), t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( INTOBJ_INT(1), t_2 ) ); - } - - /* Print( "abc", "\n" ); */ - t_1 = GF_Print; - t_2 = MakeString( "abc" ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( (1,2)(5,6), "\n" ); */ - t_1 = GF_Print; - t_2 = IdentityPerm; - t_4 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_4, 2 ); - t_3 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_3, 2 ); - SET_ELM_PLIST( t_4, 1, t_3 ); - CHANGED_BAG( t_4 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(1) ); - CHANGED_BAG( t_3 ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(2) ); - CHANGED_BAG( t_3 ); - t_3 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_3, 2 ); - SET_ELM_PLIST( t_4, 2, t_3 ); - CHANGED_BAG( t_4 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(5) ); - CHANGED_BAG( t_3 ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(6) ); - CHANGED_BAG( t_3 ); - t_2 = Array2Perm( t_4 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( [ 1, "abc" ], "\n" ); */ - t_1 = GF_Print; - t_2 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_2, 2 ); - SET_ELM_PLIST( t_2, 1, INTOBJ_INT(1) ); - t_3 = MakeString( "abc" ); - SET_ELM_PLIST( t_2, 2, t_3 ); - CHANGED_BAG( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Print( Group( (1,2,3) ), "\n" ); */ - t_1 = GF_Print; - t_3 = GF_Group; - t_4 = IdentityPerm; - t_6 = NEW_PLIST( T_PLIST, 1 ); - SET_LEN_PLIST( t_6, 1 ); - t_5 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_5, 3 ); - SET_ELM_PLIST( t_6, 1, t_5 ); - CHANGED_BAG( t_6 ); - SET_ELM_PLIST( t_5, 1, INTOBJ_INT(1) ); - CHANGED_BAG( t_5 ); - SET_ELM_PLIST( t_5, 2, INTOBJ_INT(2) ); - CHANGED_BAG( t_5 ); - SET_ELM_PLIST( t_5, 3, INTOBJ_INT(3) ); - CHANGED_BAG( t_5 ); - t_4 = Array2Perm( t_6 ); - if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) { - t_2 = CALL_1ARGS( t_3, t_4 ); - } - else { - t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( t_4 ) ); - } - CHECK_FUNC_RESULT( t_2 ); - t_3 = MakeString( "\n" ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* runtest := function ( ) - Print( 1, "\n" ); - Print( "abc", "\n" ); - Print( (1,2)(5,6), "\n" ); - Print( [ 1, "abc" ], "\n" ); - Print( Group( (1,2,3) ), "\n" ); - return; - end; */ - t_1 = NewFunction( NameFunc[2], 0, 0, HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 1); - SET_ENDLINE_BODY(t_2, 7); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_Print = GVarName( "Print" ); - G_runtest = GVarName( "runtest" ); - G_Group = GVarName( "Group" ); - - /* record names used in handlers */ - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - InitFopyGVar( "Print", &GF_Print ); - InitFopyGVar( "Group", &GF_Group ); - - /* information for the functions */ - InitGlobalBag( &FileName, "print_various.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "print_various.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "print_various.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "print_various.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "print_various.g:NameFunc[2]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "print_various.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "print_various.g", - .crc = 71331546, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__print__various ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/ranges.g.static.c b/tst/test-compile/ranges.g.static.c deleted file mode 100644 index b7b0c5fb53..0000000000 --- a/tst/test-compile/ranges.g.static.c +++ /dev/null @@ -1,454 +0,0 @@ -/* C file produced by GAC */ -#include "compiled.h" -#define FILE_CRC "77795076" - -/* global variables used in handlers */ -static GVar G_CALL__WITH__CATCH; -static Obj GF_CALL__WITH__CATCH; -static GVar G_range2; -static Obj GC_range2; -static GVar G_range3; -static Obj GC_range3; -static GVar G_runtest; -static GVar G_BreakOnError; -static GVar G_Display; -static Obj GF_Display; - -/* record names used in handlers */ - -/* information for the functions */ -static Obj NameFunc[5]; -static Obj FileName; - -/* handler for function 2 */ -static Obj HdlrFunc2 ( - Obj self, - Obj a_a, - Obj a_b ) -{ - Obj t_1 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return [ a .. b ]; */ - t_1 = Range2Check( a_a, a_b ); - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 3 */ -static Obj HdlrFunc3 ( - Obj self, - Obj a_a, - Obj a_b, - Obj a_c ) -{ - Obj t_1 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* return [ a, b .. c ]; */ - t_1 = Range3Check( a_a, a_b, a_c ); - SWITCH_TO_OLD_FRAME(oldFrame); - return t_1; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 4 */ -static Obj HdlrFunc4 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Obj t_3 = 0; - Obj t_4 = 0; - Obj t_5 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* BreakOnError := false; */ - t_1 = False; - AssGVar( G_BreakOnError, t_1 ); - - /* CALL_WITH_CATCH( range2, [ 1, 2 ^ 80 ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = GC_range2; - CHECK_BOUND( t_2, "range2" ); - t_3 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_3, 2 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(1) ); - t_4 = POW( INTOBJ_INT(2), INTOBJ_INT(80) ); - SET_ELM_PLIST( t_3, 2, t_4 ); - CHANGED_BAG( t_3 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( range2, [ - 2 ^ 80, 0 ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = GC_range2; - CHECK_BOUND( t_2, "range2" ); - t_3 = NEW_PLIST( T_PLIST, 2 ); - SET_LEN_PLIST( t_3, 2 ); - t_5 = POW( INTOBJ_INT(2), INTOBJ_INT(80) ); - C_AINV_FIA( t_4, t_5 ) - SET_ELM_PLIST( t_3, 1, t_4 ); - CHANGED_BAG( t_3 ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(0) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( range3, [ 1, 2, 2 ^ 80 ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = GC_range3; - CHECK_BOUND( t_2, "range3" ); - t_3 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_3, 3 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(1) ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(2) ); - t_4 = POW( INTOBJ_INT(2), INTOBJ_INT(80) ); - SET_ELM_PLIST( t_3, 3, t_4 ); - CHANGED_BAG( t_3 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( range3, [ - 2 ^ 80, 0, 1 ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = GC_range3; - CHECK_BOUND( t_2, "range3" ); - t_3 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_3, 3 ); - t_5 = POW( INTOBJ_INT(2), INTOBJ_INT(80) ); - C_AINV_FIA( t_4, t_5 ) - SET_ELM_PLIST( t_3, 1, t_4 ); - CHANGED_BAG( t_3 ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(0) ); - SET_ELM_PLIST( t_3, 3, INTOBJ_INT(1) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* CALL_WITH_CATCH( range3, [ 0, 2 ^ 80, 2 ^ 81 ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = GC_range3; - CHECK_BOUND( t_2, "range3" ); - t_3 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_3, 3 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(0) ); - t_4 = POW( INTOBJ_INT(2), INTOBJ_INT(80) ); - SET_ELM_PLIST( t_3, 2, t_4 ); - CHANGED_BAG( t_3 ); - t_4 = POW( INTOBJ_INT(2), INTOBJ_INT(81) ); - SET_ELM_PLIST( t_3, 3, t_4 ); - CHANGED_BAG( t_3 ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Display( [ 1, 2 .. 2 ] ); */ - t_1 = GF_Display; - t_2 = Range3Check( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(2) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* CALL_WITH_CATCH( range3, [ 2, 2, 2 ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = GC_range3; - CHECK_BOUND( t_2, "range3" ); - t_3 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_3, 3 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_3, 3, INTOBJ_INT(2) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Display( [ 2, 4 .. 6 ] ); */ - t_1 = GF_Display; - t_2 = Range3Check( INTOBJ_INT(2), INTOBJ_INT(4), INTOBJ_INT(6) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* CALL_WITH_CATCH( range3, [ 2, 4, 7 ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = GC_range3; - CHECK_BOUND( t_2, "range3" ); - t_3 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_3, 3 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_3, 3, INTOBJ_INT(7) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Display( [ 2, 4 .. 2 ] ); */ - t_1 = GF_Display; - t_2 = Range3Check( INTOBJ_INT(2), INTOBJ_INT(4), INTOBJ_INT(2) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Display( [ 2, 4 .. 0 ] ); */ - t_1 = GF_Display; - t_2 = Range3Check( INTOBJ_INT(2), INTOBJ_INT(4), INTOBJ_INT(0) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* CALL_WITH_CATCH( range3, [ 4, 2, 1 ] ); */ - t_1 = GF_CALL__WITH__CATCH; - t_2 = GC_range3; - CHECK_BOUND( t_2, "range3" ); - t_3 = NEW_PLIST( T_PLIST, 3 ); - SET_LEN_PLIST( t_3, 3 ); - SET_ELM_PLIST( t_3, 1, INTOBJ_INT(4) ); - SET_ELM_PLIST( t_3, 2, INTOBJ_INT(2) ); - SET_ELM_PLIST( t_3, 3, INTOBJ_INT(1) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_2ARGS( t_1, t_2, t_3 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) ); - } - - /* Display( [ 4, 2 .. 0 ] ); */ - t_1 = GF_Display; - t_2 = Range3Check( INTOBJ_INT(4), INTOBJ_INT(2), INTOBJ_INT(0) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* Display( [ 4, 2 .. 8 ] ); */ - t_1 = GF_Display; - t_2 = Range3Check( INTOBJ_INT(4), INTOBJ_INT(2), INTOBJ_INT(8) ); - if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) { - CALL_1ARGS( t_1, t_2 ); - } - else { - DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2 ) ); - } - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* handler for function 1 */ -static Obj HdlrFunc1 ( - Obj self ) -{ - Obj t_1 = 0; - Obj t_2 = 0; - Bag oldFrame; - - /* allocate new stack frame */ - SWITCH_TO_NEW_FRAME(self,0,0,oldFrame); - - /* range2 := function ( a, b ) - return [ a .. b ]; - end; */ - t_1 = NewFunction( NameFunc[2], 2, ArgStringToList("a,b"), HdlrFunc2 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 1); - SET_ENDLINE_BODY(t_2, 1); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_range2, t_1 ); - - /* range3 := function ( a, b, c ) - return [ a, b .. c ]; - end; */ - t_1 = NewFunction( NameFunc[3], 3, ArgStringToList("a,b,c"), HdlrFunc3 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 2); - SET_ENDLINE_BODY(t_2, 2); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_range3, t_1 ); - - /* runtest := function ( ) - BreakOnError := false; - CALL_WITH_CATCH( range2, [ 1, 2 ^ 80 ] ); - CALL_WITH_CATCH( range2, [ - 2 ^ 80, 0 ] ); - CALL_WITH_CATCH( range3, [ 1, 2, 2 ^ 80 ] ); - CALL_WITH_CATCH( range3, [ - 2 ^ 80, 0, 1 ] ); - CALL_WITH_CATCH( range3, [ 0, 2 ^ 80, 2 ^ 81 ] ); - Display( [ 1, 2 .. 2 ] ); - CALL_WITH_CATCH( range3, [ 2, 2, 2 ] ); - Display( [ 2, 4 .. 6 ] ); - CALL_WITH_CATCH( range3, [ 2, 4, 7 ] ); - Display( [ 2, 4 .. 2 ] ); - Display( [ 2, 4 .. 0 ] ); - CALL_WITH_CATCH( range3, [ 4, 2, 1 ] ); - Display( [ 4, 2 .. 0 ] ); - Display( [ 4, 2 .. 8 ] ); - return; - end; */ - t_1 = NewFunction( NameFunc[4], 0, 0, HdlrFunc4 ); - SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); - t_2 = NewFunctionBody(); - SET_STARTLINE_BODY(t_2, 4); - SET_ENDLINE_BODY(t_2, 26); - SET_FILENAME_BODY(t_2, FileName); - SET_BODY_FUNC(t_1, t_2); - AssGVar( G_runtest, t_1 ); - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; - - /* return; */ - SWITCH_TO_OLD_FRAME(oldFrame); - return 0; -} - -/* 'PostRestore' restore gvars, rnams, functions */ -static Int PostRestore ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - G_CALL__WITH__CATCH = GVarName( "CALL_WITH_CATCH" ); - G_range2 = GVarName( "range2" ); - G_range3 = GVarName( "range3" ); - G_runtest = GVarName( "runtest" ); - G_BreakOnError = GVarName( "BreakOnError" ); - G_Display = GVarName( "Display" ); - - /* record names used in handlers */ - - /* information for the functions */ - NameFunc[1] = 0; - NameFunc[2] = 0; - NameFunc[3] = 0; - NameFunc[4] = 0; - - return 0; - -} - - -/* 'InitKernel' sets up data structures, fopies, copies, handlers */ -static Int InitKernel ( StructInitInfo * module ) -{ - - /* global variables used in handlers */ - InitFopyGVar( "CALL_WITH_CATCH", &GF_CALL__WITH__CATCH ); - InitCopyGVar( "range2", &GC_range2 ); - InitCopyGVar( "range3", &GC_range3 ); - InitFopyGVar( "Display", &GF_Display ); - - /* information for the functions */ - InitGlobalBag( &FileName, "ranges.g:FileName("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc1, "ranges.g:HdlrFunc1("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[1]), "ranges.g:NameFunc[1]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc2, "ranges.g:HdlrFunc2("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[2]), "ranges.g:NameFunc[2]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc3, "ranges.g:HdlrFunc3("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[3]), "ranges.g:NameFunc[3]("FILE_CRC")" ); - InitHandlerFunc( HdlrFunc4, "ranges.g:HdlrFunc4("FILE_CRC")" ); - InitGlobalBag( &(NameFunc[4]), "ranges.g:NameFunc[4]("FILE_CRC")" ); - - return 0; - -} - -/* 'InitLibrary' sets up gvars, rnams, functions */ -static Int InitLibrary ( StructInitInfo * module ) -{ - Obj func1; - Obj body1; - - /* Complete Copy/Fopy registration */ - UpdateCopyFopyInfo(); - FileName = MakeImmString( "ranges.g" ); - PostRestore(module); - - /* create all the functions defined in this module */ - func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1); - SET_ENVI_FUNC( func1, STATE(CurrLVars) ); - body1 = NewFunctionBody(); - SET_BODY_FUNC( func1, body1 ); - CHANGED_BAG( func1 ); - CALL_0ARGS( func1 ); - - return 0; - -} - -/* returns the description of this module */ -static StructInitInfo module = { - .type = MODULE_STATIC, - .name = "ranges.g", - .crc = 77795076, - .initKernel = InitKernel, - .initLibrary = InitLibrary, - .postRestore = PostRestore, -}; - -StructInitInfo * Init__ranges ( void ) -{ - return &module; -} - -/* compiled code ends here */ diff --git a/tst/test-compile/run_all.sh b/tst/test-compile/run_all.sh index dcd6bf8c76..3ce9fc9fcb 100755 --- a/tst/test-compile/run_all.sh +++ b/tst/test-compile/run_all.sh @@ -34,17 +34,6 @@ for gfile in *.g; do fi rm -f "${gfile}.bad" - echo " now compiling ${gfile} statically ..." - ./run_compiled_static.sh "${gap}" "${gac}" "${gfile}" > "${gfile}.bad" - if ! diff -u -b "${gfile}.out" "${gfile}.bad"; then - echo "ERROR: ${gfile} failed with compiling and static linking" - retvalue=1 - fi - if ! git diff --exit-code -- ${gfile}.static.c; then - echo "ERROR: ${gfile}.static.c changed unexpectedly" - retvalue=1 - fi - rm -f "${gfile}.bad" echo done diff --git a/tst/test-compile/run_compiled_static.sh b/tst/test-compile/run_compiled_static.sh deleted file mode 100755 index 9f60d63c2f..0000000000 --- a/tst/test-compile/run_compiled_static.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# This script should be run as ./run_compiled_static.sh gac gapfile.g -# It compiles gapfile.g using gac, then runs the function 'runtest' -gap="$1" -gac="$2" -gfile="$3" - -# It provides the following features: -# 1) Stop GAP from attaching to the terminal (which it will -# use in the break loop) -# 2) Combine stderr and stdout -# 3) Rewrite the root of gap with the string GAPROOT, -# so the output is usable on other machines -GAPROOT=$("$gap" --print-gaproot) -# Clean any old files around -rm -rf .libs "$gfile.comp"* - -"$gac" "$gfile" -C -o "$gfile.static.c" 2>&1 >/dev/null - -"$gac" "$gfile" -o "$gfile.comp" 2>&1 >/dev/null - -echo "LoadStaticModule(\"$gfile\");; runtest();" | - "./$gfile.comp" -l "$GAPROOT" -r -A -q -b -x 200 2>&1 | - sed "s:${GAPROOT//:/\\:}:GAPROOT/:g" - -rm -rf .libs "$gfile.comp"*