summaryrefslogtreecommitdiff
path: root/graphics/asymptote/stack.cc
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/asymptote/stack.cc')
-rw-r--r--graphics/asymptote/stack.cc122
1 files changed, 61 insertions, 61 deletions
diff --git a/graphics/asymptote/stack.cc b/graphics/asymptote/stack.cc
index 3c56e5e048..a854a9d9ef 100644
--- a/graphics/asymptote/stack.cc
+++ b/graphics/asymptote/stack.cc
@@ -35,20 +35,20 @@ namespace vm {
const char *dereferenceNullPointer="dereference of null pointer";
mem::list<bpinfo> bplist;
-
+
namespace {
position curPos = nullPos;
const program::label nulllabel;
}
inline stack::vars_t base_frame(
- size_t size,
- size_t parentIndex,
- stack::vars_t closure
+ size_t size,
+ size_t parentIndex,
+ stack::vars_t closure
#ifdef DEBUG_FRAME
- , string name
+ , string name
#endif
- )
+ )
{
stack::vars_t vars;
#ifdef SIMPLE_FRAME
@@ -151,7 +151,7 @@ void stack::marshall(size_t args, stack::vars_t vars)
#if SIMPLE_FRAME
vars[i-1] = pop();
#else
- (*vars)[i-1] = pop();
+ (*vars)[i-1] = pop();
#endif
}
@@ -213,7 +213,7 @@ void stack::run(func *f)
#endif
}
-void stack::breakpoint(absyntax::runnable *r)
+void stack::breakpoint(absyntax::runnable *r)
{
lastPos=curPos;
indebugger=true;
@@ -222,12 +222,12 @@ void stack::breakpoint(absyntax::runnable *r)
debugOp=(s.length() > 0) ? s[0] : (char) 0;
indebugger=false;
}
-
-void stack::debug()
+
+void stack::debug()
{
if(!curPos) return;
if(indebugger) {em.clear(); return;}
-
+
switch(debugOp) {
case 'i': // inst
breakpoint();
@@ -259,7 +259,7 @@ void stack::debug()
newline=false;
break;
}
- if(!newline &&
+ if(!newline &&
(curPos.match(lastPos.filename()) && !curPos.match(lastPos.Line())))
newline=true;
}
@@ -293,45 +293,45 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
// Set up the closure, if necessary.
if (vars == 0)
- {
+ {
#ifndef SIMPLE_FRAME
- assessClosure(l);
- if (l->closureReq == lambda::NEEDS_CLOSURE)
+ assessClosure(l);
+ if (l->closureReq == lambda::NEEDS_CLOSURE)
#endif
- {
- /* make new activation record */
- vars = vm::make_frame(l, parent);
- assert(vars);
- }
+ {
+ /* make new activation record */
+ vars = vm::make_frame(l, parent);
+ assert(vars);
+ }
#ifndef SIMPLE_FRAME
- else
- {
- assert(l->closureReq == lambda::DOESNT_NEED_CLOSURE);
+ else
+ {
+ assert(l->closureReq == lambda::DOESNT_NEED_CLOSURE);
- // Use the stack to store variables.
- varlink = &theStack;
+ // Use the stack to store variables.
+ varlink = &theStack;
- // Record where the parameters start on the stack.
- frameStart = theStack.size() - frameSize;
+ // Record where the parameters start on the stack.
+ frameStart = theStack.size() - frameSize;
- // Add the parent's closure to the frame.
- push(parent);
- ++frameSize;
+ // Add the parent's closure to the frame.
+ push(parent);
+ ++frameSize;
- size_t newFrameSize = (size_t)l->framesize;
+ size_t newFrameSize = (size_t)l->framesize;
- if (newFrameSize > frameSize) {
- theStack.resize(frameStart + newFrameSize);
- frameSize = newFrameSize;
- }
- }
+ if (newFrameSize > frameSize) {
+ theStack.resize(frameStart + newFrameSize);
+ frameSize = newFrameSize;
+ }
+ }
#endif
- }
+ }
if (vars) {
- marshall(l->parentIndex, vars);
+ marshall(l->parentIndex, vars);
- SET_VARLINK;
+ SET_VARLINK;
}
/* start the new function */
@@ -343,10 +343,10 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
for (;;) {
const inst &i = *ip;
curPos = i.pos;
-
- if(curPos.filename() == fileName)
- topPos=curPos;
-
+
+ if(curPos.filename() == fileName)
+ topPos=curPos;
+
#ifdef PROFILE
prof.recordInstruction();
#endif
@@ -354,16 +354,16 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
#ifdef DEBUG_STACK
printInst(cout, ip, l->code->begin());
cout << " (";
- i.pos.printTerse(cout);
- cout << ")\n";
+ i.pos.printTerse(cout);
+ cout << ")\n";
#endif
if(settings::verbose > 4) em.trace(curPos);
-
+
if(!bplist.empty()) debug();
-
+
if(errorstream::interrupt) throw interrupted();
-
+
switch (i.op)
{
case inst::varpush:
@@ -373,7 +373,7 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
case inst::varsave:
VAR(get<Int>(i)) = top();
break;
-
+
#ifdef COMBO
case inst::varpop:
VAR(get<Int>(i)) = pop();
@@ -413,7 +413,7 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
case inst::pushclosure:
assert(vars);
push(vars);
- break;
+ break;
case inst::nop:
break;
@@ -421,12 +421,12 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
case inst::pop:
pop();
break;
-
+
case inst::intpush:
case inst::constpush:
push(i.ref);
break;
-
+
case inst::fieldpush: {
vars_t frame = pop<vars_t>();
if (!frame)
@@ -434,7 +434,7 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
push(FRAMEVAR(frame, get<Int>(i)));
break;
}
-
+
case inst::fieldsave: {
vars_t frame = pop<vars_t>();
if (!frame)
@@ -453,8 +453,8 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
break;
}
#endif
-
-
+
+
case inst::builtin: {
bltin func = get<bltin>(i);
#ifdef PROFILE
@@ -530,7 +530,7 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
push((callable*)f);
break;
}
-
+
default:
error("Internal VM error: Bad stack operand");
}
@@ -540,7 +540,7 @@ void stack::runWithOrWithoutClosure(lambda *l, vars_t vars, vars_t parent)
vm::draw(cerr,vars);
cerr << "\n";
#endif
-
+
++ip;
}
} catch (bad_item_value&) {
@@ -583,7 +583,7 @@ void stack::draw(ostream& out)
}
else
out << " ";
-
+
while (left != theStack.end())
{
if (left != theStack.begin())
@@ -597,7 +597,7 @@ void stack::draw(ostream& out)
void draw(ostream& out, frame* v)
{
out << "vars:" << endl;
-
+
while (!!v) {
item link=(*v)[v->getParentIndex()];
@@ -647,13 +647,13 @@ void errornothrow(const char* message)
em << message;
em.sync();
}
-
+
void error(const char* message)
{
errornothrow(message);
throw handled_error();
}
-
+
void error(const ostringstream& message)
{
const string& s=message.str();