32 Endl, Indent, Unindent
35 UString toString()
const {
return str; }
91 ind = ind.substr(0, ind.size() - 2);
103 for (i = 0; i <= str.
size(); i++) {
106 unescaped += str.
substr(copied,i-copied);
112 unescaped += str.
substr(copied,i-copied);
121 return str.toString();
124 void NullNode::streamTo(SourceStream &s)
const { s <<
"null"; }
126 void BooleanNode::streamTo(SourceStream &s)
const
128 s << (val ?
"true" :
"false");
131 void NumberNode::streamTo(SourceStream &s)
const { s <<
UString::from(val); }
133 void StringNode::streamTo(SourceStream &s)
const
135 s <<
'"' << unescapeStr(val) <<
'"';
138 void RegExpNode::streamTo(SourceStream &s)
const { s <<
"/" << pattern <<
"/" << flags; }
140 void ThisNode::streamTo(SourceStream &s)
const { s <<
"this"; }
142 void ResolveNode::streamTo(SourceStream &s)
const { s << ident; }
144 void GroupNode::streamTo(SourceStream &s)
const
146 s <<
"(" << group <<
")";
149 void ElementNode::streamTo(SourceStream &s)
const
151 for (
const ElementNode *n =
this; n; n = n->list) {
152 for (
int i = 0; i < n->elision; i++)
160 void ArrayNode::streamTo(SourceStream &s)
const
163 for (
int i = 0; i < elision; i++)
168 void ObjectLiteralNode::streamTo(SourceStream &s)
const
171 s <<
"{ " << list <<
" }";
176 void PropertyValueNode::streamTo(SourceStream &s)
const
178 for (
const PropertyValueNode *n =
this; n; n = n->list)
179 s << n->name <<
": " << n->assign;
182 void PropertyNode::streamTo(SourceStream &s)
const
190 void AccessorNode1::streamTo(SourceStream &s)
const
192 s << expr1 <<
"[" << expr2 <<
"]";
195 void AccessorNode2::streamTo(SourceStream &s)
const
197 s << expr <<
"." << ident;
200 void ArgumentListNode::streamTo(SourceStream &s)
const
203 for (ArgumentListNode *n = list; n; n = n->list)
204 s <<
", " << n->expr;
207 void ArgumentsNode::streamTo(SourceStream &s)
const
209 s <<
"(" << list <<
")";
212 void NewExprNode::streamTo(SourceStream &s)
const
214 s <<
"new " << expr << args;
217 void FunctionCallNode::streamTo(SourceStream &s)
const
222 void PostfixNode::streamTo(SourceStream &s)
const
225 if (oper == OpPlusPlus)
231 void DeleteNode::streamTo(SourceStream &s)
const
233 s <<
"delete " << expr;
236 void VoidNode::streamTo(SourceStream &s)
const
238 s <<
"void " << expr;
241 void TypeOfNode::streamTo(SourceStream &s)
const
243 s <<
"typeof " << expr;
246 void PrefixNode::streamTo(SourceStream &s)
const
248 s << (oper == OpPlusPlus ?
"++" :
"--") << expr;
251 void UnaryPlusNode::streamTo(SourceStream &s)
const
256 void NegateNode::streamTo(SourceStream &s)
const
261 void BitwiseNotNode::streamTo(SourceStream &s)
const
266 void LogicalNotNode::streamTo(SourceStream &s)
const
271 void MultNode::streamTo(SourceStream &s)
const
273 s << term1 << oper << term2;
276 void AddNode::streamTo(SourceStream &s)
const
278 s << term1 << oper << term2;
281 void AppendStringNode::streamTo(SourceStream &s)
const
283 s << term <<
"+" <<
'"' << unescapeStr(str) <<
'"';
286 void ShiftNode::streamTo(SourceStream &s)
const
289 if (oper == OpLShift)
291 else if (oper == OpRShift)
298 void RelationalNode::streamTo(SourceStream &s)
const
326 void EqualNode::streamTo(SourceStream &s)
const
348 void BitOperNode::streamTo(SourceStream &s)
const
351 if (oper == OpBitAnd)
353 else if (oper == OpBitXOr)
360 void BinaryLogicalNode::streamTo(SourceStream &s)
const
362 s << expr1 << (oper == OpAnd ?
" && " :
" || ") << expr2;
365 void ConditionalNode::streamTo(SourceStream &s)
const
367 s << logical <<
" ? " << expr1 <<
" : " << expr2;
370 void AssignNode::streamTo(SourceStream &s)
const
417 void CommaNode::streamTo(SourceStream &s)
const
419 s << expr1 <<
", " << expr2;
422 void StatListNode::streamTo(SourceStream &s)
const
424 for (
const StatListNode *n =
this; n; n = n->list)
428 void AssignExprNode::streamTo(SourceStream &s)
const
433 void VarDeclNode::streamTo(SourceStream &s)
const
438 void VarDeclListNode::streamTo(SourceStream &s)
const
441 for (VarDeclListNode *n = list; n; n = n->list)
445 void VarStatementNode::streamTo(SourceStream &s)
const
447 s << SourceStream::Endl <<
"var " << list <<
";";
450 void BlockNode::streamTo(SourceStream &s)
const
452 s << SourceStream::Endl <<
"{" << SourceStream::Indent
453 << source << SourceStream::Unindent << SourceStream::Endl <<
"}";
456 void EmptyStatementNode::streamTo(SourceStream &s)
const
458 s << SourceStream::Endl <<
";";
461 void ExprStatementNode::streamTo(SourceStream &s)
const
463 s << SourceStream::Endl << expr <<
";";
466 void IfNode::streamTo(SourceStream &s)
const
468 s << SourceStream::Endl <<
"if (" << expr <<
")" << SourceStream::Indent
469 << statement1 << SourceStream::Unindent;
471 s << SourceStream::Endl <<
"else" << SourceStream::Indent
472 << statement2 << SourceStream::Unindent;
475 void DoWhileNode::streamTo(SourceStream &s)
const
477 s << SourceStream::Endl <<
"do " << SourceStream::Indent
478 << statement << SourceStream::Unindent << SourceStream::Endl
479 <<
"while (" << expr <<
");";
482 void WhileNode::streamTo(SourceStream &s)
const
484 s << SourceStream::Endl <<
"while (" << expr <<
")" << SourceStream::Indent
485 << statement << SourceStream::Unindent;
488 void ForNode::streamTo(SourceStream &s)
const
490 s << SourceStream::Endl <<
"for ("
494 <<
")" << SourceStream::Indent << statement << SourceStream::Unindent;
497 void ForInNode::streamTo(SourceStream &s)
const
499 s << SourceStream::Endl <<
"for (";
501 s <<
"var " << varDecl;
504 s <<
" in " << expr <<
")" << SourceStream::Indent
505 << statement << SourceStream::Unindent;
508 void ContinueNode::streamTo(SourceStream &s)
const
510 s << SourceStream::Endl <<
"continue";
516 void BreakNode::streamTo(SourceStream &s)
const
518 s << SourceStream::Endl <<
"break";
524 void ReturnNode::streamTo(SourceStream &s)
const
526 s << SourceStream::Endl <<
"return";
532 void WithNode::streamTo(SourceStream &s)
const
534 s << SourceStream::Endl <<
"with (" << expr <<
") "
538 void CaseClauseNode::streamTo(SourceStream &s)
const
540 s << SourceStream::Endl;
542 s <<
"case " << expr;
545 s <<
":" << SourceStream::Indent;
548 s << SourceStream::Unindent;
551 void ClauseListNode::streamTo(SourceStream &s)
const
553 for (
const ClauseListNode *n =
this; n; n = n->next())
557 void CaseBlockNode::streamTo(SourceStream &s)
const
559 for (
const ClauseListNode *n = list1; n; n = n->next())
563 for (
const ClauseListNode *n = list2; n; n = n->next())
567 void SwitchNode::streamTo(SourceStream &s)
const
569 s << SourceStream::Endl <<
"switch (" << expr <<
") {"
570 << SourceStream::Indent << block << SourceStream::Unindent
571 << SourceStream::Endl <<
"}";
574 void LabelNode::streamTo(SourceStream &s)
const
576 s << SourceStream::Endl <<
label <<
":" << SourceStream::Indent
577 << statement << SourceStream::Unindent;
580 void ThrowNode::streamTo(SourceStream &s)
const
582 s << SourceStream::Endl <<
"throw " << expr <<
";";
585 void CatchNode::streamTo(SourceStream &s)
const
587 s << SourceStream::Endl <<
"catch (" << ident <<
")" << block;
590 void FinallyNode::streamTo(SourceStream &s)
const
592 s << SourceStream::Endl <<
"finally " << block;
595 void TryNode::streamTo(SourceStream &s)
const
597 s << SourceStream::Endl <<
"try " << block
602 void ParameterNode::streamTo(SourceStream &s)
const
605 for (ParameterNode *n = next; n; n = n->next)
609 void FuncDeclNode::streamTo(SourceStream &s)
const {
610 s << SourceStream::Endl <<
"function " << ident <<
"(";
616 void FuncExprNode::streamTo(SourceStream &s)
const
618 s <<
"function " <<
"("
623 void SourceElementsNode::streamTo(SourceStream &s)
const
625 for (
const SourceElementsNode *n =
this; n; n = n->elements)
Represents an Identifier for a Javascript object.
const UString & ustring() const
returns a UString of the identifier
UString substr(int pos=0, int len=-1) const
static UString from(int i)
Constructs a string from an int.
kdbgstream & operator<<(const TQValueList< T > &list)
TQString label(StdAccel id)