in src/langs/swift/combinator.js [530:605]
grammerValue(emitter, gram, ignoreCast) {
if (is.annotation(gram)) {
this.emitAnnotation(emitter, gram);
return;
}
if (gram.needToReadable) {
emitter.emit(`${this.config.tea.core.name}.${this.config.tea.core.toReadable}(`);
}
if (gram.type === 'map' || gram.type === 'model_construct_params') {
if (gram.type === 'model_construct_params') {
gram.dataType = new TypeMap(
new TypeString(), new TypeGeneric()
);
}
this.emitMap(emitter, gram);
} else if (gram.type === 'string') {
emitter.emit(`"${gram.value}"`);
} else if (gram.type === 'null') {
emitter.emit('nil');
} else if (gram.type === 'behavior' || gram.type === 'call'
|| gram.type === 'var' || gram.type === 'instance') {
this.grammer(emitter, gram.value, false, false, ignoreCast);
} else if (gram.type === 'number' || gram.type === 'param' || gram.type === 'bool') {
emitter.emit(gram.value);
} else if (gram.type === 'expr') {
if (Array.isArray(gram.value)) {
gram.value.forEach(gramItem => {
this.grammer(emitter, gramItem, false, false);
});
} else {
this.grammer(emitter, gram.value, false, false);
}
} else if (gram.type === 'array') {
let itemType = this.emitType(gram.dataType.itemType);
if (gram.value.length) {
emitter.emitln('[');
this.levelUp();
gram.value.forEach((item, i) => {
if (item instanceof AnnotationItem) {
this.emitAnnotation(emitter, item);
return;
}
emitter.emit('', this.level);
this.grammerValue(emitter, item, false, false);
if (i < gram.value.length - 1) {
emitter.emitln(',');
} else {
emitter.emitln();
}
});
this.levelDown();
emitter.emit(']', this.level);
} else {
emitter.emit(`[${itemType}]()`);
}
} else if (gram.type === 'not') {
emitter.emit(_symbol(Symbol.reverse()));
this.grammerValue(emitter, gram.value);
} else {
debug.stack(gram);
}
if (gram.dataType && gram.needCast) {
if (is.array(gram.dataType)) {
emitter.emit(' ?? []');
} else if (is.map(gram.dataType)) {
emitter.emit(' ?? [:]');
} else if (is.string(gram.dataType)) {
emitter.emit(' ?? ""');
} else {
emitter.emit('!');
}
}
if (gram.needToReadable) {
emitter.emit(')');
}
}