From 021bbc7dfb2dab4b02a3394937fb781ef763e516 Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Thu, 9 Mar 2023 20:12:14 +0100 Subject: [PATCH] Floor/Ceiling --- cpg-language-go/src/main/golang/expressions.go | 8 ++++---- cpg-language-go/src/main/golang/frontend/handler.go | 4 ++-- cpg-language-go/src/test/resources/golang/slices.go | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cpg-language-go/src/main/golang/expressions.go b/cpg-language-go/src/main/golang/expressions.go index 45b9b85caba..d1716ea3369 100644 --- a/cpg-language-go/src/main/golang/expressions.go +++ b/cpg-language-go/src/main/golang/expressions.go @@ -210,12 +210,12 @@ func (r *ArraySubscriptionExpression) SetSubscriptExpression(e *Expression) { (*jnigi.ObjectRef)(r).CallMethod(env, "setSubscriptExpression", nil, (*jnigi.ObjectRef)(e).Cast(ExpressionClass)) } -func (s *RangeExpression) SetLowerBound(e *Expression) { - (*jnigi.ObjectRef)(s).CallMethod(env, "setLowerBound", nil, (*jnigi.ObjectRef)(e).Cast(ExpressionClass)) +func (s *RangeExpression) SetFloor(e *Expression) { + (*jnigi.ObjectRef)(s).CallMethod(env, "setFloor", nil, (*jnigi.ObjectRef)(e).Cast(ExpressionClass)) } -func (s *RangeExpression) SetUpperBound(e *Expression) { - (*jnigi.ObjectRef)(s).CallMethod(env, "setUpperBound", nil, (*jnigi.ObjectRef)(e).Cast(ExpressionClass)) +func (s *RangeExpression) SetCeiling(e *Expression) { + (*jnigi.ObjectRef)(s).CallMethod(env, "setCeiling", nil, (*jnigi.ObjectRef)(e).Cast(ExpressionClass)) } func (s *RangeExpression) SetThird(e *Expression) { diff --git a/cpg-language-go/src/main/golang/frontend/handler.go b/cpg-language-go/src/main/golang/frontend/handler.go index 7553587d984..8d594a22348 100644 --- a/cpg-language-go/src/main/golang/frontend/handler.go +++ b/cpg-language-go/src/main/golang/frontend/handler.go @@ -1037,10 +1037,10 @@ func (this *GoLanguageFrontend) handleSliceExpr(fset *token.FileSet, sliceExpr * // Build the slice expression s := this.NewRangeExpression(fset, sliceExpr) if sliceExpr.Low != nil { - s.SetLowerBound(this.handleExpr(fset, sliceExpr.Low)) + s.SetFloor(this.handleExpr(fset, sliceExpr.Low)) } if sliceExpr.High != nil { - s.SetUpperBound(this.handleExpr(fset, sliceExpr.High)) + s.SetCeiling(this.handleExpr(fset, sliceExpr.High)) } if sliceExpr.Max != nil { s.SetThird(this.handleExpr(fset, sliceExpr.Max)) diff --git a/cpg-language-go/src/test/resources/golang/slices.go b/cpg-language-go/src/test/resources/golang/slices.go index 00563b29f9b..4c6c44a4967 100644 --- a/cpg-language-go/src/test/resources/golang/slices.go +++ b/cpg-language-go/src/test/resources/golang/slices.go @@ -3,19 +3,19 @@ package main import "fmt" func main() { - var a = []int{1,2,3} + a := []int{1,2,3} // [1] - var b = a[:1] + b := a[:1] // [2, 3] - var c = a[1:] + c := a[1:] // [1] - var d = a[0:1] + d := a[0:1] // [1] - var e = a[0:1:1] + e := a[0:1:1] fmt.Printf("%v %v %v %v %v", a, b, c, d, e) } \ No newline at end of file