コード例 #1
0
ファイル: gapmpi.c プロジェクト: ChristopherRussell/gap
/* called after MPI_Init() and after GAP system initialization */
void Init_MPIvars( void ) {
  UInt gvar;

  AssGVar( gvar = GVarName("MPI_TAG_UB"), INTOBJ_INT(MPI_TAG_UB) );
  MakeReadOnlyGVar(gvar);
  AssGVar( gvar = GVarName("MPI_HOST"), INTOBJ_INT(MPI_HOST) );
  MakeReadOnlyGVar(gvar);
  AssGVar( gvar = GVarName("MPI_IO"), INTOBJ_INT(MPI_IO) );
  MakeReadOnlyGVar(gvar);
  AssGVar( gvar = GVarName("MPI_COMM_WORLD"), INTOBJ_INT(MPI_COMM_WORLD) );
  MakeReadOnlyGVar(gvar);
  AssGVar( gvar = GVarName("MPI_ANY_SOURCE"), INTOBJ_INT(MPI_ANY_SOURCE) );
  MakeReadOnlyGVar(gvar);
  AssGVar( gvar = GVarName("MPI_ANY_TAG"), INTOBJ_INT(MPI_ANY_TAG) );
  MakeReadOnlyGVar(gvar);
#ifdef USE_MPINU
  AssGVar( gvar = GVarName("MPI_USE_MPINU"), True );
  #ifdef MPINU_V2
    AssGVar( gvar = GVarName("MPI_USE_MPINU_V2"), True );
  #else
    AssGVar( gvar = GVarName("MPI_USE_MPINU_V2"), False );
  #endif
#else
  AssGVar( gvar = GVarName("MPI_USE_MPINU"), False );
#endif
  MakeReadOnlyGVar(gvar);
}
コード例 #2
0
ファイル: linboxing.c プロジェクト: fingolfin/gap-osx-binary
/** 
Function called by GAP after a workspace restore. This is also called by us in
InitLibrary();
**/ 
static Int PostRestore(StructInitInfo* module)
{
  Int i;
  Int gvar;
  Obj tmp;
  
  gvar = GVarName("LinBox");
  tmp = (Obj)VAL_GVAR(gvar);
  if(!tmp) 
  {
    tmp = (Obj)NEW_PREC(0);
  }

  /* Write the names of my functions into th LinBox record */
  for(i = 0; GVarFuncs[i].name != 0; i++) 
  {
    AssPRec(
      tmp, 
      RNamName((Char*)GVarFuncs[i].name), 
      NewFunctionC(
        GVarFuncs[i].name, 
        GVarFuncs[i].nargs, 
        GVarFuncs[i].args, 
        GVarFuncs[i].handler) );
  }
  
  MakeReadWriteGVar(gvar);
  AssGVar(gvar, tmp);
  MakeReadOnlyGVar(gvar);
  return 0;
}
コード例 #3
0
ファイル: c_filt1.c プロジェクト: BlairArchibald/gap
/* handler for function 2 */
static Obj  HdlrFunc2 (
 Obj  self )
{
 Obj t_1 = 0;
 Bag oldFrame;
 OLD_BRK_CURR_STAT
 
 /* allocate new stack frame */
 SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
 REM_BRK_CURR_STAT();
 SET_BRK_CURR_STAT(0);
 
 /* WITH_IMPS_FLAGS_CACHE := [  ]; */
 t_1 = NEW_PLIST( T_PLIST, 0 );
 SET_LEN_PLIST( t_1, 0 );
 AssGVar( G_WITH__IMPS__FLAGS__CACHE, t_1 );
 
 /* return; */
 RES_BRK_CURR_STAT();
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
 
 /* return; */
 RES_BRK_CURR_STAT();
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
コード例 #4
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;
}
コード例 #5
0
ファイル: plus.g.dynamic.c プロジェクト: cdwensley/gap
/* 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 = NewBag( T_BODY, sizeof(BodyHeader) );
 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);
 CHANGED_BAG( STATE(CurrLVars) );
 AssGVar( G_runtest, t_1 );
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
コード例 #6
0
ファイル: assert.g.dynamic.c プロジェクト: cdwensley/gap
/* 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 = NewBag( T_BODY, sizeof(BodyHeader) );
 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);
 CHANGED_BAG( STATE(CurrLVars) );
 AssGVar( G_runtest, t_1 );
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
コード例 #7
0
ファイル: c_filt1.c プロジェクト: BlairArchibald/gap
/* handler for function 3 */
static Obj  HdlrFunc3 (
 Obj  self,
 Obj  a_flags )
{
 Obj l_with = 0;
 Obj l_changed = 0;
 Obj l_imp = 0;
 Obj l_hash = 0;
 Obj l_hash2 = 0;
 Obj l_i = 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;
 Obj t_9 = 0;
 Obj t_10 = 0;
 Obj t_11 = 0;
 Bag oldFrame;
 OLD_BRK_CURR_STAT
 
 /* allocate new stack frame */
 SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
 REM_BRK_CURR_STAT();
 SET_BRK_CURR_STAT(0);
 
 /* hash := HASH_FLAGS( flags ) mod 11001; */
 t_3 = GF_HASH__FLAGS;
 t_2 = CALL_1ARGS( t_3, a_flags );
 CHECK_FUNC_RESULT( t_2 )
 t_1 = MOD( t_2, INTOBJ_INT(11001) );
 l_hash = t_1;
 
 /* for i in [ 0 .. 3 ] do */
 for ( t_1 = INTOBJ_INT(0);
       ((Int)t_1) <= ((Int)INTOBJ_INT(3));
       t_1 = (Obj)(((UInt)t_1)+4) ) {
  l_i = t_1;
  
  /* hash2 := 2 * ((hash + 31 * i) mod 11001) + 1; */
  C_PROD_INTOBJS( t_6, INTOBJ_INT(31), l_i )
  C_SUM_FIA( t_5, l_hash, t_6 )
  t_4 = MOD( t_5, INTOBJ_INT(11001) );
  C_PROD_FIA( t_3, INTOBJ_INT(2), t_4 )
  C_SUM_FIA( t_2, t_3, INTOBJ_INT(1) )
  l_hash2 = t_2;
  
  /* if IsBound( WITH_IMPS_FLAGS_CACHE[hash2] ) then */
  t_4 = GC_WITH__IMPS__FLAGS__CACHE;
  CHECK_BOUND( t_4, "WITH_IMPS_FLAGS_CACHE" )
  CHECK_INT_POS( l_hash2 )
  t_3 = C_ISB_LIST( t_4, l_hash2 );
  t_2 = (Obj)(UInt)(t_3 != False);
  if ( t_2 ) {
   
   /* if IS_IDENTICAL_OBJ( WITH_IMPS_FLAGS_CACHE[hash2], flags ) then */
   t_4 = GF_IS__IDENTICAL__OBJ;
   t_6 = GC_WITH__IMPS__FLAGS__CACHE;
   CHECK_BOUND( t_6, "WITH_IMPS_FLAGS_CACHE" )
   C_ELM_LIST_FPL( t_5, t_6, l_hash2 )
   t_3 = CALL_2ARGS( t_4, t_5, a_flags );
   CHECK_FUNC_RESULT( t_3 )
   CHECK_BOOL( t_3 )
   t_2 = (Obj)(UInt)(t_3 != False);
   if ( t_2 ) {
    
    /* WITH_IMPS_FLAGS_CACHE_HIT := WITH_IMPS_FLAGS_CACHE_HIT + 1; */
    t_3 = GC_WITH__IMPS__FLAGS__CACHE__HIT;
    CHECK_BOUND( t_3, "WITH_IMPS_FLAGS_CACHE_HIT" )
    C_SUM_FIA( t_2, t_3, INTOBJ_INT(1) )
    AssGVar( G_WITH__IMPS__FLAGS__CACHE__HIT, t_2 );
    
    /* return WITH_IMPS_FLAGS_CACHE[hash2 + 1]; */
    t_3 = GC_WITH__IMPS__FLAGS__CACHE;
    CHECK_BOUND( t_3, "WITH_IMPS_FLAGS_CACHE" )
    C_SUM_FIA( t_4, l_hash2, INTOBJ_INT(1) )
    CHECK_INT_POS( t_4 )
    C_ELM_LIST_FPL( t_2, t_3, t_4 )
    RES_BRK_CURR_STAT();
    SWITCH_TO_OLD_FRAME(oldFrame);
    return t_2;
    
   }
   /* fi */
   
  }
  
  /* else */
  else {
   
   /* break; */
   break;
   
  }
  /* fi */
  
 }
 /* od */
 
 /* if i = 3 then */
 t_1 = (Obj)(UInt)(((Int)l_i) == ((Int)INTOBJ_INT(3)));
 if ( t_1 ) {
  
  /* WITH_IMPS_FLAGS_COUNT := (WITH_IMPS_FLAGS_COUNT + 1) mod 4; */
  t_3 = GC_WITH__IMPS__FLAGS__COUNT;
  CHECK_BOUND( t_3, "WITH_IMPS_FLAGS_COUNT" )
  C_SUM_FIA( t_2, t_3, INTOBJ_INT(1) )
  t_1 = MOD( t_2, INTOBJ_INT(4) );
  AssGVar( G_WITH__IMPS__FLAGS__COUNT, t_1 );
  
  /* i := WITH_IMPS_FLAGS_COUNT; */
  t_1 = GC_WITH__IMPS__FLAGS__COUNT;
  CHECK_BOUND( t_1, "WITH_IMPS_FLAGS_COUNT" )
  l_i = t_1;
  
  /* hash2 := 2 * ((hash + 31 * i) mod 11001) + 1; */
  C_PROD_FIA( t_5, INTOBJ_INT(31), l_i )
  C_SUM_FIA( t_4, l_hash, t_5 )
  t_3 = MOD( t_4, INTOBJ_INT(11001) );
  C_PROD_FIA( t_2, INTOBJ_INT(2), t_3 )
  C_SUM_FIA( t_1, t_2, INTOBJ_INT(1) )
  l_hash2 = t_1;
  
 }
 /* fi */
 
 /* WITH_IMPS_FLAGS_CACHE_MISS := WITH_IMPS_FLAGS_CACHE_MISS + 1; */
 t_2 = GC_WITH__IMPS__FLAGS__CACHE__MISS;
 CHECK_BOUND( t_2, "WITH_IMPS_FLAGS_CACHE_MISS" )
 C_SUM_FIA( t_1, t_2, INTOBJ_INT(1) )
 AssGVar( G_WITH__IMPS__FLAGS__CACHE__MISS, t_1 );
 
 /* with := flags; */
 l_with = a_flags;
 
 /* changed := true; */
 t_1 = True;
 l_changed = t_1;
 
 /* while changed od */
 while ( 1 ) {
  t_1 = (Obj)(UInt)(l_changed != False);
  if ( ! t_1 ) break;
  
  /* changed := false; */
  t_1 = False;
  l_changed = t_1;
  
  /* for imp in IMPLICATIONS do */
  t_4 = GC_IMPLICATIONS;
  CHECK_BOUND( t_4, "IMPLICATIONS" )
  if ( IS_SMALL_LIST(t_4) ) {
   t_3 = (Obj)(UInt)1;
   t_1 = INTOBJ_INT(1);
  }
  else {
   t_3 = (Obj)(UInt)0;
   t_1 = CALL_1ARGS( GF_ITERATOR, t_4 );
  }
  while ( 1 ) {
   if ( t_3 ) {
    if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) )  break;
    t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
    t_1 = (Obj)(((UInt)t_1)+4);
    if ( t_2 == 0 )  continue;
   }
   else {
    if ( CALL_1ARGS( GF_IS_DONE_ITER, t_1 ) != False )  break;
    t_2 = CALL_1ARGS( GF_NEXT_ITER, t_1 );
   }
   l_imp = t_2;
   
   /* if IS_SUBSET_FLAGS( with, imp[2] ) and not IS_SUBSET_FLAGS( with, imp[1] ) then */
   t_8 = GF_IS__SUBSET__FLAGS;
   C_ELM_LIST_FPL( t_9, l_imp, INTOBJ_INT(2) )
   t_7 = CALL_2ARGS( t_8, l_with, t_9 );
   CHECK_FUNC_RESULT( t_7 )
   CHECK_BOOL( t_7 )
   t_6 = (Obj)(UInt)(t_7 != False);
   t_5 = t_6;
   if ( t_5 ) {
    t_10 = GF_IS__SUBSET__FLAGS;
    C_ELM_LIST_FPL( t_11, l_imp, INTOBJ_INT(1) )
    t_9 = CALL_2ARGS( t_10, l_with, t_11 );
    CHECK_FUNC_RESULT( t_9 )
    CHECK_BOOL( t_9 )
    t_8 = (Obj)(UInt)(t_9 != False);
    t_7 = (Obj)(UInt)( ! ((Int)t_8) );
    t_5 = t_7;
   }
   if ( t_5 ) {
    
    /* with := AND_FLAGS( with, imp[1] ); */
    t_6 = GF_AND__FLAGS;
    C_ELM_LIST_FPL( t_7, l_imp, INTOBJ_INT(1) )
    t_5 = CALL_2ARGS( t_6, l_with, t_7 );
    CHECK_FUNC_RESULT( t_5 )
    l_with = t_5;
    
    /* changed := true; */
    t_5 = True;
    l_changed = t_5;
    
   }
   /* fi */
   
  }
  /* od */
  
 }
 /* od */
 
 /* WITH_IMPS_FLAGS_CACHE[hash2] := flags; */
 t_1 = GC_WITH__IMPS__FLAGS__CACHE;
 CHECK_BOUND( t_1, "WITH_IMPS_FLAGS_CACHE" )
 CHECK_INT_POS( l_hash2 )
 C_ASS_LIST_FPL( t_1, l_hash2, a_flags )
 
 /* WITH_IMPS_FLAGS_CACHE[hash2 + 1] := with; */
 t_1 = GC_WITH__IMPS__FLAGS__CACHE;
 CHECK_BOUND( t_1, "WITH_IMPS_FLAGS_CACHE" )
 C_SUM_FIA( t_2, l_hash2, INTOBJ_INT(1) )
 CHECK_INT_POS( t_2 )
 C_ASS_LIST_FPL( t_1, t_2, l_with )
 
 /* return with; */
 RES_BRK_CURR_STAT();
 SWITCH_TO_OLD_FRAME(oldFrame);
 return l_with;
 
 /* return; */
 RES_BRK_CURR_STAT();
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
コード例 #8
0
ファイル: c_filt1.c プロジェクト: BlairArchibald/gap
/* handler for function 1 */
static Obj  HdlrFunc1 (
 Obj  self )
{
 Obj t_1 = 0;
 Obj t_2 = 0;
 Obj t_3 = 0;
 Obj t_4 = 0;
 Bag oldFrame;
 OLD_BRK_CURR_STAT
 
 /* allocate new stack frame */
 SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
 REM_BRK_CURR_STAT();
 SET_BRK_CURR_STAT(0);
 
 /* WITH_HIDDEN_IMPS_FLAGS_COUNT := 0; */
 AssGVar( G_WITH__HIDDEN__IMPS__FLAGS__COUNT, INTOBJ_INT(0) );
 
 /* WITH_HIDDEN_IMPS_FLAGS_CACHE_MISS := 0; */
 AssGVar( G_WITH__HIDDEN__IMPS__FLAGS__CACHE__MISS, INTOBJ_INT(0) );
 
 /* WITH_HIDDEN_IMPS_FLAGS_CACHE_HIT := 0; */
 AssGVar( G_WITH__HIDDEN__IMPS__FLAGS__CACHE__HIT, INTOBJ_INT(0) );
 
 /* IMPLICATIONS := [  ]; */
 t_1 = NEW_PLIST( T_PLIST, 0 );
 SET_LEN_PLIST( t_1, 0 );
 AssGVar( G_IMPLICATIONS, t_1 );
 
 /* WITH_IMPS_FLAGS_CACHE := [  ]; */
 t_1 = NEW_PLIST( T_PLIST, 0 );
 SET_LEN_PLIST( t_1, 0 );
 AssGVar( G_WITH__IMPS__FLAGS__CACHE, t_1 );
 
 /* WITH_IMPS_FLAGS_COUNT := 0; */
 AssGVar( G_WITH__IMPS__FLAGS__COUNT, INTOBJ_INT(0) );
 
 /* WITH_IMPS_FLAGS_CACHE_HIT := 0; */
 AssGVar( G_WITH__IMPS__FLAGS__CACHE__HIT, INTOBJ_INT(0) );
 
 /* WITH_IMPS_FLAGS_CACHE_MISS := 0; */
 AssGVar( G_WITH__IMPS__FLAGS__CACHE__MISS, INTOBJ_INT(0) );
 
 /* Unbind( CLEAR_IMP_CACHE ); */
 AssGVar( G_CLEAR__IMP__CACHE, 0 );
 
 /* BIND_GLOBAL( "CLEAR_IMP_CACHE", function (  )
      WITH_IMPS_FLAGS_CACHE := [  ];
      return;
  end ); */
 t_1 = GF_BIND__GLOBAL;
 C_NEW_STRING( t_2, 15, "CLEAR_IMP_CACHE" );
 t_3 = NewFunction( NameFunc[2], NargFunc[2], NamsFunc[2], HdlrFunc2 );
 ENVI_FUNC( t_3 ) = TLS(CurrLVars);
 t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) );
 STARTLINE_BODY(t_4) = INTOBJ_INT(39);
 ENDLINE_BODY(t_4) = INTOBJ_INT(41);
 FILENAME_BODY(t_4) = FileName;
 BODY_FUNC(t_3) = t_4;
 CHANGED_BAG( TLS(CurrLVars) );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* BIND_GLOBAL( "WITH_IMPS_FLAGS", function ( flags )
      local  with, changed, imp, hash, hash2, i;
      hash := HASH_FLAGS( flags ) mod 11001;
      for i  in [ 0 .. 3 ]  do
          hash2 := 2 * ((hash + 31 * i) mod 11001) + 1;
          if IsBound( WITH_IMPS_FLAGS_CACHE[hash2] )  then
              if IS_IDENTICAL_OBJ( WITH_IMPS_FLAGS_CACHE[hash2], flags )  then
                  WITH_IMPS_FLAGS_CACHE_HIT := WITH_IMPS_FLAGS_CACHE_HIT + 1;
                  return WITH_IMPS_FLAGS_CACHE[hash2 + 1];
              fi;
          else
              break;
          fi;
      od;
      if i = 3  then
          WITH_IMPS_FLAGS_COUNT := (WITH_IMPS_FLAGS_COUNT + 1) mod 4;
          i := WITH_IMPS_FLAGS_COUNT;
          hash2 := 2 * ((hash + 31 * i) mod 11001) + 1;
      fi;
      WITH_IMPS_FLAGS_CACHE_MISS := WITH_IMPS_FLAGS_CACHE_MISS + 1;
      with := flags;
      changed := true;
      while changed  do
          changed := false;
          for imp  in IMPLICATIONS  do
              if IS_SUBSET_FLAGS( with, imp[2] ) and not IS_SUBSET_FLAGS( with, imp[1] )  then
                  with := AND_FLAGS( with, imp[1] );
                  changed := true;
              fi;
          od;
      od;
      WITH_IMPS_FLAGS_CACHE[hash2] := flags;
      WITH_IMPS_FLAGS_CACHE[hash2 + 1] := with;
      return with;
  end ); */
 t_1 = GF_BIND__GLOBAL;
 C_NEW_STRING( t_2, 15, "WITH_IMPS_FLAGS" );
 t_3 = NewFunction( NameFunc[3], NargFunc[3], NamsFunc[3], HdlrFunc3 );
 ENVI_FUNC( t_3 ) = TLS(CurrLVars);
 t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) );
 STARTLINE_BODY(t_4) = INTOBJ_INT(44);
 ENDLINE_BODY(t_4) = INTOBJ_INT(83);
 FILENAME_BODY(t_4) = FileName;
 BODY_FUNC(t_3) = t_4;
 CHANGED_BAG( TLS(CurrLVars) );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* UNBIND_GLOBAL( "RANK_FILTER" ); */
 t_1 = GF_UNBIND__GLOBAL;
 C_NEW_STRING( t_2, 11, "RANK_FILTER" );
 CALL_1ARGS( t_1, t_2 );
 
 /* BIND_GLOBAL( "RANK_FILTER", function ( filter )
      local  rank, flags, i;
      rank := 0;
      if IS_FUNCTION( filter )  then
          flags := FLAGS_FILTER( filter );
      else
          flags := filter;
      fi;
      for i  in TRUES_FLAGS( WITH_HIDDEN_IMPS_FLAGS( flags ) )  do
          if IsBound( RANK_FILTERS[i] )  then
              rank := rank + RANK_FILTERS[i];
          else
              rank := rank + 1;
          fi;
      od;
      return rank;
  end ); */
 t_1 = GF_BIND__GLOBAL;
 C_NEW_STRING( t_2, 11, "RANK_FILTER" );
 t_3 = NewFunction( NameFunc[4], NargFunc[4], NamsFunc[4], HdlrFunc4 );
 ENVI_FUNC( t_3 ) = TLS(CurrLVars);
 t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) );
 STARTLINE_BODY(t_4) = INTOBJ_INT(97);
 ENDLINE_BODY(t_4) = INTOBJ_INT(114);
 FILENAME_BODY(t_4) = FileName;
 BODY_FUNC(t_3) = t_4;
 CHANGED_BAG( TLS(CurrLVars) );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* RankFilter := RANK_FILTER; */
 t_1 = GC_RANK__FILTER;
 CHECK_BOUND( t_1, "RANK_FILTER" )
 AssGVar( G_RankFilter, t_1 );
 
 /* UNBIND_GLOBAL( "RANK_FILTER_STORE" ); */
 t_1 = GF_UNBIND__GLOBAL;
 C_NEW_STRING( t_2, 17, "RANK_FILTER_STORE" );
 CALL_1ARGS( t_1, t_2 );
 
 /* BIND_GLOBAL( "RANK_FILTER_STORE", function ( filter )
      local  hash, rank, flags;
      if IS_FUNCTION( filter )  then
          flags := FLAGS_FILTER( filter );
      else
          flags := filter;
      fi;
      hash := HASH_FLAGS( flags );
      rank := RANK_FILTER( flags );
      ADD_LIST( RANK_FILTER_LIST_CURRENT, hash );
      ADD_LIST( RANK_FILTER_LIST_CURRENT, rank );
      return rank;
  end ); */
 t_1 = GF_BIND__GLOBAL;
 C_NEW_STRING( t_2, 17, "RANK_FILTER_STORE" );
 t_3 = NewFunction( NameFunc[5], NargFunc[5], NamsFunc[5], HdlrFunc5 );
 ENVI_FUNC( t_3 ) = TLS(CurrLVars);
 t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) );
 STARTLINE_BODY(t_4) = INTOBJ_INT(119);
 ENDLINE_BODY(t_4) = INTOBJ_INT(133);
 FILENAME_BODY(t_4) = FileName;
 BODY_FUNC(t_3) = t_4;
 CHANGED_BAG( TLS(CurrLVars) );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* UNBIND_GLOBAL( "RANK_FILTER_COMPLETION" ); */
 t_1 = GF_UNBIND__GLOBAL;
 C_NEW_STRING( t_2, 22, "RANK_FILTER_COMPLETION" );
 CALL_1ARGS( t_1, t_2 );
 
 /* BIND_GLOBAL( "RANK_FILTER_COMPLETION", function ( filter )
      local  hash, flags;
      if IS_FUNCTION( filter )  then
          flags := FLAGS_FILTER( filter );
      else
          flags := filter;
      fi;
      hash := HASH_FLAGS( flags );
      if hash <> RANK_FILTER_LIST[RANK_FILTER_COUNT]  then
          Error( "corrupted completion file" );
      fi;
      RANK_FILTER_COUNT := RANK_FILTER_COUNT + 2;
      return RANK_FILTER_LIST[RANK_FILTER_COUNT - 1];
  end ); */
 t_1 = GF_BIND__GLOBAL;
 C_NEW_STRING( t_2, 22, "RANK_FILTER_COMPLETION" );
 t_3 = NewFunction( NameFunc[6], NargFunc[6], NamsFunc[6], HdlrFunc6 );
 ENVI_FUNC( t_3 ) = TLS(CurrLVars);
 t_4 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) );
 STARTLINE_BODY(t_4) = INTOBJ_INT(136);
 ENDLINE_BODY(t_4) = INTOBJ_INT(151);
 FILENAME_BODY(t_4) = FileName;
 BODY_FUNC(t_3) = t_4;
 CHANGED_BAG( TLS(CurrLVars) );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* return; */
 RES_BRK_CURR_STAT();
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
 
 /* return; */
 RES_BRK_CURR_STAT();
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
コード例 #9
0
ファイル: c_filt1.c プロジェクト: BlairArchibald/gap
/* handler for function 6 */
static Obj  HdlrFunc6 (
 Obj  self,
 Obj  a_filter )
{
 Obj l_hash = 0;
 Obj l_flags = 0;
 Obj t_1 = 0;
 Obj t_2 = 0;
 Obj t_3 = 0;
 Obj t_4 = 0;
 Bag oldFrame;
 OLD_BRK_CURR_STAT
 
 /* allocate new stack frame */
 SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
 REM_BRK_CURR_STAT();
 SET_BRK_CURR_STAT(0);
 
 /* if IS_FUNCTION( filter ) then */
 t_3 = GF_IS__FUNCTION;
 t_2 = CALL_1ARGS( t_3, a_filter );
 CHECK_FUNC_RESULT( t_2 )
 CHECK_BOOL( t_2 )
 t_1 = (Obj)(UInt)(t_2 != False);
 if ( t_1 ) {
  
  /* flags := FLAGS_FILTER( filter ); */
  t_2 = GF_FLAGS__FILTER;
  t_1 = CALL_1ARGS( t_2, a_filter );
  CHECK_FUNC_RESULT( t_1 )
  l_flags = t_1;
  
 }
 
 /* else */
 else {
  
  /* flags := filter; */
  l_flags = a_filter;
  
 }
 /* fi */
 
 /* hash := HASH_FLAGS( flags ); */
 t_2 = GF_HASH__FLAGS;
 t_1 = CALL_1ARGS( t_2, l_flags );
 CHECK_FUNC_RESULT( t_1 )
 l_hash = t_1;
 
 /* if hash <> RANK_FILTER_LIST[RANK_FILTER_COUNT] then */
 t_3 = GC_RANK__FILTER__LIST;
 CHECK_BOUND( t_3, "RANK_FILTER_LIST" )
 t_4 = GC_RANK__FILTER__COUNT;
 CHECK_BOUND( t_4, "RANK_FILTER_COUNT" )
 CHECK_INT_POS( t_4 )
 C_ELM_LIST_FPL( t_2, t_3, t_4 )
 t_1 = (Obj)(UInt)( ! EQ( l_hash, t_2 ));
 if ( t_1 ) {
  
  /* Error( "corrupted completion file" ); */
  t_1 = GF_Error;
  C_NEW_STRING( t_2, 25, "corrupted completion file" );
  CALL_1ARGS( t_1, t_2 );
  
 }
 /* fi */
 
 /* RANK_FILTER_COUNT := RANK_FILTER_COUNT + 2; */
 t_2 = GC_RANK__FILTER__COUNT;
 CHECK_BOUND( t_2, "RANK_FILTER_COUNT" )
 C_SUM_FIA( t_1, t_2, INTOBJ_INT(2) )
 AssGVar( G_RANK__FILTER__COUNT, t_1 );
 
 /* return RANK_FILTER_LIST[RANK_FILTER_COUNT - 1]; */
 t_2 = GC_RANK__FILTER__LIST;
 CHECK_BOUND( t_2, "RANK_FILTER_LIST" )
 t_4 = GC_RANK__FILTER__COUNT;
 CHECK_BOUND( t_4, "RANK_FILTER_COUNT" )
 C_DIFF_FIA( t_3, t_4, INTOBJ_INT(1) )
 CHECK_INT_POS( t_3 )
 C_ELM_LIST_FPL( t_1, t_2, t_3 )
 RES_BRK_CURR_STAT();
 SWITCH_TO_OLD_FRAME(oldFrame);
 return t_1;
 
 /* return; */
 RES_BRK_CURR_STAT();
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
コード例 #10
0
ファイル: function_types.g.static.c プロジェクト: dimpase/gap
/* 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, 0, HdlrFunc2 );
 SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
 t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
 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);
 CHANGED_BAG( STATE(CurrLVars) );
 AssGVar( G_f1, t_1 );
 
 /* f2 := function ( a, b )
      Print( "f2:", a, ":", b, "\n" );
      return;
  end; */
 t_1 = NewFunction( NameFunc[3], 2, 0, HdlrFunc3 );
 SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
 t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
 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);
 CHANGED_BAG( STATE(CurrLVars) );
 AssGVar( G_f2, t_1 );
 
 /* f3 := function ( a... )
      Print( "f3:", a, "\n" );
      return;
  end; */
 t_1 = NewFunction( NameFunc[4], -1, 0, HdlrFunc4 );
 SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
 t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
 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);
 CHANGED_BAG( STATE(CurrLVars) );
 AssGVar( G_f3, t_1 );
 
 /* f4 := function ( a, b... )
      Print( "f4:", a, ":", b, "\n" );
      return;
  end; */
 t_1 = NewFunction( NameFunc[5], -2, 0, HdlrFunc5 );
 SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
 t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
 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);
 CHANGED_BAG( STATE(CurrLVars) );
 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 );
      return;
  end; */
 t_1 = NewFunction( NameFunc[6], 0, 0, HdlrFunc6 );
 SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
 t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
 SET_STARTLINE_BODY(t_2, 17);
 SET_ENDLINE_BODY(t_2, 26);
 SET_FILENAME_BODY(t_2, FileName);
 SET_BODY_FUNC(t_1, t_2);
 CHANGED_BAG( STATE(CurrLVars) );
 AssGVar( G_runtest, t_1 );
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
コード例 #11
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 );
 CALL_2ARGS( t_1, 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) );
 CALL_2ARGS( t_1, 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 );
 CALL_2ARGS( t_1, 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) );
 CALL_2ARGS( t_1, 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 );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* Display( [ 1, 2 .. 2 ] ); */
 t_1 = GF_Display;
 t_2 = Range3Check( INTOBJ_INT(1), INTOBJ_INT(2), INTOBJ_INT(2) );
 CALL_1ARGS( t_1, 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) );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* Display( [ 2, 4 .. 6 ] ); */
 t_1 = GF_Display;
 t_2 = Range3Check( INTOBJ_INT(2), INTOBJ_INT(4), INTOBJ_INT(6) );
 CALL_1ARGS( t_1, 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) );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* Display( [ 2, 4 .. 2 ] ); */
 t_1 = GF_Display;
 t_2 = Range3Check( INTOBJ_INT(2), INTOBJ_INT(4), INTOBJ_INT(2) );
 CALL_1ARGS( t_1, t_2 );
 
 /* Display( [ 2, 4 .. 0 ] ); */
 t_1 = GF_Display;
 t_2 = Range3Check( INTOBJ_INT(2), INTOBJ_INT(4), INTOBJ_INT(0) );
 CALL_1ARGS( t_1, 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) );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* Display( [ 4, 2 .. 0 ] ); */
 t_1 = GF_Display;
 t_2 = Range3Check( INTOBJ_INT(4), INTOBJ_INT(2), INTOBJ_INT(0) );
 CALL_1ARGS( t_1, t_2 );
 
 /* Display( [ 4, 2 .. 8 ] ); */
 t_1 = GF_Display;
 t_2 = Range3Check( INTOBJ_INT(4), INTOBJ_INT(2), INTOBJ_INT(8) );
 CALL_1ARGS( t_1, t_2 );
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
コード例 #12
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;
}