Пример #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();
  }
}
Пример #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("}");
  }
}
Пример #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();
  }
}