Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 164x 164x 164x 164x 46x 46x 46x 46x 43x 3x 3x 40x 40x 46x 46x 40x 46x 46x 46x 46x 46x 46x 46x 46x 46x 1x 1x 46x 157x 157x 157x 1x | import {ExpressionNode} from "../../nodes"; import {AnyType, CLikeType, CharacterType, NumericGenericType, NumericType, StringType, StructureType, UnknownType, VoidType} from "../../types/basic"; import {AbstractType} from "../../types/basic/_abstract_type"; import * as Expressions from "../../2_statements/expressions"; import {CurrentScope} from "../_current_scope"; import {Source} from "./source"; import {TypeUtils} from "../_type_utils"; export class StringTemplate { public runSyntax(node: ExpressionNode, scope: CurrentScope, filename: string): AbstractType { const typeUtils = new TypeUtils(scope); const ret = StringType.get(); for (const templateSource of node.findAllExpressions(Expressions.StringTemplateSource)) { const s = templateSource.findDirectExpression(Expressions.Source); const type = new Source().runSyntax(s, scope, filename, ret); if (type === undefined) { throw new Error("No target type determined"); } else if ((typeUtils.isCharLike(type) === false && typeUtils.isHexLike(type) === false) || type instanceof StructureType) { throw new Error("String template, not character like, " + type.constructor.name); } const format = templateSource.findDirectExpression(Expressions.StringTemplateFormatting); const formatConcat = format?.concatTokens(); for (const formatSource of format?.findAllExpressions(Expressions.Source) || []) { new Source().runSyntax(formatSource, scope, filename); } if (formatConcat?.includes("ALPHA = ") && !(type instanceof UnknownType) && !(type instanceof VoidType) && !(type instanceof StringType) && !(type instanceof CLikeType) && !(type instanceof CharacterType) && !(type instanceof NumericGenericType) && !(type instanceof NumericType) && !(type instanceof AnyType)) { throw new Error("Cannot apply ALPHA to this type"); } } return ret; } } |