public AstVariableDeclaration(JObject node) : base(node) { // Set our properties Name = node.SelectToken("name")?.Value <string>(); Visibility = GetVisibilityFromString(node.SelectToken("visibility")?.Value <string>()); TypeName = Create <AstElementaryTypeName>(node.SelectToken("typeName") as JObject); StateVariable = node.SelectToken("stateVariable")?.Value <bool>() == true; Constant = node.SelectToken("constant")?.Value <bool>() == true; // Determine our storage location string storageLoc = node.SelectToken("storageLocation")?.Value <string>()?.ToLower(CultureInfo.InvariantCulture); switch (storageLoc) { case "default": StorageLocation = AstVariableStorageLocation.Default; break; case "memory": StorageLocation = AstVariableStorageLocation.Memory; break; case "storage": StorageLocation = AstVariableStorageLocation.Storage; break; default: throw new ArgumentException($"Invalid {nameof(AstVariableStorageLocation)} values when parsing {nameof(AstVariableDeclaration)}"); } // Parse our type descriptions TypeDescriptions = new AstTypeDescriptions(node); }
public AstElementaryTypeName(JObject node) : base(node) { // Set our properties Name = node.SelectToken("name")?.Value <string>(); TypeDescriptions = new AstTypeDescriptions(node); }