-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
243 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...e/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/statements/expressions/SliceExpression.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2023, Fraunhofer AISEC. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* $$$$$$\ $$$$$$$\ $$$$$$\ | ||
* $$ __$$\ $$ __$$\ $$ __$$\ | ||
* $$ / \__|$$ | $$ |$$ / \__| | ||
* $$ | $$$$$$$ |$$ |$$$$\ | ||
* $$ | $$ ____/ $$ |\_$$ | | ||
* $$ | $$\ $$ | $$ | $$ | | ||
* \$$$$$ |$$ | \$$$$$ | | ||
* \______/ \__| \______/ | ||
* | ||
*/ | ||
package de.fraunhofer.aisec.cpg.graph.statements.expressions | ||
|
||
/** | ||
* Represents the specification of a slice (e.g., of an array). Usually used in combination with an | ||
* [ArraySubscriptionExpression] as the [ArraySubscriptionExpression.subscriptExpression]. | ||
* | ||
* Examples can be found in Go: | ||
* ```go | ||
* a := []int{1,2,3} | ||
* b := a[:1] | ||
* ``` | ||
* | ||
* or Python: | ||
* ```python | ||
* a = (1,2,3) | ||
* b = a[:1] | ||
* ``` | ||
* | ||
* Individual meaning of the slice indices might differ per language. | ||
*/ | ||
class SliceExpression : Expression() { | ||
|
||
/** The lower bound of the slice. This index is usually *inclusive*. */ | ||
var lowerBound: Expression? = null | ||
|
||
/** The upper bound of the slice. This index is usually *exclusive*. */ | ||
var upperBound: Expression? = null | ||
|
||
/** | ||
* Some languages offer a third value. The meaning depends completely on the language. For | ||
* example, Python allows specifying a step, while Go allows to control the underlying array's | ||
* capacity (not length). | ||
*/ | ||
var third: Expression? = null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
a := []int{1,2,3} | ||
// [1] | ||
b := a[:1] | ||
// [2, 3] | ||
c := a[1:] | ||
// [1] | ||
d := a[0:1] | ||
// [1] | ||
e := a[0:1:1] | ||
|
||
fmt.Printf("%v %v %v %v %v", a, b, c, d, e) | ||
} |
Oops, something went wrong.