Skip to content

Commit 6cee84b

Browse files
authored
Modernize source file headers (AssemblyScript#1144)
1 parent a3b18e7 commit 6cee84b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+793
-548
lines changed

cli/asc.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview Definitions for asc.
3+
* @license Apache-2.0
4+
*/
5+
16
import { OptionDescription } from "./util/options";
27
export { OptionDescription };
38

cli/asc.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
"use strict";
21
/**
3-
* Compiler frontend for node.js
2+
* @license
3+
* Copyright 2020 Daniel Wirtz / The AssemblyScript Authors.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* SPDX-License-Identifier: Apache-2.0
18+
*/
19+
20+
/**
21+
* @fileoverview Compiler frontend for node.js
422
*
523
* Uses the low-level API exported from src/index.ts so it works with the compiler compiled to
624
* JavaScript as well as the compiler compiled to WebAssembly (eventually). Runs the sources
725
* directly through ts-node if distribution files are not present (indicated by a `-dev` version).
826
*
927
* Can also be packaged as a bundle suitable for in-browser use with the standard library injected
1028
* in the build step. See dist/asc.js for the bundle and webpack.config.js for building details.
11-
*
12-
* @module cli/asc
1329
*/
1430

1531
// Use "." instead of "/" as cwd in browsers

cli/transform.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Definitions for custom compiler transforms that can be applied with the `--transform` option.
3-
* @module cli/transform
4-
*//***/
2+
* @fileoverview Compiler transform interface definitions.
3+
* @license Apache-2.0
4+
*/
55

66
import { Program, Parser, Module } from "..";
77
import { OutputStream } from "./asc";

cli/transform.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
/**
2+
* @fileoverview Compiler transform interface.
3+
* @license Apache-2.0
4+
*/
5+
16
// becomes replaced with the actual base by asc
27
exports.Transform = function Transform() {};

cli/util/colors.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview Terminal colors utility definitions.
3+
* @license Apache-2.0
4+
*/
5+
16
interface Colors {
27
/** Whether terminal colors are supported. */
38
supported: boolean;

cli/util/colors.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview Terminal colors utility.
3+
* @license Apache-2.0
4+
*/
5+
16
var proc = typeof process !== "undefined" && process || {};
27
var isCI = proc.env && "CI" in proc.env; // doesn't work when bundled because 'process' is a mock
38

cli/util/find.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview File finding utility definitions.
3+
* @license Apache-2.0
4+
*/
5+
16
export function files(dirname: string, filter?: ((name: string) => bool) | RegExp): string[];
27
export const TS: RegExp;
38
export const TS_EXCEPT_DTS: RegExp;

cli/util/find.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview File finding utility.
3+
* @license Apache-2.0
4+
*/
5+
16
const fs = require("fs");
27
const path = require("path");
38

cli/util/mkdirp.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview Recursive mkdir definitions.
3+
* @license Apache-2.0
4+
*/
5+
16
interface Options {
27
mode?: number;
38
}

cli/util/mkdirp.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
/*
2-
Copyright 2010 James Halliday (mail@substack.net)
3-
4-
This project is free software released under the MIT/X11 license:
5-
6-
Permission is hereby granted, free of charge, to any person obtaining a copy
7-
of this software and associated documentation files (the "Software"), to deal
8-
in the Software without restriction, including without limitation the rights
9-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
copies of the Software, and to permit persons to whom the Software is
11-
furnished to do so, subject to the following conditions:
12-
13-
The above copyright notice and this permission notice shall be included in
14-
all copies or substantial portions of the Software.
15-
16-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22-
THE SOFTWARE.
23-
*/
1+
/**
2+
* @fileoverview Recursive mkdir.
3+
* @license
4+
* Copyright 2010 James Halliday (mail@substack.net)
5+
*
6+
* This project is free software released under the MIT/X11 license:
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
2426

2527
var path = require("path");
2628
var fs = require("fs");

cli/util/options.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview Command line options utility definitions.
3+
* @license Apache-2.0
4+
*/
5+
16
/** Command line option description. */
27
export interface OptionDescription {
38
/** Textual description. */

cli/util/options.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview Command line options utility.
3+
* @license Apache-2.0
4+
*/
5+
16
const colorsUtil = require("./colors");
27

38
// type | meaning

cli/util/utf8.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview UTF8 utility definitions.
3+
* @license Apache-2.0
4+
*/
5+
16
/**
27
* Calculates the UTF8 byte length of a string.
38
* @param {string} string String

cli/util/utf8.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @fileoverview UTF8 utility.
3+
* @license Apache-2.0
4+
*/
5+
16
// @protobufjs/utf8
27

38
/**

scripts/build-diagnostics.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ var fs = require("fs");
22

33
var messages = require(__dirname + "/../src/diagnosticMessages.json");
44

5-
var sb = [
6-
"/**\n",
7-
" * Generated from diagnosticsMessages.json. Do not edit.\n",
8-
" * @module diagnostics\n",
9-
" *//***/\n\n",
10-
"/* tslint:disable:max-line-length */\n\n"
11-
];
5+
var header = `/**
6+
* @fileoverview Generated from diagnosticsMessages.json. Do not edit.
7+
* @license Apache-2.0
8+
*/
9+
10+
/* tslint:disable:max-line-length */
11+
12+
`.replace(/\r\n/g, "\n");
13+
14+
var sb = [ header ];
1215

1316
function makeKey(text) {
1417
return text.replace(/[^\w]+/g, "_").replace(/_+$/, "");

src/ast.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
/**
2-
* Abstract syntax tree representing a source file once parsed.
3-
* @module ast
4-
*//***/
2+
* @fileoverview Abstract syntax tree representing a source file once parsed.
3+
*
4+
* Each node in the AST is represented by an instance of a subclass of `Node`,
5+
* with its `Node#kind` represented by one of the `NodeKind` constants, which
6+
* dependent code typically switches over. The intended way to create a node
7+
* is to use the respective `Node.createX` method instead of its constructor.
8+
*
9+
* Note that the AST does not contain any type information except type names.
10+
*
11+
* @license Apache-2.0
12+
*/
13+
14+
// TODO: Make the AST more easily serializable by refactoring `Node#range` so
15+
// it doesn't reference the non-serializable `Source` object.
516

617
import {
718
CommonFlags,

src/builtins.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
/**
2-
* Built-in elements providing WebAssembly core functionality.
3-
* @module builtins
4-
*//***/
2+
* @fileoverview Built-in elements providing core WebAssembly functionality.
3+
*
4+
* Each builtin is linked to its definition in std/assembly/builtins.ts.
5+
* When its prototype is called, the compiler recognizes the `@builtin`
6+
* decorator, looks up the respective handler in the global builtins map
7+
* and executes it, with the handler directly emitting WebAssembly code
8+
* according to context.
9+
*
10+
* Builtins can be categorized into core builtins that typically are generic
11+
* and emit code directly and aliases calling core builtins with overridden
12+
* contexts. The latter is used by inline assembler aliases of WebAssembly
13+
* instructions, like `i64.load8_u` deferring to `<i64>load<u8>`.
14+
*
15+
* The `contextIsExact` modifier is used to force a specific instruction
16+
* family. A `i32.store8` deferring to `<i32>store<i8>` for example is
17+
* ambiguous in that the input can still be an i32 or an i64, leading to
18+
* either an `i32.store8` or an `i64.store8`, so `i32` is forced there.
19+
* This behavior is indicated by `from i32/i64` in the comments below.
20+
*
21+
* @license Apache-2.0
22+
*/
23+
24+
// TODO: Add builtins for `i32.add` etc. that do not have a core builtin.
525

6-
import {
26+
import {
727
Compiler,
828
Constraints,
929
RuntimeFeatures
@@ -586,7 +606,7 @@ export class BuiltinContext {
586606
contextIsExact: bool;
587607
}
588608

589-
/** Registered builtins. */
609+
/** Global builtins map. */
590610
export const builtins = new Map<string,(ctx: BuiltinContext) => ExpressionRef>();
591611

592612
// === Static type evaluation =================================================================

src/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Common constants.
3-
* @module common
4-
*//***/
2+
* @fileoverview Common constants used by various parts of the compiler.
3+
* @license Apache-2.0
4+
*/
55

66
/** Indicates traits of a {@link Node} or {@link Element}. */
77
export enum CommonFlags {

src/compiler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* The AssemblyScript compiler.
3-
* @module compiler
4-
*//***/
2+
* @fileoverview The AssemblyScript compiler.
3+
* @license Apache-2.0
4+
*/
55

66
import {
77
BuiltinNames,

src/definitions.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
/**
2-
* Definition builders for WebIDL and TypeScript.
3-
* @module definitions
4-
*//***/
2+
* @fileoverview Builders for various definitions describing a module.
3+
*
4+
* - TSDBuilder: Creates a TypeScript definition file (.d.ts)
5+
* - IDLBuilder: Creates a WebIDL interface definition (.webidl)
6+
*
7+
* @license Apache-2.0
8+
*/
59

6-
import {
10+
import {
711
CommonFlags
812
} from "./common";
913

src/diagnosticMessages.generated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Generated from diagnosticsMessages.json. Do not edit.
3-
* @module diagnostics
4-
*//***/
2+
* @fileoverview Generated from diagnosticsMessages.json. Do not edit.
3+
* @license Apache-2.0
4+
*/
55

66
/* tslint:disable:max-line-length */
77

src/diagnostics.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/**
2-
* Shared diagnostic handling inherited by the parser and the compiler.
3-
* @module diagnostics
4-
* @preferred
5-
*//***/
2+
* @fileoverview Shared diagnostic handling.
3+
* @license Apache-2.0
4+
*/
65

76
import {
87
Range

src/extra/ast.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* Abstract Syntax Tree extras.
2+
* @fileoverview Abstract Syntax Tree extras.
33
*
4-
* Not needed in a standalone compiler but useful for testing the parser.
4+
* Provides serialization of the AssemblyScript AST back to it source form.
55
*
6-
* @module extra/ast
7-
*//***/
6+
* @license Apache-2.0
7+
*/
88

99
import {
1010
Node,

0 commit comments

Comments
 (0)