Exemple #1
0
	def test_builtin_code(self):
		f = BuiltinFunction('+')
		c = FunctionCallExpr(f, [NumberLiteralExpr(0), NumberLiteralExpr(0)])
		self.assertEqual(c.code(), '0 + 0')
Exemple #2
0
 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])
Exemple #3
0
	def test_builtin_arity(self):
		f = BuiltinFunction('+')
		self.assertEqual(f.arity(), 2)
Exemple #4
0
 def _visitBinaryExpr(self, ctx):
     lhs = self.visit(ctx.lhs)
     rhs = self.visit(ctx.rhs)
     f = BuiltinFunction(ctx.op.text)
     return FunctionCallExpr(f, [lhs, rhs])
Exemple #5
0
 def visitNotExpr(self, ctx: SolidityParser.NotExprContext):
     f = BuiltinFunction('!')
     expr = self.visit(ctx.expr)
     return FunctionCallExpr(f, [expr])
Exemple #6
0
 def visitSignExpr(self, ctx: SolidityParser.SignExprContext):
     f = BuiltinFunction('sign' + ctx.op.getText())
     expr = self.visit(ctx.expr)
     return FunctionCallExpr(f, expr)
Exemple #7
0
 def visitParenthesisExpr(self, ctx: SolidityParser.ParenthesisExprContext):
     f = BuiltinFunction('parenthesis')
     expr = self.visit(ctx.expr)
     return FunctionCallExpr(f, [expr])
Exemple #8
0
 def visitIndexExpr(self, ctx: SolidityParser.IndexExprContext):
     f = BuiltinFunction('index')
     arr = self.visit(ctx.arr)
     index = self.visit(ctx.index)
     return FunctionCallExpr(f, [arr, index])