stage inline it if that's reasonable. */
RefPtr<VariableDeclaration> temporary = new VariableDeclaration;
temporary->type = args.front().type->name;
- temporary->name = get_unused_variable_name(*current_block, "_temp", string());
+ temporary->name = get_unused_variable_name(*current_block, "_temp");
temporary->init_expression = call.arguments.front();
current_block->body.insert(insert_point, temporary);
pass = INLINE;
staging_block.parent = &tgt_blk;
staging_block.variables.clear();
- remap_prefix = source_func->name;
std::vector<RefPtr<VariableDeclaration> > params;
params.reserve(source_func->parameters.size());
global identifiers used by the source function. */
pass = RENAME;
staging_block.parent = source_func->body.parent;
- remap_prefix = target_func.name;
target_func.visit(*this);
// Put the argument expressions in place after all renaming has been done.
staging_block.variables[var.name] = &var;
if(referenced_names.count(var.name))
{
- string mapped_name = get_unused_variable_name(staging_block, var.name, remap_prefix);
+ string mapped_name = get_unused_variable_name(staging_block, var.name);
if(mapped_name!=var.name)
{
staging_block.variables[mapped_name] = &var;
if(pass==INLINE && ret.expression)
{
// Create a new variable to hold the return value of the inlined function.
- r_result_name = get_unused_variable_name(staging_block, "_return", source_func->name);
+ r_result_name = get_unused_variable_name(staging_block, "_return");
RefPtr<VariableDeclaration> var = new VariableDeclaration;
var->source = ret.source;
var->line = ret.line;
// This will later get removed by UnusedVariableRemover.
if(result_name.empty())
- result_name = "msp_unused_from_inline";
+ result_name = "_msp_unused_from_inline";
RefPtr<VariableReference> ref = new VariableReference;
ref->name = result_name;
FunctionDeclaration *source_func;
Block staging_block;
- std::string remap_prefix;
Pass pass;
RefPtr<Statement> r_inlined_statement;
std::set<Node *> dependencies;
{ }
-string get_unused_variable_name(const Block &block, const string &base, const string &prefix_hint)
+string get_unused_variable_name(const Block &block, const string &base)
{
string name = base;
- bool prefixed = false;
unsigned number = 1;
- unsigned size_without_number = name.size();
+ unsigned base_size = name.size();
while(1)
{
bool unused = true;
if(unused)
return name;
- if(!prefixed && !prefix_hint.empty())
- {
- if(name.front()!='_')
- name = "_"+name;
- name = prefix_hint+name;
- if(name.front()!='_')
- name = "_"+name;
- prefixed = true;
- size_without_number = name.size();
- }
- else
- {
- name.erase(size_without_number);
- name += format("_%d", number);
- ++number;
- }
+ name.erase(base_size);
+ name += format("_%d", number);
+ ++number;
}
}
Module();
};
-std::string get_unused_variable_name(const Block &, const std::string &, const std::string &);
+std::string get_unused_variable_name(const Block &, const std::string &);
} // namespace SL
} // namespace GL
layout(location=2) in float size;
void main()
{
- float _main_size = scale+1.0;
- float _func_scale = size*2.0;
- float s = _func_scale*_func_scale+1.0;
- gl_Position = position*_main_size*_main_size*s*s;
+ float size_1 = scale+1.0;
+ float scale_1 = size*2.0;
+ float s = scale_1*scale_1+1.0;
+ gl_Position = position*size_1*size_1*s*s;
}
*/
void main()
{
float s = scale*2.0;
- float _get_size_s = size*0.5;
- gl_Position = position*s*s*_get_size_s*_get_size_s;
+ float s_1 = size*0.5;
+ gl_Position = position*s*s*s_1*s_1;
}
*/
void main()
{
float s = scale+1.0;
- float _func_s = scale*2.0;
- gl_Position = position*_func_s*_func_s*s*s;
+ float s_1 = scale*2.0;
+ gl_Position = position*s_1*s_1*s*s;
}
*/
void main()
{
float _return = scale+1.0;
- float _func_return = scale*2.0;
- gl_Position = position*vec2(_func_return, _func_return).xxyy*_return*_return;
+ float _return_1 = scale*2.0;
+ gl_Position = position*vec2(_return_1, _return_1).xxyy*_return*_return;
}
*/
void main()
{
vec4 color = texture(tex, _vs_out_texcoord);
- vec3 _srgb_to_linear_color = color.rgb;
- frag_color = vec4(mix(_srgb_to_linear_color/12.92, pow((_srgb_to_linear_color+0.055)/1.055, vec3(2.4)), lessThan(_srgb_to_linear_color, vec3(0.04045))), color.a);
+ vec3 color_1 = color.rgb;
+ frag_color = vec4(mix(color_1/12.92, pow((color_1+0.055)/1.055, vec3(2.4)), lessThan(color_1, vec3(0.04045))), color.a);
}
*/