33 Endl, Indent, Unindent
36 UString toString()
const {
return str; }
92 ind = ind.substr(0, ind.size() - 2);
104 for (i = 0; i <= str.
size(); i++) {
107 unescaped += str.
substr(copied,i-copied);
113 unescaped += str.
substr(copied,i-copied);
122 return str.toString();
125 void NullNode::streamTo(SourceStream &s)
const { s <<
"null"; }
127 void BooleanNode::streamTo(SourceStream &s)
const 129 s << (val ?
"true" :
"false");
132 void NumberNode::streamTo(SourceStream &s)
const { s <<
UString::from(val); }
134 void StringNode::streamTo(SourceStream &s)
const 136 s <<
'"' << unescapeStr(val) <<
'"';
139 void RegExpNode::streamTo(SourceStream &s)
const { s <<
"/" << pattern <<
"/" << flags; }
141 void ThisNode::streamTo(SourceStream &s)
const { s <<
"this"; }
143 void ResolveNode::streamTo(SourceStream &s)
const { s << ident; }
145 void GroupNode::streamTo(SourceStream &s)
const 147 s <<
"(" << group <<
")";
150 void ElementNode::streamTo(SourceStream &s)
const 152 for (
const ElementNode *n =
this; n; n = n->list) {
153 for (
int i = 0; i < n->elision; i++)
161 void ArrayNode::streamTo(SourceStream &s)
const 164 for (
int i = 0; i < elision; i++)
169 void ObjectLiteralNode::streamTo(SourceStream &s)
const 172 s <<
"{ " << list <<
" }";
177 void PropertyValueNode::streamTo(SourceStream &s)
const 179 for (
const PropertyValueNode *n =
this; n; n = n->list)
180 s << n->name <<
": " << n->assign;
183 void PropertyNode::streamTo(SourceStream &s)
const 191 void AccessorNode1::streamTo(SourceStream &s)
const 193 s << expr1 <<
"[" << expr2 <<
"]";
196 void AccessorNode2::streamTo(SourceStream &s)
const 198 s << expr <<
"." << ident;
201 void ArgumentListNode::streamTo(SourceStream &s)
const 204 for (ArgumentListNode *n = list; n; n = n->list)
205 s <<
", " << n->expr;
208 void ArgumentsNode::streamTo(SourceStream &s)
const 210 s <<
"(" << list <<
")";
213 void NewExprNode::streamTo(SourceStream &s)
const 215 s <<
"new " << expr << args;
218 void FunctionCallNode::streamTo(SourceStream &s)
const 223 void PostfixNode::streamTo(SourceStream &s)
const 226 if (oper == OpPlusPlus)
232 void DeleteNode::streamTo(SourceStream &s)
const 234 s <<
"delete " << expr;
237 void VoidNode::streamTo(SourceStream &s)
const 239 s <<
"void " << expr;
242 void TypeOfNode::streamTo(SourceStream &s)
const 244 s <<
"typeof " << expr;
247 void PrefixNode::streamTo(SourceStream &s)
const 249 s << (oper == OpPlusPlus ?
"++" :
"--") << expr;
252 void UnaryPlusNode::streamTo(SourceStream &s)
const 257 void NegateNode::streamTo(SourceStream &s)
const 262 void BitwiseNotNode::streamTo(SourceStream &s)
const 267 void LogicalNotNode::streamTo(SourceStream &s)
const 272 void MultNode::streamTo(SourceStream &s)
const 274 s << term1 << oper << term2;
277 void AddNode::streamTo(SourceStream &s)
const 279 s << term1 << oper << term2;
282 void AppendStringNode::streamTo(SourceStream &s)
const 284 s << term <<
"+" <<
'"' << unescapeStr(str) <<
'"';
287 void ShiftNode::streamTo(SourceStream &s)
const 290 if (oper == OpLShift)
292 else if (oper == OpRShift)
299 void RelationalNode::streamTo(SourceStream &s)
const 327 void EqualNode::streamTo(SourceStream &s)
const 349 void BitOperNode::streamTo(SourceStream &s)
const 352 if (oper == OpBitAnd)
354 else if (oper == OpBitXOr)
361 void BinaryLogicalNode::streamTo(SourceStream &s)
const 363 s << expr1 << (oper == OpAnd ?
" && " :
" || ") << expr2;
366 void ConditionalNode::streamTo(SourceStream &s)
const 368 s << logical <<
" ? " << expr1 <<
" : " << expr2;
371 void AssignNode::streamTo(SourceStream &s)
const 418 void CommaNode::streamTo(SourceStream &s)
const 420 s << expr1 <<
", " << expr2;
423 void StatListNode::streamTo(SourceStream &s)
const 425 for (
const StatListNode *n =
this; n; n = n->list)
429 void AssignExprNode::streamTo(SourceStream &s)
const 434 void VarDeclNode::streamTo(SourceStream &s)
const 439 void VarDeclListNode::streamTo(SourceStream &s)
const 442 for (VarDeclListNode *n = list; n; n = n->list)
446 void VarStatementNode::streamTo(SourceStream &s)
const 448 s << SourceStream::Endl <<
"var " << list <<
";";
451 void BlockNode::streamTo(SourceStream &s)
const 453 s << SourceStream::Endl <<
"{" << SourceStream::Indent
454 << source << SourceStream::Unindent << SourceStream::Endl <<
"}";
457 void EmptyStatementNode::streamTo(SourceStream &s)
const 459 s << SourceStream::Endl <<
";";
462 void ExprStatementNode::streamTo(SourceStream &s)
const 464 s << SourceStream::Endl << expr <<
";";
467 void IfNode::streamTo(SourceStream &s)
const 469 s << SourceStream::Endl <<
"if (" << expr <<
")" << SourceStream::Indent
470 << statement1 << SourceStream::Unindent;
472 s << SourceStream::Endl <<
"else" << SourceStream::Indent
473 << statement2 << SourceStream::Unindent;
476 void DoWhileNode::streamTo(SourceStream &s)
const 478 s << SourceStream::Endl <<
"do " << SourceStream::Indent
479 << statement << SourceStream::Unindent << SourceStream::Endl
480 <<
"while (" << expr <<
");";
483 void WhileNode::streamTo(SourceStream &s)
const 485 s << SourceStream::Endl <<
"while (" << expr <<
")" << SourceStream::Indent
486 << statement << SourceStream::Unindent;
489 void ForNode::streamTo(SourceStream &s)
const 491 s << SourceStream::Endl <<
"for (" 495 <<
")" << SourceStream::Indent << statement << SourceStream::Unindent;
498 void ForInNode::streamTo(SourceStream &s)
const 500 s << SourceStream::Endl <<
"for (";
502 s <<
"var " << varDecl;
505 s <<
" in " << expr <<
")" << SourceStream::Indent
506 << statement << SourceStream::Unindent;
509 void ContinueNode::streamTo(SourceStream &s)
const 511 s << SourceStream::Endl <<
"continue";
517 void BreakNode::streamTo(SourceStream &s)
const 519 s << SourceStream::Endl <<
"break";
525 void ReturnNode::streamTo(SourceStream &s)
const 527 s << SourceStream::Endl <<
"return";
533 void WithNode::streamTo(SourceStream &s)
const 535 s << SourceStream::Endl <<
"with (" << expr <<
") " 539 void CaseClauseNode::streamTo(SourceStream &s)
const 541 s << SourceStream::Endl;
543 s <<
"case " << expr;
546 s <<
":" << SourceStream::Indent;
549 s << SourceStream::Unindent;
552 void ClauseListNode::streamTo(SourceStream &s)
const 554 for (
const ClauseListNode *n =
this; n; n = n->next())
558 void CaseBlockNode::streamTo(SourceStream &s)
const 560 for (
const ClauseListNode *n = list1; n; n = n->next())
564 for (
const ClauseListNode *n = list2; n; n = n->next())
568 void SwitchNode::streamTo(SourceStream &s)
const 570 s << SourceStream::Endl <<
"switch (" << expr <<
") {" 571 << SourceStream::Indent << block << SourceStream::Unindent
572 << SourceStream::Endl <<
"}";
575 void LabelNode::streamTo(SourceStream &s)
const 577 s << SourceStream::Endl <<
label <<
":" << SourceStream::Indent
578 << statement << SourceStream::Unindent;
581 void ThrowNode::streamTo(SourceStream &s)
const 583 s << SourceStream::Endl <<
"throw " << expr <<
";";
586 void CatchNode::streamTo(SourceStream &s)
const 588 s << SourceStream::Endl <<
"catch (" << ident <<
")" << block;
591 void FinallyNode::streamTo(SourceStream &s)
const 593 s << SourceStream::Endl <<
"finally " << block;
596 void TryNode::streamTo(SourceStream &s)
const 598 s << SourceStream::Endl <<
"try " << block
603 void ParameterNode::streamTo(SourceStream &s)
const 606 for (ParameterNode *n = next; n; n = n->next)
610 void FuncDeclNode::streamTo(SourceStream &s)
const {
611 s << SourceStream::Endl <<
"function " << ident <<
"(";
617 void FuncExprNode::streamTo(SourceStream &s)
const 619 s <<
"function " <<
"(" 624 void SourceElementsNode::streamTo(SourceStream &s)
const 626 for (
const SourceElementsNode *n =
this; n; n = n->elements)
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)
const UString & ustring() const
returns a UString of the identifier
Represents an Identifier for a Javascript object.