Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ object PropertyNames {
*/
val ArgumentIndex: String = "ARGUMENT_INDEX"

/** This field is used to keep track of the argument label for languages that support them, such as Swift. It is used
* in addition to `ARGUMENT_INDEX` and can be used to reconstruct the original call syntax more faithfully. For
* example, in Swift, a method call may look like `foo(arg1: 42, arg2: "hello")` where `arg1` and `arg2` are argument
* labels. In this case, the `ARGUMENT_LABEL` field for the first argument would be set to `arg1` and for the second
* argument it would be set to `arg2`. Contrary to the `ARGUMENT_NAME` the label should not be expected to match the
* name of any parameter, and is not needed for dataflow purposes at all.
*/
val ArgumentLabel: String = "ARGUMENT_LABEL"

/** For calls involving named parameters, the `ARGUMENT_NAME` field holds the name of the parameter initialized by the
* expression. For all other calls, this field is unset.
* expression. For all other calls, this field is unset. Note that the `ARGUMENT_NAME` should be an exact match of
* the NAME of a METHOD_PARAMETER_{IN,OUT}. It overrides ARGUMENT_INDEX for dataflow purposes.
*/
val ArgumentName: String = "ARGUMENT_NAME"

Expand Down Expand Up @@ -293,6 +303,7 @@ object PropertyNames {
Seq(
AliasTypeFullName,
ArgumentIndex,
ArgumentLabel,
ArgumentName,
AstParentFullName,
AstParentType,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ trait AnnotationBase extends AbstractNode with ExpressionBase with StaticType[An
import io.shiftleft.codepropertygraph.generated.accessors.languagebootstrap.*
val res = new java.util.HashMap[String, Any]()
if ((-1: Int) != this.argumentIndex) res.put("ARGUMENT_INDEX", this.argumentIndex)
this.argumentLabel.foreach { p => res.put("ARGUMENT_LABEL", p) }
this.argumentName.foreach { p => res.put("ARGUMENT_NAME", p) }
if (("<empty>": String) != this.code) res.put("CODE", this.code)
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
Expand All @@ -41,9 +42,18 @@ object Annotation {
* this case, the last argument index determines the return expression of a BLOCK expression. If the `PARAMETER_NAME`
* field is set, then the `ARGUMENT_INDEX` field is ignored. It is suggested to set it to -1.
*
* ▸ ArgumentLabel (String); Cardinality `ZeroOrOne` (optional); This field is used to keep track of the argument label
* for languages that support them, such as Swift. It is used in addition to `ARGUMENT_INDEX` and can be used to
* reconstruct the original call syntax more faithfully. For example, in Swift, a method call may look like
* `foo(arg1: 42, arg2: "hello")` where `arg1` and `arg2` are argument labels. In this case, the `ARGUMENT_LABEL` field
* for the first argument would be set to `arg1` and for the second argument it would be set to `arg2`. Contrary to the
* `ARGUMENT_NAME` the label should not be expected to match the name of any parameter, and is not needed for dataflow
* purposes at all.
*
* ▸ ArgumentName (String); Cardinality `ZeroOrOne` (optional); For calls involving named parameters, the
* `ARGUMENT_NAME` field holds the name of the parameter initialized by the expression. For all other calls, this field
* is unset.
* is unset. Note that the `ARGUMENT_NAME` should be an exact match of the NAME of a METHOD_PARAMETER_{IN,OUT}. It
* overrides ARGUMENT_INDEX for dataflow purposes.
*
* ▸ Code (String); Cardinality `one` (mandatory with default value `<empty>`); This field holds the code snippet that
* the node represents.
Expand Down Expand Up @@ -82,36 +92,38 @@ class Annotation(graph_4762: flatgraph.Graph, seq_4762: Int)

override def productElementName(n: Int): String =
n match {
case 0 => "argumentIndex"
case 1 => "argumentName"
case 2 => "code"
case 3 => "columnNumber"
case 4 => "fullName"
case 5 => "lineNumber"
case 6 => "name"
case 7 => "offset"
case 8 => "offsetEnd"
case 9 => "order"
case _ => ""
case 0 => "argumentIndex"
case 1 => "argumentLabel"
case 2 => "argumentName"
case 3 => "code"
case 4 => "columnNumber"
case 5 => "fullName"
case 6 => "lineNumber"
case 7 => "name"
case 8 => "offset"
case 9 => "offsetEnd"
case 10 => "order"
case _ => ""
}

override def productElement(n: Int): Any =
n match {
case 0 => this.argumentIndex
case 1 => this.argumentName
case 2 => this.code
case 3 => this.columnNumber
case 4 => this.fullName
case 5 => this.lineNumber
case 6 => this.name
case 7 => this.offset
case 8 => this.offsetEnd
case 9 => this.order
case _ => null
case 0 => this.argumentIndex
case 1 => this.argumentLabel
case 2 => this.argumentName
case 3 => this.code
case 4 => this.columnNumber
case 5 => this.fullName
case 6 => this.lineNumber
case 7 => this.name
case 8 => this.offset
case 9 => this.offsetEnd
case 10 => this.order
case _ => null
}

override def productPrefix = "Annotation"
override def productArity = 10
override def productArity = 11

override def canEqual(that: Any): Boolean = that != null && that.isInstanceOf[Annotation]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ trait AnnotationLiteralBase extends AbstractNode with ExpressionBase with Static
import io.shiftleft.codepropertygraph.generated.accessors.languagebootstrap.*
val res = new java.util.HashMap[String, Any]()
if ((-1: Int) != this.argumentIndex) res.put("ARGUMENT_INDEX", this.argumentIndex)
this.argumentLabel.foreach { p => res.put("ARGUMENT_LABEL", p) }
this.argumentName.foreach { p => res.put("ARGUMENT_NAME", p) }
if (("<empty>": String) != this.code) res.put("CODE", this.code)
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
Expand All @@ -40,9 +41,18 @@ object AnnotationLiteral {
* this case, the last argument index determines the return expression of a BLOCK expression. If the `PARAMETER_NAME`
* field is set, then the `ARGUMENT_INDEX` field is ignored. It is suggested to set it to -1.
*
* ▸ ArgumentLabel (String); Cardinality `ZeroOrOne` (optional); This field is used to keep track of the argument label
* for languages that support them, such as Swift. It is used in addition to `ARGUMENT_INDEX` and can be used to
* reconstruct the original call syntax more faithfully. For example, in Swift, a method call may look like
* `foo(arg1: 42, arg2: "hello")` where `arg1` and `arg2` are argument labels. In this case, the `ARGUMENT_LABEL` field
* for the first argument would be set to `arg1` and for the second argument it would be set to `arg2`. Contrary to the
* `ARGUMENT_NAME` the label should not be expected to match the name of any parameter, and is not needed for dataflow
* purposes at all.
*
* ▸ ArgumentName (String); Cardinality `ZeroOrOne` (optional); For calls involving named parameters, the
* `ARGUMENT_NAME` field holds the name of the parameter initialized by the expression. For all other calls, this field
* is unset.
* is unset. Note that the `ARGUMENT_NAME` should be an exact match of the NAME of a METHOD_PARAMETER_{IN,OUT}. It
* overrides ARGUMENT_INDEX for dataflow purposes.
*
* ▸ Code (String); Cardinality `one` (mandatory with default value `<empty>`); This field holds the code snippet that
* the node represents.
Expand Down Expand Up @@ -78,33 +88,35 @@ class AnnotationLiteral(graph_4762: flatgraph.Graph, seq_4762: Int)
override def productElementName(n: Int): String =
n match {
case 0 => "argumentIndex"
case 1 => "argumentName"
case 2 => "code"
case 3 => "columnNumber"
case 4 => "lineNumber"
case 5 => "name"
case 6 => "offset"
case 7 => "offsetEnd"
case 8 => "order"
case 1 => "argumentLabel"
case 2 => "argumentName"
case 3 => "code"
case 4 => "columnNumber"
case 5 => "lineNumber"
case 6 => "name"
case 7 => "offset"
case 8 => "offsetEnd"
case 9 => "order"
case _ => ""
}

override def productElement(n: Int): Any =
n match {
case 0 => this.argumentIndex
case 1 => this.argumentName
case 2 => this.code
case 3 => this.columnNumber
case 4 => this.lineNumber
case 5 => this.name
case 6 => this.offset
case 7 => this.offsetEnd
case 8 => this.order
case 1 => this.argumentLabel
case 2 => this.argumentName
case 3 => this.code
case 4 => this.columnNumber
case 5 => this.lineNumber
case 6 => this.name
case 7 => this.offset
case 8 => this.offsetEnd
case 9 => this.order
case _ => null
}

override def productPrefix = "AnnotationLiteral"
override def productArity = 9
override def productArity = 10

override def canEqual(that: Any): Boolean = that != null && that.isInstanceOf[AnnotationLiteral]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ trait ArrayInitializerBase extends AbstractNode with ExpressionBase with StaticT
import io.shiftleft.codepropertygraph.generated.accessors.languagebootstrap.*
val res = new java.util.HashMap[String, Any]()
if ((-1: Int) != this.argumentIndex) res.put("ARGUMENT_INDEX", this.argumentIndex)
this.argumentLabel.foreach { p => res.put("ARGUMENT_LABEL", p) }
this.argumentName.foreach { p => res.put("ARGUMENT_NAME", p) }
if (("<empty>": String) != this.code) res.put("CODE", this.code)
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
Expand All @@ -39,9 +40,18 @@ object ArrayInitializer {
* this case, the last argument index determines the return expression of a BLOCK expression. If the `PARAMETER_NAME`
* field is set, then the `ARGUMENT_INDEX` field is ignored. It is suggested to set it to -1.
*
* ▸ ArgumentLabel (String); Cardinality `ZeroOrOne` (optional); This field is used to keep track of the argument label
* for languages that support them, such as Swift. It is used in addition to `ARGUMENT_INDEX` and can be used to
* reconstruct the original call syntax more faithfully. For example, in Swift, a method call may look like
* `foo(arg1: 42, arg2: "hello")` where `arg1` and `arg2` are argument labels. In this case, the `ARGUMENT_LABEL` field
* for the first argument would be set to `arg1` and for the second argument it would be set to `arg2`. Contrary to the
* `ARGUMENT_NAME` the label should not be expected to match the name of any parameter, and is not needed for dataflow
* purposes at all.
*
* ▸ ArgumentName (String); Cardinality `ZeroOrOne` (optional); For calls involving named parameters, the
* `ARGUMENT_NAME` field holds the name of the parameter initialized by the expression. For all other calls, this field
* is unset.
* is unset. Note that the `ARGUMENT_NAME` should be an exact match of the NAME of a METHOD_PARAMETER_{IN,OUT}. It
* overrides ARGUMENT_INDEX for dataflow purposes.
*
* ▸ Code (String); Cardinality `one` (mandatory with default value `<empty>`); This field holds the code snippet that
* the node represents.
Expand Down Expand Up @@ -74,31 +84,33 @@ class ArrayInitializer(graph_4762: flatgraph.Graph, seq_4762: Int)
override def productElementName(n: Int): String =
n match {
case 0 => "argumentIndex"
case 1 => "argumentName"
case 2 => "code"
case 3 => "columnNumber"
case 4 => "lineNumber"
case 5 => "offset"
case 6 => "offsetEnd"
case 7 => "order"
case 1 => "argumentLabel"
case 2 => "argumentName"
case 3 => "code"
case 4 => "columnNumber"
case 5 => "lineNumber"
case 6 => "offset"
case 7 => "offsetEnd"
case 8 => "order"
case _ => ""
}

override def productElement(n: Int): Any =
n match {
case 0 => this.argumentIndex
case 1 => this.argumentName
case 2 => this.code
case 3 => this.columnNumber
case 4 => this.lineNumber
case 5 => this.offset
case 6 => this.offsetEnd
case 7 => this.order
case 1 => this.argumentLabel
case 2 => this.argumentName
case 3 => this.code
case 4 => this.columnNumber
case 5 => this.lineNumber
case 6 => this.offset
case 7 => this.offsetEnd
case 8 => this.order
case _ => null
}

override def productPrefix = "ArrayInitializer"
override def productArity = 8
override def productArity = 9

override def canEqual(that: Any): Boolean = that != null && that.isInstanceOf[ArrayInitializer]
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,15 @@ trait DeclarationNew extends NewNode with DeclarationBase with StaticType[Declar
def name(value: String): this.type
}

trait ExpressionEMT extends AnyRef with CfgNodeEMT with HasArgumentIndexEMT with HasArgumentNameEMT
trait ExpressionEMT
extends AnyRef
with CfgNodeEMT
with HasArgumentIndexEMT
with HasArgumentLabelEMT
with HasArgumentNameEMT

trait ExpressionBase extends AbstractNode with CfgNodeBase with StaticType[ExpressionEMT]
// new properties: ARGUMENT_INDEX, ARGUMENT_NAME
// new properties: ARGUMENT_INDEX, ARGUMENT_LABEL, ARGUMENT_NAME
// inherited properties: CODE, COLUMN_NUMBER, LINE_NUMBER, OFFSET, OFFSET_END, ORDER
// inherited interfaces: AST_NODE
// implementing nodes: ANNOTATION, ANNOTATION_LITERAL, ARRAY_INITIALIZER, BLOCK, CALL, CONTROL_STRUCTURE, FIELD_IDENTIFIER, IDENTIFIER, LITERAL, METHOD_REF, RETURN, TEMPLATE_DOM, TYPE_REF, UNKNOWN
Expand All @@ -98,6 +103,10 @@ trait ExpressionNew extends NewNode with ExpressionBase with AstNodeNew with Cfg
def argumentIndex: Int
def argumentIndex_=(value: Int): Unit
def argumentIndex(value: Int): this.type
def argumentLabel: Option[String]
def argumentLabel_=(value: Option[String]): Unit
def argumentLabel(value: Option[String]): this.type
def argumentLabel(value: String): this.type
def argumentName: Option[String]
def argumentName_=(value: Option[String]): Unit
def argumentName(value: Option[String]): this.type
Expand All @@ -114,6 +123,11 @@ trait HasAliasTypeFullNameEMT
*/
trait HasArgumentIndexEMT

/** Node types with this marker trait are guaranteed to have the ARGUMENT_LABEL property. EMT stands for: "erased marker
* trait", it exists only at compile time in order to improve type safety.
*/
trait HasArgumentLabelEMT

/** Node types with this marker trait are guaranteed to have the ARGUMENT_NAME property. EMT stands for: "erased marker
* trait", it exists only at compile time in order to improve type safety.
*/
Expand Down
Loading