Changeset c54f5d0 in mainline for uspace/app/bithenge/script.c
- Timestamp:
- 2012-08-09T05:23:54Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 71450c8
- Parents:
- 3c70376
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/script.c
r3c70376 rc54f5d0 66 66 TOKEN_IF, 67 67 TOKEN_IN, 68 TOKEN_PARTIAL, 68 69 TOKEN_REPEAT, 69 70 TOKEN_STRUCT, … … 232 233 } else if (!str_cmp(value, "in")) { 233 234 state->token = TOKEN_IN; 235 free(value); 236 } else if (!str_cmp(value, "partial")) { 237 state->token = TOKEN_PARTIAL; 234 238 free(value); 235 239 } else if (!str_cmp(value, "repeat")) { … … 871 875 } 872 876 877 static bithenge_transform_t *parse_partial(state_t *state) 878 { 879 expect(state, TOKEN_PARTIAL); 880 bithenge_transform_t *offset_xform = NULL; 881 if (state->token == '(') { 882 next_token(state); 883 bithenge_expression_t *offset = parse_expression(state); 884 expect(state, ')'); 885 886 bithenge_expression_t *in_expr; 887 int rc = bithenge_in_node_expression(&in_expr); 888 if (rc != EOK) 889 error_errno(state, rc); 890 if (state->error != EOK) { 891 bithenge_expression_dec_ref(offset); 892 return NULL; 893 } 894 895 rc = bithenge_subblob_expression(&offset, in_expr, offset, 896 NULL, true); 897 if (rc != EOK) { 898 error_errno(state, rc); 899 return NULL; 900 } 901 902 rc = bithenge_expression_transform(&offset_xform, offset); 903 if (rc != EOK) { 904 error_errno(state, rc); 905 return NULL; 906 } 907 } 908 expect(state, '{'); 909 bithenge_transform_t *xform = parse_transform(state); 910 expect(state, '}'); 911 if (state->error != EOK) { 912 bithenge_transform_dec_ref(offset_xform); 913 bithenge_transform_dec_ref(xform); 914 return NULL; 915 } 916 917 int rc = bithenge_partial_transform(&xform, xform); 918 if (rc != EOK) { 919 error_errno(state, rc); 920 bithenge_transform_dec_ref(offset_xform); 921 return NULL; 922 } 923 924 if (offset_xform) { 925 bithenge_transform_t **xforms = malloc(2 * sizeof(*xforms)); 926 if (!xforms) { 927 error_errno(state, ENOMEM); 928 bithenge_transform_dec_ref(xform); 929 bithenge_transform_dec_ref(offset_xform); 930 return NULL; 931 } 932 xforms[0] = xform; 933 xforms[1] = offset_xform; 934 rc = bithenge_new_composed_transform(&xform, xforms, 2); 935 if (rc != EOK) { 936 error_errno(state, rc); 937 return NULL; 938 } 939 } 940 941 return xform; 942 } 943 873 944 /* The TOKEN_STRUCT and '{' must already have been skipped. */ 874 945 static bithenge_transform_t *parse_struct(state_t *state) … … 952 1023 } else if (state->token == TOKEN_IF) { 953 1024 return parse_if(state, false); 1025 } else if (state->token == TOKEN_PARTIAL) { 1026 return parse_partial(state); 954 1027 } else if (state->token == TOKEN_REPEAT) { 955 1028 return parse_repeat(state);
Note:
See TracChangeset
for help on using the changeset viewer.