"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetadataStructGen = void 0;
const generator_1 = require("../generator");
class MetadataStructGen {
    gen(schema) {
        const structDef = `struct ${schema.getMetadataStructName()} {`;
        const structFields = schema.storage.fields
            .filter((field) => field.arrayLength !== 0 && field.totalBits !== 0)
            .map((field) => {
            let fieldType = field.fieldType;
            if (fieldType == "literef") {
                fieldType = "uint64";
            }
            if (fieldType == "char8" || fieldType == "char16" || fieldType == "char32" || fieldType == "char64") {
                fieldType = "string";
            }
            if (field.arrayLength > 1) {
                fieldType += `[${field.arrayLength}]`;
            }
            return `    ${fieldType} ${field.key};`;
        })
            .join("\n");
        const structEnd = "}";
        return (0, generator_1.ind)(4, `${structDef}\n` +
            `${structFields}\n` +
            `${structEnd}\n`);
    }
}
exports.MetadataStructGen = MetadataStructGen;
