Obj NewPolymakeExternalObject(enum polymake_object_type t) {
  Obj o;
  o = NewBag(T_POLYMAKE, 2*sizeof(Obj));
 
  switch(t) {
    case T_POLYMAKE_EXTERNAL_CONE:
      ADDR_OBJ(o)[0] = TheTypeExternalPolymakeCone;
      break;
    case T_POLYMAKE_EXTERNAL_FAN:
      ADDR_OBJ(o)[0] = TheTypeExternalPolymakeFan;
      break;
    case T_POLYMAKE_EXTERNAL_POLYTOPE:
      ADDR_OBJ(o)[0] = TheTypeExternalPolymakePolytope;
      break;
    case T_POLYMAKE_EXTERNAL_TROPICAL_HYPERSURFACE:
      ADDR_OBJ(o)[0] = TheTypeExternalPolymakeTropicalHypersurface;
      break;
    case T_POLYMAKE_EXTERNAL_TROPICAL_POLYTOPE:
      ADDR_OBJ(o)[0] = TheTypeExternalPolymakeTropicalPolytope;
      break;
    case T_POLYMAKE_EXTERNAL_MATROID:
      ADDR_OBJ(o)[0] = TheTypeExternalPolymakeMatroid;
      break;
  }
  ADDR_OBJ(o)[1] = NULL;
  return o;
}
示例#2
0
文件: macfloat.c 项目: hulpke/gap
Obj NEW_MACFLOAT( Double val )
{
    Obj f;
    f = NewBag(T_MACFLOAT,SIZE_MACFLOAT);
    SET_VAL_MACFLOAT(f,val);
    return f;
}
示例#3
0
文件: fr_dll.c 项目: jakobkroeker/fr
static void *
my_malloc_hook (size_t size, const void *caller)
{
  fprintf(stderr,"allocating %d\n", size);

  return *NewBag(T_DATOBJ, size + sizeof(Int));
}
示例#4
0
文件: serialize.c 项目: dimpase/gap
static Obj DeserializeBinary(UInt tnum)
{
    UInt len = ReadByteBlockLength();
    Obj  result = NewBag(tnum, len);
    ReadByteBlockData(result, 0, len);
    return result;
}
示例#5
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 = 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
Obj NewObjSet(void) {
  Obj result = NewBag(T_OBJSET,
    (OBJSET_HDRSIZE+DEFAULT_OBJSET_SIZE)*sizeof(Bag));
  ADDR_WORD(result)[OBJSET_SIZE] = DEFAULT_OBJSET_SIZE;
  ADDR_WORD(result)[OBJSET_BITS] = DEFAULT_OBJSET_BITS;
  ADDR_WORD(result)[OBJSET_USED] = 0;
  ADDR_WORD(result)[OBJSET_DIRTY] = 0;
  return result;
}
示例#7
0
文件: weakptr.c 项目: LiftnLearn/gap
Obj CopyObjWPObj (
    Obj                 obj,
    Int                 mut )
{
    Obj                 copy;           /* copy, result                    */
    Obj                 tmp;            /* temporary variable              */
    Obj                 elm;
    UInt                i;              /* loop variable                   */

    /* make a copy                                                         */
    if ( mut ) {
        copy = NewBag( T_WPOBJ, SIZE_OBJ(obj) );
        ADDR_OBJ(copy)[0] = ADDR_OBJ(obj)[0];
    }
    else {
        copy = NewBag( T_PLIST+IMMUTABLE, SIZE_OBJ(obj) );
        SET_LEN_PLIST(copy,LengthWPObj(obj));
    }

    /* leave a forwarding pointer                                          */
    tmp = NEW_PLIST( T_PLIST, 2 );
    SET_LEN_PLIST( tmp, 2 );
    SET_ELM_PLIST( tmp, 1, ADDR_OBJ(obj)[0] );
    SET_ELM_PLIST( tmp, 2, copy );
    ADDR_OBJ(obj)[0] = tmp;
    CHANGED_BAG(obj);

    /* now it is copied                                                    */
    RetypeBag( obj, T_WPOBJ + COPYING );

    /* copy the subvalues                                                  */
    for ( i =  SIZE_OBJ(obj)/sizeof(Obj)-1; i > 0; i-- ) {
        elm = ADDR_OBJ(obj)[i];
        if ( elm != 0  && !IS_WEAK_DEAD_BAG(elm)) {
            tmp = COPY_OBJ( elm, mut );
            ADDR_OBJ(copy)[i] = tmp;
            CHANGED_BAG( copy );
        }
    }

    /* return the copy                                                     */
    return copy;
}
示例#8
0
文件: weakptr.c 项目: LiftnLearn/gap
Obj FuncWeakPointerObj( Obj self, Obj list ) { 
  Obj wp; 
  Int i;
  Int len; 
  len = LEN_LIST(list);
  wp = (Obj) NewBag(T_WPOBJ, (len+1)*sizeof(Obj));
  STORE_LEN_WPOBJ(wp,len); 
  for (i = 1; i <= len ; i++) 
    { 
      ELM_WPOBJ(wp,i) = ELM0_LIST(list,i); 
      CHANGED_BAG(wp);          /* this must be here in case list is 
                                 in fact an object and causes a GC in the 
                                 element access method */
    }

  return wp; 
} 
示例#9
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 = 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;
}
示例#10
0
文件: boehm_gc.c 项目: phs75/gap
Region * NewRegion(void)
{
    Region *           result;
    pthread_rwlock_t * lock;
    Obj                region_obj;
#ifndef DISABLE_GC
    result = GC_malloc(sizeof(Region) + (MAX_THREADS + 1));
    lock = GC_malloc_atomic(sizeof(*lock));
    GC_register_finalizer(lock, LockFinalizer, NULL, NULL, NULL);
#else
    result = calloc(1, sizeof(Region) + (MAX_THREADS + 1));
    lock = malloc(sizeof(*lock));
#endif
    pthread_rwlock_init(lock, NULL);
    region_obj = NewBag(T_REGION, sizeof(Region *));
    MakeBagPublic(region_obj);
    *(Region **)(ADDR_OBJ(region_obj)) = result;
    result->obj = region_obj;
    result->lock = lock;
    return result;
}
示例#11
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) );
 CHANGED_BAG( STATE(CurrLVars) );
 body1 = NewBag( T_BODY, sizeof(BodyHeader));
 SET_BODY_FUNC( func1, body1 );
 CHANGED_BAG( func1 );
 CALL_0ARGS( func1 );
 
 /* return success */
 return 0;
 
}
示例#12
0
/* 'InitLibrary' sets up gvars, rnams, functions */
static Int InitLibrary ( StructInitInfo * module )
{
 Obj func1;
 Obj body1;
 
 /* Complete Copy/Fopy registration */
 UpdateCopyFopyInfo();
 
 /* global variables used in handlers */
 G_IS__FUNCTION = GVarName( "IS_FUNCTION" );
 G_ADD__LIST = GVarName( "ADD_LIST" );
 G_Error = GVarName( "Error" );
 G_IS__IDENTICAL__OBJ = GVarName( "IS_IDENTICAL_OBJ" );
 G_AND__FLAGS = GVarName( "AND_FLAGS" );
 G_HASH__FLAGS = GVarName( "HASH_FLAGS" );
 G_WITH__HIDDEN__IMPS__FLAGS = GVarName( "WITH_HIDDEN_IMPS_FLAGS" );
 G_IS__SUBSET__FLAGS = GVarName( "IS_SUBSET_FLAGS" );
 G_TRUES__FLAGS = GVarName( "TRUES_FLAGS" );
 G_FLAGS__FILTER = GVarName( "FLAGS_FILTER" );
 G_WITH__HIDDEN__IMPS__FLAGS__COUNT = GVarName( "WITH_HIDDEN_IMPS_FLAGS_COUNT" );
 G_WITH__HIDDEN__IMPS__FLAGS__CACHE__MISS = GVarName( "WITH_HIDDEN_IMPS_FLAGS_CACHE_MISS" );
 G_WITH__HIDDEN__IMPS__FLAGS__CACHE__HIT = GVarName( "WITH_HIDDEN_IMPS_FLAGS_CACHE_HIT" );
 G_IMPLICATIONS = GVarName( "IMPLICATIONS" );
 G_WITH__IMPS__FLAGS__CACHE = GVarName( "WITH_IMPS_FLAGS_CACHE" );
 G_WITH__IMPS__FLAGS__COUNT = GVarName( "WITH_IMPS_FLAGS_COUNT" );
 G_WITH__IMPS__FLAGS__CACHE__HIT = GVarName( "WITH_IMPS_FLAGS_CACHE_HIT" );
 G_WITH__IMPS__FLAGS__CACHE__MISS = GVarName( "WITH_IMPS_FLAGS_CACHE_MISS" );
 G_CLEAR__IMP__CACHE = GVarName( "CLEAR_IMP_CACHE" );
 G_BIND__GLOBAL = GVarName( "BIND_GLOBAL" );
 G_UNBIND__GLOBAL = GVarName( "UNBIND_GLOBAL" );
 G_RANK__FILTERS = GVarName( "RANK_FILTERS" );
 G_RankFilter = GVarName( "RankFilter" );
 G_RANK__FILTER = GVarName( "RANK_FILTER" );
 G_RANK__FILTER__LIST__CURRENT = GVarName( "RANK_FILTER_LIST_CURRENT" );
 G_RANK__FILTER__LIST = GVarName( "RANK_FILTER_LIST" );
 G_RANK__FILTER__COUNT = GVarName( "RANK_FILTER_COUNT" );
 
 /* record names used in handlers */
 
 /* information for the functions */
 C_NEW_STRING( DefaultName, 14, "local function" );
 C_NEW_STRING( FileName, 21, "GAPROOT/lib/filter1.g" );
 NameFunc[1] = DefaultName;
 NamsFunc[1] = 0;
 NargFunc[1] = 0;
 NameFunc[2] = DefaultName;
 NamsFunc[2] = 0;
 NargFunc[2] = 0;
 NameFunc[3] = DefaultName;
 NamsFunc[3] = 0;
 NargFunc[3] = 1;
 NameFunc[4] = DefaultName;
 NamsFunc[4] = 0;
 NargFunc[4] = 1;
 NameFunc[5] = DefaultName;
 NamsFunc[5] = 0;
 NargFunc[5] = 1;
 NameFunc[6] = DefaultName;
 NamsFunc[6] = 0;
 NargFunc[6] = 1;
 
 /* create all the functions defined in this module */
 func1 = NewFunction(NameFunc[1],NargFunc[1],NamsFunc[1],HdlrFunc1);
 ENVI_FUNC( func1 ) = TLS(CurrLVars);
 CHANGED_BAG( TLS(CurrLVars) );
 body1 = NewBag( T_BODY, NUMBER_HEADER_ITEMS_BODY*sizeof(Obj));
 BODY_FUNC( func1 ) = body1;
 CHANGED_BAG( func1 );
 CALL_0ARGS( func1 );
 
 /* return success */
 return 0;
 
}
示例#13
0
/* 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;
}
示例#14
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, 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;
}