Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
be7805e0
Commit
be7805e0
authored
Mar 05, 2020
by
aniket-engg
Committed by
Aniket
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common unit tests updated
parent
0569590c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
631 additions
and
219 deletions
+631
-219
abstractAstView.ts
...analyzer/src/solidity-analyzer/modules/abstractAstView.ts
+2
-2
staticAnalysisCommon.ts
...zer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
+38
-30
contractDefinition.json
...-analyzer/test/analysis/astBlocks/contractDefinition.json
+103
-0
externalDirect.json
remix-analyzer/test/analysis/astBlocks/externalDirect.json
+95
-15
index.js
remix-analyzer/test/analysis/astBlocks/index.js
+3
-0
libCall.json
remix-analyzer/test/analysis/astBlocks/libCall.json
+55
-27
localCall.json
remix-analyzer/test/analysis/astBlocks/localCall.json
+79
-24
nowAst.json
remix-analyzer/test/analysis/astBlocks/nowAst.json
+15
-0
stateVariableContractNode.json
...er/test/analysis/astBlocks/stateVariableContractNode.json
+0
-0
storageVariableNodes.json
...nalyzer/test/analysis/astBlocks/storageVariableNodes.json
+108
-54
superLocal.json
remix-analyzer/test/analysis/astBlocks/superLocal.json
+38
-17
thisLocalCall.json
remix-analyzer/test/analysis/astBlocks/thisLocalCall.json
+37
-16
unaryOperation.json
remix-analyzer/test/analysis/astBlocks/unaryOperation.json
+33
-0
staticAnalysisCommon-test.ts
remix-analyzer/test/analysis/staticAnalysisCommon-test.ts
+0
-0
library.sol
...er/test/analysis/test-contracts/solidity-v0.5/library.sol
+25
-34
No files found.
remix-analyzer/src/solidity-analyzer/modules/abstractAstView.ts
View file @
be7805e0
import
{
getStateVariableDeclarationsF
or
mContractNode
,
import
{
getStateVariableDeclarationsF
ro
mContractNode
,
getInheritsFromName
,
getContractName
,
getFunctionOrModifierDefinitionParameterPart
,
getType
,
getDeclaredVariableName
,
getFunctionDefinitionReturnParameterPart
}
from
'./staticAnalysisCommon'
...
...
@@ -57,7 +57,7 @@ export default class abstractAstView {
relevantNodes
:
[],
modifiers
:
[],
inheritsFrom
:
[],
stateVariables
:
getStateVariableDeclarationsF
or
mContractNode
(
node
)
stateVariables
:
getStateVariableDeclarationsF
ro
mContractNode
(
node
)
})
}
else
if
(
node
.
nodeType
===
"InheritanceSpecifier"
)
{
const
currentContract
=
that
.
getCurrentContract
(
that
)
...
...
remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
View file @
be7805e0
...
...
@@ -47,7 +47,7 @@ const basicRegex = {
FUNCTIONTYPE
:
'^function
\\
('
,
EXTERNALFUNCTIONTYPE
:
'^function
\\
(.*
\\
).* external'
,
CONSTANTFUNCTIONTYPE
:
'^function
\\
(.*
\\
).* (view|pure)'
,
REFTYPE
:
'(
storage
)|(mapping
\\
()|(
\\
[
\\
])'
,
REFTYPE
:
'(
storage
)|(mapping
\\
()|(
\\
[
\\
])'
,
FUNCTIONSIGNATURE
:
'^function
\\
(([^
\\
(]*)
\\
)'
,
LIBRARYTYPE
:
'^type
\\
(library (.*)
\\
)'
}
...
...
@@ -169,9 +169,9 @@ function getLocalCallName (localCallNode: FunctionCallAstNode): string {
* @localCallNode {ASTNode} Function call node
* @return {string} name of the function called
*/
function
getThisLocalCallName
(
l
ocalCallNode
:
FunctionCallAstNode
):
string
{
if
(
!
isThisLocalCall
(
l
ocalCallNode
.
expression
))
throw
new
Error
(
'staticAnalysisCommon.js: not an this local call Node'
)
return
l
ocalCallNode
.
expression
.
memberName
function
getThisLocalCallName
(
thisL
ocalCallNode
:
FunctionCallAstNode
):
string
{
if
(
!
isThisLocalCall
(
thisL
ocalCallNode
.
expression
))
throw
new
Error
(
'staticAnalysisCommon.js: not an this local call Node'
)
return
thisL
ocalCallNode
.
expression
.
memberName
}
/**
...
...
@@ -180,9 +180,9 @@ function getThisLocalCallName (localCallNode: FunctionCallAstNode): string {
* @localCallNode {ASTNode} Function call node
* @return {string} name of the function called
*/
function
getSuperLocalCallName
(
l
ocalCallNode
:
FunctionCallAstNode
):
string
{
if
(
!
isSuperLocalCall
(
l
ocalCallNode
.
expression
))
throw
new
Error
(
'staticAnalysisCommon.js: not an super local call Node'
)
return
l
ocalCallNode
.
expression
.
memberName
function
getSuperLocalCallName
(
superL
ocalCallNode
:
FunctionCallAstNode
):
string
{
if
(
!
isSuperLocalCall
(
superL
ocalCallNode
.
expression
))
throw
new
Error
(
'staticAnalysisCommon.js: not an super local call Node'
)
return
superL
ocalCallNode
.
expression
.
memberName
}
/**
...
...
@@ -256,8 +256,8 @@ function getFunctionDefinitionName (funcDef: FunctionDefinitionAstNode): string
* @func {ASTNode} Inheritance specifier
* @return {string} name of contract inherited from
*/
function
getInheritsFromName
(
inheritsNode
:
InheritanceSpecifierAstNode
):
UserDefinedTypeNameAstNode
{
return
inheritsNode
.
baseName
function
getInheritsFromName
(
inheritsNode
:
InheritanceSpecifierAstNode
):
string
{
return
inheritsNode
.
baseName
.
name
}
/**
...
...
@@ -292,7 +292,7 @@ function getDeclaredVariableType (varDeclNode: VariableDeclarationAstNode): stri
* @contractNode {ASTNode} Contract Definition node
* @return {list variable declaration} state variable node list
*/
function
getStateVariableDeclarationsF
or
mContractNode
(
contractNode
:
ContractDefinitionAstNode
):
VariableDeclarationAstNode
[]
{
function
getStateVariableDeclarationsF
ro
mContractNode
(
contractNode
:
ContractDefinitionAstNode
):
VariableDeclarationAstNode
[]
{
return
contractNode
.
nodes
.
filter
(
el
=>
el
.
nodeType
===
"VariableDeclaration"
)
}
...
...
@@ -355,9 +355,9 @@ function getFunctionCallTypeParameterType (func: FunctionCallAstNode): string |
* @funcCall {ASTNode} function call node
* @return {string} name of the lib defined
*/
function
getLibraryCallContractName
(
node
:
MemberAccess
AstNode
):
string
|
undefined
{
if
(
!
isLibraryCall
(
node
))
throw
new
Error
(
'staticAnalysisCommon.js: not an this library call Node'
)
const
types
:
RegExpExecArray
|
null
=
new
RegExp
(
basicRegex
.
LIBRARYTYPE
).
exec
(
node
.
expression
.
typeDescriptions
.
typeString
)
function
getLibraryCallContractName
(
node
:
FunctionCall
AstNode
):
string
|
undefined
{
if
(
!
isLibraryCall
(
node
.
expression
))
throw
new
Error
(
'staticAnalysisCommon.js: not an this library call Node'
)
const
types
:
RegExpExecArray
|
null
=
new
RegExp
(
basicRegex
.
LIBRARYTYPE
).
exec
(
node
.
expression
.
expression
.
typeDescriptions
.
typeString
)
if
(
types
)
return
types
[
1
]
}
...
...
@@ -522,6 +522,9 @@ function isLocalCallGraphRelevantNode (node: FunctionCallAstNode): boolean {
* @return {bool}
*/
function
isBuiltinFunctionCall
(
node
:
FunctionCallAstNode
):
boolean
{
// console.log('isBuiltinFunctionCall isLocalCall', isLocalCall(node))
// console.log('isBuiltinFunctionCall getLocalCallName', getLocalCallName(node))
// console.log('isBuiltinFunctionCall getFunctionCallTypeParameterType', getFunctionCallTypeParameterType(node))
return
(
isLocalCall
(
node
)
&&
builtinFunctions
[
getLocalCallName
(
node
)
+
'('
+
getFunctionCallTypeParameterType
(
node
)
+
')'
]
===
true
)
||
isAbiNamespaceCall
(
node
)
}
...
...
@@ -567,7 +570,7 @@ function isRequireCall (node: FunctionCallAstNode): boolean {
* @return {bool}
*/
function
isStorageVariableDeclaration
(
node
:
VariableDeclarationAstNode
):
boolean
{
return
expressionType
(
node
,
basicRegex
.
REFTYPE
)
return
node
.
storageLocation
===
'storage'
&&
new
RegExp
(
basicRegex
.
REFTYPE
).
test
(
node
.
typeDescriptions
.
typeIdentifier
)
}
/**
...
...
@@ -731,7 +734,7 @@ function isLibrary (node: ContractDefinitionAstNode): boolean {
* @return {bool}
*/
function
isCallToNonConstLocalFunction
(
node
:
FunctionCallAstNode
):
boolean
{
return
isLocalCall
(
node
)
&&
!
expressionType
(
node
,
basicRegex
.
CONSTANTFUNCTIONTYPE
)
return
isLocalCall
(
node
)
&&
!
expressionType
Description
(
node
,
basicRegex
.
CONSTANTFUNCTIONTYPE
)
}
/**
...
...
@@ -862,8 +865,8 @@ function isLLSend (node: MemberAccessAstNode): boolean {
*/
function
isLLCall
(
node
:
MemberAccessAstNode
):
boolean
{
return
isMemberAccess
(
node
,
exactMatch
(
util
.
escapeRegExp
(
lowLevelCallTypes
.
CALL
.
type
)),
undefined
,
exactMatch
(
basicTypes
.
ADDRESS
),
exactMatch
(
lowLevelCallTypes
.
CALL
.
ident
))
exactMatch
(
util
.
escapeRegExp
(
lowLevelCallTypes
[
'CALL-v0.5'
]
.
type
)),
undefined
,
exactMatch
(
basicTypes
.
ADDRESS
),
exactMatch
(
lowLevelCallTypes
[
'CALL-v0.5'
]
.
ident
))
}
/**
...
...
@@ -895,8 +898,8 @@ function isLLCallcode (node: MemberAccessAstNode): boolean {
*/
function
isLLDelegatecall
(
node
:
MemberAccessAstNode
):
boolean
{
return
isMemberAccess
(
node
,
exactMatch
(
util
.
escapeRegExp
(
lowLevelCallTypes
.
DELEGATECALL
.
type
)),
undefined
,
exactMatch
(
basicTypes
.
ADDRESS
),
exactMatch
(
lowLevelCallTypes
.
DELEGATECALL
.
ident
))
exactMatch
(
util
.
escapeRegExp
(
lowLevelCallTypes
[
'DELEGATECALL-v0.5'
]
.
type
)),
undefined
,
exactMatch
(
basicTypes
.
ADDRESS
),
exactMatch
(
lowLevelCallTypes
[
'DELEGATECALL-v0.5'
]
.
ident
))
}
/**
...
...
@@ -959,10 +962,15 @@ function isBytesLengthCheck (node: MemberAccessAstNode): boolean {
// #################### Complex Node Identification - Private
function
isMemberAccess
(
node
:
MemberAccessAstNode
,
retType
:
string
,
accessor
:
string
|
undefined
,
accessorType
:
string
,
memberName
:
string
|
undefined
):
boolean
{
return
typeDescription
(
node
,
retType
)
&&
memName
(
node
,
memberName
)
&&
memName
(
node
.
expression
,
accessor
)
&&
expressionTypeDescription
(
node
.
expression
,
accessorType
)
const
nodeTypeDef
:
boolean
=
typeDescription
(
node
,
retType
)
console
.
log
(
'MemberAccess typeDef ->'
,
nodeTypeDef
)
const
nodeMemName
:
boolean
=
memName
(
node
,
memberName
)
console
.
log
(
'MemberAccess nodeMemName ->'
,
nodeMemName
)
const
nodeExpMemName
:
boolean
=
memName
(
node
.
expression
,
accessor
)
console
.
log
(
'MemberAccess nodeExpMemName ->'
,
nodeExpMemName
)
const
nodeExpTypeDef
:
boolean
=
expressionTypeDescription
(
node
,
accessorType
)
console
.
log
(
'MemberAccess nodeExpTypeDef ->'
,
nodeExpTypeDef
)
return
nodeTypeDef
&&
nodeMemName
&&
nodeExpTypeDef
&&
nodeExpMemName
}
function
isSpecialVariableAccess
(
node
:
MemberAccessAstNode
,
varType
:
any
):
boolean
{
...
...
@@ -979,9 +987,9 @@ function isSpecialVariableAccess (node: MemberAccessAstNode, varType: any): bool
// return (node && (nr === undefined || nr === null)) || (node && nr === 0 && !node.children) || (node && node.children && node.children.length >= nr)
// }
function
expressionType
(
node
,
typeRegex
)
{
return
new
RegExp
(
typeRegex
).
test
(
node
.
expression
.
typeDescriptions
.
typeString
)
}
//
function expressionType (node, typeRegex) {
//
return new RegExp(typeRegex).test(node.expression.typeDescriptions.typeString)
//
}
function
expressionTypeDescription
(
node
,
typeRegex
)
{
return
new
RegExp
(
typeRegex
).
test
(
node
.
expression
.
typeDescriptions
.
typeString
)
...
...
@@ -996,8 +1004,8 @@ function nodeType (node, typeRegex) {
}
function
memName
(
node
,
memNameRegex
)
{
const
regex
=
new
RegExp
(
memNameRegex
)
return
regex
.
test
(
node
.
name
)
||
regex
.
test
(
node
.
memberName
)
//
const regex = new RegExp(memNameRegex)
return
(
node
&&
!
memNameRegex
)
||
new
RegExp
(
memNameRegex
).
test
(
node
.
name
)
||
new
RegExp
(
memNameRegex
)
.
test
(
node
.
memberName
)
}
function
operator
(
node
,
opRegex
)
{
...
...
@@ -1056,7 +1064,7 @@ function buildAbiSignature (funName: string, paramTypes: any[]): string {
const
helpers
=
{
// nrOfChildren,
// minNrOfChildren,
expressionType
,
expressionType
Description
,
nodeType
,
memName
,
operator
,
...
...
@@ -1086,7 +1094,7 @@ export {
getLibraryCallMemberName
,
getFullQualifiedFunctionCallIdent
,
getFullQuallyfiedFuncDefinitionIdent
,
getStateVariableDeclarationsF
or
mContractNode
,
getStateVariableDeclarationsF
ro
mContractNode
,
getFunctionOrModifierDefinitionParameterPart
,
getFunctionDefinitionReturnParameterPart
,
getUnAssignedTopLevelBinOps
,
...
...
remix-analyzer/test/analysis/astBlocks/contractDefinition.json
0 → 100644
View file @
be7805e0
{
"abstract"
:
false
,
"baseContracts"
:
[],
"contractDependencies"
:
[],
"contractKind"
:
"contract"
,
"documentation"
:
null
,
"fullyImplemented"
:
true
,
"id"
:
8
,
"linearizedBaseContracts"
:
[
8
],
"name"
:
"C"
,
"nodeType"
:
"ContractDefinition"
,
"nodes"
:
[
{
"body"
:
{
"id"
:
6
,
"nodeType"
:
"Block"
,
"src"
:
"42:23:0"
,
"statements"
:
[
{
"assignments"
:
[
4
],
"declarations"
:
[
{
"constant"
:
false
,
"id"
:
4
,
"name"
:
"a"
,
"nodeType"
:
"VariableDeclaration"
,
"overrides"
:
null
,
"scope"
:
6
,
"src"
:
"52:6:0"
,
"stateVariable"
:
false
,
"storageLocation"
:
"default"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
},
"typeName"
:
{
"id"
:
3
,
"name"
:
"uint"
,
"nodeType"
:
"ElementaryTypeName"
,
"src"
:
"52:4:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
},
"value"
:
null
,
"visibility"
:
"internal"
}
],
"id"
:
5
,
"initialValue"
:
null
,
"nodeType"
:
"VariableDeclarationStatement"
,
"src"
:
"52:6:0"
}
]
},
"documentation"
:
null
,
"functionSelector"
:
"26121ff0"
,
"id"
:
7
,
"implemented"
:
true
,
"kind"
:
"function"
,
"modifiers"
:
[],
"name"
:
"f"
,
"nodeType"
:
"FunctionDefinition"
,
"overrides"
:
null
,
"parameters"
:
{
"id"
:
1
,
"nodeType"
:
"ParameterList"
,
"parameters"
:
[],
"src"
:
"27:2:0"
},
"returnParameters"
:
{
"id"
:
2
,
"nodeType"
:
"ParameterList"
,
"parameters"
:
[],
"src"
:
"42:0:0"
},
"scope"
:
8
,
"src"
:
"17:48:0"
,
"stateMutability"
:
"pure"
,
"virtual"
:
false
,
"visibility"
:
"public"
}
],
"scope"
:
9
,
"src"
:
"0:67:0"
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/externalDirect.json
View file @
be7805e0
{
"attributes"
:
{
"member_name"
:
"info"
,
"type"
:
"function () payable external returns (uint256)"
},
"children"
:
[
"argumentTypes"
:
null
,
"arguments"
:
[],
"expression"
:
{
"argumentTypes"
:
[],
"expression"
:
{
"attributes"
:
{
"type"
:
"contract InfoFeed"
,
"value"
:
"f"
"argumentTypes"
:
null
,
"arguments"
:
[
{
"argumentTypes"
:
null
,
"hexValue"
:
"30"
,
"id"
:
9
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
true
,
"kind"
:
"number"
,
"lValueRequested"
:
false
,
"nodeType"
:
"Literal"
,
"src"
:
"83:1:0"
,
"subdenomination"
:
null
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_rational_0_by_1"
,
"typeString"
:
"int_const 0"
},
"value"
:
"0"
}
],
"expression"
:
{
"argumentTypes"
:
[
{
"typeIdentifier"
:
"t_rational_0_by_1"
,
"typeString"
:
"int_const 0"
}
],
"id"
:
8
,
"name"
:
"c"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
5
,
"src"
:
"81:1:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_type$_t_contract$_c_$5_$"
,
"typeString"
:
"type(contract c)"
}
},
"id"
:
30
,
"name"
:
"Identifier"
,
"src"
:
"405:1:0"
"id"
:
10
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
true
,
"kind"
:
"typeConversion"
,
"lValueRequested"
:
false
,
"names"
:
[],
"nodeType"
:
"FunctionCall"
,
"src"
:
"81:4:0"
,
"tryCall"
:
false
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_contract$_c_$5"
,
"typeString"
:
"contract c"
}
},
"id"
:
11
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"memberName"
:
"f"
,
"nodeType"
:
"MemberAccess"
,
"referencedDeclaration"
:
4
,
"src"
:
"81:6:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_function_external_nonpayable$__$returns$__$"
,
"typeString"
:
"function () external"
}
],
"id"
:
32
,
"name"
:
"MemberAccess"
,
"src"
:
"405:6:0"
},
"id"
:
12
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"kind"
:
"functionCall"
,
"lValueRequested"
:
false
,
"names"
:
[],
"nodeType"
:
"FunctionCall"
,
"src"
:
"81:8:0"
,
"tryCall"
:
false
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_tuple$__$"
,
"typeString"
:
"tuple()"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/index.js
View file @
be7805e0
module
.
exports
=
{
localCall
:
require
(
'./localCall.json'
),
contractDefinition
:
require
(
'./contractDefinition.json'
),
unaryOperation
:
require
(
'./unaryOperation.json'
),
nowAst
:
require
(
'./nowAst.json'
),
thisLocalCall
:
require
(
'./thisLocalCall.json'
),
libCall
:
require
(
'./libCall.json'
),
externalDirect
:
require
(
'./externalDirect.json'
),
...
...
remix-analyzer/test/analysis/astBlocks/libCall.json
View file @
be7805e0
{
"argumentTypes"
:
null
,
"expression"
:
{
"argumentTypes"
:
null
,
"id"
:
33
,
"name"
:
"L"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
21
,
"src"
:
"244:1:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_type$_t_contract$_L_$21_$"
,
"typeString"
:
"type(library L)"
}
},
"id"
:
34
,
{
"argumentTypes"
:
null
,
"arguments"
:
[
{
"argumentTypes"
:
null
,
"id"
:
95
,
"name"
:
"knownValues"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
79
,
"src"
:
"1392:11:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_struct$_Data_$6_storage"
,
"typeString"
:
"struct Set.Data storage ref"
}
},
{
"argumentTypes"
:
null
,
"id"
:
96
,
"name"
:
"value"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
81
,
"src"
:
"1405:5:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
}
],
"expression"
:
{
"argumentTypes"
:
[
{
"typeIdentifier"
:
"t_struct$_Data_$6_storage"
,
"typeString"
:
"struct Set.Data storage ref"
},
{
"typeIdentifier"
:
"t_uint256', typeString: 'uint256"
}
],
"expression"
:
{
"argumentTypes"
:
null
,
"id"
:
93
,
"name"
:
"Set"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
77
,
"src"
:
"1381:3:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_type$_t_contract$_Set_$77_$"
,
"typeString"
:
"type(library Set)"
}
},
"id"
:
94
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"memberName"
:
"insert"
,
"nodeType"
:
"MemberAccess"
,
"referencedDeclaration"
:
33
,
"src"
:
"1381:10:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_function_delegatecall_nonpayable$_t_struct$_Data_$6_storage_ptr_$_t_uint256_$returns$_t_bool_$"
,
"typeString"
:
"function (struct Set.Data storage pointer,uint256) returns (bool)"
}
},
"id"
:
97
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"kind"
:
"functionCall"
,
"lValueRequested"
:
false
,
"memberName"
:
"f"
,
"nodeType"
:
"MemberAccess"
,
"referencedDeclaration"
:
6
,
"src"
:
"244:3:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_function_delegatecall_nonpayable$_t_uint256_$returns$__$"
,
"typeString"
:
"function (uint256)"
}
"names"
:
[],
"nodeType"
:
"FunctionCall"
,
"src"
:
"1381:30:0"
,
"tryCall"
:
false
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_bool"
,
"typeString"
:
"bool"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/localCall.json
View file @
be7805e0
{
"argumentTypes"
:
null
,
"arguments"
:
[],
"expression"
:
"argumentTypes"
:
null
,
"arguments"
:
[
{
"argumentTypes"
:
[],
"id"
:
13
,
"name"
:
"sha3"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
8
,
"src"
:
"129:4:0"
,
"argumentTypes"
:
null
,
"hexValue"
:
"616263"
,
"id"
:
15
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
true
,
"kind"
:
"string"
,
"lValueRequested"
:
false
,
"nodeType"
:
"Literal"
,
"src"
:
"115:5:0"
,
"subdenomination"
:
null
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_function_internal_pure$__$returns$_t_bool_$"
,
"typeString"
:
"function () pure returns (bool)"
}
"typeIdentifier"
:
"t_stringliteral_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45"
,
"typeString"
:
"literal_string
\"
abc
\"
"
},
"value"
:
"abc"
},
{
"argumentTypes"
:
null
,
"hexValue"
:
"38"
,
"id"
:
16
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
true
,
"kind"
:
"number"
,
"lValueRequested"
:
false
,
"nodeType"
:
"Literal"
,
"src"
:
"125:1:0"
,
"subdenomination"
:
null
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_rational_8_by_1"
,
"typeString"
:
"int_const 8"
},
"value"
:
"8"
}
],
"expression"
:
{
"argumentTypes"
:
[
{
"typeIdentifier"
:
"t_stringliteral_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45"
,
"typeString"
:
"literal_string
\"
abc
\"
"
},
{
"typeIdentifier"
:
"t_rational_8_by_1"
,
"typeString"
:
"int_const 8"
}
],
"id"
:
14
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"kind"
:
"functionCall"
,
"lValueRequested"
:
false
,
"names"
:
[],
"nodeType"
:
"FunctionCall"
,
"src"
:
"129:6:0"
,
"tryCall"
:
false
,
"name"
:
"e"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
6
,
"src"
:
"109:1:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_
bool
"
,
"typeString"
:
"
bool
"
"typeIdentifier"
:
"t_
function_event_nonpayable$_t_uint256_$_t_string_memory_ptr_$returns$__$
"
,
"typeString"
:
"
function (uint256,string memory)
"
}
},
"id"
:
17
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"kind"
:
"functionCall"
,
"lValueRequested"
:
false
,
"names"
:
[
"b"
,
"a"
],
"nodeType"
:
"FunctionCall"
,
"src"
:
"109:19:0"
,
"tryCall"
:
false
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_tuple$__$"
,
"typeString"
:
"tuple()"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/nowAst.json
0 → 100644
View file @
be7805e0
{
"argumentTypes"
:
null
,
"id"
:
11
,
"name"
:
"now"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
-17
,
"src"
:
"110:3:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/stateVariableContractNode.json
View file @
be7805e0
This diff is collapsed.
Click to expand it.
remix-analyzer/test/analysis/astBlocks/storageVariableNodes.json
View file @
be7805e0
{
"node1"
:
{
"attributes"
:
{
"name"
:
"x"
,
"type"
:
"struct Ballot.Voter storage pointer"
"constant"
:
false
,
"id"
:
20
,
"name"
:
"c"
,
"nodeType"
:
"VariableDeclaration"
,
"overrides"
:
null
,
"scope"
:
33
,
"src"
:
"174:11:0"
,
"stateVariable"
:
false
,
"storageLocation"
:
"storage"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_struct$_S_$3_storage_ptr"
,
"typeString"
:
"struct C.S"
},
"children"
:
[
"typeName"
:
{
"contractScope"
:
null
,
"id"
:
19
,
"name"
:
"S"
,
"nodeType"
:
"UserDefinedTypeName"
,
"referencedDeclaration"
:
3
,
"src"
:
"174:1:0"
,
"typeDescriptions"
:
{
"attributes"
:
{
"name"
:
"Voter"
},
"id"
:
43
,
"name"
:
"UserDefinedTypeName"
,
"src"
:
"604:5:0"
"typeIdentifier"
:
"t_struct$_S_$3_storage_ptr"
,
"typeString"
:
"struct C.S"
}
],
"id"
:
44
,
"name"
:
"VariableDeclaration"
,
"src"
:
"604:15:0"
},
"value"
:
null
,
"visibility"
:
"internal"
},
"node2"
:
{
"attributes"
:
{
"name"
:
"voters"
,
"type"
:
"mapping(address => struct Ballot.Voter storage ref)"
"constant"
:
false
,
"id"
:
11
,
"name"
:
""
,
"nodeType"
:
"VariableDeclaration"
,
"overrides"
:
null
,
"scope"
:
16
,
"src"
:
"82:29:0"
,
"stateVariable"
:
false
,
"storageLocation"
:
"storage"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_array$_t_mapping$_t_uint256_$_t_uint256_$_$dyn_storage_ptr"
,
"typeString"
:
"mapping(uint256 => uint256)[]"
},
"children"
:
[
"typeName"
:
{
"baseType"
:
{
"children"
:
[
"id"
:
9
,
"keyType"
:
{
"id"
:
7
,
"name"
:
"uint"
,
"nodeType"
:
"ElementaryTypeName"
,
"src"
:
"90:4:0"
,
"typeDescriptions"
:
{
"attributes"
:
{
"name"
:
"address"
},
"id"
:
16
,
"name"
:
"ElementaryTypeName"
,
"src"
:
"235:7:0"
},
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
},
"nodeType"
:
"Mapping"
,
"src"
:
"82:19:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_mapping$_t_uint256_$_t_uint256_$"
,
"typeString"
:
"mapping(uint256 => uint256)"
},
"valueType"
:
{
"id"
:
8
,
"name"
:
"uint"
,
"nodeType"
:
"ElementaryTypeName"
,
"src"
:
"96:4:0"
,
"typeDescriptions"
:
{
"attributes"
:
{
"name"
:
"Voter"
},
"id"
:
17
,
"name"
:
"UserDefinedTypeName"
,
"src"
:
"246:5:0"
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
],
"id"
:
18
,
"name"
:
"Mapping"
,
"src"
:
"227:25:0"
}
},
"id"
:
10
,
"length"
:
null
,
"nodeType"
:
"ArrayTypeName"
,
"src"
:
"82:21:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_array$_t_mapping$_t_uint256_$_t_uint256_$_$dyn_storage_ptr"
,
"typeString"
:
"mapping(uint256 => uint256)[]"
}
],
"id"
:
19
,
"name"
:
"VariableDeclaration"
,
"src"
:
"227:32:0"
}
},
"node3"
:
{
"attributes"
:
{
"name"
:
"voters"
,
"type"
:
"bytes32"
"constant"
:
false
,
"id"
:
125
,
"name"
:
"f"
,
"nodeType"
:
"VariableDeclaration"
,
"overrides"
:
null
,
"scope"
:
160
,
"src"
:
"1005:14:0"
,
"stateVariable"
:
false
,
"storageLocation"
:
"memory"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_bytes_memory_ptr"
,
"typeString"
:
"bytes"
},
"children"
:
[
"typeName"
:
{
"id"
:
124
,
"name"
:
"bytes"
,
"nodeType"
:
"ElementaryTypeName"
,
"src"
:
"1005:5:0"
,
"typeDescriptions"
:
{
"attributes"
:
{
"name"
:
"bytes"
},
"id"
:
16
,
"name"
:
"ElementaryTypeName"
,
"src"
:
"235:7:0"
"typeIdentifier"
:
"t_bytes_storage_ptr"
,
"typeString"
:
"bytes"
}
],
"id"
:
19
,
"name"
:
"VariableDeclaration"
,
"src"
:
"227:32:0"
},
"value"
:
null
,
"visibility"
:
"internal"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/superLocal.json
View file @
be7805e0
{
"argumentTypes"
:
[],
"argumentTypes"
:
null
,
"arguments"
:
[],
"expression"
:
{
"argumentTypes"
:
null
,
"id"
:
10
,
"name"
:
"super"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
-25
,
"src"
:
"162:5:0"
,
"argumentTypes"
:
[],
"expression"
:
{
"argumentTypes"
:
null
,
"id"
:
10
,
"name"
:
"super"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
-25
,
"src"
:
"162:5:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_super$_B_$17"
,
"typeString"
:
"contract super B"
}
},
"id"
:
12
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"memberName"
:
"x"
,
"nodeType"
:
"MemberAccess"
,
"referencedDeclaration"
:
4
,
"src"
:
"162:7:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_
super$_B_$17
"
,
"typeString"
:
"
contract super B
"
"typeIdentifier"
:
"t_
function_internal_pure$__$returns$__$
"
,
"typeString"
:
"
function () pure
"
}
},
"id"
:
1
2
,
"id"
:
1
3
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"kind"
:
"functionCall"
,
"lValueRequested"
:
false
,
"
memberName"
:
"x"
,
"nodeType"
:
"
MemberAccess
"
,
"
referencedDeclaration"
:
4
,
"
src"
:
"162:7:0"
,
"
names"
:
[]
,
"nodeType"
:
"
FunctionCall
"
,
"
src"
:
"162:9:0"
,
"
tryCall"
:
false
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_
function_internal_pure$__$returns
$__$"
,
"typeString"
:
"
function () pure
"
"typeIdentifier"
:
"t_
tuple
$__$"
,
"typeString"
:
"
tuple()
"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/thisLocalCall.json
View file @
be7805e0
{
"argumentTypes"
:
null
,
"arguments"
:
[],
"expression"
:
{
"argumentTypes"
:
null
,
"id"
:
13
,
"name"
:
"this"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
-28
,
"src"
:
"138:4:0"
,
"argumentTypes"
:
[],
"expression"
:
{
"argumentTypes"
:
null
,
"id"
:
10
,
"name"
:
"this"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
-28
,
"src"
:
"99:4:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_contract$_C_$26"
,
"typeString"
:
"contract C"
}
},
"id"
:
11
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"memberName"
:
"f"
,
"nodeType"
:
"MemberAccess"
,
"referencedDeclaration"
:
25
,
"src"
:
"99:6:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_
contract$_C_$21
"
,
"typeString"
:
"
contract C
"
"typeIdentifier"
:
"t_
function_external_nonpayable$__$returns$_t_uint256_$_t_uint256_$
"
,
"typeString"
:
"
function () external returns (uint256,uint256)
"
}
},
"id"
:
1
4
,
"id"
:
1
2
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"kind"
:
"functionCall"
,
"lValueRequested"
:
false
,
"
memberName"
:
"h"
,
"nodeType"
:
"
MemberAccess
"
,
"
referencedDeclaration"
:
4
,
"
src"
:
"138:6:0"
,
"
names"
:
[]
,
"nodeType"
:
"
FunctionCall
"
,
"
src"
:
"99:8:0"
,
"
tryCall"
:
true
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_
function_external_payable$__$returns$_
_$"
,
"typeString"
:
"
function () payable external
"
"typeIdentifier"
:
"t_
tuple$_t_uint256_$_t_uint256
_$"
,
"typeString"
:
"
tuple(uint256,uint256)
"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/unaryOperation.json
0 → 100644
View file @
be7805e0
{
"argumentTypes"
:
null
,
"id"
:
13
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"nodeType"
:
"UnaryOperation"
,
"operator"
:
"++"
,
"prefix"
:
false
,
"src"
:
"95:3:0"
,
"subExpression"
:
{
"argumentTypes"
:
null
,
"id"
:
12
,
"name"
:
"x"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
4
,
"src"
:
"95:1:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
},
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/staticAnalysisCommon-test.ts
View file @
be7805e0
This diff is collapsed.
Click to expand it.
remix-analyzer/test/analysis/test-contracts/solidity-v0.5/library.sol
View file @
be7805e0
pragma solidity >=0.4.9 <0.7.0;
contract
Set {
library
Set {
// We define a new struct datatype that will be used to
// hold its data in the calling contract.
// struct Data { uint
flags; }
struct Data { mapping(uint => bool)
flags; }
// Note that the first parameter is of type "storage
// reference" and thus only its storage address and not
...
...
@@ -11,35 +11,35 @@ contract Set {
// special feature of library functions. It is idiomatic
// to call the first parameter 'self', if the function can
// be seen as a method of that object.
//function insert(Data memory
self, uint value) public
//
returns (bool)
//
{
//
if (self.flags[value])
//
return false; // already there
//
self.flags[value] = true;
function insert(Data storage
self, uint value) public
returns (bool)
{
if (self.flags[value])
return false; // already there
self.flags[value] = true;
//
return true;
//
}
return true;
}
// function remove(Data memory
self, uint value) public
//
returns (bool)
//
{
//
if (!self.flags[value])
//
return false; // not there
//
self.flags[value] = false;
//
return true;
//
}
function remove(Data storage
self, uint value) public
returns (bool)
{
if (!self.flags[value])
return false; // not there
self.flags[value] = false;
return true;
}
function contains(
uint value) public pure
returns (
uint
)
function contains(
Data storage self, uint value) public
returns (
bool
)
{
return
value
;
return
self.flags[value]
;
}
}
contract C {
Set
x
;
Set
.Data knownValues
;
function register(uint value) public {
// The library functions can be called without a
...
...
@@ -47,18 +47,8 @@ contract C {
// "instance" will be the current contract.
address payable a;
a.send(10 wei);
//if (!Set.insert(knownValues, value))
// revert();
}
function tests2() public {
x = Set(0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c);
uint y = x.contains(103);
if(y == 103){
y++;
} else {
y--;
}
if (!Set.insert(knownValues, value))
revert();
}
// In this contract, we can also directly access knownValues.flags, if we want.
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment