Lines Matching refs:SS

399 // inline std::ostream& operator<<(std::ostream& SS, StringRef R) {
400 // return SS.write(R.data(), R.size());
420 static void print(const SExpr *E, StreamType &SS) {
422 printer.printSExpr(E, SS, Prec_MAX);
428 void newline(StreamType &SS) {
429 SS << "\n";
485 void printBlockLabel(StreamType & SS, const BasicBlock *BB, int index) {
487 SS << "BB_null";
490 SS << "BB_";
491 SS << BB->blockID();
493 SS << ":";
494 SS << index;
498 void printSExpr(const SExpr *E, StreamType &SS, unsigned P, bool Sub=true) {
500 self()->printNull(SS);
504 SS << "_x" << E->id();
509 SS << "(";
510 self()->printSExpr(E, SS, Prec_MAX);
511 SS << ")";
518 self()->print##X(cast<X>(E), SS); \
525 void printNull(StreamType &SS) {
526 SS << "#null";
529 void printFuture(const Future *E, StreamType &SS) {
530 self()->printSExpr(E->maybeGetResult(), SS, Prec_Atom);
533 void printUndefined(const Undefined *E, StreamType &SS) {
534 SS << "#undefined";
537 void printWildcard(const Wildcard *E, StreamType &SS) {
538 SS << "*";
542 void printLiteralT(const LiteralT<T> *E, StreamType &SS) {
543 SS << E->value();
546 void printLiteralT(const LiteralT<uint8_t> *E, StreamType &SS) {
547 SS << "'" << E->value() << "'";
550 void printLiteral(const Literal *E, StreamType &SS) {
552 SS << getSourceLiteralString(E->clangExpr());
559 SS << "void";
563 SS << "true";
565 SS << "false";
571 printLiteralT(&E->as<int8_t>(), SS);
573 printLiteralT(&E->as<uint8_t>(), SS);
577 printLiteralT(&E->as<int16_t>(), SS);
579 printLiteralT(&E->as<uint16_t>(), SS);
583 printLiteralT(&E->as<int32_t>(), SS);
585 printLiteralT(&E->as<uint32_t>(), SS);
589 printLiteralT(&E->as<int64_t>(), SS);
591 printLiteralT(&E->as<uint64_t>(), SS);
600 printLiteralT(&E->as<float>(), SS);
603 printLiteralT(&E->as<double>(), SS);
610 SS << "\"";
611 printLiteralT(&E->as<StringRef>(), SS);
612 SS << "\"";
615 SS << "#ptr";
618 SS << "#vref";
622 SS << "#lit";
625 void printLiteralPtr(const LiteralPtr *E, StreamType &SS) {
627 SS << D->getNameAsString();
629 SS << "<temporary>";
632 void printVariable(const Variable *V, StreamType &SS, bool IsVarDecl=false) {
634 SS << "this";
636 SS << V->name() << V->id();
639 void printFunction(const Function *E, StreamType &SS, unsigned sugared = 0) {
642 SS << "\\("; // Lambda
645 SS << "("; // Slot declarations
648 SS << ", "; // Curried functions
651 self()->printVariable(E->variableDecl(), SS, true);
652 SS << ": ";
653 self()->printSExpr(E->variableDecl()->definition(), SS, Prec_MAX);
657 self()->printFunction(cast<Function>(B), SS, 2);
659 SS << ")";
660 self()->printSExpr(B, SS, Prec_Decl);
664 void printSFunction(const SFunction *E, StreamType &SS) {
665 SS << "@";
666 self()->printVariable(E->variableDecl(), SS, true);
667 SS << " ";
668 self()->printSExpr(E->body(), SS, Prec_Decl);
671 void printCode(const Code *E, StreamType &SS) {
672 SS << ": ";
673 self()->printSExpr(E->returnType(), SS, Prec_Decl-1);
674 SS << " -> ";
675 self()->printSExpr(E->body(), SS, Prec_Decl);
678 void printField(const Field *E, StreamType &SS) {
679 SS << ": ";
680 self()->printSExpr(E->range(), SS, Prec_Decl-1);
681 SS << " = ";
682 self()->printSExpr(E->body(), SS, Prec_Decl);
685 void printApply(const Apply *E, StreamType &SS, bool sugared = false) {
688 printApply(cast<Apply>(F), SS, true);
689 SS << ", ";
691 self()->printSExpr(F, SS, Prec_Postfix);
692 SS << "(";
694 self()->printSExpr(E->arg(), SS, Prec_MAX);
696 SS << ")$";
699 void printSApply(const SApply *E, StreamType &SS) {
700 self()->printSExpr(E->sfun(), SS, Prec_Postfix);
702 SS << "@(";
703 self()->printSExpr(E->arg(), SS, Prec_MAX);
704 SS << ")";
708 void printProject(const Project *E, StreamType &SS) {
714 SS << E->slotName();
721 SS << "&";
722 SS << E->clangDecl()->getQualifiedNameAsString();
726 self()->printSExpr(E->record(), SS, Prec_Postfix);
728 SS << "->";
730 SS << ".";
731 SS << E->slotName();
734 void printCall(const Call *E, StreamType &SS) {
737 self()->printApply(cast<Apply>(T), SS, true);
738 SS << ")";
741 self()->printSExpr(T, SS, Prec_Postfix);
742 SS << "()";
746 void printAlloc(const Alloc *E, StreamType &SS) {
747 SS << "new ";
748 self()->printSExpr(E->dataType(), SS, Prec_Other-1);
751 void printLoad(const Load *E, StreamType &SS) {
752 self()->printSExpr(E->pointer(), SS, Prec_Postfix);
754 SS << "^";
757 void printStore(const Store *E, StreamType &SS) {
758 self()->printSExpr(E->destination(), SS, Prec_Other-1);
759 SS << " := ";
760 self()->printSExpr(E->source(), SS, Prec_Other-1);
763 void printArrayIndex(const ArrayIndex *E, StreamType &SS) {
764 self()->printSExpr(E->array(), SS, Prec_Postfix);
765 SS << "[";
766 self()->printSExpr(E->index(), SS, Prec_MAX);
767 SS << "]";
770 void printArrayAdd(const ArrayAdd *E, StreamType &SS) {
771 self()->printSExpr(E->array(), SS, Prec_Postfix);
772 SS << " + ";
773 self()->printSExpr(E->index(), SS, Prec_Atom);
776 void printUnaryOp(const UnaryOp *E, StreamType &SS) {
777 SS << getUnaryOpcodeString(E->unaryOpcode());
778 self()->printSExpr(E->expr(), SS, Prec_Unary);
781 void printBinaryOp(const BinaryOp *E, StreamType &SS) {
782 self()->printSExpr(E->expr0(), SS, Prec_Binary-1);
783 SS << " " << getBinaryOpcodeString(E->binaryOpcode()) << " ";
784 self()->printSExpr(E->expr1(), SS, Prec_Binary-1);
787 void printCast(const Cast *E, StreamType &SS) {
789 SS << "cast[";
792 SS << "none";
795 SS << "extendNum";
798 SS << "truncNum";
801 SS << "toFloat";
804 SS << "toInt";
807 SS << "objToPtr";
810 SS << "](";
811 self()->printSExpr(E->expr(), SS, Prec_Unary);
812 SS << ")";
815 self()->printSExpr(E->expr(), SS, Prec_Unary);
818 void printSCFG(const SCFG *E, StreamType &SS) {
819 SS << "CFG {\n";
821 printBasicBlock(BBI, SS);
822 SS << "}";
823 newline(SS);
826 void printBBInstr(const SExpr *E, StreamType &SS) {
830 SS << "let " << V->name() << V->id() << " = ";
835 SS << "let _x" << E->id() << " = ";
837 self()->printSExpr(E, SS, Prec_MAX, Sub);
838 SS << ";";
839 newline(SS);
842 void printBasicBlock(const BasicBlock *E, StreamType &SS) {
843 SS << "BB_" << E->blockID() << ":";
845 SS << " BB_" << E->parent()->blockID();
846 newline(SS);
849 printBBInstr(A, SS);
852 printBBInstr(I, SS);
856 self()->printSExpr(T, SS, Prec_MAX, false);
857 SS << ";";
858 newline(SS);
860 newline(SS);
863 void printPhi(const Phi *E, StreamType &SS) {
864 SS << "phi(";
866 self()->printSExpr(E->values()[0], SS, Prec_MAX);
871 SS << ", ";
872 self()->printSExpr(V, SS, Prec_MAX);
875 SS << ")";
878 void printGoto(const Goto *E, StreamType &SS) {
879 SS << "goto ";
880 printBlockLabel(SS, E->targetBlock(), E->index());
883 void printBranch(const Branch *E, StreamType &SS) {
884 SS << "branch (";
885 self()->printSExpr(E->condition(), SS, Prec_MAX);
886 SS << ") ";
887 printBlockLabel(SS, E->thenBlock(), -1);
888 SS << " ";
889 printBlockLabel(SS, E->elseBlock(), -1);
892 void printReturn(const Return *E, StreamType &SS) {
893 SS << "return ";
894 self()->printSExpr(E->returnValue(), SS, Prec_Other);
897 void printIdentifier(const Identifier *E, StreamType &SS) {
898 SS << E->name();
901 void printIfThenElse(const IfThenElse *E, StreamType &SS) {
903 printSExpr(E->condition(), SS, Prec_Unary);
904 SS << " ? ";
905 printSExpr(E->thenExpr(), SS, Prec_Unary);
906 SS << " : ";
907 printSExpr(E->elseExpr(), SS, Prec_Unary);
910 SS << "if (";
911 printSExpr(E->condition(), SS, Prec_MAX);
912 SS << ") then ";
913 printSExpr(E->thenExpr(), SS, Prec_Other);
914 SS << " else ";
915 printSExpr(E->elseExpr(), SS, Prec_Other);
918 void printLet(const Let *E, StreamType &SS) {
919 SS << "let ";
920 printVariable(E->variableDecl(), SS, true);
921 SS << " = ";
922 printSExpr(E->variableDecl()->definition(), SS, Prec_Decl-1);
923 SS << "; ";
924 printSExpr(E->body(), SS, Prec_Decl-1);