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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import * as Expressions from "../../2_statements/expressions";
import {StatementNode} from "../../nodes";
import {InlineData} from "../expressions/inline_data";
import {AnyType, DataType, PackedType, UnknownType, UTCLongType, VoidType} from "../../types/basic";
import {AbstractType} from "../../types/basic/_abstract_type";
import {Target} from "../expressions/target";
import {StatementSyntax} from "../_statement_syntax";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
export class GetTime implements StatementSyntax {
public runSyntax(node: StatementNode, input: SyntaxInput): void {
const target = node.findDirectExpression(Expressions.Target);
const stamp = node.findDirectTokenByText("STAMP") !== undefined;
const inline = target?.findDirectExpression(Expressions.InlineData);
if (inline) {
InlineData.runSyntax(inline, input, new PackedType(8, 0));
} else if (target) {
const type = Target.runSyntax(target, input);
if (stamp === true && this.compatibleTimeStamp(type) === false) {
const message = "GET TIME STAMP FIELD, target type not compatible";
input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
return;
}
}
}
// the target must be a timestamp, ie. packed(timestamp and timestampl) or utclong
private compatibleTimeStamp(type: AbstractType | undefined): boolean {
return type === undefined
|| type instanceof PackedType
|| type instanceof UTCLongType
|| type instanceof VoidType
|| type instanceof AnyType
|| type instanceof DataType
|| type instanceof UnknownType
|| type.isGeneric();
}
}
|