示例#1
0
文件: build_ast.py 项目: fmerg/zkay
    def visitFunctionCallExpr(self,
                              ctx: SolidityParser.FunctionCallExprContext):
        func = self.visit(ctx.func)
        args = self.handle_field(ctx.args)

        if isinstance(func, IdentifierExpr):
            if func.idf.name == 'reveal':
                if len(args) != 2:
                    ReclassifyException(
                        f'Invalid number of arguments for reveal: {args}')
                return ReclassifyExpr(args[0], args[1])

        return FunctionCallExpr(func, args)
示例#2
0
文件: test_ast.py 项目: fmerg/zkay
	def test_builtin_code(self):
		f = BuiltinFunction('+')
		c = FunctionCallExpr(f, [NumberLiteralExpr(0), NumberLiteralExpr(0)])
		self.assertEqual(c.code(), '0 + 0')
示例#3
0
文件: build_ast.py 项目: fmerg/zkay
 def visitIteExpr(self, ctx: SolidityParser.IteExprContext):
     f = BuiltinFunction('ite')
     cond = self.visit(ctx.cond)
     then_expr = self.visit(ctx.then_expr)
     else_expr = self.visit(ctx.else_expr)
     return FunctionCallExpr(f, [cond, then_expr, else_expr])
示例#4
0
文件: build_ast.py 项目: fmerg/zkay
 def _visitBinaryExpr(self, ctx):
     lhs = self.visit(ctx.lhs)
     rhs = self.visit(ctx.rhs)
     f = BuiltinFunction(ctx.op.text)
     return FunctionCallExpr(f, [lhs, rhs])
示例#5
0
文件: build_ast.py 项目: fmerg/zkay
 def visitNotExpr(self, ctx: SolidityParser.NotExprContext):
     f = BuiltinFunction('!')
     expr = self.visit(ctx.expr)
     return FunctionCallExpr(f, [expr])
示例#6
0
文件: build_ast.py 项目: fmerg/zkay
 def visitSignExpr(self, ctx: SolidityParser.SignExprContext):
     f = BuiltinFunction('sign' + ctx.op.getText())
     expr = self.visit(ctx.expr)
     return FunctionCallExpr(f, expr)
示例#7
0
文件: build_ast.py 项目: fmerg/zkay
 def visitParenthesisExpr(self, ctx: SolidityParser.ParenthesisExprContext):
     f = BuiltinFunction('parenthesis')
     expr = self.visit(ctx.expr)
     return FunctionCallExpr(f, [expr])
示例#8
0
文件: build_ast.py 项目: fmerg/zkay
 def visitIndexExpr(self, ctx: SolidityParser.IndexExprContext):
     f = BuiltinFunction('index')
     arr = self.visit(ctx.arr)
     index = self.visit(ctx.index)
     return FunctionCallExpr(f, [arr, index])