diff --git a/NOTICE b/NOTICE index 6b1a795506..1836dd6c2d 100644 --- a/NOTICE +++ b/NOTICE @@ -36,6 +36,7 @@ under the licensing terms detailed in LICENSE: * Peter Salomonsen * ookangzheng * yjhmelody +* bnbarak Portions of this software are derived from third-party works licensed under the following terms: @@ -61,6 +62,6 @@ the following terms: The 3-Clause BSD License (https://opensource.org/licenses/BSD-3-Clause) * Arm Optimized Routines: https://github.com/ARM-software/optimized-routines - + Copyright (c) Arm Limited The MIT License (https://opensource.org/licenses/MIT) diff --git a/cli/asc.js b/cli/asc.js index 931c17a31c..f9c8a86b7e 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -245,6 +245,15 @@ exports.main = function main(argv, options, callback) { options = {}; } + // Bundle semantic version + let bundleMinorVersion = 0, bundleMajorVersion = 0, bundlePatchVersion = 0; + const versionParts = (exports.version || "").split("."); + if (versionParts.length === 3) { + bundleMajorVersion = parseInt(versionParts[0]) | 0; + bundleMinorVersion = parseInt(versionParts[1]) | 0; + bundlePatchVersion = parseInt(versionParts[2]) | 0; + } + const stdout = options.stdout || process.stdout; const stderr = options.stderr || process.stderr; const readFile = options.readFile || readFileNode; @@ -422,6 +431,7 @@ exports.main = function main(argv, options, callback) { assemblyscript.setPedantic(compilerOptions, opts.pedantic); assemblyscript.setLowMemoryLimit(compilerOptions, opts.lowMemoryLimit >>> 0); assemblyscript.setExportRuntime(compilerOptions, opts.exportRuntime); + assemblyscript.setBundleVersion(compilerOptions, bundleMajorVersion, bundleMinorVersion, bundlePatchVersion); if (!opts.stackSize && opts.runtime == "incremental") { opts.stackSize = assemblyscript.DEFAULT_STACK_SIZE; } diff --git a/src/common.ts b/src/common.ts index 0beb11c26b..6a67b3fd05 100644 --- a/src/common.ts +++ b/src/common.ts @@ -178,6 +178,9 @@ export namespace CommonNames { export const ASC_FEATURE_MULTI_VALUE = "ASC_FEATURE_MULTI_VALUE"; export const ASC_FEATURE_GC = "ASC_FEATURE_GC"; export const ASC_FEATURE_MEMORY64 = "ASC_FEATURE_MEMORY64"; + export const ASC_VERSION_MAJOR = "ASC_VERSION_MAJOR"; + export const ASC_VERSION_MINOR = "ASC_VERSION_MINOR"; + export const ASC_VERSION_PATCH = "ASC_VERSION_PATCH"; // classes export const I8 = "I8"; export const I16 = "I16"; diff --git a/src/compiler.ts b/src/compiler.ts index c7ea707feb..786f3619f0 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -251,6 +251,12 @@ export class Options { exportRuntime: bool = false; /** Stack size in bytes, if using a stack. */ stackSize: i32 = 0; + /** Semantic major bundle version from root package.json */ + bundleMajorVersion: i32 = 0; + /** Semantic minor bundle version from root package.json */ + bundleMinorVersion: i32 = 0; + /** Semantic patch bundle version from root package.json */ + bundlePatchVersion: i32 = 0; /** Hinted optimize level. Not applied by the compiler itself. */ optimizeLevelHint: i32 = 0; @@ -1509,7 +1515,7 @@ export class Compiler extends DiagnosticEmitter { if (!this.compileFunctionBody(instance, stmts)) { stmts.push(module.unreachable()); } - + this.currentFlow = previousFlow; // create the function @@ -7533,7 +7539,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.local_tee(local.index, expr, ftype.isManaged); } } - + return expr; } diff --git a/src/index.ts b/src/index.ts index 9ae88ab49d..93019b838c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -142,6 +142,18 @@ export function setStackSize(options: Options, stackSize: i32): void { options.stackSize = stackSize; } +/** Sets the bundle semantic version. */ +export function setBundleVersion( + options: Options, + bundleMajorVersion: i32, + bundleMinorVersion: i32, + bundlePatchVersion: i32, +): void { + options.bundleMajorVersion = bundleMajorVersion; + options.bundleMinorVersion = bundleMinorVersion; + options.bundlePatchVersion = bundlePatchVersion; +} + /** Sign extension operations. */ export const FEATURE_SIGN_EXTENSION = Feature.SIGN_EXTENSION; /** Mutable global imports and exports. */ diff --git a/src/program.ts b/src/program.ts index 833a9682d4..8e38b2686f 100644 --- a/src/program.ts +++ b/src/program.ts @@ -1013,6 +1013,12 @@ export class Program extends DiagnosticEmitter { i64_new(options.lowMemoryLimit, 0)); this.registerConstantInteger(CommonNames.ASC_EXPORT_RUNTIME, Type.bool, i64_new(options.exportRuntime ? 1 : 0, 0)); + this.registerConstantInteger(CommonNames.ASC_VERSION_MAJOR, Type.i32, + i64_new(options.bundleMajorVersion)); + this.registerConstantInteger(CommonNames.ASC_VERSION_MINOR, Type.i32, + i64_new(options.bundleMinorVersion)); + this.registerConstantInteger(CommonNames.ASC_VERSION_PATCH, Type.i32, + i64_new(options.bundlePatchVersion)); // register feature hints this.registerConstantInteger(CommonNames.ASC_FEATURE_SIGN_EXTENSION, Type.bool, @@ -3084,8 +3090,8 @@ export class File extends Element { /** Creates an imported namespace from this file. */ asAliasNamespace( - name: string, - parent: Element, + name: string, + parent: Element, localIdentifier: IdentifierExpression ): Namespace { var declaration = this.program.makeNativeNamespaceDeclaration(name); diff --git a/tests/compiler/asc-constants.ts b/tests/compiler/asc-constants.ts index 3b007986a3..049e86b33b 100644 --- a/tests/compiler/asc-constants.ts +++ b/tests/compiler/asc-constants.ts @@ -16,3 +16,7 @@ ASC_FEATURE_REFERENCE_TYPES; ASC_FEATURE_MULTI_VALUE; ASC_FEATURE_GC; ASC_FEATURE_MEMORY64; + +ASC_VERSION_MAJOR; +ASC_VERSION_MINOR; +ASC_VERSION_PATCH; diff --git a/tests/compiler/asc-constants.untouched.wat b/tests/compiler/asc-constants.untouched.wat index b57c8e0d6e..c17173ce8a 100644 --- a/tests/compiler/asc-constants.untouched.wat +++ b/tests/compiler/asc-constants.untouched.wat @@ -19,6 +19,9 @@ (global $~lib/ASC_FEATURE_MULTI_VALUE i32 (i32.const 0)) (global $~lib/ASC_FEATURE_GC i32 (i32.const 0)) (global $~lib/ASC_FEATURE_MEMORY64 i32 (i32.const 0)) + (global $~lib/ASC_VERSION_MAJOR i32 (i32.const 0)) + (global $~lib/ASC_VERSION_MINOR i32 (i32.const 0)) + (global $~lib/ASC_VERSION_PATCH i32 (i32.const 0)) (global $~lib/memory/__data_end i32 (i32.const 8)) (global $~lib/memory/__stack_pointer (mut i32) (i32.const 16392)) (global $~lib/memory/__heap_base i32 (i32.const 16392)) @@ -59,6 +62,12 @@ drop i32.const 0 drop + i32.const 0 + drop + i32.const 0 + drop + i32.const 0 + drop ) (func $~start call $start:asc-constants pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy