diff --git a/remix-analyzer/src/types.ts b/remix-analyzer/src/types.ts index 95f362f88a..6f19f5c39b 100644 --- a/remix-analyzer/src/types.ts +++ b/remix-analyzer/src/types.ts @@ -40,7 +40,490 @@ export interface CompilationResult { } } } - + +///////////////////////////////////////////// +///////////// Specfic AST Nodes ///////////// +///////////////////////////////////////////// + +export interface SourceUnitAstNode { + id: number + nodeType: 'SourceUnit' + src: string + absolutePath: string + exportedSymbols: Object + nodes: Array +} + +export interface PragmaDirectiveAstNode { + id: number + nodeType: 'PragmaDirective' + src: string + literals?: Array +} + +export interface ImportDirectiveAstNode { + id: number + nodeType: 'ImportDirective' + src: string + absolutePath: string + file: string + scope: number + sourceUnit: number + symbolAliases: Array +} + +export interface ContractDefinitionAstNode { + id: number + nodeType: 'ContractDefinition' + src: string + name: string + documentation: Object + contractKind: 'interface' | 'contract' | 'library' + abstract: string + fullyImplemented: Object + linearizedBaseContracts: Object + baseContracts: Object + contractDependencies: Object + nodes: Array + scope: number +} + +export interface InheritanceSpecifierAstNode { + id: number + nodeType: 'InheritanceSpecifier' + src: string + baseName: string + arguments: Object +} + +export interface UsingForDirectiveAstNode { + id: number + nodeType: 'UsingForDirective' + src: string + libraryName: Object + typeName: Object +} + +export interface StructDefinitionAstNode { + id: number + nodeType: 'StructDefinition' + src: string + name: string + visibility: string + canonicalName: string + members: Object + scope: number +} + +export interface EnumDefinitionAstNode { + id: number + nodeType: 'EnumDefinition' + src: string + name: string + canonicalName: string + members: Object +} + +export interface EnumValueAstNode { + id: number + nodeType: 'EnumValue' + src: string + name: string +} + +export interface ParameterListAstNode { + id: number + nodeType: 'ParameterList' + src: string + parameters: Object +} + +export interface OverrideSpecifierAstNode { + id: number + nodeType: 'OverrideSpecifier' + src: string + overrides: Object +} + +export interface FunctionDefinitionAstNode { + id: number + nodeType: 'FunctionDefinition' + src: string + name: string + documentation: Object + kind: string + stateMutability: string + visibility: string + virtual: boolean + overrides: Object + parameters: Object + returnParameters: Object + modifiers: Object + body: Object + implemented: boolean + scope: number + functionSelector?: string + baseFunctions?: Object +} + +export interface VariableDeclarationAstNode { + id: number + nodeType: 'VariableDeclaration' + src: string + name: string + typeName: Object + constant: boolean + stateVariable: boolean + storageLocation: 'storage' | 'memory' | 'calldata' | 'default' + overrides: Object + visibility: string + value: Object + scope: number + typeDescriptions: Object + functionSelector?: string + indexed?: boolean + baseFunctions?: Object +} + +export interface ModifierDefinitionAstNode { + id: number + nodeType: 'ModifierDefinition' + src: string + name: string + documentation: Object + visibility: string + parameters: Object + virtual: boolean + overrides: Object + body: Object + baseModifiers?: Object +} + +export interface ModifierInvocationAstNode { + id: number + nodeType: 'ModifierInvocation' + src: string + modifierName: Object + arguments: Object +} + +export interface EventDefinitionAstNode { + id: number + nodeType: 'EventDefinition' + src: string + name: string + documentation: Object + parameters: Object + anonymous: boolean +} + +export interface ElementaryTypeNameAstNode { + id: number + nodeType: 'ElementaryTypeName' + src: string + name: string + typeDescriptions: Object + stateMutability?: string +} + +export interface UserDefinedTypeNameAstNode { + id: number + nodeType: 'UserDefinedTypeName' + src: string + name: string + referencedDeclaration: number + contractScope: number + typeDescriptions: Object +} + +export interface FunctionTypeNameAstNode { + id: number + nodeType: 'FunctionTypeName' + src: string + name: string + visibility: string + stateMutability: string + parameterTypes: Object + returnParameterTypes: Object + typeDescriptions: Object +} + +export interface MappingAstNode { + id: number + nodeType: 'Mapping' + src: string + keyType: Object + valueType: Object + typeDescriptions: Object +} + +export interface ArrayTypeNameAstNode { + id: number + nodeType: 'ArrayTypeName' + src: string + baseType: Object + length: Object + typeDescriptions: Object +} + +export interface InlineAssemblyAstNode { + id: number + nodeType: 'InlineAssembly' + src: string + AST: Object + externalReferences: Object + evmVersion: string +} + +export interface BlockAstNode { + id: number + nodeType: 'Block' + src: string + statements: Object +} + +export interface PlaceholderStatementAstNode { + id: number + nodeType: 'PlaceholderStatement' + src: string +} + +export interface IfStatementAstNode { + id: number + nodeType: 'IfStatement' + src: string + condition: Object + trueBody: Object + falseBody: Object +} + +export interface TryCatchClauseAstNode { + id: number + nodeType: 'TryCatchClause' + src: string + errorName: string + parameters: Object + block: Object +} + +export interface TryStatementAstNode { + id: number + nodeType: 'TryStatement' + src: string + externalCall: Object + clauses: Object +} + +export interface WhileStatementAstNode { + id: number + nodeType: 'WhileStatement' | 'DoWhileStatement' + src: string + condition: Object + body: Object +} + +export interface ForStatementAstNode { + id: number + nodeType: 'ForStatement' + src: string + initializationExpression: Object + condition: Object + loopExpression: Object + body: Object +} + +export interface ContinueAstNode { + id: number + nodeType: 'Continue' + src: string +} + +export interface BreakAstNode { + id: number + nodeType: 'Break' + src: string +} + +export interface ReturnAstNode { + id: number + nodeType: 'Return' + src: string + expression: Object + functionReturnParameters: Object +} + +export interface ThrowAstNode { + id: number + nodeType: 'Throw' + src: string +} + +export interface EmitStatementAstNode { + id: number + nodeType: 'EmitStatement' + src: string + eventCall: Object +} + +export interface VariableDeclarationStatementAstNode { + id: number + nodeType: 'VariableDeclarationStatement' + src: string + assignments: Object + declarations: Object + initialValue: Object +} + +export interface ExpressionStatementAstNode { + id: number + nodeType: 'ExpressionStatement' + src: string + expression: Object +} + +interface ExpressionAttributes { + typeDescriptions: Object + isConstant: boolean + isPure: boolean + isLValue: boolean + lValueRequested: boolean + argumentTypes: Object +} + +export interface ConditionalAstNode extends ExpressionAttributes { + id: number + nodeType: 'Conditional' + src: string + condition: Object + trueExpression: Object + falseExpression: Object +} + +export interface AssignmentAstNode extends ExpressionAttributes { + id: number + nodeType: 'Assignment' + src: string + operator: string + leftHandSide: Object + rightHandSide: Object +} + +export interface TupleExpressionAstNode extends ExpressionAttributes { + id: number + nodeType: 'TupleExpression' + src: string + isInlineArray: boolean + components: Object +} + +export interface UnaryOperationAstNode extends ExpressionAttributes { + id: number + nodeType: 'UnaryOperation' + src: string + prefix: boolean + operator: string + subExpression: Object +} + +export interface BinaryOperationAstNode extends ExpressionAttributes { + id: number + nodeType: 'BinaryOperation' + src: string + operator: string + leftExpression: Object + rightExpression: Object + commonType: Object +} + +export interface FunctionCallAstNode extends ExpressionAttributes { + id: number + nodeType: 'FunctionCall' + src: string + expression: Object + names: Object + arguments: Object + tryCall: boolean + kind: 'functionCall' | 'typeConversion' | 'structConstructorCall' +} + +export interface FunctionCallOptionsAstNode extends ExpressionAttributes { + id: number + nodeType: 'FunctionCallOptions' + src: string + expression: Object + names: Object + options: Object +} + +export interface NewExpressionAstNode extends ExpressionAttributes { + id: number + nodeType: 'NewExpression' + src: string + typeName: Object +} + +export interface MemberAccessAstNode extends ExpressionAttributes { + id: number + nodeType: 'MemberAccess' + src: string + memberName: string + expression: Object + referencedDeclaration: Object +} + +export interface IndexAccessAstNode extends ExpressionAttributes { + id: number + nodeType: 'IndexAccess' + src: string + baseExpression: Object + indexExpression: Object +} + +export interface IndexRangeAccessAstNode extends ExpressionAttributes { + id: number + nodeType: 'IndexRangeAccess' + src: string + baseExpression: Object + startExpression: Object + endExpression: Object +} + +export interface ElementaryTypeNameExpressionAstNode extends ExpressionAttributes { + id: number + nodeType: 'ElementaryTypeNameExpression' + src: string + typeName: Object +} + +export interface LiteralAstNode extends ExpressionAttributes { + id: number + nodeType: 'Literal' + src: string + kind: 'number' | 'string' | 'bool' + value: string + hexValue: string + subdenomination: Object +} + +export interface IdentifierAstNode { + id: number + nodeType: 'Identifier' + src: string + name: string + referencedDeclaration: Object + overloadedDeclarations: Object + typeDescriptions: Object + argumentTypes: Object +} + +export interface StructuredDocumentationAstNode { + id: number + nodeType: 'StructuredDocumentation' + src: string + text: string +} + + /////////// // ERROR // /////////// diff --git a/remix-lib/src/helpers/compilerHelper.js b/remix-lib/src/helpers/compilerHelper.js index 0e5767cff2..ba919c2abb 100644 --- a/remix-lib/src/helpers/compilerHelper.js +++ b/remix-lib/src/helpers/compilerHelper.js @@ -17,7 +17,7 @@ function compilerInput (contracts) { }, outputSelection: { '*': { - '': [ 'legacyAST' ], + '': [ 'legacyAST', 'ast' ], '*': [ 'abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ] } }