Pol  Revision:cb584c9
objstrm.cpp
Go to the documentation of this file.
1 
7 #include "bobject.h"
8 #include "impstr.h"
9 
10 #include <format/format.h>
11 #include <sstream>
12 
13 namespace Pol
14 {
15 namespace Bscript
16 {
17 std::ostream& operator<<( std::ostream& os, const BObject& obj )
18 {
19  obj.impptr()->printOn( os );
20  return os;
21 }
22 fmt::Writer& operator<<( fmt::Writer& w, const BObject& obj )
23 {
24  std::ostringstream os;
25  obj.impptr()->printOn( os );
26  w << os.str();
27  return w;
28 }
29 
30 std::ostream& operator<<( std::ostream& os, const BObjectImp& objimp )
31 {
32  objimp.printOn( os );
33  return os;
34 }
35 fmt::Writer& operator<<( fmt::Writer& w, const BObjectImp& objimp )
36 {
37  std::ostringstream os;
38  objimp.printOn( os );
39  w << os.str();
40  return w;
41 }
42 
43 void BObject::printOn( std::ostream& os ) const
44 {
45  os << "{ BObject: " << BObjectImp::typestr( objimp->type() ) << " }";
46 }
47 
48 void BObjectImp::printOn( std::ostream& os ) const
49 {
50  os << "{ BObjectImp: " << typestr( type() ) << " }";
51 }
52 
53 void UninitObject::printOn( std::ostream& os ) const
54 {
55  os << "{ Uninitialized Object }";
56 }
57 
58 void ObjArray::printOn( std::ostream& os ) const
59 {
60  os << " { Array[" << ref_arr.size() << "] }";
61 }
62 
63 void String::printOn( std::ostream& os ) const
64 {
65  os << '\"' << value_ << '\"';
66 }
67 
68 #if 0
69  void SubString::printOn(std::ostream& os ) const
70  {
71  os << "{ \"";
72  os << ref_String->value_.substr( begin-1, len );
73 
74  os << "\" }";
75  }
76 #endif
77 
78 void Double::printOn( std::ostream& os ) const
79 {
80  // CHECKME: consider setting precision
81  os << dval_;
82 }
83 
84 void BLong::printOn( std::ostream& os ) const
85 {
86  os << lval_;
87 }
88 
89 void BBoolean::printOn( std::ostream& os ) const
90 {
91  os << ( bval_ ? "true" : "false" );
92 }
93 }
94 }
virtual void printOn(std::ostream &) const
Definition: objstrm.cpp:48
virtual void printOn(std::ostream &os) const POL_OVERRIDE
Definition: objstrm.cpp:53
virtual void printOn(std::ostream &) const POL_OVERRIDE
Definition: objstrm.cpp:63
virtual void printOn(std::ostream &os) const POL_OVERRIDE
Definition: objstrm.cpp:58
void printOn(std::ostream &) const
Definition: objstrm.cpp:43
std::ostream & operator<<(std::ostream &os, const CompilerContext &ctx)
Definition: compctx.h:54
virtual void printOn(std::ostream &) const POL_OVERRIDE
Definition: objstrm.cpp:84
virtual void printOn(std::ostream &) const POL_OVERRIDE
Definition: objstrm.cpp:89
BObjectImp * impptr()
Definition: bobject.h:428
ref_ptr< BObjectImp > objimp
Definition: bobject.h:404
virtual void printOn(std::ostream &) const POL_OVERRIDE
Definition: objstrm.cpp:78
Definition: berror.cpp:12
static const char * typestr(BObjectType typ)
Definition: object.cpp:218