Ejemplo n.º 1
0
void CodeGenerator::printAsBlock(StatementPtr s) {
  if (s->is(Statement::KindOfBlockStatement)) {
    s->outputCodeModel(*this);
  } else {
    printObjectHeader("BlockStatement", 2);
    printPropertyHeader("statements");
    if (s->is(Statement::KindOfStatementList)) {
      auto sl = static_pointer_cast<StatementList>(s);
      printStatementVector(sl);
    } else {
      printf("V:9:\"HH\\Vector\":1:{");
      s->outputCodeModel(*this);
      printf("}");
    }
    printPropertyHeader("sourceLocation");
    printLocation(s->getLocation());
    printObjectFooter();
  }
}
Ejemplo n.º 2
0
void CodeGenerator::printStatementVector(StatementPtr s) {
  if (s == nullptr) {
    printf("V:9:\"HH\\Vector\":0:{}");
  } else if (s->is(Statement::KindOfStatementList)) {
    auto sl = static_pointer_cast<StatementList>(s);
    printStatementVector(sl);
  } else {
    printf("V:9:\"HH\\Vector\":1:{");
    s->outputCodeModel(*this);
    printf("}");
  }
}
Ejemplo n.º 3
0
void CodeGenerator::printAsBlock(StatementPtr s, bool isEnclosed) {
  if (s != nullptr && s->is(Statement::KindOfBlockStatement)) {
    s->outputCodeModel(*this);
  } else {
    auto numProps = s == nullptr ? 0 : 2;
    if (isEnclosed) numProps++;
    printObjectHeader("BlockStatement", numProps);
    if (s != nullptr) {
      printPropertyHeader("statements");
      printStatementVector(s);
      printPropertyHeader("sourceLocation");
      printLocation(s);
    }
    if (isEnclosed) {
      printPropertyHeader("isEnclosed");
      printBool(true);
    }
    printObjectFooter();
  }
}