Types
Types represent the type of an expression (ExpressionAbc), type name (TypeNameAbc) and VariableDeclaration.
woke.ast.types
module
#
TypeAbc
class
#
Bases: ABC
Abstract base class for all types.
Source code in woke/ast/types.py
Address
class
#
Bases: TypeAbc
Address type.
Source code in woke/ast/types.py
Bool
class
#
IntAbc
class
#
Bases: TypeAbc
Base class for Int and UInt types.
Source code in woke/ast/types.py
Int
class
#
Bases: IntAbc
Signed integer type.
Source code in woke/ast/types.py
UInt
class
#
Bases: IntAbc
Unsigned integer type.
Source code in woke/ast/types.py
FixedAbc
class
#
Bases: TypeAbc
Base class for Fixed and UFixed types.
Info
Currently not fully implemented in Solidity.
Source code in woke/ast/types.py
Fixed
class
#
Bases: FixedAbc
Signed fixed-point number type as specified by the Solidity docs.
Info
Currently not fully implemented in Solidity.
Source code in woke/ast/types.py
UFixed
class
#
Bases: FixedAbc
Unsigned fixed point number type as specified by the Solidity docs.
Info
Currently not fully implemented in Solidity.
Source code in woke/ast/types.py
StringLiteral
class
#
Bases: TypeAbc
String literal type.
Warning
This expression is of the StringLiteral type:
However, this expression is of the String type and contains a child expression of the StringLiteral type:
Source code in woke/ast/types.py
String
class
#
Bases: TypeAbc
String type.
Source code in woke/ast/types.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
|
data_location: DataLocation
property
#
Can be either CALLDATA, MEMORY or STORAGE
Returns:
Type | Description |
---|---|
DataLocation
|
Data location of the string expression. |
is_pointer: bool
property
#
Storage references can be pointers or bound references. In general, local variables are of pointer type, state variables are bound references. Assignments to pointers or deleting them will not modify storage (that will only change the pointer). Assignment from non-storage objects to a variable of storage pointer type is not possible.
For anything other than STORAGE, this always returns True
because assignments
never change the contents of the original value.
Returns:
Type | Description |
---|---|
bool
|
Whether the string expression is a pointer to storage. |
Bytes
class
#
Bases: TypeAbc
Bytes type.
Source code in woke/ast/types.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
|
data_location: DataLocation
property
#
Can be either CALLDATA, MEMORY or STORAGE
Returns:
Type | Description |
---|---|
DataLocation
|
Data location of the bytes expression. |
is_pointer: bool
property
#
Storage references can be pointers or bound references. In general, local variables are of pointer type, state variables are bound references. Assignments to pointers or deleting them will not modify storage (that will only change the pointer). Assignment from non-storage objects to a variable of storage pointer type is not possible.
For anything other than STORAGE, this always returns True
because assignments
never change the contents of the original value.
Returns:
Type | Description |
---|---|
bool
|
Whether the bytes expression is a pointer to storage. |
FixedBytes
class
#
Bases: TypeAbc
Fixed-size byte array type.
Source code in woke/ast/types.py
Function
class
#
Bases: TypeAbc
Function type.
Warning
Given the following function:
and the following call: the type offoo
is Function, but the type of foo(1, 2)
is Tuple.
Source code in woke/ast/types.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
|
kind: FunctionTypeKind
property
#
Returns:
Type | Description |
---|---|
FunctionTypeKind
|
Kind of the function type. |
state_mutability: StateMutability
property
#
Returns:
Type | Description |
---|---|
StateMutability
|
State mutability of the function type. |
parameters: typ.Tuple[TypeAbc, ...]
property
#
return_parameters: typ.Tuple[TypeAbc, ...]
property
#
gas_set: bool
property
#
Example
In the case of the old syntax (deprecated), the gas
MemberAccess expression is of the Function type which returns a Function with gas_set
set to True
.
In the case of the new syntax, the {gas: 10}
FunctionCallOptions expression is of the Function type with gas_set
set to True
.
Returns:
Type | Description |
---|---|
bool
|
|
value_set: bool
property
#
Example
In the case of the old syntax (deprecated), the value
MemberAccess expression is of the Function type which returns a Function with value_set
set to True
.
In the case of the new syntax, the {value: 1}
FunctionCallOptions expression is of the Function type with value_set
set to True
.
Returns:
Type | Description |
---|---|
bool
|
|
salt_set: bool
property
#
Example
In the following example, the {salt: salt}
FunctionCallOptions expression is of the Function type with salt_set
set to True
.
Returns:
Type | Description |
---|---|
bool
|
|
attached_to: typ.Optional[typ.Tuple[TypeAbc, ...]]
property
#
A function type can be attached to a type using the UsingForDirective or internally in the case of a Solidity global symbol.
Example
In the following example, the add
MemberAccess expression on line 9 is of the Function type and is attached to the UInt type.
In this example, the push
MemberAccess expression on line 9 is of the Function type and is attached to the Array type.
Returns:
Type | Description |
---|---|
typ.Optional[typ.Tuple[TypeAbc, ...]]
|
Type to which the function is attached to. |
Tuple
class
#
Bases: TypeAbc
Tuple type.
Source code in woke/ast/types.py
components: typ.Tuple[typ.Optional[TypeAbc], ...]
property
#
A component type can be None
in the case of a tuple with a missing component.
Example
In the following example, the (success, )
expression is of the Tuple type with the components of the type Bool and None
.
Returns:
Type | Description |
---|---|
typ.Tuple[typ.Optional[TypeAbc], ...]
|
Expression types of the components of the tuple type. |
Type
class
#
Bases: TypeAbc
Type type. As opposed to other types, this type describes the type of a type, not the type of an instance of a type.
Source code in woke/ast/types.py
actual_type: TypeAbc
property
#
Example
payable
in the following example is of the Type type with the Address actual type.
super
in the following example is of the Type type with the Contract actual type.
string
in the following example is of the Type type with the String actual type.
Foo
in the following example on line 4 is of the Type type with the Enum actual type.
Returns:
Type | Description |
---|---|
TypeAbc
|
Actual type of the type type. |
Rational
class
#
Bases: TypeAbc
Rational type. Represents the type of constants or expressions with constants.
Example
1
, 0x1234
, 1e18
, 1 * 2 / 3
are all of the Rational type.
Source code in woke/ast/types.py
Modifier
class
#
Bases: TypeAbc
Modifier type.
Source code in woke/ast/types.py
Array
class
#
Bases: TypeAbc
Array type.
Source code in woke/ast/types.py
940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
|
length: typ.Optional[int]
property
#
data_location: DataLocation
property
#
Returns:
Type | Description |
---|---|
DataLocation
|
Data location of the array. |
is_pointer: bool
property
#
Storage references can be pointers or bound references. In general, local variables are of pointer type, state variables are bound references. Assignments to pointers or deleting them will not modify storage (that will only change the pointer). Assignment from non-storage objects to a variable of storage pointer type is not possible.
For anything other than STORAGE, this always returns True
because assignments
never change the contents of the original value.
Returns:
Type | Description |
---|---|
bool
|
Whether the array expression is a pointer to storage. |
Mapping
class
#
Bases: TypeAbc
Mapping type.
Source code in woke/ast/types.py
Contract
class
#
Bases: TypeAbc
Source code in woke/ast/types.py
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 |
|
is_super: bool
property
#
Warning
Until 0.7.6, the super
keyword (Identifier) was of the Contract type with is_super
set to True
.
Since 0.8.0, the super
keyword is of the Type type with Contract as the actual_type
and is_super
set to True
.
Warning
When this is True
, the name
and ir_node
properties refer to the current contract, not the base contract.
Example
The name
and ir_node
properties of the Contract type of the super
expression in the following example refer to the Foo
contract, not the Bar
contract.
Returns:
Type | Description |
---|---|
bool
|
|
ir_node: ContractDefinition
property
#
Returns:
Type | Description |
---|---|
ContractDefinition
|
Contract definition IR node. |
Struct
class
#
Bases: TypeAbc
Struct type.
Source code in woke/ast/types.py
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 |
|
data_location: DataLocation
property
#
Returns:
Type | Description |
---|---|
DataLocation
|
Data location of the struct. |
is_pointer: bool
property
#
Storage references can be pointers or bound references. In general, local variables are of pointer type, state variables are bound references. Assignments to pointers or deleting them will not modify storage (that will only change the pointer). Assignment from non-storage objects to a variable of storage pointer type is not possible.
For anything other than STORAGE, this always returns True
because assignments
never change the contents of the original value.
Returns:
Type | Description |
---|---|
bool
|
Whether the struct expression is a pointer to storage. |
ir_node: StructDefinition
property
#
Returns:
Type | Description |
---|---|
StructDefinition
|
Struct definition IR node. |
Enum
class
#
Bases: TypeAbc
Enum type.
Warning
Enum values are of the Enum type and enums are of the Type type with Enum as the actual_type.
Source code in woke/ast/types.py
ir_node: EnumDefinition
property
#
Returns:
Type | Description |
---|---|
EnumDefinition
|
Enum definition IR node. |
Magic
class
#
Bases: TypeAbc
Magic type represents Solidity language built-in objects.
Source code in woke/ast/types.py
kind: MagicTypeKind
property
#
Returns:
Type | Description |
---|---|
MagicTypeKind
|
Kind of the magic type. |
UserDefinedValueType
class
#
Bases: TypeAbc
Source code in woke/ast/types.py
ir_node: UserDefinedValueTypeDefinition
property
#
Returns:
Type | Description |
---|---|
UserDefinedValueTypeDefinition
|
User defined value type definition IR node. |
Module
class
#
Bases: TypeAbc
Module type.
Note
It is probably currently not possible to create an expression of this type.