示例#1
0
static void
generate_ARB_draw_buffers_variables(exec_list *instructions,
                                    struct _mesa_glsl_parse_state *state,
                                    bool warn, _mesa_glsl_parser_targets target)
{
    /* gl_MaxDrawBuffers is available in all shader stages.
     */
    ir_variable *const mdb =
        add_variable(instructions, state->symbols,
                     "gl_MaxDrawBuffers", glsl_type::int_type, ir_var_auto, -1);

    if (warn)
        mdb->warn_extension = "GL_ARB_draw_buffers";

    mdb->constant_value = new(mdb)
    ir_constant(int(state->Const.MaxDrawBuffers));


    /* gl_FragData is only available in the fragment shader.
     */
    if (target == fragment_shader) {
        const glsl_type *const vec4_array_type =
            glsl_type::get_array_instance(glsl_type::vec4_type,
                                          state->Const.MaxDrawBuffers);

        ir_variable *const fd =
            add_variable(instructions, state->symbols,
                         "gl_FragData", vec4_array_type,
                         ir_var_out, FRAG_RESULT_DATA0);

        if (warn)
            fd->warn_extension = "GL_ARB_draw_buffers";
    }
}
示例#2
0
static void
generate_130_vs_variables(exec_list *instructions,
                          struct _mesa_glsl_parse_state *state,
                          bool add_deprecated)
{
    generate_120_vs_variables(instructions, state, add_deprecated);

    for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) {
        add_builtin_variable(instructions, state->symbols,
                             & builtin_130_vs_variables[i]);
    }

    generate_130_uniforms(instructions, state);

    /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special
     * Variables):
     *
     *   The gl_ClipDistance array is predeclared as unsized and must
     *   be sized by the shader either redeclaring it with a size or
     *   indexing it only with integral constant expressions.
     *
     * We represent this in Mesa by initially declaring the array as
     * size 0.
     */
    const glsl_type *const clip_distance_array_type =
        glsl_type::get_array_instance(glsl_type::float_type, 0);

    add_variable(instructions, state->symbols,
                 "gl_ClipDistance", clip_distance_array_type, ir_var_shader_out,
                 VERT_RESULT_CLIP_DIST0);

}
示例#3
0
static void
generate_ARB_draw_buffers_variables(exec_list *instructions,
                                    struct _mesa_glsl_parse_state *state,
                                    bool warn, _mesa_glsl_parser_targets target)
{
    /* gl_MaxDrawBuffers is available in all shader stages.
     */
    ir_variable *const mdb =
        add_builtin_constant(instructions, state->symbols, "gl_MaxDrawBuffers",
                             state->Const.MaxDrawBuffers);

    if (warn)
        mdb->warn_extension = "GL_ARB_draw_buffers";

    /* gl_FragData is only available in the fragment shader.
     * It is not present in GLSL 3.00 ES.
     */
    if (target == fragment_shader && !state->is_version(0, 300)) {
        const glsl_type *const vec4_array_type =
            glsl_type::get_array_instance(glsl_type::vec4_type,
                                          state->Const.MaxDrawBuffers);

        ir_variable *const fd =
            add_variable(instructions, state->symbols,
                         "gl_FragData", vec4_array_type,
                         ir_var_shader_out, FRAG_RESULT_DATA0);

        if (warn)
            fd->warn_extension = "GL_ARB_draw_buffers";
    }
}
示例#4
0
void Mesh_view_3::load_generic_file(const std::string& filename) {
	if (QString(filename.c_str()).endsWith(".off")) {
		std::ifstream f(filename.c_str());
		p.clear();
		f >> p;
		f.close();
		Polyhedron::Vertex_iterator v_it, v_end = p.vertices_end();
		double minx, miny, minz, maxx, maxy, maxz;
		for (v_it = p.vertices_begin(); v_it!=v_end; ++v_it) {
			double x = v_it->point().x();
			double y = v_it->point().y();
			double z = v_it->point().z();
			if (v_it == p.vertices_begin()) {
				minx = maxx = x;
				miny = maxy = y;
				minz = maxz = z;
			} else {
				if (x < minx) minx = x; if (x > maxx) maxx =x;
				if (y < miny) miny = y; if (y > maxy) maxy =y;
				if (z < minz) minz = z; if (z > maxz) maxz =z;
			}
		}

		std::cout << "Bounding box: (" << minx << "," << miny << "," << minz << ") - (" << maxx << "," << maxy << "," << maxz << ")" << std::endl;
		double dx = maxx-minx, dy = maxy-miny, dz = maxz - minz;
		bounding_radius = sqrt(dx*dx + dy*dy + dz*dz) / 2.0;
		add_variable("Input bounding box radius", bounding_radius);
		std::cout << "Mesh_view_3: Polyhedron loaded from " << filename << " and contains " << p.size_of_facets () <<" faces and " << p.size_of_vertices() << " vertices." << std::endl;
		invalidate_cache();
	}
示例#5
0
static void
generate_110_vs_variables(exec_list *instructions,
                          struct _mesa_glsl_parse_state *state)
{
    for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) {
        add_builtin_variable(instructions, state->symbols,
                             & builtin_core_vs_variables[i]);
    }

    for (unsigned i = 0
                      ; i < Elements(builtin_110_deprecated_vs_variables)
            ; i++) {
        add_builtin_variable(instructions, state->symbols,
                             & builtin_110_deprecated_vs_variables[i]);
    }
    generate_110_uniforms(instructions, state);

    /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
     *
     *     "As with all arrays, indices used to subscript gl_TexCoord must
     *     either be an integral constant expressions, or this array must be
     *     re-declared by the shader with a size. The size can be at most
     *     gl_MaxTextureCoords. Using indexes close to 0 may aid the
     *     implementation in preserving varying resources."
     */
    const glsl_type *const vec4_array_type =
        glsl_type::get_array_instance(glsl_type::vec4_type, 0);

    add_variable(instructions, state->symbols,
                 "gl_TexCoord", vec4_array_type, ir_var_out, VERT_RESULT_TEX0);

    generate_ARB_draw_buffers_variables(instructions, state, false,
                                        vertex_shader);
}
示例#6
0
/* Creating network devices variables */
int make_net_devs_vars(server_configuration * config)
{
    static const dev_var_descr_t net_device_vars[] =
    {
        {"DEV-NAME", CALC_OFFSET(dhcp_device_t, str_name)},
        {"DEV-ETHERADDR", CALC_OFFSET(dhcp_device_t, str_ether_addr)},
        {"DEV-IPADDR", CALC_OFFSET(dhcp_device_t, str_ipaddr)},
        {"DEV-NETWORK", CALC_OFFSET(dhcp_device_t, str_network)},
        {"DEV-NETMASK", CALC_OFFSET(dhcp_device_t, str_netmask)},
        {"DEV-NETMASK-CIDR", CALC_OFFSET(dhcp_device_t, str_netmask_cidr)},
        {"DEV-IPADDR-INT", CALC_OFFSET(dhcp_device_t, str_ipaddr_int)},
        {"DEV-NETWORK-INT", CALC_OFFSET(dhcp_device_t, str_network_int)},
        {"DEV-NETMASK-INT", CALC_OFFSET(dhcp_device_t, str_netmask_int)},
        {"DEV-SRVPORT", CALC_OFFSET(dhcp_device_t, str_srv_port)},
        {"DEV-CLIPORT", CALC_OFFSET(dhcp_device_t, str_cli_port)}
    };

    int i;
    query_var_t * var;
    for(i = 0; i < sizeof(net_device_vars) / sizeof(net_device_vars[0]); ++i)
    {
        var = add_variable(&config->vars_container);
        CHECK_VALUE_CONF(var, "Can't create device variable.", FAIL);

        var->type = var_device;
        var->name = net_device_vars[i].name;
        var->offset = net_device_vars[i].offset;
    }
    return OK;
}
示例#7
0
variable_idx_t ilp_problem_t::add_variable_of_edge(
    pg::edge_idx_t idx, double coef, bool do_add_constraint_for_node)
{
    const pg::edge_t &edge = m_graph->edge(idx);

    if (ms_do_economize)
    {
        variable_idx_t var(-1);

        if (edge.is_chain_edge())
            variable_idx_t var = find_variable_with_hypernode(edge.head());
        if (edge.is_unify_edge() and edge.head() < 0)
            variable_idx_t var = find_variable_with_hypernode(edge.tail());

        if (var >= 0)
        {
            m_map_edge_to_variable[idx] = var;
            return var;
        }
    }

    variable_idx_t var = add_variable(variable_t(
        util::format("edge(%d):hn(%d,%d)", idx, edge.tail(), edge.head()), 0.0));

    if (do_add_constraint_for_node)
    {
        variable_idx_t v_tail = find_variable_with_hypernode(edge.tail());
        variable_idx_t v_head = find_variable_with_hypernode(edge.head());

        /* IF THE EDGE IS TRUE, TAIL AND HEAD MUST BE TRUE, TOO. */
        if (v_tail >= 0 and (v_head >= 0 or edge.head() < 0))
        {
            constraint_t con(
                util::format("e_hn_dependency:e(%d):hn(%d,%d)",
                       idx, edge.tail(), edge.head()),
                OPR_GREATER_EQ, 0.0);
            
            con.add_term(v_tail, 1.0);
            if (edge.head() >= 0)
                con.add_term(v_head, 1.0);
            con.add_term(var, -1.0 * con.terms().size());
            add_constraint(con);
        }

        /* IF LITERAL NODES IN THE HEAD ARE TRUE, THE NODE MUST BE TRUE, TOO. */
        if (edge.is_chain_edge() and v_head >= 0)
        {
            constraint_t con(
                util::format("n_e_dependency:e(%d)", idx), OPR_GREATER_EQ, 0.0);
            con.add_term(v_head, -1.0);
            con.add_term(var, con.terms().size());
            add_constraint(con);
        }
    }

    m_map_edge_to_variable[idx] = var;
    return var;
}
示例#8
0
static void
add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab,
                     const char *name, int value)
{
    ir_variable *const var = add_variable(instructions, symtab,
                                          name, glsl_type::int_type,
                                          ir_var_auto, -1);
    var->constant_value = new(var) ir_constant(value);
}
示例#9
0
std::vector<std::set<Face*> >* Medial_explore_3::get_medial_axis_sheets() {
	if (!has_sheets) {
		get_medial_axis();
		mat.identify_sheets();
		add_variable("Sheets - medial explore", mat.sheets.size());
		has_sheets = true;
	}
	return &(mat.sheets);
	
}
示例#10
0
static Obj *handle_defun(void *root, Obj **env, Obj **list, int type) {
    if ((*list)->car->type != TSYMBOL || (*list)->cdr->type != TCELL)
        error("Malformed defun");
    DEFINE3(fn, sym, rest);
    *sym = (*list)->car;
    *rest = (*list)->cdr;
    *fn = handle_function(root, env, rest, type);
    add_variable(root, env, sym, fn);
    return *fn;
}
示例#11
0
// (define <symbol> expr)
static Obj *prim_define(void *root, Obj **env, Obj **list) {
    if (length(*list) != 2 || (*list)->car->type != TSYMBOL)
        error("Malformed define");
    DEFINE2(sym, value);
    *sym = (*list)->car;
    *value = (*list)->cdr->car;
    *value = eval(root, env, value);
    add_variable(root, env, sym, value);
    return *value;
}
示例#12
0
variable_idx_t
    ilp_problem_t::add_variable_of_node( pg::node_idx_t idx, double coef )
{
    const pg::node_t &node = m_graph->node(idx);
    std::string lit = node.literal().to_string();
    variable_t var(util::format("n(%d):%s", idx, lit.c_str()), coef);
    variable_idx_t var_idx = add_variable(var);
    m_map_node_to_variable[idx] = var_idx;

    return var_idx;
}
struct pa_policy_context_rule *
pa_policy_context_add_property_rule(struct userdata *u, const char *varname,
                                    enum pa_classify_method method, const char *arg)
{
    struct pa_policy_context_variable *variable;
    struct pa_policy_context_rule     *rule;

    variable = add_variable(u->context, varname);
    rule     = add_rule(&variable->rules, method, arg);

    return rule;
}
示例#14
0
static ir_variable *
add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab,
                     const char *name, int value)
{
    ir_variable *const var = add_variable(instructions, symtab,
                                          name, glsl_type::int_type,
                                          ir_var_auto, -1);
    var->constant_value = new(var) ir_constant(value);
    var->constant_initializer = new(var) ir_constant(value);
    var->has_initializer = true;
    return var;
}
示例#15
0
int Trick::DataRecordGroup::restart() {
    std::vector <Trick::DataRecordBuffer *>::iterator drb_it ;

    /* delete the current rec_buffer */
    for ( drb_it = rec_buffer.begin() ; drb_it != rec_buffer.end() ; drb_it++ ) {
        delete *drb_it ;
    }
    rec_buffer.clear() ;
    /* Add back the time variable */
    add_time_variable() ;

    /* delete the current change_buffer contents */
    for ( drb_it = change_buffer.begin() ; drb_it != change_buffer.end() ; drb_it++ ) {
        delete *drb_it ;
    }
    change_buffer.clear() ;

    unsigned int jj ;
    /* add the variable names listed in the checkpoint file */
    for ( jj = 0 ; jj < num_variable_names ; jj++ ) {
        add_variable( variable_names[jj] , variable_alias[jj] ) ;
    }
    for ( jj = 0 ; jj < num_change_variable_names ; jj++ ) {
        add_variable( change_variable_names[jj] , change_variable_alias[jj] ) ;
    }

    clear_checkpoint_vars() ;

    // set the write job class to what is in the checkpoint file.
    write_job->job_class_name = job_class ;

    // reset the sim_object name.
    name = std::string("data_record_group_") + group_name ;

    /* call init to open the recording file and look up variable name addresses */
    init() ;

    return 0 ;
}
示例#16
0
variable_idx_t ilp_problem_t::add_variable_of_hypernode(
    pg::hypernode_idx_t idx, double coef, bool do_add_constraint_for_member)
{
    const std::vector<pg::node_idx_t> &hypernode = m_graph->hypernode(idx);
    if (hypernode.empty()) return -1;

    if (ms_do_economize)
    {
        /* IF A HYERNODE INCLUDE ONLY ONE LITERAL-NODE,
        * USE THE NODE'S VARIABLE AS THE HYPERNODE'S VARIABLE. */
        if (hypernode.size() == 1)
        {
            const pg::node_t &node = m_graph->node(hypernode.front());
            if (not node.is_equality_node() and not node.is_non_equality_node())
            {
                variable_idx_t var = find_variable_with_node(hypernode.front());
                if (var >= 0)
                {
                    m_map_hypernode_to_variable[idx] = var;
                    return var;
                }
            }
        }
    }

    std::string nodes =
        util::join(hypernode.begin(), hypernode.end(), ",");
    std::string name = util::format("hn(%d):n(%s)", idx, nodes.c_str());
    variable_idx_t var = add_variable(variable_t(name, coef));

    if (do_add_constraint_for_member)
    {
        /* FOR A HYPERNODE BEING TRUE, ITS ALL MEMBERS MUST BE TRUE TOO. */
        constraint_t cons(
            util::format("hn_n_dependency:hn(%d):n(%s)", idx, nodes.c_str()),
            OPR_GREATER_EQ, 0.0);
        for (auto n = hypernode.begin(); n != hypernode.end(); ++n)
        {
            variable_idx_t v = find_variable_with_node(*n);
            if (v < 0) return -1;
            cons.add_term(v, 1.0);
        }

        cons.set_bound(0.0, 1.0 * (cons.terms().size() - 1));
        cons.add_term(var, -1.0 * cons.terms().size());
        add_constraint(cons);
    }

    m_map_hypernode_to_variable[idx] = var;
    return var;
}
示例#17
0
static void
generate_130_fs_variables(exec_list *instructions,
                          struct _mesa_glsl_parse_state *state)
{
    generate_120_fs_variables(instructions, state);

    const glsl_type *const clip_distance_array_type =
        glsl_type::get_array_instance(glsl_type::float_type,
                                      state->Const.MaxClipPlanes);

    /* FINISHME: gl_ClipDistance needs a real location assigned. */
    add_variable(instructions, state->symbols,
                 "gl_ClipDistance", clip_distance_array_type, ir_var_in, -1);
}
示例#18
0
static void
generate_ARB_draw_instanced_variables(exec_list *instructions,
                                      struct _mesa_glsl_parse_state *state,
                                      bool warn,
                                      _mesa_glsl_parser_targets target)
{
    /* gl_InstanceIDARB is only available in the vertex shader.
     */
    if (target != vertex_shader)
        return;

    if (state->ARB_draw_instanced_enable) {
        ir_variable *inst =
            add_variable(instructions, state->symbols,
                         "gl_InstanceIDARB", glsl_type::int_type,
                         ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);

        if (warn)
            inst->warn_extension = "GL_ARB_draw_instanced";
    }

    bool available_in_core = state->is_version(140, 300);
    if (state->ARB_draw_instanced_enable || available_in_core) {
        /* Originally ARB_draw_instanced only specified that ARB decorated name.
         * Since no vendor actually implemented that behavior and some apps use
         * the undecorated name, the extension now specifies that both names are
         * available.
         */
        ir_variable *inst =
            add_variable(instructions, state->symbols,
                         "gl_InstanceID", glsl_type::int_type,
                         ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);

        if (!available_in_core && warn)
            inst->warn_extension = "GL_ARB_draw_instanced";
    }
}
示例#19
0
static void
generate_AMD_shader_stencil_export_variables(exec_list *instructions,
        struct _mesa_glsl_parse_state *state,
        bool warn)
{
    /* gl_FragStencilRefAMD is only available in the fragment shader.
     */
    ir_variable *const fd =
        add_variable(instructions, state->symbols,
                     "gl_FragStencilRefAMD", glsl_type::int_type,
                     ir_var_shader_out, FRAG_RESULT_STENCIL);

    if (warn)
        fd->warn_extension = "GL_AMD_shader_stencil_export";
}
示例#20
0
void Medial_explore_3::load_generic_file(const std::string& file_name) {
	if (QString(file_name.c_str()).endsWith(".off")) {
		mat.read_from_off(file_name.c_str());
		mat.compute_face_normals();
		mat.smooth_medial_surface_boundary(Application_settings::get_int_setting("medial-surface-boundary-smoothing-steps"));
		Face_iterator f_it, f_end = mat.faces_end();
		for (f_it=mat.faces_begin(); f_it!=f_end; ++f_it) {
			f_it->angle = ((double)rand())/RAND_MAX * 90.0;
//			std::cout << "Angle: " << f_it->angle << std::endl;
		}
		invalidate_cache();
	}
	if (QString(file_name.c_str()).endsWith(".moff")) {
		mat.read_from_moff(file_name.c_str());
		mat.compute_face_normals();
		mat.smooth_medial_surface_boundary(Application_settings::get_int_setting("medial-surface-boundary-smoothing-steps"));
		add_variable("Faces - medial explore", mat.faces.size());
		add_variable("Vertices - medial explore", mat.vertices.size());
		add_variable("Edges - medial explore", mat.edges.size());
		has_mat = true;
		invalidate_cache();
//		widget->repaint();
	}
}
示例#21
0
JBVariable *
ensure_variable (JBVariableType *type, const char *name)
{
  JBVariable *variable;

  g_return_val_if_fail(name != NULL, NULL);

  variable = jb_variable_get_variable(name);
  if (variable == NULL)
    {
      variable = variable_new(type, name, NULL, NULL, 0);
      add_variable(variable);
    }

  return variable;
}
示例#22
0
static ir_variable *
add_uniform(exec_list *instructions, glsl_symbol_table *symtab,
            const char *name, const glsl_type *type)
{
    ir_variable *const uni =
        add_variable(instructions, symtab, name, type, ir_var_uniform, -1);

    unsigned i;
    for (i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) {
        if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) {
            break;
        }
    }

    assert(_mesa_builtin_uniform_desc[i].name != NULL);
    const struct gl_builtin_uniform_desc* const statevar =
            &_mesa_builtin_uniform_desc[i];

    const unsigned array_count = type->is_array() ? type->length : 1;
    uni->num_state_slots = array_count * statevar->num_elements;

    ir_state_slot *slots =
        ralloc_array(uni, ir_state_slot, uni->num_state_slots);

    uni->state_slots = slots;

    for (unsigned a = 0; a < array_count; a++) {
        for (unsigned j = 0; j < statevar->num_elements; j++) {
            struct gl_builtin_uniform_element *element = &statevar->elements[j];

            memcpy(slots->tokens, element->tokens, sizeof(element->tokens));
            if (type->is_array()) {
                if (strcmp(name, "gl_CurrentAttribVertMESA") == 0 ||
                        strcmp(name, "gl_CurrentAttribFragMESA") == 0) {
                    slots->tokens[2] = a;
                } else {
                    slots->tokens[1] = a;
                }
            }

            slots->swizzle = element->swizzle;
            slots++;
        }
    }

    return uni;
}
示例#23
0
int Trick::DataRecordGroup::add_time_variable() {
    REF2 * new_ref ;

    // Create attributes for time recorded as a double
    time_value_attr.type = TRICK_DOUBLE ;
    time_value_attr.size = sizeof(double) ;
    time_value_attr.units = strdup("s") ;

    // Create a reference that records time as sys.exec.out.time
    new_ref = (REF2 *)calloc( 1 , sizeof(REF2));
    new_ref->reference = strdup("sys.exec.out.time") ;
    new_ref->address = &curr_time ;
    new_ref->attr = &time_value_attr ;
    add_variable(new_ref) ;

    return 0 ;
}
示例#24
0
static void
generate_ARB_draw_instanced_variables(exec_list *instructions,
                                      struct _mesa_glsl_parse_state *state,
                                      bool warn,
                                      _mesa_glsl_parser_targets target)
{
    /* gl_InstanceIDARB is only available in the vertex shader.
     */
    if (target == vertex_shader) {
        ir_variable *const inst =
            add_variable(instructions, state->symbols,
                         "gl_InstanceIDARB", glsl_type::int_type,
                         ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);

        if (warn)
            inst->warn_extension = "GL_ARB_draw_instanced";
    }
}
示例#25
0
static void
add_builtin_variable(exec_list *instructions, glsl_symbol_table *symtab,
                     const builtin_variable *proto)
{
    /* Create a new variable declaration from the description supplied by
     * the caller.
     */
    const glsl_type *const type = symtab->get_type(proto->type);

    assert(type != NULL);

    if (proto->mode == ir_var_uniform) {
        add_uniform(instructions, symtab, proto->name, type);
    } else {
        add_variable(instructions, symtab, proto->name, type, proto->mode,
                     proto->slot);
    }
}
示例#26
0
JBVariable *
jb_variable_add (JBVariableType *type,
		 const char *name,
		 const char *description,
		 JBVariableGroup *group,
		 JBVariableFlags flags)
{
  JBVariable *variable;

  g_return_val_if_fail(type != NULL, NULL);
  g_return_val_if_fail(name != NULL, NULL);

  variable = variable_new(type, name, description, group, flags | JB_VARIABLE_USER_SETTABLE);

  add_variable(variable);

  return variable;
}
void store_variable_in_tree(Trie* _variable, char *_declaration_sentence)
{
	delete_se(_declaration_sentence);
	int cnt_se = count_symbol_num(_declaration_sentence);
	enum Type type = declaration_variable_type(_declaration_sentence);
	char **variable_name = (char **)malloc(sizeof(char*)*(cnt_se + 1));
	int flag = 0;
	char *variable_sentence = declaration_variable_start(_declaration_sentence);
	delete_space(variable_sentence);
	for (unsigned i = 0; i < strlen(variable_sentence); i++)
	{
		if (i == 0 && variable_sentence[i] == ',')
		{
			flag = 1;
		}
		else if(variable_sentence[i]==','&&variable_sentence[i+1]==',')
		{
			flag = 1;
		}
	}
	if (flag == 0)
	{
		variable_name = string_division(variable_sentence);

		for (int j = 0; j < cnt_se + 1; j++)
		{
			if (!strcmp(*(variable_name + j), "int") || !strcmp(*(variable_name + j), "double") || !strcmp(*(variable_name + j), "print"))
			{
				printf("ERROR In Line %d : The variable's name is illegal.\n",line_cnt);
				exit(1);
			}
			else
			{
				add_variable(type, *(variable_name + j), _variable);
			}
		}
	}
	else
	{
		printf("ERROR In Line %d : The variable's name is illegal.\n",line_cnt);
		exit(1);
	}
}
示例#28
0
const char *translate(const char *format, const void *userdata,
    const char *vars, variant args[])
{
    unsigned int i = 0;
    const char *ic = vars;
    char symbol[32];
    char *oc = symbol;
    opstack *stack = NULL;
    const char *rv;

    brelease();
    free_variables();

    assert(format);
    assert(*ic == 0 || isalnum(*ic));
    while (*ic) {
        *oc++ = *ic++;
        if (!isalnum(*ic)) {
            variant x = args[i++];
            *oc = '\0';
            oc = symbol;
            add_variable(strcpy(balloc(strlen(symbol) + 1), symbol), x);
            while (*ic && !isalnum(*ic))
                ++ic;
        }
    }

    if (format[0] == '"') {
        rv = parse(&stack, format, userdata);
    }
    else {
        rv = parse_string(&stack, format, userdata);
    }
    if (rv != NULL) {
        if (rv[0]) {
            log_error("residual data after parsing: %s\n", rv);
        }
        rv = (const char *)opop(&stack).v;
        free(stack->begin);
        free(stack);
    }
    return rv;
}
示例#29
0
static void litespeed_php_import_environment_variables(zval *array_ptr)
{
    char buf[128];
    char **env, *p, *t = buf;
    size_t alloc_size = sizeof(buf);
    unsigned long nlen; /* ptrdiff_t is not portable */

    if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
        Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) &&
        zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0
    ) {
        zval_ptr_dtor_nogc(array_ptr);
        ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]);
        return;
    } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
        Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) &&
        zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0
    ) {
        zval_ptr_dtor_nogc(array_ptr);
        ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]);
        return;
    }

    tsrm_env_lock();
    for (env = environ; env != NULL && *env != NULL; env++) {
        p = strchr(*env, '=');
        if (!p) {               /* malformed entry? */
            continue;
        }
        nlen = p - *env;
        if (nlen >= alloc_size) {
            alloc_size = nlen + 64;
            t = (t == buf ? emalloc(alloc_size): erealloc(t, alloc_size));
        }
        memcpy(t, *env, nlen);
        t[nlen] = '\0';
        add_variable(t, nlen, p + 1, strlen( p + 1 ), array_ptr);
    }
    tsrm_env_unlock();
    if (t != buf && t != NULL) {
        efree(t);
    }
}
示例#30
0
static void
generate_130_vs_variables(exec_list *instructions,
                          struct _mesa_glsl_parse_state *state)
{
    generate_120_vs_variables(instructions, state);

    for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) {
        add_builtin_variable(instructions, state->symbols,
                             & builtin_130_vs_variables[i]);
    }

    const glsl_type *const clip_distance_array_type =
        glsl_type::get_array_instance(glsl_type::float_type,
                                      state->Const.MaxClipPlanes);

    /* FINISHME: gl_ClipDistance needs a real location assigned. */
    add_variable(instructions, state->symbols,
                 "gl_ClipDistance", clip_distance_array_type, ir_var_out, -1);

}