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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
/*
FALCON - The Falcon Programming Language
FILE: poopseq.h
Virtual sequence that can be used to iterate over poop providers.
*AT THE MOMENT* providing just "append" method to re-use sequence
comprehension in OOP and POOP contexts.
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: Mon, 10 Aug 2009 10:53:29 +0200
-------------------------------------------------------------------
(C) Copyright 2009: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
#include <falcon/poopseq.h>
#include <falcon/rosstream.h>
#include <falcon/error.h>
#include <falcon/eng_messages.h>
#include <falcon/fassert.h>
#include <falcon/vm.h>
#include <falcon/item.h>
namespace Falcon {
Item m_appendMth;
uint32 m_mark;
PoopSeq::PoopSeq( VMachine* vm, const Item &iobj ):
m_mark( vm->generation() ),
m_vm( vm )
{
switch( iobj.type() )
{
case FLC_ITEM_OBJECT:
if( ! iobj.asObjectSafe()->getMethod( "append", m_appendMth ) )
{
throw new CodeError( ErrorParam( e_miss_iface, __LINE__ )
.origin( e_orig_runtime )
.extra( "append") );
}
break;
case FLC_ITEM_DICT:
if( ! iobj.asDict()->getMethod( "append", m_appendMth ) )
{
throw new CodeError( ErrorParam( e_miss_iface, __LINE__ )
.origin( e_orig_runtime )
.extra( "append") );
}
break;
default:
throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
.origin( e_orig_runtime )
.extra( "O|D" ) );
}
}
PoopSeq::PoopSeq( const PoopSeq& other ):
m_appendMth( other.m_appendMth ),
m_mark( other.m_vm->generation() ),
m_vm( other.m_vm )
{}
PoopSeq::~PoopSeq()
{
}
bool PoopSeq::empty() const
{
return true;
}
void PoopSeq::gcMark( uint32 gen )
{
if ( m_mark != gen )
{
m_mark = gen;
Sequence::gcMark( gen );
memPool->markItem( m_appendMth );
}
}
PoopSeq* PoopSeq::clone() const
{
return new PoopSeq( *this );
}
const Item &PoopSeq::front() const
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime )
.extra( "PoopSeq::front" ) );
}
const Item &PoopSeq::back() const
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime )
.extra( "PoopSeq::back" ) );
}
void PoopSeq::clear()
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime )
.extra( "PoopSeq::clear" ) );
}
void PoopSeq::append( const Item& itm )
{
m_vm->pushParam( itm );
m_vm->callItemAtomic( m_appendMth, 1 );
}
void PoopSeq::prepend( const Item& itm )
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ ).origin( e_orig_runtime ).extra( "PoopSeq::prepend" ) );
}
//============================================================
// Iterator management.
//============================================================
void PoopSeq::getIterator( Iterator& tgt, bool tail ) const
{
Sequence::getIterator( tgt, tail );
// nothing to do
}
void PoopSeq::copyIterator( Iterator& tgt, const Iterator& source ) const
{
Sequence::copyIterator( tgt, source );
// nothing to do
}
void PoopSeq::insert( Iterator &iter, const Item &data )
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::insert" ) );
}
void PoopSeq::erase( Iterator &iter )
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::erase" ) );
}
bool PoopSeq::hasNext( const Iterator &iter ) const
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::erase" ) );
}
bool PoopSeq::hasPrev( const Iterator &iter ) const
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::erase" ) );
}
bool PoopSeq::hasCurrent( const Iterator &iter ) const
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::next" ) );
}
bool PoopSeq::next( Iterator &iter ) const
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::next" ) );
}
bool PoopSeq::prev( Iterator &iter ) const
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::prev" ) );
}
Item& PoopSeq::getCurrent( const Iterator &iter )
{
throw new CodeError( ErrorParam( e_not_implemented, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::prev" ) );
}
Item& PoopSeq::getCurrentKey( const Iterator &iter )
{
throw new CodeError( ErrorParam( e_non_dict_seq, __LINE__ )
.origin( e_orig_runtime ).extra( "PoopSeq::getCurrentKey" ) );
}
bool PoopSeq::equalIterator( const Iterator &first, const Iterator &second ) const
{
return false;
}
}
/* end of poopseq.cpp */
|