Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate module metadata to be an object #2357

Merged
merged 1 commit into from
Jun 28, 2023
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
1 change: 1 addition & 0 deletions src/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ jv block_list_funcs(block body, int omit_underscores) {
}

block gen_module(block metadata) {
assert(block_is_const(metadata) && block_const_kind(metadata) == JV_KIND_OBJECT);
inst* i = inst_new(MODULEMETA);
i->imm.constant = block_const(metadata);
if (jv_get_kind(i->imm.constant) != JV_KIND_OBJECT)
Expand Down
35 changes: 18 additions & 17 deletions src/lexer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#line 2 "src/lexer.c"
#line 1 "src/lexer.c"

#line 4 "src/lexer.c"
#line 3 "src/lexer.c"

#define YY_INT_ALIGNED short int

Expand Down Expand Up @@ -281,6 +281,7 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
typedef uint64_t flex_uint64_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
Expand Down Expand Up @@ -445,7 +446,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
yy_size_t yy_n_chars;

/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
Expand Down Expand Up @@ -522,7 +523,7 @@ static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner

YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner );

void *yyalloc ( yy_size_t , yyscan_t yyscanner );
void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
Expand Down Expand Up @@ -569,7 +570,7 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
*/
#define YY_DO_BEFORE_ACTION \
yyg->yytext_ptr = yy_bp; \
yyleng = (int) (yy_cp - yy_bp); \
yyleng = (yy_size_t) (yy_cp - yy_bp); \
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
Expand Down Expand Up @@ -842,8 +843,8 @@ struct yyguts_t
size_t yy_buffer_stack_max; /**< capacity of stack. */
YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
char yy_hold_char;
int yy_n_chars;
int yyleng_r;
yy_size_t yy_n_chars;
yy_size_t yyleng_r;
char *yy_c_buf_p;
int yy_init;
int yy_start;
Expand Down Expand Up @@ -900,7 +901,7 @@ FILE *yyget_out ( yyscan_t yyscanner );

void yyset_out ( FILE * _out_str , yyscan_t yyscanner );

int yyget_leng ( yyscan_t yyscanner );
yy_size_t yyget_leng ( yyscan_t yyscanner );

char *yyget_text ( yyscan_t yyscanner );

Expand Down Expand Up @@ -985,7 +986,7 @@ static int input ( yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
int n; \
yy_size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
Expand Down Expand Up @@ -1636,7 +1637,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

else
{
int num_to_read =
yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;

while ( num_to_read <= 0 )
Expand All @@ -1650,7 +1651,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
yy_size_t new_size = b->yy_buf_size * 2;

if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
Expand Down Expand Up @@ -1708,7 +1709,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
Expand Down Expand Up @@ -1815,7 +1816,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

else
{ /* need more input */
int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++yyg->yy_c_buf_p;

switch ( yy_get_next_buffer( yyscanner ) )
Expand Down Expand Up @@ -2193,12 +2194,12 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
yy_size_t i;

/* Get memory for full buffer, including space for trailing EOB's. */
n = (yy_size_t) (_yybytes_len + 2);
Expand Down Expand Up @@ -2283,7 +2284,7 @@ static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
yy_size_t yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yytext[yyleng] = yyg->yy_hold_char; \
yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
Expand Down Expand Up @@ -2351,7 +2352,7 @@ FILE *yyget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
int yyget_leng (yyscan_t yyscanner)
yy_size_t yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
Expand Down
11 changes: 6 additions & 5 deletions src/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#define jq_yyHEADER_H 1
#define jq_yyIN_HEADER 1

#line 6 "src/lexer.h"
#line 5 "src/lexer.h"

#line 8 "src/lexer.h"
#line 7 "src/lexer.h"

#define YY_INT_ALIGNED short int

Expand Down Expand Up @@ -285,6 +285,7 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
typedef uint64_t flex_uint64_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
Expand Down Expand Up @@ -398,7 +399,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
yy_size_t yy_n_chars;

/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
Expand Down Expand Up @@ -442,7 +443,7 @@ void yypop_buffer_state ( yyscan_t yyscanner );

YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner );

void *yyalloc ( yy_size_t , yyscan_t yyscanner );
void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
Expand Down Expand Up @@ -500,7 +501,7 @@ FILE *yyget_out ( yyscan_t yyscanner );

void yyset_out ( FILE * _out_str , yyscan_t yyscanner );

int yyget_leng ( yyscan_t yyscanner );
yy_size_t yyget_leng ( yyscan_t yyscanner );

char *yyget_text ( yyscan_t yyscanner );

Expand Down
Loading