Exemplo n.º 1
0
    inline void runAll(Code *code, bool full) {
        if (code) {
            if (Code *next = code->getNext()) {
                out << '(';

                ++indent;
                putIndent();
                code->runVisit(this);

                while (next) {
                    // out << ',';

                    putIndent();
                    next->runVisit(this);
                    next = next->getNext();
                }

                --indent;
                putIndent();
                out << ')';
            } else {
                if (full) {
                    out << '(';
                }
                code->runVisit(this);
                if (full) {
                    out << ')';
                }
            }
        } else {
            out << "()";
        }
    }
Exemplo n.º 2
0
// save as text (must implement!)
bool ConfigVarBase::saveText( SaveStruct &s ) const
{
	QTextStream &ts = *s.ts;
	QString name = getName();
	const ChildList &cl = getChilds();
	if ( !s.firstItem )
	{
		ts << ",\n";
	}
	s.firstItem = 0;
	if ( !cl.empty() )
	{
		// must serialize as group now
		// put indent
		putIndent(ts, s.indent);
		if ( !name.isEmpty() )
		{
			ts << '"' << escape(name) << '"' << " : {\n";
		}
		else
		{
			ts << "{\n";
		}
		SaveStruct ls(s);
		ls.indent++;
		ls.firstItem = 1;
		size_t nwr = 0;
		for (size_t i=0; i<cl.size(); i++)
		{
			if ( cl[i]->varFlags & CF_TRANSIENT )
				continue;
			if ( !cl[i]->saveText(ls) )
				return 0;
			nwr++;
		}
		if ( nwr )
			ts << '\n';
		putIndent(ts, s.indent);
		ts << "}";

	}
	return 1;
}
Exemplo n.º 3
0
    inline void putField(const field_t &field) {
        putIndent();
        out << '"' << field.name.id << '"';

        if (field.import) {
            out << " import";
        }

        if (field.hidden) {
            out << " hidden";
        }

        out << " " << (void *) field.code << ": ";
        runAll(field.code, false);
    }
Exemplo n.º 4
0
    CodeVisitorRepr(
        Block *to_env, std::ostream &to_out, size_t to_indent = 0
    ): env(to_env), out(to_out), indent(to_indent) {
        out << '{';
        ++indent;

        if (!env->getArguments().empty()) {
            putIndent();
            out << "arguments:";
            ++indent;
            for (const argument_t &i: env->getArguments()) {
                putIndent();

                switch (i.mode) {
                case argument_t::Mode::M_IN:
                    out << "in ";
                    break;
                case argument_t::Mode::M_OUT:
                    out << "out ";
                    break;
                case argument_t::Mode::M_VAR:
                    out << "var ";
                    break;
                default:
                    // never reach
                    throw libblock::error_t("internal error");
                }

                out << i.name.id;
            }
            --indent;
        }

        if (!env->getMemberType().empty()) {
            putIndent();
            out << "type:";
            putFields(env->getMemberType());
        }

        if (!env->getMemberExpr().empty()) {
            putIndent();
            out << "expr:";
            putFields(env->getMemberExpr());
        }

        if (!env->getMemberVar().empty()) {
            putIndent();
            out << "var:";
            putFields(env->getMemberVar());
        }

        if (!env->getMemberStatic().empty()) {
            putIndent();
            out << "static:";
            putFields(env->getMemberStatic());
        }

        if (!env->getMemberFast().empty()) {
            putIndent();
            out << "fast:";
            putFields(env->getMemberFast());
        }

        --indent;
        putIndent();
        out << '}';
    }