/usr/include/falcon/continuation.h is in falconpl-dev 0.9.6.9-git20120606-2.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | /*
FALCON - The Falcon Programming Language.
FILE: continuation.h
Continuation object.
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: Sat, 05 Dec 2009 17:04:27 +0100
-------------------------------------------------------------------
(C) Copyright 2009: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
#ifndef FALCON_CONTINUATION_H_
#define FALCON_CONTINUATION_H_
#include <falcon/itemarray.h>
#include <falcon/vmcontext.h>
namespace Falcon
{
class Continuation: public BaseAlloc
{
public:
/** Form the continuation.
The place where the continuation is formed will be used
as the return point when the invoke method is called.
*/
Continuation( VMachine* vm );
Continuation( const Continuation& e );
virtual ~Continuation();
/** Applies the continuation on the virtual machine.
If the continuation has already been suspended, then
it resumes the continuation and returns true.
Otherwise, it does nothing and returns false.
The parameter is set into the return value in case of positive jump.
*/
bool jump( const Item& jump_param );
/** Invoke the continuation.
The effect of the invocation is that of:
1) saving the current context.
2) returning the given value to the original caller.
3) applying the original context and unrolling the stack up to the call level.
*/
void suspend( const Item& retval );
void reset()
{
m_bComplete = false;
m_tgtSymbol = 0;
}
/** Returns true if the topmost code in this continuation has been fully executed.
In other words, it returns false if it has been not yet executed or
executed but suspended.
* */
bool complete() const {
return m_tgtSymbol != 0 && m_tgtPC >= m_tgtSymbol->getFuncDef()->codeSize();
}
bool ready() const {
return m_tgtSymbol == 0;
}
ItemArray ¶ms() { return m_params; }
StackFrame* frames() const { return m_top; }
// the first parameter of the bottom call...
bool updateSuspendItem( const Item& itm );
private:
VMachine* m_vm;
VMContext* m_context;
/** Level at which the stack is created */
uint32 m_stackLevel;
/** Symbol/module where the continuation is invoked. */
const Symbol* m_tgtSymbol;
/** Symbol/module where the continuation is invoked. */
LiveModule *m_tgtLModule;
uint32 m_tgtPC;
/** Frame where the call is started. */
StackFrame* m_callingFrame;
/** Current frame when the continuation is called. */
StackFrame* m_top;
/** First frame on top of the calling frame. */
StackFrame* m_bottom;
/** Parameters for the bottom frame (safely stored here) */
ItemArray m_params;
bool m_bComplete;
int32 m_refCount;
};
class ContinuationCarrier: public CoreObject
{
public:
ContinuationCarrier( const CoreClass* cc );
ContinuationCarrier( const ContinuationCarrier& other );
virtual ~ContinuationCarrier();
virtual ContinuationCarrier *clone() const;
virtual bool setProperty( const String &prop, const Item &value );
virtual bool getProperty( const String &prop, Item &value ) const;
Continuation* cont() const { return m_cont; }
void cont( Continuation* cc ) { m_cont = cc; }
virtual void gcMark( uint32 mark );
const Item& ccItem() const { return m_citem; }
void ccItem( const Item& itm ) { m_citem = itm; }
const Item& suspendItem() const { return m_suspendItem; }
Item& suspendItem() { return m_suspendItem; }
static CoreObject* factory( const CoreClass* cls, void* data, bool deser );
private:
Continuation* m_cont;
Item m_citem;
Item m_suspendItem;
uint32 m_mark;
};
}
#endif /* CONTINUATION_H_ */
|