From d49acf2bd4334b37a00087ca27ec20192f76b77f Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 9 Oct 2020 00:59:40 +0530 Subject: [PATCH] legacyAST removed --- apps/remix-ide/src/app/compiler/compiler-input.js | 2 +- libs/remix-analyzer/src/types.ts | 10 ---------- libs/remix-astwalker/src/astWalker.ts | 10 +++++----- libs/remix-astwalker/src/types.ts | 9 --------- libs/remix-astwalker/tests/resources/legacyAST.ts | 2 +- libs/remix-debug/bin/rdb | 2 +- libs/remix-debug/test.js | 2 +- libs/remix-debug/test/helpers/compilerHelper.js | 2 +- libs/remix-lib/src/helpers/compilerHelper.js | 2 +- libs/remix-solidity/src/compiler/compiler-input.ts | 2 +- libs/remix-solidity/src/compiler/types.ts | 12 +----------- libs/remix-tests/src/types.ts | 10 ---------- 12 files changed, 13 insertions(+), 52 deletions(-) diff --git a/apps/remix-ide/src/app/compiler/compiler-input.js b/apps/remix-ide/src/app/compiler/compiler-input.js index 326eaba816..150ca56173 100644 --- a/apps/remix-ide/src/app/compiler/compiler-input.js +++ b/apps/remix-ide/src/app/compiler/compiler-input.js @@ -12,7 +12,7 @@ module.exports = (sources, opts) => { libraries: opts.libraries, outputSelection: { '*': { - '': [ 'legacyAST', 'ast'], + '': [ 'ast'], '*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ] } } diff --git a/libs/remix-analyzer/src/types.ts b/libs/remix-analyzer/src/types.ts index bb22f630e2..5eaccca5c9 100644 --- a/libs/remix-analyzer/src/types.ts +++ b/libs/remix-analyzer/src/types.ts @@ -720,8 +720,6 @@ export interface CommonYulAstNode { id: number /** The AST object */ ast: AstNode - /** The legacy AST object */ - legacyAST: AstNodeLegacy } ///////// @@ -742,14 +740,6 @@ export interface CommonYulAstNode { [x: string]: any } - export interface AstNodeLegacy { - id: number - name: string - src: string - children?: Array - attributes?: AstNodeAtt - } - export interface AstNodeAtt { operator?: string string?: null diff --git a/libs/remix-astwalker/src/astWalker.ts b/libs/remix-astwalker/src/astWalker.ts index 5ee9e46e71..f6563ded0a 100644 --- a/libs/remix-astwalker/src/astWalker.ts +++ b/libs/remix-astwalker/src/astWalker.ts @@ -1,5 +1,5 @@ import { EventEmitter } from "events"; -import { AstNodeLegacy, Node, AstNode } from "./index"; +import { Node, AstNode } from "./index"; export declare interface AstWalker { new(): EventEmitter; @@ -34,16 +34,16 @@ export function isAstNode(node: Record): boolean { */ export class AstWalker extends EventEmitter { manageCallback( - node: AstNodeLegacy | AstNode, + node: AstNode, callback: Record | Function // eslint-disable-line @typescript-eslint/ban-types ): any { // FIXME: we shouldn't be doing this callback determination type on each AST node, // since the callback function is set once per walk. // Better would be to store the right one as a variable and // return that. - if (node) { - if ((node).name in callback) { - return callback[(node).name](node); + if (node) { + if ((node).name in callback) { + return callback[(node).name](node); } else { return callback["*"](node); } diff --git a/libs/remix-astwalker/src/types.ts b/libs/remix-astwalker/src/types.ts index c924615e92..7ffc364249 100644 --- a/libs/remix-astwalker/src/types.ts +++ b/libs/remix-astwalker/src/types.ts @@ -24,7 +24,6 @@ export interface LineColRange { export interface Node { ast?: AstNode; - legacyAST?: AstNodeLegacy; source?: string; id?: number; } @@ -47,14 +46,6 @@ export interface AstNode { [x: string]: any; } -export interface AstNodeLegacy { - id: number; // This is unique across all nodes in an AST tree - name: string; // This corresponds to "nodeType" in ASTNode - src: string; - children?: Array; // This corresponds to "nodes" in ASTNode - attributes?: AstNodeAtt; -} - export interface AstNodeAtt { operator?: string; string?: null; diff --git a/libs/remix-astwalker/tests/resources/legacyAST.ts b/libs/remix-astwalker/tests/resources/legacyAST.ts index ca3898f011..d3388b1f90 100644 --- a/libs/remix-astwalker/tests/resources/legacyAST.ts +++ b/libs/remix-astwalker/tests/resources/legacyAST.ts @@ -1,5 +1,5 @@ import { Node } from '../../src/' -let node: Node; +let node: any; node = { "legacyAST": { "children": [{ "attributes": { "literals": ["solidity", ">=", "0.5", ".0", "<", "0.6", ".0"] }, "id": 1, "name": "PragmaDirective", "src": "0:31:0" }, { "attributes": { "SourceUnit": 53, "absolutePath": "mortal.sol", "file": "mortal.sol", "scope": 26, "symbolAliases": [null], "unitAlias": "" }, "id": 2, "name": "ImportDirective", "src": "32:20:0" }, { "attributes": { "contractDependencies": [52], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [25, 52], "name": "Greeter", "scope": 26 }, "children": [{ "attributes": { "arguments": null }, "children": [{ "attributes": { "contractScope": null, "name": "Mortal", "referencedDeclaration": 52, "type": "contract Mortal" }, "id": 3, "name": "UserDefinedTypeName", "src": "74:6:0" }], "id": 4, "name": "InheritanceSpecifier", "src": "74:6:0" }, { "attributes": { "constant": false, "name": "greeting", "scope": 25, "stateVariable": true, "storageLocation": "default", "type": "string", "value": null, "visibility": "internal" }, "children": [{ "attributes": { "name": "string", "type": "string" }, "id": 5, "name": "ElementaryTypeName", "src": "141:6:0" }], "id": 6, "name": "VariableDeclaration", "src": "141:15:0" }, { "attributes": { "documentation": null, "implemented": true, "isConstructor": true, "kind": "constructor", "modifiers": [null], "name": "", "scope": 25, "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" }, "children": [{ "children": [{ "attributes": { "constant": false, "name": "_greeting", "scope": 16, "stateVariable": false, "storageLocation": "memory", "type": "string", "value": null, "visibility": "internal" }, "children": [{ "attributes": { "name": "string", "type": "string" }, "id": 7, "name": "ElementaryTypeName", "src": "225:6:0" }], "id": 8, "name": "VariableDeclaration", "src": "225:23:0" }], "id": 9, "name": "ParameterList", "src": "224:25:0" }, { "attributes": { "parameters": [null] }, "children": [], "id": 10, "name": "ParameterList", "src": "257:0:0" }, { "children": [{ "children": [{ "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "=", "type": "string storage ref" }, "children": [{ "attributes": { "argumentTypes": null, "overloadedDeclarations": [null], "referencedDeclaration": 6, "type": "string storage ref", "value": "greeting" }, "id": 11, "name": "Identifier", "src": "267:8:0" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [null], "referencedDeclaration": 8, "type": "string memory", "value": "_greeting" }, "id": 12, "name": "Identifier", "src": "278:9:0" }], "id": 13, "name": "Assignment", "src": "267:20:0" }], "id": 14, "name": "ExpressionStatement", "src": "267:20:0" }], "id": 15, "name": "Block", "src": "257:37:0" }], "id": 16, "name": "FunctionDefinition", "src": "213:81:0" }, { "attributes": { "documentation": null, "implemented": true, "isConstructor": false, "kind": "function", "modifiers": [null], "name": "greet", "scope": 25, "stateMutability": "view", "superFunction": null, "visibility": "public" }, "children": [{ "attributes": { "parameters": [null] }, "children": [], "id": 17, "name": "ParameterList", "src": "338:2:0" }, { "children": [{ "attributes": { "constant": false, "name": "", "scope": 24, "stateVariable": false, "storageLocation": "memory", "type": "string", "value": null, "visibility": "internal" }, "children": [{ "attributes": { "name": "string", "type": "string" }, "id": 18, "name": "ElementaryTypeName", "src": "362:6:0" }], "id": 19, "name": "VariableDeclaration", "src": "362:13:0" }], "id": 20, "name": "ParameterList", "src": "361:15:0" }, { "children": [{ "attributes": { "functionReturnParameters": 20 }, "children": [{ "attributes": { "argumentTypes": null, "overloadedDeclarations": [null], "referencedDeclaration": 6, "type": "string storage ref", "value": "greeting" }, "id": 21, "name": "Identifier", "src": "394:8:0" }], "id": 22, "name": "Return", "src": "387:15:0" }], "id": 23, "name": "Block", "src": "377:32:0" }], "id": 24, "name": "FunctionDefinition", "src": "324:85:0" }], "id": 25, "name": "ContractDefinition", "src": "54:357:0" }], "name": "SourceUnit", "attributes": { "absolutePath": "greeter.sol", "exportedSymbols": { "Greeter": [25] } }, "id": 26, "src": "0:412:0" } } diff --git a/libs/remix-debug/bin/rdb b/libs/remix-debug/bin/rdb index fcee04b8d8..edb866e5ce 100755 --- a/libs/remix-debug/bin/rdb +++ b/libs/remix-debug/bin/rdb @@ -44,7 +44,7 @@ const inputJson = { }, outputSelection: { '*': { - '': [ 'legacyAST' ], + '': [ 'ast' ], '*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ] } } diff --git a/libs/remix-debug/test.js b/libs/remix-debug/test.js index abfa0da629..e1749a27d9 100644 --- a/libs/remix-debug/test.js +++ b/libs/remix-debug/test.js @@ -19,7 +19,7 @@ var inputJson = { }, outputSelection: { '*': { - '': [ 'legacyAST' ], + '': [ 'ast' ], '*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ] } } diff --git a/libs/remix-debug/test/helpers/compilerHelper.js b/libs/remix-debug/test/helpers/compilerHelper.js index ba919c2abb..1bc2c13996 100644 --- a/libs/remix-debug/test/helpers/compilerHelper.js +++ b/libs/remix-debug/test/helpers/compilerHelper.js @@ -17,7 +17,7 @@ function compilerInput (contracts) { }, outputSelection: { '*': { - '': [ 'legacyAST', 'ast' ], + '': [ 'ast' ], '*': [ 'abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ] } } diff --git a/libs/remix-lib/src/helpers/compilerHelper.js b/libs/remix-lib/src/helpers/compilerHelper.js index ba919c2abb..1bc2c13996 100644 --- a/libs/remix-lib/src/helpers/compilerHelper.js +++ b/libs/remix-lib/src/helpers/compilerHelper.js @@ -17,7 +17,7 @@ function compilerInput (contracts) { }, outputSelection: { '*': { - '': [ 'legacyAST', 'ast' ], + '': [ 'ast' ], '*': [ 'abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ] } } diff --git a/libs/remix-solidity/src/compiler/compiler-input.ts b/libs/remix-solidity/src/compiler/compiler-input.ts index e65ae5fb82..ff527a1ca0 100644 --- a/libs/remix-solidity/src/compiler/compiler-input.ts +++ b/libs/remix-solidity/src/compiler/compiler-input.ts @@ -14,7 +14,7 @@ export default (sources: Source, opts: CompilerInputOptions): string => { libraries: opts.libraries, outputSelection: { '*': { - '': [ 'legacyAST', 'ast' ], + '': [ 'ast' ], '*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates', 'evm.assembly' ] } } diff --git a/libs/remix-solidity/src/compiler/types.ts b/libs/remix-solidity/src/compiler/types.ts index 42691d51c4..bbbd9624f1 100644 --- a/libs/remix-solidity/src/compiler/types.ts +++ b/libs/remix-solidity/src/compiler/types.ts @@ -122,7 +122,7 @@ export interface CompilerInput { // outputSelection?: { '*': { - '': [ 'legacyAST', 'ast' ], + '': [ 'ast' ], '*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates', 'evm.assembly' ] } } @@ -266,8 +266,6 @@ export interface CompilationResult { id: number /** The AST object */ ast: AstNode - /** The legacy AST object */ - legacyAST: AstNodeLegacy } ///////// @@ -288,14 +286,6 @@ export interface CompilationResult { [x: string]: any } - export interface AstNodeLegacy { - id: number - name: string - src: string - children?: Array - attributes?: AstNodeAtt - } - export interface AstNodeAtt { operator?: string string?: null diff --git a/libs/remix-tests/src/types.ts b/libs/remix-tests/src/types.ts index e6c996c355..a57f557726 100644 --- a/libs/remix-tests/src/types.ts +++ b/libs/remix-tests/src/types.ts @@ -81,16 +81,6 @@ export interface CompilationSource { id: number /** The AST object */ ast: AstNode - /** The legacy AST object */ - legacyAST: AstNodeLegacy -} - -export interface AstNodeLegacy { - id: number - name: string - src: string - children?: Array - attributes?: AstNodeAtt } export interface AstNodeAtt {