Types reference improved

pull/5370/head
aniket-engg 5 years ago committed by Aniket
parent d93e039d79
commit a41cc40858
  1. 172
      remix-analyzer/src/types.ts

@ -43,7 +43,6 @@ export interface CompilationResult {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
///////////// Specfic AST Nodes ///////////////////////////// ///////////// Specfic AST Nodes /////////////////////////////
///////////// (ToDo: YUL ones need to be added) /////////////
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
interface TypeDescription { interface TypeDescription {
@ -67,6 +66,11 @@ export interface PragmaDirectiveAstNode {
literals?: Array<string> literals?: Array<string>
} }
interface SymbolAlias {
foreign: IdentifierAstNode
local: string | null
}
export interface ImportDirectiveAstNode { export interface ImportDirectiveAstNode {
id: number id: number
nodeType: 'ImportDirective' nodeType: 'ImportDirective'
@ -75,7 +79,8 @@ export interface ImportDirectiveAstNode {
file: string file: string
scope: number scope: number
sourceUnit: number sourceUnit: number
symbolAliases: Array<string> symbolAliases: Array<SymbolAlias>
unitAlias: string
} }
export interface ContractDefinitionAstNode { export interface ContractDefinitionAstNode {
@ -88,9 +93,9 @@ export interface ContractDefinitionAstNode {
abstract: boolean abstract: boolean
fullyImplemented: boolean fullyImplemented: boolean
linearizedBaseContracts: Array<number> linearizedBaseContracts: Array<number>
baseContracts: Array<any> baseContracts: Array<InheritanceSpecifierAstNode>
contractDependencies: Array<any> contractDependencies: Array<number>
nodes: Array<AstNode> nodes: Array<any>
scope: number scope: number
} }
@ -98,16 +103,16 @@ export interface InheritanceSpecifierAstNode {
id: number id: number
nodeType: 'InheritanceSpecifier' nodeType: 'InheritanceSpecifier'
src: string src: string
baseName: string baseName: UserDefinedTypeNameAstNode
arguments: object | null arguments: LiteralAstNode | null
} }
export interface UsingForDirectiveAstNode { export interface UsingForDirectiveAstNode {
id: number id: number
nodeType: 'UsingForDirective' nodeType: 'UsingForDirective'
src: string src: string
libraryName: object libraryName: UserDefinedTypeNameAstNode
typeName: object | null typeName: UserDefinedTypeNameAstNode | ElementaryTypeNameAstNode | null
} }
export interface StructDefinitionAstNode { export interface StructDefinitionAstNode {
@ -117,7 +122,7 @@ export interface StructDefinitionAstNode {
name: string name: string
visibility: string visibility: string
canonicalName: string canonicalName: string
members: object members: Array<VariableDeclarationAstNode>
scope: number scope: number
} }
@ -127,7 +132,7 @@ export interface EnumDefinitionAstNode {
src: string src: string
name: string name: string
canonicalName: string canonicalName: string
members: object members: Array<EnumValueAstNode>
} }
export interface EnumValueAstNode { export interface EnumValueAstNode {
@ -141,14 +146,14 @@ export interface ParameterListAstNode {
id: number id: number
nodeType: 'ParameterList' nodeType: 'ParameterList'
src: string src: string
parameters: Array<any> parameters: Array<VariableDeclarationAstNode>
} }
export interface OverrideSpecifierAstNode { export interface OverrideSpecifierAstNode {
id: number id: number
nodeType: 'OverrideSpecifier' nodeType: 'OverrideSpecifier'
src: string src: string
overrides: object overrides: Array<UserDefinedTypeNameAstNode>
} }
export interface FunctionDefinitionAstNode { export interface FunctionDefinitionAstNode {
@ -161,7 +166,7 @@ export interface FunctionDefinitionAstNode {
stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable' stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable'
visibility: string visibility: string
virtual: boolean virtual: boolean
overrides: object | null overrides: OverrideSpecifierAstNode | null
parameters: ParameterListAstNode parameters: ParameterListAstNode
returnParameters: ParameterListAstNode returnParameters: ParameterListAstNode
modifiers: Array<any> modifiers: Array<any>
@ -169,7 +174,7 @@ export interface FunctionDefinitionAstNode {
implemented: boolean implemented: boolean
scope: number scope: number
functionSelector?: string functionSelector?: string
baseFunctions?: object baseFunctions?: Array<number>
} }
export interface VariableDeclarationAstNode { export interface VariableDeclarationAstNode {
@ -181,7 +186,7 @@ export interface VariableDeclarationAstNode {
constant: boolean constant: boolean
stateVariable: boolean stateVariable: boolean
storageLocation: 'storage' | 'memory' | 'calldata' | 'default' storageLocation: 'storage' | 'memory' | 'calldata' | 'default'
overrides: object | null overrides: OverrideSpecifierAstNode | null
visibility: string visibility: string
value: string | null value: string | null
scope: number scope: number
@ -198,19 +203,19 @@ export interface ModifierDefinitionAstNode {
name: string name: string
documentation: object | null documentation: object | null
visibility: string visibility: string
parameters: object parameters: ParameterListAstNode
virtual: boolean virtual: boolean
overrides: object | null overrides: OverrideSpecifierAstNode | null
body: object body: BlockAstNode
baseModifiers?: object baseModifiers?: Array<number>
} }
export interface ModifierInvocationAstNode { export interface ModifierInvocationAstNode {
id: number id: number
nodeType: 'ModifierInvocation' nodeType: 'ModifierInvocation'
src: string src: string
modifierName: object modifierName: IdentifierAstNode
arguments: object | null arguments: Array<LiteralAstNode> | null
} }
export interface EventDefinitionAstNode { export interface EventDefinitionAstNode {
@ -219,7 +224,7 @@ export interface EventDefinitionAstNode {
src: string src: string
name: string name: string
documentation: object | null documentation: object | null
parameters: object parameters: ParameterListAstNode
anonymous: boolean anonymous: boolean
} }
@ -229,7 +234,7 @@ export interface ElementaryTypeNameAstNode {
src: string src: string
name: string name: string
typeDescriptions: TypeDescription typeDescriptions: TypeDescription
stateMutability?: string stateMutability?: 'pure' | 'view' | 'nonpayable' | 'payable'
} }
export interface UserDefinedTypeNameAstNode { export interface UserDefinedTypeNameAstNode {
@ -238,8 +243,8 @@ export interface UserDefinedTypeNameAstNode {
src: string src: string
name: string name: string
referencedDeclaration: number referencedDeclaration: number
contractScope: number contractScope: number | null
typeDescriptions: object typeDescriptions: TypeDescription
} }
export interface FunctionTypeNameAstNode { export interface FunctionTypeNameAstNode {
@ -248,36 +253,44 @@ export interface FunctionTypeNameAstNode {
src: string src: string
name: string name: string
visibility: string visibility: string
stateMutability: string stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable'
parameterTypes: object parameterTypes: ParameterListAstNode
returnParameterTypes: object returnParameterTypes: ParameterListAstNode
typeDescriptions: object typeDescriptions: TypeDescription
} }
export interface MappingAstNode { export interface MappingAstNode {
id: number id: number
nodeType: 'Mapping' nodeType: 'Mapping'
src: string src: string
keyType: object keyType: UserDefinedTypeNameAstNode | ElementaryTypeNameAstNode
valueType: object valueType: UserDefinedTypeNameAstNode | ElementaryTypeNameAstNode
typeDescriptions: object typeDescriptions: TypeDescription
} }
export interface ArrayTypeNameAstNode { export interface ArrayTypeNameAstNode {
id: number id: number
nodeType: 'ArrayTypeName' nodeType: 'ArrayTypeName'
src: string src: string
baseType: object baseType: UserDefinedTypeNameAstNode | ElementaryTypeNameAstNode
length: object length: LiteralAstNode | null
typeDescriptions: TypeDescription typeDescriptions: TypeDescription
} }
interface externalReference {
declaration: number
isOffset: boolean
isSlot: boolean
src: string
valueSize: number
}
export interface InlineAssemblyAstNode { export interface InlineAssemblyAstNode {
id: number id: number
nodeType: 'InlineAssembly' nodeType: 'InlineAssembly'
src: string src: string
AST: object AST: YulBlockAstNode
externalReferences: Array<any> externalReferences: Array<externalReference>
evmVersion: string evmVersion: string
} }
@ -285,7 +298,7 @@ export interface BlockAstNode {
id: number id: number
nodeType: 'Block' nodeType: 'Block'
src: string src: string
statements: Array<any> statements: Array<object>
} }
export interface PlaceholderStatementAstNode { export interface PlaceholderStatementAstNode {
@ -308,8 +321,8 @@ export interface TryCatchClauseAstNode {
nodeType: 'TryCatchClause' nodeType: 'TryCatchClause'
src: string src: string
errorName: string errorName: string
parameters: object parameters: ParameterListAstNode
block: object block: BlockAstNode
} }
export interface TryStatementAstNode { export interface TryStatementAstNode {
@ -317,7 +330,7 @@ export interface TryStatementAstNode {
nodeType: 'TryStatement' nodeType: 'TryStatement'
src: string src: string
externalCall: object externalCall: object
clauses: object clauses: Array<TryCatchClauseAstNode>
} }
export interface WhileStatementAstNode { export interface WhileStatementAstNode {
@ -325,17 +338,17 @@ export interface WhileStatementAstNode {
nodeType: 'WhileStatement' | 'DoWhileStatement' nodeType: 'WhileStatement' | 'DoWhileStatement'
src: string src: string
condition: object condition: object
body: object body: BlockAstNode
} }
export interface ForStatementAstNode { export interface ForStatementAstNode {
id: number id: number
nodeType: 'ForStatement' nodeType: 'ForStatement'
src: string src: string
initializationExpression: object initializationExpression: VariableDeclarationStatementAstNode
condition: object condition: object
loopExpression: object loopExpression: ExpressionStatementAstNode
body: object body: BlockAstNode
} }
export interface ContinueAstNode { export interface ContinueAstNode {
@ -354,7 +367,7 @@ export interface ReturnAstNode {
id: number id: number
nodeType: 'Return' nodeType: 'Return'
src: string src: string
expression: object expression: object | null
functionReturnParameters: number functionReturnParameters: number
} }
@ -368,7 +381,7 @@ export interface EmitStatementAstNode {
id: number id: number
nodeType: 'EmitStatement' nodeType: 'EmitStatement'
src: string src: string
eventCall: object eventCall: FunctionCallAstNode
} }
export interface VariableDeclarationStatementAstNode { export interface VariableDeclarationStatementAstNode {
@ -376,7 +389,7 @@ export interface VariableDeclarationStatementAstNode {
nodeType: 'VariableDeclarationStatement' nodeType: 'VariableDeclarationStatement'
src: string src: string
assignments: Array<number> assignments: Array<number>
declarations: Array<any> declarations: Array<object>
initialValue: object initialValue: object
} }
@ -393,7 +406,7 @@ interface ExpressionAttributes {
isPure: boolean isPure: boolean
isLValue: boolean isLValue: boolean
lValueRequested: boolean lValueRequested: boolean
argumentTypes: object | null argumentTypes: Array<TypeDescription> | null
} }
export interface ConditionalAstNode extends ExpressionAttributes { export interface ConditionalAstNode extends ExpressionAttributes {
@ -419,7 +432,7 @@ export interface TupleExpressionAstNode extends ExpressionAttributes {
nodeType: 'TupleExpression' nodeType: 'TupleExpression'
src: string src: string
isInlineArray: boolean isInlineArray: boolean
components: Array<any> components: Array<object>
} }
export interface UnaryOperationAstNode extends ExpressionAttributes { export interface UnaryOperationAstNode extends ExpressionAttributes {
@ -436,8 +449,8 @@ export interface BinaryOperationAstNode extends ExpressionAttributes {
nodeType: 'BinaryOperation' nodeType: 'BinaryOperation'
src: string src: string
operator: string operator: string
leftExpression: LiteralAstNode leftExpression: object
rightExpression: LiteralAstNode rightExpression: object
commonType: TypeDescription commonType: TypeDescription
} }
@ -446,7 +459,7 @@ export interface FunctionCallAstNode extends ExpressionAttributes {
nodeType: 'FunctionCall' nodeType: 'FunctionCall'
src: string src: string
expression: object expression: object
names: object names: Array<any>
arguments: object arguments: object
tryCall: boolean tryCall: boolean
kind: 'functionCall' | 'typeConversion' | 'structConstructorCall' kind: 'functionCall' | 'typeConversion' | 'structConstructorCall'
@ -457,15 +470,15 @@ export interface FunctionCallOptionsAstNode extends ExpressionAttributes {
nodeType: 'FunctionCallOptions' nodeType: 'FunctionCallOptions'
src: string src: string
expression: object expression: object
names: object names: Array<string>
options: object options: Array<object>
} }
export interface NewExpressionAstNode extends ExpressionAttributes { export interface NewExpressionAstNode extends ExpressionAttributes {
id: number id: number
nodeType: 'NewExpression' nodeType: 'NewExpression'
src: string src: string
typeName: object typeName: UserDefinedTypeNameAstNode | ElementaryTypeNameAstNode
} }
export interface MemberAccessAstNode extends ExpressionAttributes { export interface MemberAccessAstNode extends ExpressionAttributes {
@ -474,7 +487,7 @@ export interface MemberAccessAstNode extends ExpressionAttributes {
src: string src: string
memberName: string memberName: string
expression: object expression: object
referencedDeclaration: object referencedDeclaration: number | null
} }
export interface IndexAccessAstNode extends ExpressionAttributes { export interface IndexAccessAstNode extends ExpressionAttributes {
@ -498,7 +511,7 @@ export interface ElementaryTypeNameExpressionAstNode extends ExpressionAttribute
id: number id: number
nodeType: 'ElementaryTypeNameExpression' nodeType: 'ElementaryTypeNameExpression'
src: string src: string
typeName: object typeName: ElementaryTypeNameAstNode
} }
export interface LiteralAstNode extends ExpressionAttributes { export interface LiteralAstNode extends ExpressionAttributes {
@ -508,7 +521,7 @@ export interface LiteralAstNode extends ExpressionAttributes {
kind: 'number' | 'string' | 'bool' kind: 'number' | 'string' | 'bool'
value: string value: string
hexValue: string hexValue: string
subdenomination: object | null subdenomination: 'wei' | 'szabo' | 'finney' | 'ether' | null
} }
export interface IdentifierAstNode { export interface IdentifierAstNode {
@ -519,7 +532,7 @@ export interface IdentifierAstNode {
referencedDeclaration: number referencedDeclaration: number
overloadedDeclarations: Array<any> overloadedDeclarations: Array<any>
typeDescriptions: TypeDescription typeDescriptions: TypeDescription
argumentTypes: object | null argumentTypes: Array<TypeDescription> | null
} }
export interface StructuredDocumentationAstNode { export interface StructuredDocumentationAstNode {
@ -530,6 +543,45 @@ export interface StructuredDocumentationAstNode {
} }
/////////////////////////////////////////////////////////
///////////// YUL AST Nodes /////////////////////////////
/////////////////////////////////////////////////////////
export interface YulTypedNameAstNode {
name: string
nodeType: 'YulTypedName'
src: string
type: string
}
export interface YulIdentifierAstNode {
name: string
nodeType: 'YulIdentifier'
src: string
}
export interface YulLiteralAstNode {
kind: string
nodeType: 'YulLiteral'
src: string
type: string
value: string
}
export interface YulVariableDeclarationAstNode {
nodeType: 'YulVariableDeclaration'
src: string
value: YulIdentifierAstNode | YulLiteralAstNode
variables: Array<YulTypedNameAstNode>
}
export interface YulBlockAstNode {
nodeType: 'YulBlock'
src: string
statements: Array<YulVariableDeclarationAstNode>
}
/////////// ///////////
// ERROR // // ERROR //
/////////// ///////////

Loading…
Cancel
Save