text:
/*****************************************************************************

  sc_signal_unsigned.cpp -- The sc_signal<sc_unsigned<W> > implementations.

  Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22

 *****************************************************************************/

/*****************************************************************************

  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
  changes you are making here.

      Name, Affiliation, Date:
  Description of Modification:

 *****************************************************************************/

/*
$Log: scx_signal_unsigned.h,v $
Revision 1.1  2011/08/15 17:31:11  acg
 Andy Goodrich: moved specialized signals from examples to this tree.

Revision 1.2  2011/08/15 16:43:24  acg
 Torsten Maehne: changes to remove unused argument warnings.

Revision 1.1.1.1  2006/12/15 20:20:03  acg
SystemC 2.3

Revision 1.2  2005/12/26 20:11:14  acg
Fixed up copyright.

Revision 1.1.1.1  2005/12/19 23:16:42  acg
First check in of SystemC 2.1 into its own archive.

Revision 1.17  2005/09/15 23:01:52  acg
Added std:: prefix to appropriate methods and types to get around
issues with the Edison Front End.

Revision 1.16  2005/05/03 19:52:26  acg
Get proper header locations on includes.

Revision 1.15  2005/05/03 19:50:20  acg
Name space version.

Revision 1.12  2005/04/11 19:05:36  acg
Change to sc_clock for Microsoft VCC 6.0. Changes for namespaces

Revision 1.11  2005/04/03 22:52:52  acg
Namespace changes.

Revision 1.10  2005/03/21 22:31:33  acg
Changes to sc_core namespace.

Revision 1.9  2004/09/27 21:01:59  acg
Andy Goodrich - Forte Design Systems, Inc.
   - This is specialized signal support that allows better use of signals
     and ports whose target value is a SystemC native type.

*/

#include <systemc>
#include <typeinfo>

/*****************************************************************************

  sc_signal_unsigned.h -- The sc_signal<sc_dt::sc_biguint<W> > definitions.

  Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22

 *****************************************************************************/

/*****************************************************************************

  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
  changes you are making here.

      Name, Affiliation, Date:
  Description of Modification:

 *****************************************************************************/

/*
$Log: scx_signal_unsigned.h,v $
Revision 1.1  2011/08/15 17:31:11  acg
 Andy Goodrich: moved specialized signals from examples to this tree.

Revision 1.3  2011/08/15 16:43:24  acg
 Torsten Maehne: changes to remove unused argument warnings.

Revision 1.2  2011/06/28 21:23:02  acg
 Andy Goodrich: merging of SCV tree.

Revision 1.1.1.1  2006/12/15 20:20:03  acg
SystemC 2.3

Revision 1.4  2006/10/23 19:40:36  acg
 Andy Goodrich: added an explicit dynamic cast to keep gcc 4.x happy.

Revision 1.3  2006/03/21 01:31:49  acg
 Andy Goodrich: changed over to sc_get_current_process_b() from
 sc_get_current_process_base() since the function's name changed.

Revision 1.2  2005/12/26 20:11:14  acg
Fixed up copyright.

Revision 1.1.1.1  2005/12/19 23:16:42  acg
First check in of SystemC 2.1 into its own archive.

Revision 1.28  2005/09/15 23:01:52  acg
Added std:: prefix to appropriate methods and types to get around
issues with the Edison Front End.

Revision 1.27  2005/07/30 03:44:11  acg
Changes from 2.1.

Revision 1.26  2005/05/09 17:17:12  acg
Changes from 2.1.

Revision 1.25  2005/05/08 19:04:06  acg
Fix bug in concat_set(int64,off). Other changes from 2.1 examples usage.

Revision 1.24  2005/05/03 19:50:20  acg
Name space version.

Revision 1.22  2005/03/21 22:31:33  acg
Changes to sc_core namespace.

Revision 1.21  2005/01/10 17:51:58  acg
Improvements.

Revision 1.20  2004/11/09 00:11:27  acg
Added support for sc_generic_base<T> in place of sc_concatref. sc_concatref
now is derived from sc_generic_base<sc_concatref>.

Revision 1.19  2004/09/27 21:01:59  acg
Andy Goodrich - Forte Design Systems, Inc.
   - This is specialized signal support that allows better use of signals
     and ports whose target value is a SystemC native type.

*/

#if !defined(SC_SIGNAL_UNSIGNED_H)
#define SC_SIGNAL_UNSIGNED_H

#if ( !defined(_MSC_VER) || _MSC_VER > 1200 )
#    define SC_TEMPLATE template<int W>
#else
#    define SC_TEMPLATE template<> template<int W>
#endif

// FORWARD REFERENCES AND USINGS:

using sc_dt::sc_signed;
using sc_dt::int64;
using sc_dt::uint64;

namespace sc_core {

class sc_unsigned_sigref;

//==============================================================================
// CLASS sc_unsigned_part_if
//
// This class provides generic access to part selections for signals whose
// data type is sc_dt::sc_biguint<W>. This class serves as the base class for the
// sc_dt::sc_biguint<W> specialization of the sc_signal_in_if<T> class. The methods
// in this class may be over-ridden individually, those that are not overridden
// will produce an error message when called. The methods are used by the
// sc_unsigned_sigref class.
//
// Notes:
//   (1) Descriptions of the methods and operators in this class appear with
//       their implementations in sc_signal<sc_dt::sc_biguint<W> >.
//==============================================================================
class sc_unsigned_part_if : virtual public sc_interface {
  protected:
	// constructor:
  	sc_unsigned_part_if() {}

  public:
    // perform a part read.
	virtual sc_dt::sc_unsigned* part_read_target();
  	virtual sc_dt::sc_unsigned read_part( int left, int right ) const;

    // perform a part write.
	virtual sc_unsigned_sigref& select_part( int left, int right );
    virtual void write_part( sc_dt::int64 v, int left, int right );
    virtual void write_part( sc_dt::uint64 v, int left, int right );
    virtual void write_part( const sc_dt::sc_signed& v, int left, int right );
    virtual void write_part( const sc_dt::sc_unsigned& v, int left, int right );

  private:
  	sc_unsigned_part_if( const sc_unsigned_part_if& );
  	sc_unsigned_part_if& operator = ( const sc_unsigned_part_if& );
};

//==============================================================================
// CLASS sc_signal_in_if<sc_dt::sc_biguint<W> >
//
// This is the class specializations for the sc_signal_in_if<T> class to
// provide additional features for sc_signal instances whose template is
// sc_dt::sc_biguint<W>, including part access.
//
// Notes:
//   (1) Descriptions of the methods and operators in this class appear with
//       their implementations in sc_signal<sc_dt::sc_biguint<W> >.
//==============================================================================
template< int W >
class sc_signal_in_if<sc_dt::sc_biguint<W> > : public sc_unsigned_part_if {
	friend class sc_unsigned_sigref;
  public:
    typedef sc_signal_in_if<sc_dt::sc_biguint<W> > this_type;

    // get the value changed event
    virtual const sc_event& value_changed_event() const = 0;

    // read the current value
    virtual const sc_dt::sc_biguint<W>& read() const = 0;

    // get a reference to the current value (for tracing)
    virtual const sc_dt::sc_biguint<W>& get_data_ref() const = 0;

    // was there a value changed event?
    virtual bool event() const = 0;

  protected:
    // constructor
    sc_signal_in_if()
    {}

  private: // disabled
    sc_signal_in_if( const this_type& );
    this_type& operator = ( const this_type& );
};

//=============================================================================
//  CLASS : sc_unsigned_sigref
//
//  Proxy class for sc_signal_uint bit and part selection.
//=============================================================================
class sc_unsigned_sigref : public sc_dt::sc_unsigned_subref_r
{
  public:
    sc_unsigned_sigref() : sc_dt::sc_unsigned_subref_r() {}
    virtual ~sc_unsigned_sigref() {}
    virtual void concat_set(sc_dt::int64 src, int low_i);
    virtual void concat_set(const sc_dt::sc_signed& src, int low_i);
    virtual void concat_set(const sc_dt::sc_unsigned& src, int low_i);
    virtual void concat_set(const sc_dt::sc_lv_base& src, int low_i);
    virtual void concat_set(sc_dt::uint64 src, int low_i);

  public:
    inline void initialize( sc_unsigned_part_if* if_p, int left_, int right_ );

  public:
    inline void operator = ( sc_dt::uint64 v );
    inline void operator = ( const char* v );
    inline void operator = ( unsigned long v );
    inline void operator = ( long v );
    inline void operator = ( unsigned int v );
    inline void operator = ( int v );
    inline void operator = ( sc_dt::int64 v );
    inline void operator = ( double v );
    inline void operator = ( const sc_unsigned_sigref& v );
    template<typename T>
    inline void operator = ( const sc_dt::sc_generic_base<T>& v );
    inline void operator = ( const sc_dt::sc_signed& v );
    inline void operator = ( const sc_dt::sc_unsigned& v );
    inline void operator = ( const sc_dt::sc_bv_base& v );
    inline void operator = ( const sc_dt::sc_lv_base& v );

  public:
    static sc_vpool<sc_unsigned_sigref> m_pool; // Pool of objects to use.

  protected:
    sc_unsigned_part_if*                m_if_p; // Target for selection.

  private:

    // disabled
    sc_unsigned_sigref( const sc_unsigned_sigref& a );
};

//==============================================================================
// CLASS sc_signal<sc_dt::sc_biguint<W> >
//
// This class implements a signal whose value acts like an sc_dt::sc_biguint<W> data
// value. This class is a specialization of the generic sc_signal class to
// implement tailored support for the sc_dt::sc_biguint<W> class.
//
// Notes:
//   (1) Descriptions of the methods and operators in this class appear with
//       their implementations.
//==============================================================================
SC_TEMPLATE
class sc_signal<sc_dt::sc_biguint<W> > :
    public sc_dt::sc_biguint<W>,
	public sc_prim_channel,
    public sc_signal_inout_if<sc_dt::sc_biguint<W> >
{
  public: // typedefs
    typedef sc_signal<sc_dt::sc_biguint<W> > this_type;

  public: // constructors and destructor:
    inline sc_signal();
    explicit inline sc_signal(const char* name_);
    virtual inline ~sc_signal();

  public: // base methods:
    inline bool base_event() const;
    inline const sc_dt::sc_biguint<W>& base_read() const;
    inline const sc_event& base_value_changed_event() const;
    inline void base_write( sc_dt::int64 value );
    inline void base_write( sc_dt::uint64 value );
    inline void base_write( const sc_dt::sc_signed& value );
    inline void base_write( const sc_dt::sc_unsigned& value );

  public: // sc_prim_channel virtual methods:
    virtual inline const char* kind() const;
    virtual inline void update();

  public: // sc_interface virtual methods:
    virtual inline const sc_event& default_event() const;
    virtual inline void register_port(
		sc_port_base& port_, const char* if_typename_ );

  public: // sc_unsigned_channel virtual methods:
    virtual inline sc_dt::sc_unsigned* part_read_target();
    virtual inline sc_dt::sc_unsigned read_part(int left, int right) const;
	virtual sc_unsigned_sigref& select_part( int left, int right );
	virtual inline void write_part( sc_dt::int64 v, int left, int right );
	virtual inline void write_part( sc_dt::uint64 v, int left, int right );
	virtual inline void write_part( const sc_dt::sc_signed& v, int left, int right );
	virtual inline void write_part(const sc_dt::sc_unsigned& v, int left, int right);

  public: // interface virtual methods:
    virtual inline bool event() const;
    virtual inline const sc_dt::sc_biguint<W>& get_data_ref() const;
    virtual inline sc_signal<sc_dt::sc_biguint<W> >& get_signal();
    virtual inline const sc_dt::sc_biguint<W>& read() const;
    virtual inline const sc_event& value_changed_event() const;
    virtual inline void write( const sc_in<sc_dt::sc_biguint<W> >& value );
    virtual inline void write( const sc_inout<sc_dt::sc_biguint<W> >& value );
    virtual inline void write( const sc_dt::sc_biguint<W>& value );

  public: // part selections:
  	inline sc_unsigned_sigref& operator () ( int left, int right );
	// #### Need to add range() and bit()!
  	inline sc_unsigned_sigref& operator [] ( int bit );

  public: // operators:
    inline void operator = ( const this_type& new_val );
    inline void operator = ( const char* new_val );
    inline void operator = ( sc_dt::uint64 new_val );
    inline void operator = ( sc_dt::int64 new_val );
    inline void operator = ( int new_val );
    inline void operator = ( long new_val );
    inline void operator = ( short new_val );
    inline void operator = ( unsigned int new_val );
    inline void operator = ( unsigned long new_val );
    inline void operator = ( unsigned short new_val );
    template<typename T>
    inline void operator = ( const sc_dt::sc_generic_base<T>& new_val );
    inline void operator = ( const sc_dt::sc_signed& new_val );
    inline void operator = ( const sc_dt::sc_unsigned& new_val );
    inline void operator = ( const sc_dt::sc_bv_base& new_val );
    inline void operator = ( const sc_dt::sc_lv_base& new_val );

    // concatenation methods (we inherit length and gets from sc_dt::sc_biguint<W>):

    virtual inline void concat_set(sc_dt::int64 src, int low_i);
    virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i);
    virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i);
    virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i);
    virtual inline void concat_set(sc_dt::uint64 src, int low_i);

  protected: // debugging methods:
    // #### void check_port();
	void check_writer();

  private: // Disabled operations that sc_dt::sc_biguint<W> supports:
    sc_dt::sc_unsigned& operator ++ ();          // prefix
    const sc_dt::sc_unsigned& operator ++ (int); // postfix
    sc_dt::sc_unsigned& operator -- ();          // prefix
    const sc_dt::sc_unsigned& operator -- (int); // postfix
    sc_dt::sc_unsigned& operator += (const sc_dt::sc_signed&    );
    sc_dt::sc_unsigned& operator += (const sc_dt::sc_unsigned&  );
    sc_dt::sc_unsigned& operator += (sc_dt::int64               );
    sc_dt::sc_unsigned& operator += (sc_dt::uint64              );
    sc_dt::sc_unsigned& operator += (long                );
    sc_dt::sc_unsigned& operator += (unsigned long       );
    sc_dt::sc_unsigned& operator += (int                 );
    sc_dt::sc_unsigned& operator += (unsigned int        );
    sc_dt::sc_unsigned& operator -= (const sc_dt::sc_signed&    );
    sc_dt::sc_unsigned& operator -= (const sc_dt::sc_unsigned&  );
    sc_dt::sc_unsigned& operator -= (sc_dt::int64               );
    sc_dt::sc_unsigned& operator -= (sc_dt::uint64              );
    sc_dt::sc_unsigned& operator -= (long                );
    sc_dt::sc_unsigned& operator -= (unsigned long       );
    sc_dt::sc_unsigned& operator -= (int                 );
    sc_dt::sc_unsigned& operator -= (unsigned int        );
    sc_dt::sc_unsigned& operator *= (const sc_dt::sc_signed&    );
    sc_dt::sc_unsigned& operator *= (const sc_dt::sc_unsigned&  );
    sc_dt::sc_unsigned& operator *= (sc_dt::int64               );
    sc_dt::sc_unsigned& operator *= (sc_dt::uint64              );
    sc_dt::sc_unsigned& operator *= (long                );
    sc_dt::sc_unsigned& operator *= (unsigned long       );
    sc_dt::sc_unsigned& operator *= (int                 );
    sc_dt::sc_unsigned& operator *= (unsigned int        );
    sc_dt::sc_unsigned& operator /= (const sc_dt::sc_signed&    );
    sc_dt::sc_unsigned& operator /= (const sc_dt::sc_unsigned&  );
    sc_dt::sc_unsigned& operator /= (sc_dt::int64               );
    sc_dt::sc_unsigned& operator /= (sc_dt::uint64              );
    sc_dt::sc_unsigned& operator /= (long                );
    sc_dt::sc_unsigned& operator /= (unsigned long       );
    sc_dt::sc_unsigned& operator /= (int                 );
    sc_dt::sc_unsigned& operator /= (unsigned int        );
    sc_dt::sc_unsigned& operator %= (const sc_dt::sc_signed&    );
    sc_dt::sc_unsigned& operator %= (const sc_dt::sc_unsigned&  );
    sc_dt::sc_unsigned& operator %= (sc_dt::int64               );
    sc_dt::sc_unsigned& operator %= (sc_dt::uint64              );
    sc_dt::sc_unsigned& operator %= (long                );
    sc_dt::sc_unsigned& operator %= (unsigned long       );
    sc_dt::sc_unsigned& operator %= (int                 );
    sc_dt::sc_unsigned& operator %= (unsigned int        );
    sc_dt::sc_unsigned& operator &= (const sc_dt::sc_signed&    );
    sc_dt::sc_unsigned& operator &= (const sc_dt::sc_unsigned&  );
    sc_dt::sc_unsigned& operator &= (sc_dt::int64               );
    sc_dt::sc_unsigned& operator &= (sc_dt::uint64              );
    sc_dt::sc_unsigned& operator &= (long                );
    sc_dt::sc_unsigned& operator &= (unsigned long       );
    sc_dt::sc_unsigned& operator &= (int                 );
    sc_dt::sc_unsigned& operator &= (unsigned int        );
    sc_dt::sc_unsigned& operator |= (const sc_dt::sc_signed&    );
    sc_dt::sc_unsigned& operator |= (const sc_dt::sc_unsigned&  );
    sc_dt::sc_unsigned& operator |= (sc_dt::int64               );
    sc_dt::sc_unsigned& operator |= (sc_dt::uint64              );
    sc_dt::sc_unsigned& operator |= (long                );
    sc_dt::sc_unsigned& operator |= (unsigned long       );
    sc_dt::sc_unsigned& operator |= (int                 );
    sc_dt::sc_unsigned& operator |= (unsigned int        );
    sc_dt::sc_unsigned& operator ^= (const sc_dt::sc_signed&    );
    sc_dt::sc_unsigned& operator ^= (const sc_dt::sc_unsigned&  );
    sc_dt::sc_unsigned& operator ^= (sc_dt::int64               );
    sc_dt::sc_unsigned& operator ^= (sc_dt::uint64              );
    sc_dt::sc_unsigned& operator ^= (long                );
    sc_dt::sc_unsigned& operator ^= (unsigned long       );
    sc_dt::sc_unsigned& operator ^= (int                 );
    sc_dt::sc_unsigned& operator ^= (unsigned int        );

  protected:
    mutable sc_event*  m_changed_event_p; // Value changed event this object.
    sc_dt::uint64      m_event_delta;     // Delta cycle of last event.
    sc_dt::sc_unsigned m_new_val;         // New value for this object instance.
    sc_port_base*      m_output_p;        // Single write port verify field.
    sc_process_b*   m_writer_p;        // Single writer verify field.
};

SC_TEMPLATE // Return true if a changed event happened in the last delta cycle.
inline bool sc_signal<sc_dt::sc_biguint<W> >::base_event() const
{
    return simcontext()->delta_count() == m_event_delta + 1;
}

SC_TEMPLATE // Return this object's sc_dt::sc_biguint<W> object instance.
inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::base_read() const
{
	return *this;
}

SC_TEMPLATE // Return the value changed event, allocating it if necessary.
inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::base_value_changed_event() const
{
    if ( !m_changed_event_p ) m_changed_event_p = new sc_event;
    return *m_changed_event_p;
}

SC_TEMPLATE // Write a const sc_dt::sc_signed& value to this object instance.
inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( const sc_dt::sc_signed& value )
{
#   if defined(DEBUG_SYSTEMC)
        check_writer();
#   endif
    m_new_val = value;
    request_update();
}

SC_TEMPLATE // Write a const sc_dt::sc_unsigned& value to this object instance.
inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( const sc_dt::sc_unsigned& value )
{
#   if defined(DEBUG_SYSTEMC)
        check_writer();
#   endif
    m_new_val = value;
    request_update();
}

SC_TEMPLATE // Write a sc_dt::int64 value to this object instance.
inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( sc_dt::int64 value )
{
#   if defined(DEBUG_SYSTEMC)
        check_writer();
#   endif
    m_new_val = value;
    request_update();
}

SC_TEMPLATE // Write a sc_dt::uint64 value to this object instance.
inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( sc_dt::uint64 value )
{
#   if defined(DEBUG_SYSTEMC)
        check_writer();
#   endif
    m_new_val = value;
    request_update();
}

//------------------------------------------------------------------------------
//"sc_signal<sc_dt::sc_biguint<W> >::check_writer"
//
// This method checks to see if there is more than one writer for this
// object instance by keeping track of the process performing the write.
//------------------------------------------------------------------------------
SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::check_writer()
{
    sc_process_b* writer_p = sc_get_current_process_b();
    if( m_writer_p == 0 )
    {
        m_writer_p = writer_p;
    }
    else if( m_writer_p != writer_p )
    {
        sc_signal_invalid_writer( name(), kind(),
                                  m_writer_p->name(), writer_p->name() );
    }
}

//------------------------------------------------------------------------------
//"sc_signal<sc_dt::sc_biguint<W> >::concat_set"
//
// These virtual methods allow value assignments to this object instance
// from various sources. The position within the supplied source of the
// low order bit for this object instance's value is low_i.
//     src   = source value.
//     low_i = bit within src to serve as low order bit of this object
//             instance's value.
//------------------------------------------------------------------------------
SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(sc_dt::int64 src, int low_i)
{
    if ( low_i < 64 )
    {
        base_write(src >> low_i);
    }
    else
    {
        base_write( (sc_dt::int64)((src < 0 ) ?  -1 : 0 ));
    }
}

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
	const sc_dt::sc_lv_base& src, int low_i)
{
    sc_dt::sc_unsigned tmp(src.length());
    tmp = src >> low_i;
    base_write( tmp );
}

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
	const sc_dt::sc_signed& src, int low_i)
{
    base_write( (src >> low_i) );
}

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
	const sc_dt::sc_unsigned& src, int low_i)
{
    base_write( (src >> low_i) );
}

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(sc_dt::uint64 src, int low_i)
{
	base_write( (sc_dt::uint64)(( low_i < 64 ) ? src >> low_i : 0));
}

SC_TEMPLATE // Return the default event for this object instance.
inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::default_event() const
	{ return base_value_changed_event(); }

SC_TEMPLATE // Return true if a changed event happened in the last delta cycle.
inline bool sc_signal<sc_dt::sc_biguint<W> >::event() const
	{ return base_event(); }

SC_TEMPLATE // Return a reference to the value of this object instance.
inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::get_data_ref() const
	{ return *this; }

SC_TEMPLATE // Return a pointer to this object instance.
inline sc_signal<sc_dt::sc_biguint<W> >& sc_signal<sc_dt::sc_biguint<W> >::get_signal()
	{ return *this; }

SC_TEMPLATE // Return a kind value of "sc_signal".
inline const char* sc_signal<sc_dt::sc_biguint<W> >::kind() const
{
	return "sc_signal";
}

//------------------------------------------------------------------------------
//"sc_signal_uint::operator ()
//
// This operator returns a part selection of this object instance.
//     left  = left-hand bit of the selection.
//     right = right-hand bit of the selection.
//------------------------------------------------------------------------------
SC_TEMPLATE
inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::operator () (int left, int right)
{
    sc_unsigned_sigref* result_p;   // Value to return.

	result_p = sc_unsigned_sigref::m_pool.allocate();
	result_p->initialize(this, left, right);
	return *result_p;
}

//------------------------------------------------------------------------------
//"sc_signal_uint::operator []"
//
// This operator returns a bit selection of this object instance.
//     i = bit to be selected.
//------------------------------------------------------------------------------
SC_TEMPLATE
inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::operator [] ( int bit )
{
    return operator () (bit,bit);
}

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const this_type& new_val )
	{ base_write( new_val ); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const char* new_val )
	{ sc_dt::sc_biguint<W> tmp = new_val; m_new_val = tmp; request_update(); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_unsigned& new_val )
	{ base_write(new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( sc_dt::uint64 new_val )
	{ base_write(new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( sc_dt::int64 new_val )
	{ base_write(new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( int new_val )
	{ base_write((sc_dt::int64)new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( long new_val )
	{ base_write((sc_dt::int64)new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( short new_val )
	{ base_write((sc_dt::int64)new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned int new_val )
	{ base_write((sc_dt::int64)new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned long new_val )
	{ base_write((sc_dt::int64)new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned short new_val )
	{ base_write((sc_dt::int64)new_val); }

SC_TEMPLATE
template<typename T>
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = (
	const sc_dt::sc_generic_base<T>& new_val )
{
	sc_dt::sc_unsigned temp(W);
    new_val->to_sc_unsigned(temp);
    base_write(temp);
}

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_signed& new_val )
	{ base_write(new_val); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_bv_base& new_val )
	{ base_write( (sc_dt::sc_biguint<W>)new_val ); }

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_lv_base& new_val )
	{ base_write( (sc_dt::sc_biguint<W>)new_val ); }

SC_TEMPLATE
inline sc_dt::sc_unsigned* sc_signal<sc_dt::sc_biguint<W> >::part_read_target()
	{ return this; }

SC_TEMPLATE
inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::read() const
	{ return *this; }

SC_TEMPLATE // Read a portion of a value.
inline sc_dt::sc_unsigned sc_signal<sc_dt::sc_biguint<W> >::read_part(
	int left, int right ) const
{
	sc_dt::sc_unsigned tmp(left-right+1);
	tmp = (*(const sc_dt::sc_biguint<W>*)this)(left,right);
    return tmp;
}

SC_TEMPLATE
inline void sc_signal<sc_dt::sc_biguint<W> >::register_port(
	sc_port_base& port_, const char* if_typename_ )
{
#       ifdef DEBUG_SYSTEMC
		std::string nm( if_typename_ );
		if( nm == typeid( sc_signal_inout_if<sc_dt::sc_biguint<W> > ).name() )
		{
			if( m_output_p != 0 )
			{
				sc_signal_invalid_writer( name(), kind(),
					 m_output_p->name(), port_.name() );
			}
			m_output_p = &port_;
		}
#       else
            if ( &port_ && if_typename_ ) {} // Silence unused args warning.
#       endif
}

SC_TEMPLATE // Autogenerated name object instance constructor.
inline sc_signal<sc_dt::sc_biguint<W> >::sc_signal() :
	sc_prim_channel(sc_gen_unique_name( "signal" )),
	m_changed_event_p(0),
	m_new_val(W),
	m_output_p(0),
	m_writer_p(0)
{ }

SC_TEMPLATE // Explicitly named object instance constructor.
inline sc_signal<sc_dt::sc_biguint<W> >::sc_signal(const char* name_) :
	sc_prim_channel(name_),
	m_changed_event_p(0),
	m_new_val(W),
	m_output_p(0),
	m_writer_p(0)
{ }

SC_TEMPLATE // Object instance destructor.
inline sc_signal<sc_dt::sc_biguint<W> >::~sc_signal()
{
	if ( m_changed_event_p ) delete m_changed_event_p;
}

SC_TEMPLATE // Update the current value from new value.
inline void sc_signal<sc_dt::sc_biguint<W> >::update()
{
    if ( m_changed_event_p )
    {
        if ( m_new_val != *this )
        {
            m_changed_event_p->notify_delayed();
            m_event_delta = simcontext()->delta_count();
        }
    }
	sc_dt::sc_unsigned::operator = (m_new_val);
}

SC_TEMPLATE // Return the value changed event.
inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::value_changed_event() const
	{ return base_value_changed_event(); }

SC_TEMPLATE // Write a sc_in<sc_dt::sc_biguint<W> > value to this object instance.
inline void sc_signal<sc_dt::sc_biguint<W> >::write(
	const sc_in<sc_dt::sc_biguint<W> >& value )
	{ base_write( value ); }

SC_TEMPLATE // Write a sc_inout<sc_dt::sc_biguint<W> > value to this object instance.
inline void sc_signal<sc_dt::sc_biguint<W> >::write(
	const sc_inout<sc_dt::sc_biguint<W> >& value )
{ base_write( value ); }

SC_TEMPLATE // Write a sc_dt::sc_biguint<W> value to this object instance.
inline void sc_signal<sc_dt::sc_biguint<W> >::write( const sc_dt::sc_biguint<W>& value )
	{ base_write( value); }

SC_TEMPLATE // Write a portion of a value. If this is the first write in
            // a delta cycle we copy the existing value before setting the bits.
inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(sc_dt::int64 v, int left, int right)
{
	m_new_val(left, right) = v;
	request_update();
}

SC_TEMPLATE // Select a portion of a value.
inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::select_part(
	int left, int right)
{
    sc_unsigned_sigref* result_p = sc_unsigned_sigref::m_pool.allocate();
    result_p->initialize(dynamic_cast<sc_unsigned_part_if*>(this), left, right);
    return *result_p;
}

SC_TEMPLATE // Write a portion of a value. If this is the first write in
            // a delta cycle we copy the existing value before setting the bits.
inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(sc_dt::uint64 v, int left, int right)
{
	m_new_val(left, right) = v;
	request_update();
}

SC_TEMPLATE // Write a portion of a value. If this is the first write in
            // a delta cycle we copy the existing value before setting the bits.
inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(
	const sc_dt::sc_signed& v, int left, int right )
{
	m_new_val(left, right) = v;
	request_update();
}

SC_TEMPLATE // Write a portion of a value. If this is the first write in
            // a delta cycle we copy the existing value before setting the bits.
inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(
	const sc_dt::sc_unsigned& v, int left, int right )
{
	m_new_val(left, right) = v;
	request_update();
}

//==============================================================================
// CLASS sc_in<sc_dt::sc_biguint<W> >
//
// This class implements an input port whose target acts like an sc_dt::sc_biguint<W> data
// value. This class is a specialization of the generic sc_in class to
// implement tailored support for the sc_dt::sc_biguint<W> class.
//==============================================================================
SC_TEMPLATE
class sc_in<sc_dt::sc_biguint<W> > :
    public sc_port<sc_signal_in_if<sc_dt::sc_biguint<W> >, 1,
                   SC_ONE_OR_MORE_BOUND>,
    public sc_dt::sc_value_base
{
  public:

    // typedefs

    typedef sc_dt::sc_biguint<W>                      data_type;
    typedef sc_signal_in_if<sc_dt::sc_biguint<W> >    if_type;
    typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND>   base_type;
    typedef sc_in<sc_dt::sc_biguint<W> >              this_type;

    typedef if_type                                   in_if_type;
    typedef base_type                                 in_port_type;
    typedef sc_signal_inout_if<sc_dt::sc_biguint<W> > inout_if_type;
    typedef sc_inout<sc_dt::sc_biguint<W> >           inout_port_type;

  public:

    // bind methods and operators:

    void bind( const in_if_type& interface_ )
        { sc_port_base::bind( const_cast<in_if_type&>( interface_) );}
    void operator () ( const in_if_type& interface_ )
        { sc_port_base::bind( const_cast<in_if_type&>( interface_) );}
    void bind( in_port_type& parent_ )
        { sc_port_base::bind(parent_);}
    void operator () ( in_port_type& parent_ )
        { sc_port_base::bind(parent_);}
    void bind( inout_port_type& parent_ )
        { sc_port_base::bind(parent_);}
    void operator () ( inout_port_type& parent_ )
        { sc_port_base::bind(parent_);}

  protected:
    // called by pbind (for internal use only)
    virtual inline int vbind( sc_interface& interface_ )
        {
            return sc_port_b<if_type>::vbind( interface_ );
        }
    virtual inline int vbind( sc_port_base& parent_ )
        {
            in_port_type* in_parent = dynamic_cast<in_port_type*>( &parent_ );
            if( in_parent != 0 ) {
                sc_port_base::bind( *in_parent );
                return 0;
            }
            inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ );
            if( inout_parent != 0 ) {
                sc_port_base::bind( *inout_parent );
                return 0;
            }
            // type mismatch
            return 2;
        }

    // constructors

  public:
    sc_in()
        : base_type(), m_traces( 0 )
        {}

    explicit sc_in( const char* name_ )
        : base_type( name_ ), m_traces( 0 )
        {}

    explicit sc_in( const in_if_type& interface_ )
        : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
        {}

    sc_in( const char* name_, const in_if_type& interface_ )
        : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
        {}

    explicit sc_in( in_port_type& parent_ )
        : base_type( parent_ ), m_traces( 0 )
        {}

    sc_in( const char* name_, in_port_type& parent_ )
        : base_type( name_, parent_ ), m_traces( 0 )
        {}

    explicit sc_in( inout_port_type& parent_ )
        : base_type(), m_traces( 0 )
        { sc_port_base::bind( parent_ ); }

    sc_in( const char* name_, inout_port_type& parent_ )
        : base_type( name_ ), m_traces( 0 )
        { sc_port_base::bind( parent_ ); }

    sc_in( this_type& parent_ )
        : base_type( parent_ ), m_traces( 0 )
        {}

    sc_in( const char* name_, this_type& parent_ )
        : base_type( name_, parent_ ), m_traces( 0 )
        {}

    // destructor

    virtual inline ~sc_in()
        {
            remove_traces();
        }

    // bit and part selection

    sc_dt::sc_unsigned_bitref_r operator [] ( int i ) const
        { return (*this)->read()[i]; }
    sc_dt::sc_unsigned_bitref_r bit( int i ) const
        { return (*this)->read()[i]; }
    sc_dt::sc_unsigned_subref_r operator () ( int left, int right ) const
        { return (*this)->read()(left,right); }
    sc_dt::sc_unsigned_subref_r range( int left, int right ) const
        { return (*this)->read()(left,right); }

    // interface access shortcut methods

    // get the default event

    const sc_event& default_event() const
        { return (*this)->value_changed_event(); }

    // get the value changed event

    const sc_event& value_changed_event() const
        { return (*this)->value_changed_event(); }

    // read the current value

    const sc_dt::sc_biguint<W>& read() const
        { return (*this)->read(); }

    operator const sc_dt::sc_biguint<W>& () const
        { return (*this)->read(); }

    // was there a value changed event?

    bool event() const
        { return (*this)->event(); }

    // (other) event finder method(s)

    sc_event_finder& value_changed() const
        {
            return *new sc_event_finder_t<in_if_type>(
                *this, &in_if_type::value_changed_event );
        }

    // reduction methods:

    inline bool and_reduce() const
        { return (*this)->read().and_reduce(); }
    inline bool nand_reduce() const
        { return (*this)->read().nand_reduce(); }
    inline bool nor_reduce() const
        { return (*this)->read().nor_reduce(); }
    inline bool or_reduce() const
        { return (*this)->read().or_reduce(); }
    inline bool xnor_reduce() const
        { return (*this)->read().xnor_reduce(); }
    inline bool xor_reduce() const
        { return (*this)->read().xor_reduce(); }

    // called when elaboration is done
    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */

    virtual inline void end_of_elaboration()
        {
            if( m_traces != 0 ) {
                for( unsigned int i = 0; i < m_traces->size(); ++ i ) {
                    sc_trace_params* p = (*m_traces)[i];
                    sc_trace( p->tf, read(), p->name );
                }
                remove_traces();
            }
        }

    virtual inline const char* kind() const
        { return "sc_in"; }

    // called by sc_trace
    void add_trace( sc_trace_file* tf_, const std::string& name_ ) const
        {
            if( tf_ != 0 ) {
                if( m_traces == 0 ) {
                    m_traces = new sc_trace_params_vec;
                }
                m_traces->push_back( new sc_trace_params( tf_, name_ ) );
            }
        }

    // concatenation methods

    virtual inline int concat_length(bool* xz_present_p) const
        { return (*this)->read().concat_length( xz_present_p ); }
    virtual inline sc_dt::uint64 concat_get_uint64() const
        { return (*this)->read().concat_get_uint64(); }
    virtual inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const
        { return (*this)->read().concat_get_ctrl(dst_p, low_i); }
    virtual inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const
        { return (*this)->read().concat_get_data(dst_p, low_i); }

  protected:
    void remove_traces() const
        {
            if( m_traces != 0 ) {
                for( int i = m_traces->size() - 1; i >= 0; -- i ) {
                    delete (*m_traces)[i];
                }
                delete m_traces;
                m_traces = 0;
            }
        }

    mutable sc_trace_params_vec* m_traces;

  private:

    // disabled
    sc_in( const sc_in<sc_dt::sc_biguint<W> >& );
    sc_in<sc_dt::sc_biguint<W> >& operator = ( const sc_in<sc_dt::sc_biguint<W> >& );

#ifdef __GNUC__
    // Needed to circumvent a problem in the g++-2.95.2 compiler:
    // This unused variable forces the compiler to instantiate
    // an object of T template so an implicit conversion from
    // read() to a C++ intrinsic data type will work.
    static data_type dummy;
#endif

};

SC_TEMPLATE
inline std::ostream& operator << (
    std::ostream& os, const sc_in<sc_dt::sc_biguint<W> >& a )
{
    a.read().print( os );
    return os;
}

//==============================================================================
// CLASS sc_inout<sc_dt::sc_biguint<W> >
//
// This class implements an input/output port whose target acts like an
// sc_dt::sc_biguint<W> data value. It is derived from the sc_unsigned_in. This class is a
// specialization of the generic sc_inout class to implement tailored support
// for the sc_dt::sc_biguint<W> class.
//==============================================================================
SC_TEMPLATE
class sc_inout<sc_dt::sc_biguint<W> > :
    public sc_port<sc_signal_inout_if<sc_dt::sc_biguint<W> >, 1,
                   SC_ONE_OR_MORE_BOUND>,
    public sc_dt::sc_value_base
{
  public:

    // typedefs

    typedef sc_dt::sc_biguint<W>                      data_type;
    typedef sc_signal_inout_if<sc_dt::sc_biguint<W> > if_type;
    typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND>   base_type;
    typedef sc_inout<sc_dt::sc_biguint<W> >           this_type;

    typedef if_type                                   inout_if_type;
    typedef base_type                                 inout_port_type;

  public:

    // bind methods and operators:

    void bind( const inout_if_type& interface_ )
        { sc_port_base::bind( const_cast<inout_if_type&>( interface_) ); }
    void operator () ( const inout_if_type& interface_ )
        { sc_port_base::bind( const_cast<inout_if_type&>( interface_) ); }
    void bind( inout_port_type& parent_ )
        { sc_port_base::bind(parent_); }
    void operator () ( inout_port_type& parent_ )
        { sc_port_base::bind(parent_); }

  protected:
    // called by pbind (for internal use only)
    virtual inline int vbind( sc_interface& interface_ )
        {
            return sc_port_b<if_type>::vbind( interface_ );
        }
    virtual inline int vbind( sc_port_base& parent_ )
        {
            inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ );
            if( inout_parent != 0 ) {
                sc_port_base::bind( *inout_parent );
                return 0;
            }
            // type mismatch
            return 2;
        }

    // constructors

  public:
    sc_inout()
        : base_type(), m_init_val_p(0), m_traces( 0 )
        {}

    explicit sc_inout( const char* name_ )
        : base_type( name_ ), m_init_val_p(0), m_traces( 0 )
        {}

    explicit sc_inout( inout_if_type& interface_ )
        : base_type( interface_ ), m_init_val_p(0), m_traces( 0 )
        {}

    sc_inout( const char* name_, inout_if_type& interface_ )
        : base_type( name_, interface_ ), m_init_val_p(0), m_traces( 0 )
        {}

    explicit sc_inout( inout_port_type& parent_ )
        : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
        {}

    sc_inout( const char* name_, inout_port_type& parent_ )
        : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
        {}

    sc_inout( this_type& parent_ )
        : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
        {}

    sc_inout( const char* name_, this_type& parent_ )
        : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
        {}

    // destructor

    virtual inline ~sc_inout()
        {
            remove_traces();
        }

    // bit and part selection

    sc_dt::sc_unsigned_bitref_r operator [] ( int i ) const
        { return (*this)->read()[i]; }
    sc_dt::sc_unsigned_bitref_r bit( int i ) const
        { return (*this)->read()[i]; }
    sc_unsigned_sigref& operator [] ( int i )
        { return (*this)->select_part(i,i); }
    sc_unsigned_sigref& bit( int i )
        { return (*this)->select_part(i,i); }
    sc_dt::sc_unsigned_subref_r operator () ( int left, int right ) const
        { return (*this)->read()(left,right); }
    sc_dt::sc_unsigned_subref_r range( int left, int right ) const
        { return (*this)->read()(left,right); }
    sc_unsigned_sigref& operator () ( int left, int right )
        { return (*this)->select_part(left,right); }
    sc_unsigned_sigref& range( int left, int right )
        { return (*this)->select_part(left,right); }

    // interface access shortcut methods

    // get the default event

    const sc_event& default_event() const
        { return (*this)->value_changed_event(); }

    // get the value changed event

    const sc_event& value_changed_event() const
        { return (*this)->value_changed_event(); }

    // read the current value

    const sc_dt::sc_biguint<W>& read() const
        { return (*this)->read(); }

    operator const sc_dt::sc_biguint<W>& () const
        { return (*this)->read(); }

    // was there a value changed event?

    bool event() const
        { return (*this)->event(); }

    // (other) event finder method(s)

    sc_event_finder& value_changed() const
        {
            return *new sc_event_finder_t<inout_if_type>(
                *this, &inout_if_type::value_changed_event );
        }

    // reduction methods:

    inline bool and_reduce() const
        { return (*this)->read().and_reduce(); }
    inline bool nand_reduce() const
        { return (*this)->read().nand_reduce(); }
    inline bool nor_reduce() const
        { return (*this)->read().nor_reduce(); }
    inline bool or_reduce() const
        { return (*this)->read().or_reduce(); }
    inline bool xnor_reduce() const
        { return (*this)->read().xnor_reduce(); }
    inline bool xor_reduce() const
        { return (*this)->read().xor_reduce(); }

    // called when elaboration is done
    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */

    virtual inline void end_of_elaboration()
        {
            if( m_init_val_p != 0 ) {
                (*this)->write( *m_init_val_p );
                delete m_init_val_p;
                m_init_val_p = 0;
            }
            if( m_traces != 0 ) {
                for( unsigned int i = 0; i < m_traces->size(); ++ i ) {
                    sc_trace_params* p = (*m_traces)[i];
                    sc_trace( p->tf, read(), p->name );
                }
                remove_traces();
            }
        }

    virtual inline const char* kind() const
        { return "sc_inout"; }

    // value initialization

    inline void initialize( const sc_dt::sc_biguint<W>& value_ )
    {
        inout_if_type* iface = dynamic_cast<inout_if_type*>( this->get_interface() );
        if( iface != 0 ) {
            iface->write( value_ );
        } else {
            if( m_init_val_p == 0 ) {
                m_init_val_p = new sc_dt::sc_biguint<W>;
            }
            *m_init_val_p = value_;
        }
    }

    // called by sc_trace
    void add_trace( sc_trace_file* tf_, const std::string& name_ ) const
        {
            if( tf_ != 0 ) {
                if( m_traces == 0 ) {
                    m_traces = new sc_trace_params_vec;
                }
                m_traces->push_back( new sc_trace_params( tf_, name_ ) );
            }
        }

    // concatenation methods

    virtual inline int concat_length(bool* xz_present_p) const
        { return (*this)->read().concat_length( xz_present_p ); }
    virtual inline sc_dt::uint64 concat_get_uint64() const
        { return (*this)->read().concat_get_uint64(); }
    virtual inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const
        { return (*this)->read().concat_get_ctrl(dst_p, low_i); }
    virtual inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const
        { return (*this)->read().concat_get_data(dst_p, low_i); }
    virtual inline void concat_set(sc_dt::int64 src, int low_i)
        { *this = (src >> ((low_i < 64) ? low_i : 63)); }
#if 0 // ####
    virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i)
        { *this = src >> low_i; }
#endif // 0 ####
    virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i)
        { *this = (src >> low_i); }
    virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i)
        { *this = (src >> low_i); }
    virtual inline void concat_set(sc_dt::uint64 src, int low_i)
        { *this = (low_i < 64 ) ? src >> low_i : (sc_dt::uint64)0; }

    // assignment operators:

  public:
	inline void operator = ( const this_type& new_val )
		{ (*this)->write( (const sc_dt::sc_unsigned&)new_val ); }
    inline void operator = ( const char* new_val )
		{ sc_dt::sc_unsigned aa(W); aa = new_val; (*this)->write( aa ); }
    inline void operator = ( sc_dt::uint64 new_val )
        { (*this)->write(new_val); }
    inline void operator = ( sc_dt::int64 new_val )
        { (*this)->write((sc_dt::int64)new_val); }
    inline void operator = ( int new_val )
        { (*this)->write((sc_dt::int64)new_val); }
    inline void operator = ( long new_val )
        { (*this)->write((sc_dt::int64)new_val); }
    inline void operator = ( short new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( unsigned int new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( unsigned long new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( unsigned short new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    template<typename T>
    inline void operator = ( const sc_dt::sc_generic_base<T>& new_val )
		{
			sc_dt::sc_unsigned temp(W);
			new_val->to_sc_unsigned(temp);
            (*this)->write(temp);
		}
    inline void operator = ( const sc_dt::sc_signed& new_val )
        { (*this)->write(new_val); }
    inline void operator = ( const sc_dt::sc_unsigned& new_val )
        { (*this)->write(new_val); }
    inline void operator = ( const sc_dt::sc_bv_base& new_val )
        { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
    inline void operator = ( const sc_dt::sc_lv_base& new_val )
        { (*this)->write((sc_dt::sc_biguint<W>)new_val); }

    inline void write( const sc_in<sc_dt::sc_biguint<W> >& new_val )
        { (*this)->write( new_val.read() ); }
    inline void write( const sc_inout<sc_dt::sc_biguint<W> >& new_val )
        { (*this)->write( new_val.read() ); }
    inline void write( const sc_dt::sc_biguint<W>& new_val )
        { (*this)->write( new_val ); }

  protected:
    void remove_traces() const
        {
            if( m_traces != 0 ) {
                for( int i = m_traces->size() - 1; i >= 0; -- i ) {
                    delete (*m_traces)[i];
                }
                delete m_traces;
                m_traces = 0;
            }
        }

    sc_dt::sc_biguint<W>*               m_init_val_p;
    mutable sc_trace_params_vec* m_traces;

  private:

    // disabled
    sc_inout( const sc_inout<sc_dt::sc_biguint<W> >& );

#ifdef __GNUC__
    // Needed to circumvent a problem in the g++-2.95.2 compiler:
    // This unused variable forces the compiler to instantiate
    // an object of T template so an implicit conversion from
    // read() to a C++ intrinsic data type will work.
    static data_type dummy;
#endif

};

SC_TEMPLATE
inline std::ostream& operator << (
    std::ostream& os, const sc_inout<sc_dt::sc_biguint<W> >& a )
{
    a.read().print( os );
    return os;
}

//==============================================================================
// CLASS sc_out<sc_dt::sc_biguint<W> >
//
// This class implements an output port whose target acts like an
// sc_dt::sc_biguint<W> data value. This class is a derivation of sc_inout, since
// output ports are really no different from input/output ports.
//==============================================================================
SC_TEMPLATE
class sc_out<sc_dt::sc_biguint<W> > : public sc_inout<sc_dt::sc_biguint<W> >
{
  public:

    // typedefs

    typedef sc_dt::sc_biguint<W>                          data_type;

    typedef sc_out<data_type>                   this_type;
    typedef sc_inout<data_type>                 base_type;

    typedef typename base_type::inout_if_type   inout_if_type;
    typedef typename base_type::inout_port_type inout_port_type;

    // constructors

    sc_out()
        : base_type()
        {}

    explicit sc_out( const char* name_ )
        : base_type( name_ )
        {}

    explicit sc_out( inout_if_type& interface_ )
        : base_type( interface_ )
        {}

    sc_out( const char* name_, inout_if_type& interface_ )
        : base_type( name_, interface_ )
        {}

    explicit sc_out( inout_port_type& parent_ )
        : base_type( parent_ )
        {}

    sc_out( const char* name_, inout_port_type& parent_ )
        : base_type( name_, parent_ )
        {}

    sc_out( this_type& parent_ )
        : base_type( parent_ )
        {}

    sc_out( const char* name_, this_type& parent_ )
        : base_type( name_, parent_ )
        {}

    // destructor (does nothing)

    virtual inline ~sc_out()
        {}

    // assignment operators:

  public:
	inline void operator = ( const this_type& new_val )
		{ (*this)->write( (const sc_dt::sc_unsigned&)new_val ); }
    inline void operator = ( const char* new_val )
		{ sc_dt::sc_unsigned aa(W); aa = new_val; (*this)->write( aa ); }
    inline void operator = ( sc_dt::uint64 new_val )
        { (*this)->write(new_val); }
    inline void operator = ( sc_dt::int64 new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( int new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( long new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( short new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( unsigned int new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( unsigned long new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    inline void operator = ( unsigned short new_val )
        { (*this)->write((sc_dt::uint64)new_val); }
    template<typename T>
    inline void operator = ( const sc_dt::sc_generic_base<T>& new_val )
		{
			sc_dt::sc_unsigned temp(W);
			new_val->to_sc_unsigned(temp);
            (*this)->write(temp);
		}
    inline void operator = ( const sc_dt::sc_signed& new_val )
        { (*this)->write(new_val); }
    inline void operator = ( const sc_dt::sc_unsigned& new_val )
        { (*this)->write(new_val); }
    inline void operator = ( const sc_dt::sc_bv_base& new_val )
        { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
    inline void operator = ( const sc_dt::sc_lv_base& new_val )
        { (*this)->write((sc_dt::sc_biguint<W>)new_val); }

  private:

    // disabled
    sc_out( const this_type& );
};

//------------------------------------------------------------------------------
//"sc_unsigned_sigref::initialize"
//
// This method initializes an object instance from the supplied arguments.
//     if_p   -> target of this selection.
//     left_  =  left-most bit in selection.
//     right_ =  right-most bit in selection.
//------------------------------------------------------------------------------
inline void sc_unsigned_sigref::initialize(
	sc_unsigned_part_if* if_p, int left_, int right_ )
{
    m_if_p = if_p;
    m_left = left_;
    m_right = right_;
	m_obj_p = if_p->part_read_target();
}

//------------------------------------------------------------------------------
//"sc_unsigned_sigref::operator ="
//
// These operators assign a value to the bits associated with this object
// instance within this object instance's target signal.
//------------------------------------------------------------------------------
inline void sc_unsigned_sigref::operator = ( sc_dt::uint64 v )
{
	m_if_p->write_part( v, m_left, m_right );
}

inline void sc_unsigned_sigref::operator = ( const char* v )
{
	sc_dt::sc_unsigned tmp(length());
	tmp = v;
	*this = tmp;
}

inline void sc_unsigned_sigref:: operator = ( sc_dt::int64 v )
{
    *this = (sc_dt::uint64)v;
}

inline void sc_unsigned_sigref:: operator = ( int v )
{
    *this = (sc_dt::uint64)v;
}

inline void sc_unsigned_sigref:: operator = ( long v )
{
    *this = (sc_dt::uint64)v;
}

inline void sc_unsigned_sigref:: operator = ( unsigned int v )
{
    *this = (sc_dt::uint64)v;
}

inline void sc_unsigned_sigref:: operator = ( unsigned long v )
{
    *this = (sc_dt::uint64)v;
}

void sc_unsigned_sigref::operator = ( const sc_unsigned_sigref& v )
{
    *this = (sc_dt::sc_unsigned)v;
}

inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_signed& v )
{
	m_if_p->write_part( v, m_left, m_right );
}

inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_unsigned& v )
{
	m_if_p->write_part( v, m_left, m_right );
}

template<typename T>
inline void sc_unsigned_sigref:: operator = (
	const sc_dt::sc_generic_base<T>& v )
{
	sc_dt::sc_unsigned temp(m_left-m_right+1);
    v->to_sc_unsigned(temp);
	m_if_p->write_part( temp, m_left, m_right );
}

#undef SC_TEMPLATE
} // namespace sc_core
#endif // !defined(SC_SIGNAL_UNSIGNED_H)

namespace sc_core {

extern
void
sc_signal_invalid_writer( const char* name,
                          const char* kind,
                          const char* first_writer,
                          const char* second_writer );

//------------------------------------------------------------------------------
// POOL OF TEMPORARY INSTANCES OF sc_unsigned_sigref
//
// This allows use to pass const references for part and bit selections
// on sc_signal_signed object instances.
//------------------------------------------------------------------------------
sc_vpool<sc_unsigned_sigref> sc_unsigned_sigref::m_pool(8);

//------------------------------------------------------------------------------
//"sc_unsigned_part_if::default methods"
//
// These versions just produce errors if they are not overloaded but used.
//------------------------------------------------------------------------------
sc_dt::sc_unsigned* sc_unsigned_part_if::part_read_target()
{
    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
    return 0;
}
sc_dt::sc_unsigned sc_unsigned_part_if::read_part( int /*left*/, int /*right*/ ) const
{
    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
    return sc_dt::sc_unsigned(1);
}
sc_unsigned_sigref& sc_unsigned_part_if::select_part(int /*left*/, int /*right*/)
{
    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
    return *(sc_unsigned_sigref*)0;
}
void sc_unsigned_part_if::write_part( sc_dt::int64 v, int /*left*/, int /*right*/ )
{
    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
}
void sc_unsigned_part_if::write_part( sc_dt::uint64 v, int /*left*/, int /*right*/ )
{
    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
}
void sc_unsigned_part_if::write_part(
    const sc_dt::sc_signed& v, int /*left*/, int /*right*/ )
{
    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
}
void sc_unsigned_part_if::write_part(
    const sc_dt::sc_unsigned& v, int /*left*/, int /*right*/ )
{
    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
}

//------------------------------------------------------------------------------
//"sc_unsigned_sigref::concate_set"
//
// These methods assign this object instance's value from the supplied
// value starting at the supplied bit within that value.
//     src = value to use to set this object instance's value.
//     low_i = bit in src that is to be the low order bit of the value to set.
// #### OPTIMIZE
//------------------------------------------------------------------------------
void sc_unsigned_sigref::concat_set(sc_dt::int64 src, int low_i)
{
    sc_dt::int64 tmp;
    if ( low_i < 63 )
        tmp = src >> low_i;
    else
        tmp = (src < 0) ? -1 : 0;
    m_if_p->write_part( tmp, m_left, m_right );
}

void sc_unsigned_sigref::concat_set(const sc_dt::sc_signed& src, int low_i)
{
    m_if_p->write_part( src >> low_i, m_left, m_right );
}

void sc_unsigned_sigref::concat_set(const sc_dt::sc_lv_base& src, int low_i)
{
    sc_dt::sc_unsigned tmp(src.length());
    tmp = src;
    m_if_p->write_part( tmp >> low_i, m_left, m_right );
}

void sc_unsigned_sigref::concat_set(const sc_dt::sc_unsigned& src, int low_i)
{
    m_if_p->write_part( src >> low_i, m_left, m_right );
}

void sc_unsigned_sigref::concat_set(sc_dt::uint64 src, int low_i)
{
    sc_dt::uint64 tmp = (low_i < 63) ? (src >> low_i) : 0;
    m_if_p->write_part( tmp, m_left, m_right );
}

} // namespace sc_core


text:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta name="csrf-token" content="{{csrf_token()}}">
    <title>@yield('page-title')</title>

    <link rel="icon" href="{{asset('favicon.ico')}}" type="image/x-icon">

    <link href="https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext" rel="stylesheet"
          type="text/css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css">

    <link href="{{url('js/admin/plugins/bootstrap/css/bootstrap.css')}}" rel="stylesheet">

    <link href="{{url('js/admin/plugins/node-waves/waves.css')}}" rel="stylesheet"/>

    <link href="{{url('js/admin/plugins/animate-css/animate.css')}}" rel="stylesheet"/>

@yield('page-spec-css')

    <link href="{{url('css/admin/style.css')}}" rel="stylesheet">

    <link href="{{url('css/admin/themes/theme-light-blue.css')}}" rel="stylesheet"/>

Please wait...

            @yield('page-title')

                    {{Auth::user()->name}}

{{Auth::user()->email}}

                    keyboard_arrow_down

inputLog Out

                        apps
                        Dashboard

Tables

                @foreach($tablesIndex as $table)
                    @if(Auth::user()->level <= $table['userLevel'])

                                arrow_forward
                                {{$table['tableTitle']}}

                    @endif
                @endforeach

                © 2017 Gaurav Deshpande

        @yield('contents')

@yield('page-spec-js')

redpajama_set_name: RedPajamaGithub


text:
// JOOS1:PARSER_WEEDER,INVALID_INTEGER
// JOOS2:PARSER_WEEDER,INVALID_INTEGER
// JAVAC:UNKNOWN
//
/**
 * Parser/weeder:
 * - For each integer literal in the program, .... check that the
 * number is within the legal range for 32-bit signed integers.
 */
public class Je_1_IntRange_TooBigIntNegated {

    public Je_1_IntRange_TooBigIntNegated(){}

    public static int test() {
	return -(2147483648) + 2147483000 + 771;
    }
}


text:
$(document).ready(function () {

    $("#department_add_from").submit(function (e) {

        e.preventDefault();
        dataString = $("#department_add_from").serialize();

        $.ajax({
            type: "POST",
            url: BASE_URL + "department/add_department",
            data: dataString,
            dataType: "json",
            success: function (data) {

                console.log(data);
                $("#ajax-respose").html(data.response);

                if (data.status == "true")
                {
                    $("#ajax-respose").html("");
                    $("#add_department").modal('hide');
                    $('#department_list').dataTable().fnAddData([
                        data.department_data.department_name,
                        data.department_data.department_id,
                        data.department_data.status]
                            );
                    $("#department_add_from")[0].reset();

                }
            }

        });
        //alert(BASE_URL +"department/add_department");
    });

    $('#department_list').dataTable({
        "columns": [{
                "orderable": true
            },
            {
                "orderable": false
            }, {
                "orderable": false
            }],
        "lengthMenu": [
            [5, 10, 20, -1],
            [5, 10, 20, "All"] // change per page values here
        ],
        // set the initial value
        "pageLength": 10,
        "pagingType": "bootstrap_full_number",
        "language": {
            "lengthMenu": "  _MENU_ records",
            "paginate": {
                "previous": "Prev",
                "next": "Next",
                "last": "Last",
                "first": "First"
            }
        },
        "order": [
            [0, "asc"]
        ] // set first column as a default sort by asc
    });

});

$(document).on("click", ".status", function (e) {
    var current_object = $(this);
    var department_id = current_object.data("department_id");
    var status = current_object.data("status");
    $.ajax({
        type: "POST",
        url: BASE_URL + "department/change_status",
        data: {
            department_id: department_id,
            status: status
        },
        success: function (data) {
            console.log(data);
            current_object.text(data);
            current_object.data("status", data);
            var class_name = (data == "active") ? "label label-sm label-success status" : "label label-sm label-danger status";
            current_object.removeClass();
            current_object.addClass(class_name);
        }
    });
});

$(document).on("click", ".update-department", function (e) {

    var current_object = $(this);
    var department_id = current_object.data("department_id");

    $.ajax({
        type: "POST",
        url: BASE_URL + "department/department_data",
        dataType: "json",
        data: {
            department_id: department_id,
        },
        success: function (data) {
            $("#error_update").html("");
            $("#update_department_name").val(data.dname);
            $("#update_department_id_hidden").val(data.update_department_id_hidden);
        }
    });
});

$(document).on("click", ".add-department", function (e) {
    $("#ajax-respose").html("");
});

// Update designation form

// Automatically add a first row of data

$("#update_department_form").submit(function (e) {

    e.preventDefault();

    dataString = $("#update_department_form").serialize();
    $.ajax({
        type: "POST",
        url: BASE_URL + "department/department_update",
        data: dataString,
        dataType: "json",
        success: function (data) {
            console.log(data);
            $("#error_update").html(data.response_update);

            if (data.status == "true") {
                $("#myModal").modal('hide');
                $("#update_department_form")[0].reset();

            }
        }

    });
});


text:
require_relative '../../lib/carto/uuidhelper'

class Carto::UUIDHelperInstance
  include Carto::UUIDHelper
end

describe 'UUIDHelper' do

  uuid_helper = Carto::UUIDHelperInstance.new

  it 'validates a valid UUID' do
    uuid_helper.is_uuid?('5b632a9e-ae07-11e4-ac8d-080027880ca6').should be(true)
  end

  it 'validates a random UUID' do
    uuid_helper.is_uuid?(SecureRandom.uuid).should be(true)
  end

  it 'fails if content prepended' do
    uuid_helper.is_uuid?("hi" + SecureRandom.uuid).should be(false)
  end

  it 'fails if content appended' do
    uuid_helper.is_uuid?(SecureRandom.uuid + "hola").should be(false)
  end

  it 'fails if content prepended with newlines' do
    uuid_helper.is_uuid?("hi\n" + SecureRandom.uuid).should be(false)
  end

  it 'fails if content appended with newlines' do
    uuid_helper.is_uuid?(SecureRandom.uuid + "\nhola").should be(false)
  end

end


text:
/// <reference path='fourslash.ts' />

/////** this is multi declare module*/
////module mult/*3*/iM {
////    /** class b*/
////    export class b {
////    }
////}
/////** thi is multi module 2*/
////module mu/*2*/ltiM {
////    /** class c comment*/
////    export class c {
////    }
////}
////
////new /*1*/mu/*4*/ltiM.b();
////new mu/*5*/ltiM.c();

goTo.marker('1');
verify.completionListContains("multiM", "multiM", "this is multi declare module\nthi is multi module 2", "multiM", "module");

goTo.marker('2');
verify.quickInfoIs("multiM", "this is multi declare module\nthi is multi module 2", "multiM", "module");

goTo.marker('3');
verify.quickInfoIs("multiM", "this is multi declare module\nthi is multi module 2", "multiM", "module");

goTo.marker('4');
verify.quickInfoIs("multiM", "this is multi declare module\nthi is multi module 2", "multiM", "module");

goTo.marker('5');
verify.quickInfoIs("multiM", "this is multi declare module\nthi is multi module 2", "multiM", "module");


text:
'use babel';

export default function rafDebounce (fn) {
  let args;
  let context;
  let requestID;

  function later () {
    fn.apply(context, args);
    args = context = requestID = null;
  }

  function debounced () {
    if (fn == null) {
      throw new Error('raf debounced function is already disposed.');
    }
    args = arguments;
    context = this;
    if (requestID) {
      window.cancelAnimationFrame(requestID);
    }
    requestID = window.requestAnimationFrame(later);
  }

  debounced.dispose = () => {
    if (fn != null) {
      if (requestID) {
        window.cancelAnimationFrame(requestID);
      }
      args = context = requestID = fn = null;
    }
  };

  return debounced;
}


text:
  Saint-Vigor est
       un village
       situé dans le département de l'Eure en Haute-Normandie. On dénombrait 301 habitants en 2008.

Si vous envisagez de emmenager à Saint-Vigor, vous pourrez facilement trouver une maison à vendre.

Le parc d'habitations, à Saint-Vigor, était réparti en 2011 en zero appartements et 132 maisons soit
 un marché relativement équilibré.

Saint-Vigor est situé à seulement 10 km de Évreux, les étudiants qui voudrons se loger à pas cher pourront envisager de louer un logement à Saint-Vigor. Saint-Vigor est également un bon placement locatif du fait de sa proximité de Évreux et de ses Universités. Il sera facile de trouver un appartement à acheter.

À coté de Saint-Vigor sont localisées les communes de
Champenard localisée à 5 km, 174 habitants,
Écardenville-sur-Eure située à 1 km, 530 habitants,
Rouvray à 5 km, 240 habitants,
Fontaine-sous-Jouy située à 3 km, 834 habitants,
Cailly-sur-Eure à 5 km, 238 habitants,
Sainte-Colombe-près-Vernon située à 5 km, 224 habitants,
 entre autres. De plus, Saint-Vigor est située à seulement dix km de Évreux.


text:
import * as ts from 'typescript';

// Remove imports for which all identifiers have been removed.
// Needs type checker, and works even if it's not the first transformer.
// Works by removing imports for symbols whose identifiers have all been removed.
// Doesn't use the `symbol.declarations` because that previous transforms might have removed nodes
// but the type checker doesn't know.
// See https://github.com/Microsoft/TypeScript/issues/17552 for more information.
export function elideImports(
  sourceFile: ts.SourceFile,
  removedNodes: ts.Node[],
  getTypeChecker: () => ts.TypeChecker,
  compilerOptions: ts.CompilerOptions,
): Set<ts.Node> {
  const importNodeRemovals = new Set<ts.Node>();

  if (removedNodes.length === 0) {
    return importNodeRemovals;
  }

  const typeChecker = getTypeChecker();

  // Collect all imports and used identifiers
  const usedSymbols = new Set<ts.Symbol>();
  const imports: ts.ImportDeclaration[] = [];

  ts.forEachChild(sourceFile, function visit(node) {
    // Skip removed nodes.
    if (removedNodes.includes(node)) {
      return;
    }

    // Consider types for 'implements' as unused.
    // A HeritageClause token can also be an 'AbstractKeyword'
    // which in that case we should not elide the import.
    if (ts.isHeritageClause(node) && node.token === ts.SyntaxKind.ImplementsKeyword) {
      return;
    }

    // Record import and skip
    if (ts.isImportDeclaration(node)) {
      if (!node.importClause?.isTypeOnly) {
        imports.push(node);
      }

      return;
    }

    let symbol: ts.Symbol | undefined;
    if (ts.isTypeReferenceNode(node)) {
      if (!compilerOptions.emitDecoratorMetadata) {
        // Skip and mark as unused if emitDecoratorMetadata is disabled.
        return;
      }

      const parent = node.parent;
      let isTypeReferenceForDecoratoredNode = false;

      switch (parent.kind) {
        case ts.SyntaxKind.GetAccessor:
        case ts.SyntaxKind.PropertyDeclaration:
        case ts.SyntaxKind.MethodDeclaration:
          isTypeReferenceForDecoratoredNode = !!parent.decorators?.length;
          break;
        case ts.SyntaxKind.Parameter:
          // - A constructor parameter can be decorated or the class itself is decorated.
          // - The parent of the parameter is decorated example a method declaration or a set accessor.
          // In all cases we need the type reference not to be elided.
          isTypeReferenceForDecoratoredNode = !!(
            parent.decorators?.length ||
            (ts.isSetAccessor(parent.parent) && !!parent.parent.decorators?.length) ||
            (ts.isConstructorDeclaration(parent.parent) &&
              !!parent.parent.parent.decorators?.length)
          );
          break;
      }

      if (isTypeReferenceForDecoratoredNode) {
        symbol = typeChecker.getSymbolAtLocation(node.typeName);
      }
    } else {
      switch (node.kind) {
        case ts.SyntaxKind.Identifier:
          const parent = node.parent;
          if (parent && ts.isShorthandPropertyAssignment(parent)) {
            const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(parent);
            if (shorthandSymbol) {
              symbol = shorthandSymbol;
            }
          } else {
            symbol = typeChecker.getSymbolAtLocation(node);
          }
          break;
        case ts.SyntaxKind.ExportSpecifier:
          symbol = typeChecker.getExportSpecifierLocalTargetSymbol(node as ts.ExportSpecifier);
          break;
        case ts.SyntaxKind.ShorthandPropertyAssignment:
          symbol = typeChecker.getShorthandAssignmentValueSymbol(node);
          break;
      }
    }

    if (symbol) {
      usedSymbols.add(symbol);
    }

    ts.forEachChild(node, visit);
  });

  if (imports.length === 0) {
    return importNodeRemovals;
  }

  const isUnused = (node: ts.Identifier) => {
    // Do not remove JSX factory imports
    if (node.text === compilerOptions.jsxFactory) {
      return false;
    }

    const symbol = typeChecker.getSymbolAtLocation(node);

    return symbol && !usedSymbols.has(symbol);
  };

  for (const node of imports) {
    if (!node.importClause) {
      // "import 'abc';"
      continue;
    }

    const namedBindings = node.importClause.namedBindings;

    if (namedBindings && ts.isNamespaceImport(namedBindings)) {
      // "import * as XYZ from 'abc';"
      if (isUnused(namedBindings.name)) {
        importNodeRemovals.add(node);
      }
    } else {
      const specifierNodeRemovals = [];
      let clausesCount = 0;

      // "import { XYZ, ... } from 'abc';"
      if (namedBindings && ts.isNamedImports(namedBindings)) {
        let removedClausesCount = 0;
        clausesCount += namedBindings.elements.length;

        for (const specifier of namedBindings.elements) {
          if (isUnused(specifier.name)) {
            removedClausesCount++;
            // in case we don't have any more namedImports we should remove the parent ie the {}
            const nodeToRemove =
              clausesCount === removedClausesCount ? specifier.parent : specifier;

            specifierNodeRemovals.push(nodeToRemove);
          }
        }
      }

      // "import XYZ from 'abc';"
      if (node.importClause.name) {
        clausesCount++;

        if (isUnused(node.importClause.name)) {
          specifierNodeRemovals.push(node.importClause.name);
        }
      }

      if (specifierNodeRemovals.length === clausesCount) {
        importNodeRemovals.add(node);
      } else {
        for (const specifierNodeRemoval of specifierNodeRemovals) {
          importNodeRemovals.add(specifierNodeRemoval);
        }
      }
    }
  }

  return importNodeRemovals;
}


text:
// Module dependencies
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var authorizedClientIds = ['mobile', 'mobileReader'];

/**
 * OAuth Client Schema.
 *
 */
var OAuthClientsSchema = new Schema({
  clientId: String,
  clientSecret: String,
  redirectUri: String
});

OAuthClientsSchema.statics.getClient = function(clientId, clientSecret, callback) {
  'use strict';

  console.log('calling getClient');
  if(clientSecret === null) {
    return OAuthClientsModel.findOne({clientId: clientId}, callback);
  }
  OAuthClientsModel.findOne({
    clientId: clientId,
    clientSecret: clientSecret}, callback);
};

OAuthClientsSchema.statics.grantTypeAllowed = function(clientId, grantType, callback) {
  'use strict';

  console.log('calling grantTypeAllowed');

  if(grantType === 'password') {
    return callback(false, authorizedClientIds.indexOf(clientId) >= 0);
  }

  callback(false, true);
};

mongoose.model('OAuthClients', OAuthClientsSchema);
var OAuthClientsModel = mongoose.model('OAuthClients');

module.exports = OAuthClientsModel;


text:
"""Auto-generated file, do not edit by hand. TD metadata"""
from ..phonemetadata import NumberFormat, PhoneNumberDesc, PhoneMetadata

PHONE_METADATA_TD = PhoneMetadata(id='TD', country_code=235, international_prefix='00|16',
    general_desc=PhoneNumberDesc(national_number_pattern='(?:22|[69]\\d|77)\\d{6}', possible_length=(8,)),
    fixed_line=PhoneNumberDesc(national_number_pattern='22(?:[37-9]0|5[0-5]|6[89])\\d{4}', example_number='22501234', possible_length=(8,)),
    mobile=PhoneNumberDesc(national_number_pattern='(?:6[023568]|77|9\\d)\\d{6}', example_number='63012345', possible_length=(8,)),
    preferred_international_prefix='00',
    number_format=[NumberFormat(pattern='(\\d{2})(\\d{2})(\\d{2})(\\d{2})', format='\\1 \\2 \\3 \\4', leading_digits_pattern=['[2679]'])])


text:
package org.abstractj.kalium.crypto;

import org.abstractj.kalium.encoders.Encoder;

import static org.abstractj.kalium.NaCl.Sodium.CRYPTO_GENERICHASH_BLAKE2B_BYTES;
import static org.abstractj.kalium.NaCl.Sodium.CRYPTO_HASH_SHA256_BYTES;
import static org.abstractj.kalium.NaCl.Sodium.CRYPTO_HASH_SHA512_BYTES;
import static org.abstractj.kalium.NaCl.sodium;

public class Hash {

    public byte[] sha256(byte[] message) {
        byte[] buffer = new byte[CRYPTO_HASH_SHA256_BYTES];
        sodium().crypto_hash_sha256(buffer, message, message.length);
        return buffer;
    }

    public byte[] sha512(byte[] message) {
        byte[] buffer = new byte[CRYPTO_HASH_SHA512_BYTES];
        sodium().crypto_hash_sha512(buffer, message, message.length);
        return buffer;
    }

    public String sha256(String message, Encoder encoder) {
        byte[] hash = sha256(message.getBytes());
        return encoder.encode(hash);
    }

    public String sha512(String message, Encoder encoder) {
        byte[] hash = sha512(message.getBytes());
        return encoder.encode(hash);
    }

    public byte[] blake2(byte[] message) throws UnsupportedOperationException {
        byte[] buffer = new byte[CRYPTO_GENERICHASH_BLAKE2B_BYTES];
        sodium().crypto_generichash_blake2b(buffer, CRYPTO_GENERICHASH_BLAKE2B_BYTES, message, message.length, null, 0);
        return buffer;
    }

    public String blake2(String message, Encoder encoder) throws UnsupportedOperationException {
        byte[] hash = blake2(message.getBytes());
        return encoder.encode(hash);
    }

    public byte[] blake2(byte[] message, byte[] key, byte[] salt, byte[] personal) throws UnsupportedOperationException {
        byte[] buffer = new byte[CRYPTO_GENERICHASH_BLAKE2B_BYTES];
        sodium().crypto_generichash_blake2b_salt_personal(buffer, CRYPTO_GENERICHASH_BLAKE2B_BYTES,
                                                          message, message.length,
                                                          key, key.length,
                                                          salt, personal);
        return buffer;
    }
}


text:
class NotMountSpecAnnotationsContributor {

  @<caret>

  void onCreate() {}
}


text:
'use babel';

import GrammarTabColorsView from '../lib/grammar-tab-colors-view';

describe('GrammarTabColorsView', () => {
  it('has one valid test', () => {
    expect('life').toBe('easy');
  });
});