Skip to content

Commit

Permalink
Floor/Ceiling
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Mar 9, 2023
1 parent 3b55403 commit 021bbc7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions cpg-language-go/src/main/golang/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions cpg-language-go/src/main/golang/frontend/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions cpg-language-go/src/test/resources/golang/slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 021bbc7

Please sign in to comment.