Example #1
0
  void visitEnumStatement(EnumStatement *node) override {
    if (!node->name()) {
      for (size_t i = 0; i < node->entries()->length(); i++) {
        EnumConstant *cs = node->entries()->at(i);

        JsonObject *val = new (pool_) JsonObject();
        val->add(atom_name_, toJson(cs->name()));
        startDoc(val, "enum value", cs->name(), cs->loc());

        constants_->add(val);
      }
      return;
    }

    JsonObject *obj = new (pool_) JsonObject();
    obj->add(atom_name_, toJson(node->name()));
    startDoc(obj, "enum", node->name(), node->loc());

    JsonList *list = new (pool_) JsonList();
    for (size_t i = 0; i < node->entries()->length(); i++) {
      EnumConstant *cs = node->entries()->at(i);

      JsonObject *val = new (pool_) JsonObject();
      val->add(atom_name_, toJson(cs->name()));
      startDoc(val, "enum value", cs->name(), cs->loc());

      list->add(val);
    }
    obj->add(atom_entries_, list);

    enums_->add(obj);
  }
Example #2
0
  void visitTypedefDecl(TypedefDecl *decl) override {
    JsonObject *obj = new (pool_) JsonObject();
    obj->add(atom_name_, toJson(decl->name()));
    startDoc(obj, "typedef", decl->name(), decl->loc());

    obj->add(atom_type_, toJson(decl->te()));

    typedefs_->add(obj);
  }
Example #3
0
  void visitPropertyDecl(PropertyDecl *node) override {
    JsonObject *obj = new (pool_) JsonObject();
    obj->add(atom_name_, toJson(node->name()));
    startDoc(obj, "property", node->name(), node->loc());

    obj->add(atom_type_, toJson(node->te()));
    obj->add(atom_getter_, new (pool_) JsonBool(!!node->getter()));
    obj->add(atom_setter_, new (pool_) JsonBool(!!node->setter()));
    props_->add(obj);
  }
Example #4
0
  void visitMethodDecl(MethodDecl *node) override {
    JsonObject *obj = new (pool_) JsonObject();
    obj->add(atom_name_, toJson(node->name()));
    startDoc(obj, "method", node->name(), node->loc());

    FunctionNode *fun = node->method();
    obj->add(atom_returnType_, toJson(fun->signature()->returnType()));
    obj->add(atom_parameters_, toJson(fun->signature()->parameters()));
    methods_->add(obj);
  }
Example #5
0
  void visitMethodmapDecl(MethodmapDecl *node) override {
    JsonObject *obj = new (pool_) JsonObject();
    obj->add(atom_name_, toJson(node->name()));
    startDoc(obj, "class", node->name(), node->loc());

    SaveAndSet<JsonList *> new_props(&props_, new (pool_) JsonList());
    SaveAndSet<JsonList *> new_methods(&methods_, new (pool_) JsonList());
    for (size_t i = 0; i < node->body()->length(); i++)
      node->body()->at(i)->accept(this);

    obj->add(atom_methods_, methods_);
    obj->add(atom_properties_, props_);
    methodmaps_->add(obj);
  }
Example #6
0
  void visitFunctionStatement(FunctionStatement *node) override {
    JsonObject *obj = new (pool_) JsonObject();
    obj->add(atom_name_, toJson(node->name()));
    startDoc(obj, "function", node->name(), node->loc());

    if (node->token() == TOK_FORWARD)
      obj->add(atom_kind_, toJson("forward"));
    else if (node->token() == TOK_NATIVE)
      obj->add(atom_kind_, toJson("native"));
    else
      obj->add(atom_kind_, toJson("stock"));

    obj->add(atom_returnType_, toJson(node->signature()->returnType()));
    obj->add(atom_parameters_, toJson(node->signature()->parameters()));

    functions_->add(obj);
  }
Example #7
0
void SWorker::results(int total_ms) {

	JsonObject r;
	r.add("elapsed", total_ms);
	
	// results are really out there...
	r.add("file", "results.dat");
	
    stringstream ss;
    r.write(true, &ss);

    StringMsg msg(0, 0, ss.str());
   	zmq::message_t message(2);
    msg.set(&message);
    result->send(message);

}
Example #8
0
  void visitTypesetDecl(TypesetDecl *decl) override {
    JsonObject *obj = new (pool_) JsonObject();
    obj->add(atom_name_, toJson(decl->name()));
    startDoc(obj, "typeset", decl->name(), decl->loc());

    JsonList *list = new (pool_) JsonList();
    for (size_t i = 0; i < decl->types()->length(); i++) {
      const TypesetDecl::Entry &entry = decl->types()->at(i);
      JsonObject *te = new (pool_) JsonObject();
      te->add(atom_type_, toJson(entry.te));
      unsigned start, end;
      if (comments_.findCommentFor(entry.loc, &start, &end)) {
        te->add(atom_doc_start_, new (pool_) JsonInt(start));
        te->add(atom_doc_end_, new (pool_) JsonInt(end));
      }
      list->add(te);
    }
    obj->add(cc_.add("types"), list);

    typesets_->add(obj);
  }
Example #9
0
  JsonList *toJson(const ParameterList *params) {
    JsonList *list = new (pool_) JsonList();
    for (size_t i = 0; i < params->length(); i++) {
      VarDecl *decl = params->at(i);
      JsonObject *obj = new (pool_) JsonObject();

      obj->add(atom_type_, toJson(decl, false));

      if (decl->name()) {
        obj->add(atom_name_, toJson(decl->name()));
        obj->add(atom_decl_, toJson(decl, true));
      } else {
        obj->add(atom_name_, toJson("..."));

        AutoString builder = BuildTypeName(decl->te(), nullptr, TypeDiagFlags::Names);
        builder = builder + " ...";
        obj->add(atom_decl_, toJson(builder.ptr()));
      }
      list->add(obj);
    }
    return list;
  }
Example #10
0
  JsonObject *analyze(ParseTree *tree) {
    functions_ = new (pool_) JsonList();
    methodmaps_ = new (pool_) JsonList();
    enums_ = new (pool_) JsonList();
    constants_ = new (pool_) JsonList();
    typesets_ = new (pool_) JsonList();
    typedefs_ = new (pool_) JsonList();

    for (size_t i = 0; i < tree->statements()->length(); i++) {
      Statement *stmt = tree->statements()->at(i);
      stmt->accept(this);
    }

    JsonObject *obj = new (pool_) JsonObject();
    obj->add(cc_.add("functions"), functions_);
    obj->add(cc_.add("methodmaps"), methodmaps_);
    obj->add(cc_.add("enums"), enums_);
    obj->add(cc_.add("constants"), constants_);
    obj->add(cc_.add("typesets"), typesets_);
    obj->add(cc_.add("typedefs"), typedefs_);
    return obj;
  }
Example #11
0
JsonObject createObject() {

	// {"x":{"a":{"b":1}},"y":{"d":{"e":2},"g":{"h":3,"o":{"p":9}},"z":[{"i"5},{"j":6},{"l":{"m":7,"n":8}}]}
	JsonObject o;
	{
		JsonObject x;
		{
			JsonObject a;
			a.add("b", 1);
			x.add("a", a);
		}
		o.add("x", x);
	}
	{
		JsonObject y;
		{
			JsonObject d;
			d.add("e", 2);
			y.add("d", d);
		}
		{
			JsonObject g;
			g.add("h", 3);
			JsonObject oo;
			oo.add("p", 9);
			g.add("o", oo);
			y.add("g", g);
		}
		o.add("y", y);	
	}
	{
		JsonArray z;
		{
			JsonObject i;
			i.add("i", 5);
			z.add(i);
		}
		{
			JsonObject j;
			j.add("j", 6);
			z.add(j);
		}
		{
			JsonObject l;
			JsonObject s;
			s.add("m", 7);
			s.add("n", 8);
			l.add("l", s);
			z.add(l);
		}
		o.add("z", z);	
	}
	
	return o;
}