MCPcopy Create free account
hub / github.com/boostorg/build / var_parse_var_compile

Function var_parse_var_compile

src/engine/function.cpp:1938–2021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1936 compiler * c );
1937
1938static void var_parse_var_compile( VAR_PARSE_VAR const * parse, compiler * c )
1939{
1940 int32_t expand_name = 0;
1941 int32_t is_get_grist = 0;
1942 int32_t has_modifiers = 0;
1943 /* Special case common modifiers */
1944 if ( parse->modifiers->size == 1 )
1945 {
1946 VAR_PARSE_GROUP * mod = dynamic_array_at( VAR_PARSE_GROUP *, parse->modifiers, 0 );
1947 if ( mod->elems->size == 1 )
1948 {
1949 VAR_PARSE * mod1 = dynamic_array_at( VAR_PARSE *, mod->elems, 0 );
1950 if ( mod1->type == VAR_PARSE_TYPE_STRING )
1951 {
1952 OBJECT * s = ( (VAR_PARSE_STRING *)mod1 )->s;
1953 if ( ! strcmp ( object_str( s ), "G" ) )
1954 {
1955 is_get_grist = 1;
1956 }
1957 }
1958 }
1959 }
1960 /* If there are modifiers, emit them in reverse order. */
1961 if ( parse->modifiers->size > 0 && !is_get_grist )
1962 {
1963 int32_t i;
1964 has_modifiers = 1;
1965 for ( i = 0; i < parse->modifiers->size; ++i )
1966 var_parse_group_compile( dynamic_array_at( VAR_PARSE_GROUP *,
1967 parse->modifiers, parse->modifiers->size - i - 1 ), c );
1968 }
1969
1970 /* If there is a subscript, emit it. */
1971 if ( parse->subscript )
1972 var_parse_group_compile( parse->subscript, c );
1973
1974 /* If the variable name is empty, look it up. */
1975 if ( parse->name->elems->size == 0 )
1976 compile_emit( c, INSTR_PUSH_VAR, compile_emit_constant( c,
1977 constant_empty ) );
1978 /* If the variable name does not need to be expanded, look it up. */
1979 else if ( parse->name->elems->size == 1 && dynamic_array_at( VAR_PARSE *,
1980 parse->name->elems, 0 )->type == VAR_PARSE_TYPE_STRING )
1981 {
1982 OBJECT * const name = ( (VAR_PARSE_STRING *)dynamic_array_at(
1983 VAR_PARSE *, parse->name->elems, 0 ) )->s;
1984 int32_t const idx = get_argument_index( object_str( name ) );
1985 if ( idx != -1 )
1986 compile_emit( c, INSTR_PUSH_ARG, idx );
1987 else
1988 compile_emit( c, INSTR_PUSH_VAR, compile_emit_constant( c, name ) );
1989 }
1990 /* Otherwise, push the var names and use the group instruction. */
1991 else
1992 {
1993 var_parse_group_compile( parse->name, c );
1994 expand_name = 1;
1995 }

Callers 2

var_parse_compileFunction · 0.85
compile_parseFunction · 0.85

Calls 5

object_strFunction · 0.85
var_parse_group_compileFunction · 0.85
compile_emitFunction · 0.85
compile_emit_constantFunction · 0.85
get_argument_indexFunction · 0.85

Tested by

no test coverage detected