예제 #1
0
파일: make.c 프로젝트: jackspirou/orson
refObject makeCharacter(int self)
{ refCharacter newCharacter = makeHunk(characterSize);
  degree(newCharacter) = characterDegree;
  size(newCharacter)   = characterSize;
  state(newCharacter)  = 0;
  tag(newCharacter)    = characterTag;
  self(newCharacter)   = self;
  return toRefObject(newCharacter); }
예제 #2
0
파일: make.c 프로젝트: jackspirou/orson
refObject makeInteger(int self)
{ refInteger newInteger = makeHunk(integerSize);
  degree(newInteger)  = integerDegree;
  size(newInteger)    = integerSize;
  state(newInteger)   = 0;
  tag(newInteger)     = integerTag;
  self(newInteger)    = self;
  return toRefObject(newInteger); }
예제 #3
0
파일: make.c 프로젝트: jackspirou/orson
refObject makeReal(double self)
{ refReal newReal = makeHunk(realSize);
  degree(newReal) = realDegree;
  size(newReal)   = realSize;
  state(newReal)  = 0;
  tag(newReal)    = realTag;
  self(newReal)   = self;
  return toRefObject(newReal); }
예제 #4
0
파일: make.c 프로젝트: jackspirou/orson
refObject makeCell(refObject type, refObject value)
{ refCell newCell = makeHunk(cellSize);
  degree(newCell) = cellDegree;
  size(newCell)   = cellSize;
  state(newCell)  = 0;
  tag(newCell)    = cellTag;
  type(newCell)   = type;
  value(newCell)  = value;
  return toRefObject(newCell); }
예제 #5
0
파일: make.c 프로젝트: jackspirou/orson
refObject makeTriple(refObject car, refObject cdr, refObject info)
{ refTriple newTriple = makeHunk(tripleSize);
  degree(newTriple) = tripleDegree;
  size(newTriple)   = tripleSize;
  state(newTriple)  = 0;
  tag(newTriple)    = pairTag;
  car(newTriple)    = car;
  cdr(newTriple)    = cdr;
  info(newTriple)   = info;
  return toRefObject(newTriple); }
예제 #6
0
파일: make.c 프로젝트: jackspirou/orson
refObject makePaire(refObject car, refObject cdr, int info)
{ refPair newPair = makeHunk(pairSize);
  degree(newPair) = pairDegree;
  size(newPair)   = pairSize;
  state(newPair)  = 0;
  tag(newPair)    = pairTag;
  car(newPair)    = car;
  cdr(newPair)    = cdr;
  info(newPair)   = info;
  return toRefObject(newPair); }
예제 #7
0
파일: make.c 프로젝트: jackspirou/orson
refObject makeStub(refObject name)
{ refStub newStub = makeHunk(stubSize);
  degree(newStub) = stubDegree;
  size(newStub)   = stubSize;
  state(newStub)  = 0;
  tag(newStub)    = nameTag;
  number(newStub) = nameCount;
  nameCount += 1;
  if (name == nil)
  { string(newStub) = "unique"; }
  else
  { string(newStub) = string(toRefName(name)); }
  return toRefObject(newStub); }
예제 #8
0
파일: make.c 프로젝트: jackspirou/orson
refObject makingJoker(refChar string, int hook, ...)
{ refJoker newJoker = malloc(jokerSize);
  if (newJoker == nil)
  { fail("Cannot make '%s' in makingJoker!", string); }
  else
  { vaList hooks;
    degree(newJoker) = jokerDegree;
    size(newJoker)   = jokerSize;
    state(newJoker)  = 0x7F;
    tag(newJoker)    = jokerTag;
    self(newJoker)   = setEmpty();
    string(newJoker) = string;
    vaStart(hooks, hook);
    while (hook != 0)
    { self(newJoker) = setAdjoin(self(newJoker), hook);
      hook = vaArg(hooks, int); }
    vaEnd(hooks);
    return toRefObject(newJoker); }}
예제 #9
0
파일: hunk.c 프로젝트: jamesbmoen/orson
void reclaimSizedHunks()
{ int          count;
  refHunk      lastHunk;
  refHeap      nextHeap;
  refHunk      nextHunk;
  refFrame     nextFrame;
  refRefObject refsStart;
  int          size;
  int          total;

//  Mark protected global variables.

  mark(bases);
  mark(cellSimple);
  mark(characterZero);
  mark(countName);
  mark(emptyAlts);
  mark(emptyClosure);
  mark(emptyString);
  mark(fakeCall);
  mark(firstProc);
  mark(formCall);
  mark(integerOne);
  mark(integerMinusOne);
  mark(integerZero);
  mark(lastProc);
  mark(layers);
  mark(linkName);
  mark(markable);
  mark(markingName);
  mark(toRefObject(matches));
  mark(nullSimple);
  mark(plainLayer);
  mark(realZero);
  mark(resultName);
  mark(rowChar0);
  mark(rowRowChar0);
  mark(rowVoid);
  mark(rowVoidExternal);
  mark(skolemLayer);
  mark(symNoName);
  mark(typeExeJoker);
  mark(typeFojJoker);
  mark(typeMutJoker);
  mark(typeObjJoker);
  mark(typeTypeObjJoker);
  mark(typeSymNoName);
  mark(typeVoid);
  mark(typeTypeVoid);
  mark(vajJoker);
  mark(voidExternal);

//  Mark stack frames.

  nextFrame = frames;
  while (nextFrame != nil)
  { count = count(nextFrame);
    refsStart = refs(nextFrame);
    while (count > 0)
    { mark(d(refsStart));
      count -= 1;
      refsStart += 1; }
    nextFrame = link(nextFrame); }

//  Make a pass through the chain of heaps, looking at every hunk. If we find a
//  hunk whose TAG is HUNK TAG, then we skip it, because it's already in a free
//  list somewhere. If we find a marked hunk, then we simply unmark it, because
//  it's still in use. If we find an unmarked hunk, then it's not in use, so we
//  reset its TAG to HUNK TAG, and add it to the appropriate free list in SIZED
//  HUNKS.

  total = 0;
  nextHeap = heaps;
  while (nextHeap != nil)
  { nextHunk = toRefHunk(hunks(nextHeap) + hunkSize);
    lastHunk = r(lastHunk(nextHeap));
    while (nextHunk != lastHunk)
    { if (isHunk(nextHunk))
      { nextHunk = toRefHunk(toRefChar(nextHunk) + space(nextHunk)); }
      else
      { size = size(nextHunk);
        if (state(nextHunk) == 0)
        { tag(nextHunk) = hunkTag;
          space(nextHunk) = size;
          next(nextHunk) = sizedHunks[size];
          sizedHunks[size] = nextHunk;
          total += size; }
        else
        { state(nextHunk) = 0; }
        nextHunk = toRefHunk(toRefChar(nextHunk) + size); }}
    nextHeap = next(nextHeap); }

//  Write optional debugging information.

  if (maxDebugLevel >= 0)
  { fprintf(stream(debug), "[0] Reclaimed %i bytes\n", total); }}