Ejemplo n.º 1
0
/* get a new empty vlist */
var_t*
eppic_newvlist()
{
var_t*p=eppic_newvar("");
    TAG(p);
    TAG(p->name);
    return p;
}
/**
 * Loads the template data from an iff file. We should already be in the form
 * for this template.
 *
 * @param file		file to load from
 */
void ServerStaticObjectTemplate::load(Iff &file)
{
static const int MAX_NAME_SIZE = 256;
char paramName[MAX_NAME_SIZE];

	if (file.getCurrentName() != ServerStaticObjectTemplate_tag)
	{
		ServerObjectTemplate::load(file);
		return;
	}

	file.enterForm();
	m_templateVersion = file.getCurrentName();
	if (m_templateVersion == TAG(D,E,R,V))
	{
		file.enterForm();
		file.enterChunk();
		std::string baseFilename;
		file.read_string(baseFilename);
		file.exitChunk();
		const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
		DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
		if (m_baseData == base && base != NULL)
			base->releaseReference();
		else
		{
			if (m_baseData != NULL)
				m_baseData->releaseReference();
			m_baseData = base;
		}
		file.exitForm();
		m_templateVersion = file.getCurrentName();
	}
	if (getHighestTemplateVersion() != TAG(0,0,0,1))
	{
		if (DataLint::isEnabled())
			DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
	}

	file.enterForm();

	file.enterChunk();
	int paramCount = file.read_int32();
	file.exitChunk();
	for (int i = 0; i < paramCount; ++i)
	{
		file.enterChunk();
		file.read_string(paramName, MAX_NAME_SIZE);
		if (strcmp(paramName, "clientOnlyBuildout") == 0)
			m_clientOnlyBuildout.loadFromIff(file);
		file.exitChunk(true);
	}

	file.exitForm();
	ServerObjectTemplate::load(file);
	file.exitForm();
	return;
}	// ServerStaticObjectTemplate::load
Ejemplo n.º 3
0
inline TInt DMemSamplerImpl::GatherThreads()
    {
    // The thread memory consumption
    
    NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
    DObjectCon& threads = *Kern::Containers()[EThread];
    threads.Wait(); // Obtain the container mutex so the list does get changed under us
    
    this->iThreadCount = 0; 
    this->iNewThreadCount = 0;
    this->iTotalMemoryOk = false;           

    TInt totalThreadCount = threads.Count();

    for(TInt i(0);i<totalThreadCount;i++)
        {
        DThread* t = (DThread*)(threads)[i];

        LOGSTRING3("Processing thread %d, tag: 0x%x",i,TAG(t));

        if( (TAG(t) & PROFILER_MEM_THREAD_MARK) == 0)
            {
            LOGSTRING4("Marking thread %d/%d, old tag 0x%x",i,(totalThreadCount-1), TAG(t));
            // this thread's chunk has not been reported yet
            this->threadNamesToReport[iNewThreadCount] = t;
            iNewThreadCount++;
            // tag the thread
            TAG(t) |= PROFILER_MEM_THREAD_MARK;
            }

        // the chunk has been tagged, add heap chunks to the list
        this->threadsToSample[this->iThreadCount] = t;
        this->iThreadCount++;
        LOGSTRING2("Added thread %d to threads to sample",i);
        }
    
    if(this->iThreadCount > 0 || this->iNewThreadCount > 0)
        {
        this->iThreadsProcessing = EStartingToProcess;
        
        // process the first sample
        TInt length = this->ProcessThreads();
        
        if(length == 0)
            {
            this->iThreadsProcessing = ENothingToProcess;
            }
        threads.Signal();  // Release the container mutex
        NKern::ThreadLeaveCS();  // End of critical section
        return length;
        }
    
    LOGTEXT("MemSamplerImpl::SampleImpl - Error, no threads"); 
    threads.Signal();  // Release the container mutex
    NKern::ThreadLeaveCS();  // End of critical section
    return 0;
    }
Ejemplo n.º 4
0
Archivo: brainfuck.c Proyecto: svip/THC
int pagemain(int argc, char** argv) {
  struct html_builder builderv;
  struct html_builder *builder = &builderv;
  UNUSED(argc);
  UNUSED(argv);
  char output[MAXOUTPUT] = { 0 };
  
  webpage_start(builder, "Brainfuck", "Brainfuck-fortolker");

  TAG(("article"),
    TAG(("header"),
      TAG(("h1"), TEXT("Brainfuck-fortolker"));
    TAG(("p"), TEXT("Har du også svært ved at programmere i C, men kan sagtens finde ud af at programmere i Brianfuck?"));
    TAG(("p"), TEXT("Så er denne fortolker noget for dig!"));
    if ( getenv("CONTENT_LENGTH") != NULL ) {
      if ( handle_postdata(output) == 0 ) {
    TAG(("p", "style", "font-weight: bold;"), TEXT("Her er dit nye C-program:"));
    TAG(("pre"), TEXT(output));
      } else {
    TAG(("p", "style", "font-weight: bold;"), TEXT("Hva sulan!  Dit Brainfuck-kode kunne ikke oversættes til C!"));
      }
    } else {
    TAG(("form", "method", "post"),/*, "enctype", "multipart/form-data"),*/
      TAG(("fieldset"),
        TAG(("legend"), TEXT("Brainfuck til C"));
        TAG(("label", "for", "brainfuck-program"), TEXT("Programmet:"));
        TAG(("textarea", "type", "text", "id", "brainfuck-program", "name", "brainfuck-program", "rows", "15", "cols", "52"), TEXT(""));
        TAG(("input", "type", "submit", "name", "brainfuck-submit", "value", "Oversæt!"), );
        )
      )
    }
Ejemplo n.º 5
0
cell factor_vm::object_class(cell obj)
{
	switch(TAG(obj))
	{
	case TUPLE_TYPE:
		return untag<tuple>(obj)->layout;
	case OBJECT_TYPE:
		return untag<object>(obj)->h.value;
	default:
		return tag_fixnum(TAG(obj));
	}
}
/**
 * Loads the template data from an iff file. We should already be in the form
 * for this template.
 *
 * @param file		file to load from
 */
void ServerPlayerQuestObjectTemplate::load(Iff &file)
{
static const int MAX_NAME_SIZE = 256;
char paramName[MAX_NAME_SIZE];

	if (file.getCurrentName() != ServerPlayerQuestObjectTemplate_tag)
	{
		ServerTangibleObjectTemplate::load(file);
		return;
	}

	file.enterForm();
	m_templateVersion = file.getCurrentName();
	if (m_templateVersion == TAG(D,E,R,V))
	{
		file.enterForm();
		file.enterChunk();
		std::string baseFilename;
		file.read_string(baseFilename);
		file.exitChunk();
		const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
		DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
		if (m_baseData == base && base != NULL)
			base->releaseReference();
		else
		{
			if (m_baseData != NULL)
				m_baseData->releaseReference();
			m_baseData = base;
		}
		file.exitForm();
		m_templateVersion = file.getCurrentName();
	}
	if (getHighestTemplateVersion() != TAG(0,0,0,0))
	{
		if (DataLint::isEnabled())
			DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
		m_versionOk = false;
	}

	file.enterForm();

	file.enterChunk();
	int paramCount = file.read_int32();
	file.exitChunk();
	UNREF(paramName);
	UNREF(paramCount);

	file.exitForm();
	ServerTangibleObjectTemplate::load(file);
	file.exitForm();
	return;
}	// ServerPlayerQuestObjectTemplate::load
Ejemplo n.º 7
0
P op_errormessage(void)
{
  LBIG e, pid, port;
  P nb, tnb; 
  B *m, *s;

  if (o_6 < FLOORopds) goto baderror;
  if (CLASS(o_6) != NUM) goto baderror;
  if (! VALUE(o_6, &pid)) goto baderror;
  if (TAG(o_5) != (ARRAY | BYTETYPE)) goto baderror;
  if (CLASS(o_4) != NUM) goto baderror;
  if (! VALUE(o_4, &port)) goto baderror;
  if (TAG(o_3) != (ARRAY | BYTETYPE)) goto baderror;
  if (CLASS(o_2) != NUM) goto baderror;
  if (!VALUE(o_2, &e)) goto baderror;
  if (TAG(o_1) != (ARRAY | BYTETYPE)) goto baderror;

  s = (B *)VALUE_BASE(o_1); 
  tnb = ARRAY_SIZE(o_1);
  nb = dm_snprintf((char*) s, tnb, "On %*s port %llu, pid %llu: ",
		   (int) ARRAY_SIZE(o_5),
		   (char*) VALUE_BASE(o_5),
                   (unsigned long long) port,
		   (unsigned long long) pid);
  s += nb;
  tnb -= nb;

  if ((P)e < 0) /*Clib error */
    nb = dm_snprintf((char*) s, tnb, "errno: %s",
		     (char*) strerror(-(int)e));
  else { /* one of our error codes: decode */
    m = geterror((P) e);
    nb = strlen((char*) m);
    if (nb > tnb) nb = tnb;
    moveB(m, s, nb);
  }
  s += nb;
  tnb -= nb;

  nb = dm_snprintf((char*)s, tnb, " in %*s\n",
		   (int) ARRAY_SIZE(o_3),
		   (char*) VALUE_BASE(o_3));

  ARRAY_SIZE(o_1) = (P)(s + nb) - VALUE_BASE(o_1);
  moveframe(o_1,o_6);
  FREEopds = o_5;
  return OK;

 baderror:
  printf("**Error with corrupted error info on operand stack!\n");
  return op_halt();
}
Ejemplo n.º 8
0
static void
_dialogLoadInit (
        Dialog    *dialog,
        vresource  res
    )
{
    vclassSendSuper (_dialogClass, vobjectLOAD_INIT, (dialog, res));

    dialog->completeItem = (completeitem *)
        vdialogFindItem ((vdialog *) dialog, TAG ("CompleteItem"));
    dialog->completeList = (completelist *)
        vdialogFindItem ((vdialog *) dialog, TAG ("CompleteList"));
}
Ejemplo n.º 9
0
static void gc_initialize(unsigned int heap_size)
{
    gc_space_size = heap_size;
    gc_free = gc_cur_space = malloc(gc_space_size);
    memset(gc_cur_space, 0xcd, gc_space_size);
    gc_to_space = malloc(gc_space_size);
    memset(gc_to_space, 0xfd, gc_space_size);
    heap_end = gc_cur_space + gc_space_size;

    if (TAG(gc_cur_space) != 0 || TAG(gc_to_space) != 0) {
        error_exit("memory not aligned\n");
    }
}
Ejemplo n.º 10
0
static int
check_gost(const dst_private_t *priv, isc_boolean_t external) {

	if (external)
		return ((priv->nelements == 0)? 0 : -1);

	if (priv->nelements != GOST_NTAGS)
		return (-1);
	if ((priv->elements[0].tag != TAG(DST_ALG_ECCGOST, 0)) &&
	    (priv->elements[0].tag != TAG(DST_ALG_ECCGOST, 1)))
		return (-1);
	return (0);
}
Ejemplo n.º 11
0
int
bdd_lookup_in_cache31(cmu_bdd_manager bddm, int tag, INT_PTR d1, INT_PTR d2, INT_PTR d3, INT_PTR *result)
{
  long hash;
  cache_entry *bin;
  cache_entry p;
  cache_entry q;
  bdd f;
  void (*return_fn)(cmu_bdd_manager, cache_entry);

  bddm->op_cache.lookups++;
  hash=HASH3(d1, d2, d3);
  BDD_REDUCE(hash, bddm->op_cache.size);
  bin=bddm->op_cache.table[hash].entry;
  if ((p=bin[0]))
    {
      q=CACHE_POINTER(p);
      if (q->slot[0] != d1 || q->slot[1] != d2 || q->slot[2] != d3 || TAG(p) != tag)
	{
	if ((p=bin[1]))
	  {
	    q=CACHE_POINTER(p);
	    if (q->slot[0] != d1 || q->slot[1] != d2 || q->slot[2] != d3 || TAG(p) != tag)
	      return (0);
	    bin[1]=bin[0];
	    bin[0]=p;
	  }
	else
	  return (0);
	}
    }
  else
    return (0);
  bddm->op_cache.hits++;
  if ((return_fn=bddm->op_cache.return_fn[TAG(p)]))
    {
    if (return_fn == RETURN_BDD_FN)
      {
	f=(bdd)q->slot[3];
	{
	  BDD_SETUP(f);
	  BDD_TEMP_INCREFS(f);
	}
      }
    else
      (*return_fn)(bddm, q);
    }
  *result=q->slot[3];
  return (1);
}
Ejemplo n.º 12
0
static int create_task_grid(unsigned piter)
{
	unsigned i, j;
	int ret;

/*	FPRINTF(stderr, "start iter %d...\n", piter); */
	callback_cnt = (ni*nj);

	/* create non-entry tasks */
	for (j = 0; j < nj; j++)
	for (i = 1; i < ni; i++)
	{
		/* create a new task */
		struct starpu_task *task = starpu_task_create();
		task->callback_func = callback_cpu;
		/* jb->argcb = &coords[i][j]; */
		task->cl = &cl;
		task->cl_arg = NULL;

		task->use_tag = 1;
		task->tag_id = TAG(i, j, piter);

		/* express deps : (i,j) depends on (i-1, j-1) & (i-1, j+1) */
		express_deps(i, j, piter);

		ret = starpu_task_submit(task);
		if (ret == -ENODEV) return 77;
		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
	}

	/* create entry tasks */
	for (j = 0; j < nj; j++)
	{
		/* create a new task */
		struct starpu_task *task = starpu_task_create();
		task->callback_func = callback_cpu;
		task->cl = &cl;
		task->cl_arg = NULL;

		task->use_tag = 1;
		/* this is an entry task */
		task->tag_id = TAG(0, j, piter);

		ret = starpu_task_submit(task);
		if (ret == -ENODEV) return 77;
		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
	}
	return 0;
}
Ejemplo n.º 13
0
P op_screensize(void)
{
#if X_DISPLAY_MISSING
	return NO_XWINDOWS;
#else
  if (dvtdisplay == NULL) return NO_XWINDOWS;
  if (o2 > CEILopds) return OPDS_OVF;
  TAG(o1) = TAG(o2) = NUM | LONGBIGTYPE; 
  ATTR(o1) = ATTR(o2) = 0;
  LONGBIG_VAL(o1) = rootwindowattr.width;
  LONGBIG_VAL(o2) = rootwindowattr.height;
  FREEopds = o3;
  return OK;
#endif
}
Ejemplo n.º 14
0
cell factor_vm::lookup_method(cell obj, cell methods)
{
	cell tag = TAG(obj);
	cell method = array_nth(untag<array>(methods),tag);

	if(tag == TUPLE_TYPE)
	{
		if(TAG(method) == ARRAY_TYPE)
			return lookup_tuple_method(obj,method);
		else
			return method;
	}
	else
		return method;
}
Ejemplo n.º 15
0
	cell type() const {
		cell tag = TAG(value_);
		if(tag == OBJECT_TYPE)
			return untagged()->h.hi_tag();
		else
			return tag;
	}
Ejemplo n.º 16
0
// n k | (n/k)
DM_INLINE_STATIC P combinations(void) {
  P n, k, i, j;

  if (o_2 < FLOORopds) return OPDS_UNF;
  if (CLASS(o_1) != NUM) return OPD_CLA;
  if (CLASS(o_2) != NUM) return OPD_CLA;
  if (! PVALUE(o_2, &n)) return UNDF_VAL;
  if (! PVALUE(o_1, &k)) return UNDF_VAL;
  if (n < 0 || k < 0 || n < k) return RNG_CHK;
  if (n > max_kn) return RNG_CHK;

  TAG(o_2) = (NUM | DOUBLETYPE);
  ATTR(o_2) = 0;
  FREEopds = o_1;
  if (n == k || k == 0) {
    *(D*) NUM_VAL(o_1) = 1;
    return OK;
  }

  if (n <= max_n) {
    *(D*) NUM_VAL(o_1) = binom[n][k];
    return OK;
  }

  for (i = max_n+1; i <= n; ++i) {
    binom[i][0] = binom[i][i] = 1;
    for (j = 1; j < i; ++j) {
      binom[i][j] = binom[i-1][j-1] + binom[i-1][j];
    }
  }
  max_n = n;

  *(D*) NUM_VAL(o_1) = binom[n][k];
  return OK;
}
Ejemplo n.º 17
0
SEXP dot_external_access_args(SEXP args) {
    args = CDR(args);
    int index = 0;
    for (; args != R_NilValue; args = CDR(args)) {
	index++;
	SEXP tag = TAG(args);
	const char *name = isNull(tag) ? "" : CHAR(PRINTNAME(tag));
	SEXP value = CAR(args);
	if (length(value) == 0) {
	    Rprintf("%d: '%s' length 0\n", index, name);
	    continue;
	}
	switch (TYPEOF(value)) {
	case LGLSXP:
	case INTSXP:
	    Rprintf("%d: '%s' %d\n", index, name, INTEGER(value)[0]);
	    break;
	case REALSXP:
	    Rprintf("%d: '%s' %f\n", index, name, REAL(value)[0]);
	    break;
	case CPLXSXP: {
	    Rcomplex complexValue = COMPLEX(value)[0];
	    Rprintf("%d: '%s' %f+%fi\n", index, name, complexValue.r,
		    complexValue.i);
	    break;
	}
	case STRSXP:
	    Rprintf("%d: '%s' %s\n", index, name, CHAR(STRING_ELT(value, 0)));
	    break;
	default:
	    Rprintf("%d: %s other\n", index, name);
	}
    }
    return R_NilValue;
}
Ejemplo n.º 18
0
SEXP showArgs(SEXP args)
{
    int i, nargs;
    Rcomplex cpl;
    char *name;

    if((nargs = length(args) - 1) > 0) {
	for(i = 0; i < nargs; i++) {
	    args = CDR(args);
	    name = CHAR(PRINTNAME(TAG(args)));
	    switch(TYPEOF(CAR(args))) {
	    case REALSXP:
		Rprintf("[%d] '%s' %f\n", i+1, name, REAL(CAR(args))[0]);
		break;
	    case LGLSXP:
	    case INTSXP:
		Rprintf("[%d] '%s' %d\n", i+1, name, INTEGER(CAR(args))[0]);
		break;
	    case CPLXSXP:
		cpl = COMPLEX(CAR(args))[0];
		Rprintf("[%d] '%s' %f + %fi\n", i+1, name, cpl.r, cpl.i);
		break;
	    case STRSXP:
		Rprintf("[%d] '%s' %s\n", i+1, name,
		       CHAR(STRING_ELT(CAR(args), 0)));
		break;
	    default:
		Rprintf("[%d] '%s' R type\n", i+1, name);
	    }
	}
    }
    return(R_NilValue);
}
Ejemplo n.º 19
0
EDWORD* get_mpc_info(MPC_header *m, struct parameters *p)
{
    int done = 0;
    int i = 0;
    int offset = 0;
    
    while (!done)
    {
        EDWORD currentWord = *(p->fileBuffer + i);
        
        if (currentWord == REVDWBYTES(TAG(m->header[0], m->header[1], m->header[2], m->header[3])))
        {
            printf("Found Header\n");
            offset = i;
            offset+=1;
            
            done = 1;
        }
        
        if (i > 100)
        {
            printf("No MPC Header Found.\n");
            return 0;
        }
        
        i+=1;
    }
    
    m->size = *(p->fileBuffer + offset);
    offset+=1;
    
    m->unknown = *(p->fileBuffer + offset);
    offset+=1;
    
    // Add 1 more to the number of markers to account for the first maker (0, 0)
    m->numberMarkers = *(p->fileBuffer + offset) + 1;
    offset+=1;
    
    m->tempo = *(p->fileBuffer + offset);
    offset+=1;
    
    // Allocate memory for the markers
    EDWORD *markers = (EDWORD *) malloc(sizeof(EDWORD) * (m->numberMarkers * 2));
    
    for (int j = 0; j < m->numberMarkers; j++)
    {
        int loc = j * 2;
        
        *(markers + loc) = *(p->fileBuffer + offset);
        printf("Tick: %d, ", *(markers + loc));
        offset+=1;
        
        *(markers + loc + 1) = *(p->fileBuffer + offset);
        printf("Frame: %d\n", *(markers + loc + 1));
        offset+=1;
    }
    
    return markers;
    
}
Ejemplo n.º 20
0
void check_attribute_compatibility(SEXP left, SEXP right) {
  SEXP att_left  = ATTRIB(left);
  SEXP att_right = ATTRIB(right);
  int n_left = count_attributes(att_left);
  int n_right = count_attributes(att_right);
  
  if (Rf_inherits(left, "POSIXct") &&  Rf_inherits(right, "POSIXct")) {
    return;
  }

  if (n_left != n_right)
    stop("attributes of different sizes");

  List list_left(n_left), list_right(n_left);

  SEXP p_left = att_left;
  int i = 0;
  while (!Rf_isNull(p_left)) {
    SEXP name = TAG(p_left);
    if (name != R_NamesSymbol && name != R_DimSymbol) {
      list_left[i]  = CAR(p_left);
      list_right[i] = grab_attribute(name, att_right);
    }
    p_left = CDR(p_left);
  }
  RObject test = Language("all.equal", list_left, list_right).fast_eval();
  if (!is<bool>(test) || !as<bool>(test)) {
    stop("attributes are different");
  }
}
Ejemplo n.º 21
0
/*
 * SetItemNotify - sets up a menu item's notify function
 */
static void SetItemNotify(vmainview *view, vdialog *dialog, 
			  const char *menuId, const char *mitemId, 
			  vmenuItemNoteProc notify)
{
  vmenubar	*menubar;
  vmenu		*menu;
  vmenuItem	*mitem;

  menubar = (vmenubar*)vdialogFindItem(dialog, TAG("Menu Bar"));
  menu    = vmenubarFindMenu(menubar, TAG(menuId));
  vmenuSetData(menu, dialog);

  mitem   = vmenuFindItem(menu, TAG(mitemId));
  vmenuSetItemData(mitem, view);
  vmenuSetItemNotify(mitem, notify);
}
Ejemplo n.º 22
0
static int
check_hmac_md5(const dst_private_t *priv, isc_boolean_t old) {
	int i, j;

	if (priv->nelements != HMACMD5_NTAGS) {
		/*
		 * If this is a good old format and we are accepting
		 * the old format return success.
		 */
		if (old && priv->nelements == OLD_HMACMD5_NTAGS &&
		    priv->elements[0].tag == TAG_HMACMD5_KEY)
			return (0);
		return (-1);
	}
	/*
	 * We must be new format at this point.
	 */
	for (i = 0; i < HMACMD5_NTAGS; i++) {
		for (j = 0; j < priv->nelements; j++)
			if (priv->elements[j].tag == TAG(DST_ALG_HMACMD5, i))
				break;
		if (j == priv->nelements)
			return (-1);
	}
	return (0);
}
Ejemplo n.º 23
0
SEXP grab_attribute(SEXP name, SEXP x) {
  while (!Rf_isNull(x)) {
    if (TAG(x) == name) return CAR(x);
    x = CDR(x);
  }
  stop("cannot find attribute '%s' ", SymbolString(Symbol(name)).get_utf8_cstring());
}
Ejemplo n.º 24
0
// x l | Pl(x)
DM_INLINE_STATIC P legendre(void) {
  P l, i;
  D x, Px, Px_1, Px_2;
  if (o_2 < FLOORopds) return OPDS_UNF;
  if (CLASS(o_1) != NUM) return OPD_CLA;
  if (! PVALUE(o_1, &l)) return UNDF_VAL;
  if (l < 0) return RNG_CHK;
  if (TAG(o_2) != (NUM | DOUBLETYPE)) return OPD_TYP;

  FREEopds = o_1;
  if (l == 0) {
    *(D*) NUM_VAL(o_1) = 1;
    return OK;
  }

  Px = x = *(D*) NUM_VAL(o_1);
  Px_1 = 1;
  for (i = 2; i <= l; ++i) {
    Px_2 = Px_1;
    Px_1 = Px;
    Px = ((D)(2*i-1))/i*x*Px_1 - ((D)(i-1))/i*Px_2;
  }

  *(D*) NUM_VAL(o_1) = Px;
  return OK;

}
Ejemplo n.º 25
0
void shownat(VAL f) {
    switch(f->ty) {
    case FUN:
	printf("FUN %d %d",((function*)(f->info))->ftag,((function*)(f->info))->next);
	break;
    case CON:
	if (TAG(f)==0) printf("O");
	if (TAG(f)==1) {
	    printf("S");
	    shownat(GETCONARG(f,0));
	}
	break;
    case TYPE:
	printf("TYPE");
    }
}
Ejemplo n.º 26
0
void natToInt(VM* vm, VAL* oldbase) {
    INITFRAME;
    RESERVE(3);
    ADDTOP(3);

    switch(TAG(LOC(0))) {
    case 0:
        PROJECT(vm, LOC(0), 2, 0);
        RVAL = MKINT(0);
        TOPBASE(0);
        REBASE;
        break;
    case 1:
        PROJECT(vm, LOC(0), 1, 1);
        RESERVE(1);
        TOP(0) = LOC(1);
        STOREOLD;
        BASETOP(0);
        ADDTOP(1);
        CALL(natToInt);
        LOC(2) = RVAL;
        RVAL = ADD(LOC(2), MKINT(1));
        TOPBASE(0);
        REBASE;
        break;
    }
}
Ejemplo n.º 27
0
void plus(VM* vm, VAL* oldbase) {
    INITFRAME;
    RESERVE(2);
    ADDTOP(2);

    switch(TAG(LOC(0))) {
    case 0:
        PROJECT(vm, LOC(0), 2, 0);
        RVAL = LOC(1);
        TOPBASE(0);
        REBASE;
        break;
    case 1:
        PROJECT(vm, LOC(0), 2, 1);
        RESERVE(2);
        TOP(0) = LOC(2);
        TOP(1) = LOC(1);
        STOREOLD;
        BASETOP(0);
        ADDTOP(2);
        CALL(plus);
        LOC(3) = RVAL;
        RVAL = MKCON(vm, 1, 1, LOC(3));
        TOPBASE(0);
        REBASE;
        break;
    }
}
Ejemplo n.º 28
0
SEXP setOption(SEXP tag, SEXP value)
{
    SEXP opt, old, t;
    t = opt = SYMVALUE(Rf_install(".Options"));
    if (!Rf_isList(opt))
        Rf_error("corrupted options list");
    opt = FindTaggedItem(opt, tag);

    /* The option is being removed. */
    if (value == R_NilValue) {
        for ( ; t != R_NilValue ; t = CDR(t))
            if (TAG(CDR(t)) == tag) {
                old = CAR(t);
                SETCDR(t, CDDR(t));
                return old;
            }
        return R_NilValue;
    }
    /* If the option is new, a new slot */
    /* is added to the end of .Options */
    if (opt == R_NilValue) {
        while (CDR(t) != R_NilValue)
            t = CDR(t);
        PROTECT(value);
        SETCDR(t, Rf_allocList(1));
        UNPROTECT(1);
        opt = CDR(t);
        SET_TAG(opt, tag);
    }
    old = CAR(opt);
    SETCAR(opt, value);
    return old;
}
Ejemplo n.º 29
0
/* used in removeAttrib, commentgets and classgets */
static SEXP stripAttrib(SEXP tag, SEXP lst)
{
    if(lst == R_NilValue) return lst;
    if(tag == TAG(lst)) return stripAttrib(tag, CDR(lst));
    SETCDR(lst, stripAttrib(tag, CDR(lst)));
    return lst;
}
Ejemplo n.º 30
0
/********
 * doAbout()
 *	Show help window for our sample (explains the options)
 *
 * -> command context info <yawn>
 * <- true
 ********/
static int
doAbout(vcommandFunction *com, vdict *context)
{
  if (!gAboutBox)
    {
      vresource res;

      res = vresourceGet(vapplicationGetResources(vapplicationGetCurrent()), 
			 TAG("aOverview"));
      gAboutBox = vconfirmLoad(res);

      vconfirmSetCancel(gAboutBox, vFALSE);
      vconfirmSetOverride(gAboutBox, vTRUE);
      vconfirmSetOkTitleScribed(gAboutBox, vnameScribeGlobal(vname_Close));

      vconfirmPlace(gAboutBox, gDialog, vrectPLACE_CENTER,vrectPLACE_CENTER);
    }

  if (!vdialogIsOpen(vconfirmGetDialog(gAboutBox)))
    vconfirmOpen(gAboutBox);

  else {
    vwindowUniconify(vconfirmGetWindow(gAboutBox));
    vwindowRaise(vconfirmGetWindow(gAboutBox));
  }

  return vTRUE;
}