C#: Extract init only accessors and custom modifiers

This commit is contained in:
Tamas Vajk
2020-12-14 11:54:47 +01:00
parent 57c163f314
commit 7662b55ecc
14 changed files with 149 additions and 23 deletions

View File

@@ -247,8 +247,12 @@ class Setter extends Accessor {
override Property getProperty() { cil_setter(result, this) }
/** Holds if this setter is an `init`-only accessor. */
predicate isInitOnly() { none() }
/** Holds if this setter is an `init` accessor. */
predicate isInitOnly() {
exists(Type t | t.getQualifiedName() = "System.Runtime.CompilerServices.IsExternalInit" |
cil_custom_modifiers(this, t, 1)
)
}
}
/**

View File

@@ -1712,6 +1712,7 @@ cil_field(
@cil_variable = @cil_field | @cil_stack_variable;
@cil_stack_variable = @cil_local_variable | @cil_parameter;
@cil_member = @cil_method | @cil_type | @cil_field | @cil_property | @cil_event;
@cil_custom_modifier_receiver = @cil_method | @cil_property | @cil_parameter | @cil_field; // todo: add function pointer type
#keyset[method, index]
cil_parameter(
@@ -1726,6 +1727,12 @@ cil_parameter_out(unique int id: @cil_parameter ref);
cil_setter(unique int prop: @cil_property ref,
int method: @cil_method ref);
#keyset[id, modifier]
cil_custom_modifiers(
int id: @cil_custom_modifier_receiver ref,
int modifier: @cil_type ref,
int kind: int ref); // modreq: 1, modopt: 0
cil_getter(unique int prop: @cil_property ref,
int method: @cil_method ref);