add core plugins mv content imports and compiler artefacts mv utils mv compiler helpers mv compiler abstract rm compiler input mv all to solidity mv fetch and compile fixed imports mv offset line converter url resolver fix await calls packages package location versions func can be undefined window can be undefined settings dependency for contentimport undefined windowpull/5370/head
parent
dadc3309a9
commit
22bb7c365b
@ -1,46 +0,0 @@ |
||||
'use strict' |
||||
var remixLib = require('@remix-project/remix-lib') |
||||
var txHelper = remixLib.execution.txHelper |
||||
|
||||
module.exports = class CompilerAbstract { |
||||
constructor (languageversion, data, source) { |
||||
this.languageversion = languageversion |
||||
this.data = data |
||||
this.source = source // source code
|
||||
} |
||||
|
||||
getContracts () { |
||||
return this.data.contracts |
||||
} |
||||
|
||||
getContract (name) { |
||||
return txHelper.getContract(name, this.data.contracts) |
||||
} |
||||
|
||||
visitContracts (calllback) { |
||||
return txHelper.visitContracts(this.data.contracts, calllback) |
||||
} |
||||
|
||||
getData () { |
||||
return this.data |
||||
} |
||||
|
||||
getAsts () { |
||||
return this.data.sources // ast
|
||||
} |
||||
|
||||
getSourceName (fileIndex) { |
||||
if (this.data && this.data.sources) { |
||||
return Object.keys(this.data.sources)[fileIndex] |
||||
} else if (Object.keys(this.source.sources).length === 1) { |
||||
// if we don't have ast, we return the only one filename present.
|
||||
const sourcesArray = Object.keys(this.source.sources) |
||||
return sourcesArray[0] |
||||
} |
||||
return null |
||||
} |
||||
|
||||
getSourceCode () { |
||||
return this.source |
||||
} |
||||
} |
@ -1,21 +0,0 @@ |
||||
'use strict' |
||||
|
||||
module.exports = (sources, opts) => { |
||||
return JSON.stringify({ |
||||
language: 'Solidity', |
||||
sources: sources, |
||||
settings: { |
||||
optimizer: { |
||||
enabled: opts.optimize === true || opts.optimize === 1, |
||||
runs: 200 |
||||
}, |
||||
libraries: opts.libraries, |
||||
outputSelection: { |
||||
'*': { |
||||
'': ['ast'], |
||||
'*': ['abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates'] |
||||
} |
||||
} |
||||
} |
||||
}) |
||||
} |
@ -0,0 +1 @@ |
||||
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } |
@ -0,0 +1,3 @@ |
||||
# compiler-artefacts |
||||
|
||||
This library was generated with [Nx](https://nx.dev). |
@ -0,0 +1,11 @@ |
||||
{ |
||||
"name": "@remix-core-plugin/compiler-artefacts", |
||||
"version": "0.0.1", |
||||
"description": "This library was generated with [Nx](https://nx.dev).", |
||||
"main": "index.js", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"author": "Remix Team", |
||||
"license": "ISC" |
||||
} |
@ -0,0 +1 @@ |
||||
export * from './lib/compiler-artefacts' |
@ -1,16 +1,17 @@ |
||||
'use strict' |
||||
import { Plugin } from '@remixproject/engine' |
||||
import * as packageJson from '../../../../../package.json' |
||||
import CompilerAbstract from './compiler-abstract' |
||||
import { CompilerAbstract } from '@remix-project/remix-solidity' |
||||
|
||||
const profile = { |
||||
name: 'compilerArtefacts', |
||||
methods: [], |
||||
methods: ['get', 'addResolvedContract'], |
||||
events: [], |
||||
version: packageJson.version |
||||
version: '0.0.1' |
||||
} |
||||
|
||||
module.exports = class CompilerArtefacts extends Plugin { |
||||
export class CompilerArtefacts extends Plugin { |
||||
compilersArtefactsPerFile: any |
||||
compilersArtefacts: any |
||||
constructor () { |
||||
super(profile) |
||||
this.compilersArtefacts = {} |
@ -0,0 +1,10 @@ |
||||
{ |
||||
"extends": "../../../tsconfig.json", |
||||
"files": [], |
||||
"include": [], |
||||
"references": [ |
||||
{ |
||||
"path": "./tsconfig.lib.json" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,12 @@ |
||||
{ |
||||
"extends": "./tsconfig.json", |
||||
"compilerOptions": { |
||||
"module": "commonjs", |
||||
"outDir": "../../../dist/out-tsc", |
||||
"declaration": true, |
||||
"rootDir": "./src", |
||||
"types": ["node"] |
||||
}, |
||||
"exclude": ["**/*.spec.ts"], |
||||
"include": ["**/*.ts"] |
||||
} |
@ -0,0 +1 @@ |
||||
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } |
@ -0,0 +1,3 @@ |
||||
# compiler-content-imports |
||||
|
||||
This library was generated with [Nx](https://nx.dev). |
@ -0,0 +1,11 @@ |
||||
{ |
||||
"name": "@remix-core-plugin/compiler-content-imports", |
||||
"version": "0.0.1", |
||||
"description": "This library was generated with [Nx](https://nx.dev).", |
||||
"main": "index.js", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"author": "Remix Team", |
||||
"license": "ISC" |
||||
} |
@ -0,0 +1 @@ |
||||
export * from './lib/compiler-content-imports' |
@ -0,0 +1,10 @@ |
||||
{ |
||||
"extends": "../../../tsconfig.json", |
||||
"files": [], |
||||
"include": [], |
||||
"references": [ |
||||
{ |
||||
"path": "./tsconfig.lib.json" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,12 @@ |
||||
{ |
||||
"extends": "./tsconfig.json", |
||||
"compilerOptions": { |
||||
"module": "commonjs", |
||||
"outDir": "../../../dist/out-tsc", |
||||
"declaration": true, |
||||
"rootDir": "./src", |
||||
"types": ["node"] |
||||
}, |
||||
"exclude": ["**/*.spec.ts"], |
||||
"include": ["**/*.ts"] |
||||
} |
@ -0,0 +1 @@ |
||||
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } |
@ -0,0 +1,3 @@ |
||||
# compiler-fetch-and-compile |
||||
|
||||
This library was generated with [Nx](https://nx.dev). |
@ -0,0 +1,11 @@ |
||||
{ |
||||
"name": "@remix-core-plugin/compiler-fetch-and-compile", |
||||
"version": "0.0.1", |
||||
"description": "This library was generated with [Nx](https://nx.dev).", |
||||
"main": "index.js", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"author": "Remix Team", |
||||
"license": "ISC" |
||||
} |
@ -0,0 +1 @@ |
||||
export * from './lib/compiler-fetch-and-compile' |
@ -0,0 +1,10 @@ |
||||
{ |
||||
"extends": "../../../tsconfig.json", |
||||
"files": [], |
||||
"include": [], |
||||
"references": [ |
||||
{ |
||||
"path": "./tsconfig.lib.json" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,12 @@ |
||||
{ |
||||
"extends": "./tsconfig.json", |
||||
"compilerOptions": { |
||||
"module": "commonjs", |
||||
"outDir": "../../../dist/out-tsc", |
||||
"declaration": true, |
||||
"rootDir": "./src", |
||||
"types": ["node"] |
||||
}, |
||||
"exclude": ["**/*.spec.ts"], |
||||
"include": ["**/*.ts"] |
||||
} |
@ -0,0 +1 @@ |
||||
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } |
@ -0,0 +1,3 @@ |
||||
# offset-line-to-column-converter |
||||
|
||||
This library was generated with [Nx](https://nx.dev). |
@ -0,0 +1,11 @@ |
||||
{ |
||||
"name": "@remix-core-plugin/offset-line-to-column-converter", |
||||
"version": "0.0.1", |
||||
"description": "This library was generated with [Nx](https://nx.dev).", |
||||
"main": "index.js", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"author": "Remix Team", |
||||
"license": "ISC" |
||||
} |
@ -0,0 +1 @@ |
||||
export * from './lib/offset-line-to-column-converter' |
@ -0,0 +1,77 @@ |
||||
'use strict' |
||||
import { Plugin } from '@remixproject/engine' |
||||
|
||||
import { sourceMappingDecoder } from '@remix-project/remix-debug' |
||||
|
||||
const profile = { |
||||
name: 'offsetToLineColumnConverter', |
||||
methods: ['offsetToLineColumn'], |
||||
events: [], |
||||
version: '0.0.1' |
||||
} |
||||
|
||||
export class OffsetToLineColumnConverter extends Plugin { |
||||
lineBreakPositionsByContent: {} |
||||
sourceMappingDecoder: any |
||||
constructor () { |
||||
super(profile) |
||||
this.lineBreakPositionsByContent = {} |
||||
this.sourceMappingDecoder = sourceMappingDecoder |
||||
} |
||||
|
||||
/** |
||||
* Convert offset representation with line/column representation. |
||||
* This is also used to resolve the content: |
||||
* @arg file is the index of the file in the content sources array and content sources array does have filename as key and not index. |
||||
* So we use the asts (which references both index and filename) to look up the actual content targeted by the @arg file index. |
||||
* @param {{start, length}} rawLocation - offset location |
||||
* @param {number} file - The index where to find the source in the sources parameters |
||||
* @param {Object.<string, {content}>} sources - Map of content sources |
||||
* @param {Object.<string, {ast, id}>} asts - Map of content sources |
||||
*/ |
||||
offsetToLineColumn (rawLocation, file, sources, asts) { |
||||
if (!this.lineBreakPositionsByContent[file]) { |
||||
const sourcesArray = Object.keys(sources) |
||||
if (!asts || (file === 0 && sourcesArray.length === 1)) { |
||||
// if we don't have ast, we process the only one available content (applicable also for compiler older than 0.4.12)
|
||||
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[sourcesArray[0]].content) |
||||
} else { |
||||
for (var filename in asts) { |
||||
const source = asts[filename] |
||||
if (source.id === file) { |
||||
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) |
||||
break |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) |
||||
} |
||||
|
||||
/** |
||||
* Convert offset representation with line/column representation. |
||||
* @param {{start, length}} rawLocation - offset location |
||||
* @param {number} file - The index where to find the source in the sources parameters |
||||
* @param {string} content - source |
||||
*/ |
||||
offsetToLineColumnWithContent (rawLocation, file, content) { |
||||
this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(content) |
||||
return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) |
||||
} |
||||
|
||||
/** |
||||
* Clear the cache |
||||
*/ |
||||
clear () { |
||||
this.lineBreakPositionsByContent = {} |
||||
} |
||||
|
||||
/** |
||||
* called by plugin API |
||||
*/ |
||||
activate () { |
||||
this.on('solidity', 'compilationFinished', () => { |
||||
this.clear() |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,10 @@ |
||||
{ |
||||
"extends": "../../../tsconfig.json", |
||||
"files": [], |
||||
"include": [], |
||||
"references": [ |
||||
{ |
||||
"path": "./tsconfig.lib.json" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,12 @@ |
||||
{ |
||||
"extends": "./tsconfig.json", |
||||
"compilerOptions": { |
||||
"module": "commonjs", |
||||
"outDir": "../../../dist/out-tsc", |
||||
"declaration": true, |
||||
"rootDir": "./src", |
||||
"types": ["node"] |
||||
}, |
||||
"exclude": ["**/*.spec.ts"], |
||||
"include": ["**/*.ts"] |
||||
} |
@ -0,0 +1,48 @@ |
||||
'use strict' |
||||
import txHelper from './txHelper' |
||||
|
||||
export class CompilerAbstract { |
||||
languageversion: any |
||||
data: any |
||||
source: any |
||||
constructor (languageversion, data, source) { |
||||
this.languageversion = languageversion |
||||
this.data = data |
||||
this.source = source // source code
|
||||
} |
||||
|
||||
getContracts () { |
||||
return this.data.contracts |
||||
} |
||||
|
||||
getContract (name) { |
||||
return txHelper.getContract(name, this.data.contracts) |
||||
} |
||||
|
||||
visitContracts (calllback) { |
||||
return txHelper.visitContracts(this.data.contracts, calllback) |
||||
} |
||||
|
||||
getData () { |
||||
return this.data |
||||
} |
||||
|
||||
getAsts () { |
||||
return this.data.sources // ast
|
||||
} |
||||
|
||||
getSourceName (fileIndex) { |
||||
if (this.data && this.data.sources) { |
||||
return Object.keys(this.data.sources)[fileIndex] |
||||
} else if (Object.keys(this.source.sources).length === 1) { |
||||
// if we don't have ast, we return the only one filename present.
|
||||
const sourcesArray = Object.keys(this.source.sources) |
||||
return sourcesArray[0] |
||||
} |
||||
return null |
||||
} |
||||
|
||||
getSourceCode () { |
||||
return this.source |
||||
} |
||||
} |
@ -1,7 +1,7 @@ |
||||
'use strict' |
||||
import { canUseWorker, urlFromVersion } from './compiler-utils' |
||||
import { Compiler } from '@remix-project/remix-solidity' |
||||
import CompilerAbstract from './compiler-abstract' |
||||
import { CompilerAbstract } from './compiler-abstract' |
||||
import { Compiler } from './compiler' |
||||
|
||||
export const compile = async (compilationTargets, settings, contentResolverCallback) => { |
||||
const res = await (() => { |
@ -1,3 +1,6 @@ |
||||
export { Compiler } from './compiler/compiler' |
||||
export { compile } from './compiler/compiler-helpers' |
||||
export { default as CompilerInput } from './compiler/compiler-input' |
||||
export { CompilerAbstract } from './compiler/compiler-abstract' |
||||
export * from './compiler/types' |
||||
export * from './compiler/compiler-utils' |
||||
|
Loading…
Reference in new issue