UNPKG

@designliquido/delegua

Version:

Linguagem de programação simples e moderna usando português estruturado.

46 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Atribuir = void 0; const variavel_1 = require("./variavel"); /** * Construto de atribuição de um valor a um símbolo. */ class Atribuir { constructor(hashArquivo, alvo, valor, indice, simboloOperador) { this.linha = Number(alvo.linha); this.hashArquivo = hashArquivo; this.alvo = alvo; this.valor = valor; if (indice !== undefined) { const alvoComoVariavel = alvo; const tipoAlvo = alvoComoVariavel === null || alvoComoVariavel === void 0 ? void 0 : alvoComoVariavel.tipo; const alvoSuportaIndice = alvo instanceof variavel_1.Variavel && (tipoAlvo === 'vetor' || tipoAlvo === 'dicionário' || tipoAlvo === 'qualquer' || (tipoAlvo === null || tipoAlvo === void 0 ? void 0 : tipoAlvo.endsWith('[]'))); if (!alvoSuportaIndice) { throw new Error('`indice` só pode ser informado quando o alvo for uma variável de vetor ou dicionário.'); } this.indice = indice; } if (simboloOperador !== undefined) { this.simboloOperador = simboloOperador; } } async aceitar(visitante) { return await visitante.visitarExpressaoDeAtribuicao(this); } paraTexto() { let indiceResolvido = 'índice=(não definido)'; if (this.indice) { indiceResolvido = `índice=${this.indice.paraTexto()}`; } return `<atribuir alvo=${this.alvo.paraTexto()} ${indiceResolvido} valor=${this.valor.paraTexto()} />`; } paraTextoSaida() { throw new Error('Método não implementado.'); } } exports.Atribuir = Atribuir; //# sourceMappingURL=atribuir.js.map