MCPcopy Create free account
hub / github.com/CashScript/cashscript / processPragma

Method processPragma

packages/cashc/src/ast/AstBuilder.ts:119–133  ·  view source on GitHub ↗
(ctx: PragmaDirectiveContext)

Source from the content-addressed store, hash-verified

117 }
118
119 processPragma(ctx: PragmaDirectiveContext): void {
120 const pragmaName = getPragmaName(ctx.pragmaName().getText());
121 if (pragmaName !== PragmaName.CASHSCRIPT) throw new Error(); // Shouldn't happen
122
123 // Strip any -beta tags
124 const actualVersion = version.replace(/-.*/g, '');
125
126 ctx.pragmaValue().versionConstraint_list().forEach((constraint) => {
127 const op = getVersionOpFromCtx(constraint.versionOperator());
128 const versionConstraint = `${op}${constraint.VersionLiteral().getText()}`;
129 if (!semver.satisfies(actualVersion, versionConstraint)) {
130 throw new VersionError(actualVersion, versionConstraint);
131 }
132 });
133 }
134
135 visitContractDefinition(ctx: ContractDefinitionContext): ContractNode {
136 const name = ctx.Identifier().getText();

Callers 1

visitSourceFileMethod · 0.95

Calls 7

getPragmaNameFunction · 0.85
getVersionOpFromCtxFunction · 0.85
VersionLiteralMethod · 0.80
pragmaNameMethod · 0.45
pragmaValueMethod · 0.45
versionOperatorMethod · 0.45

Tested by

no test coverage detected