-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This implements the simplest possible implementation of inlining functions. It only supports a function consisting of a single `return`, when it has been explicitly named as `i_whatever`. Basically, this works in cases where you might want to use a macro, excpet this gives the minifier full visibility through it. The simplicity of this implementation means that it's likely possible to get into trouble by marking certain functions as to-be-inlined. In particular, I'm pretty sure the following will break it: - inlining overloaded functions - inlining a function into a scope which has a local shadowing a global, where the inlined function refers to that global (though this will also break a macro)
- Loading branch information
Showing
7 changed files
with
149 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
float a() | ||
{ | ||
return vec3(2.,3.,4.).x+vec3(2.,3.,4.).y; | ||
} | ||
float b(float g) | ||
{ | ||
float x=(g+10.)*vec3(20.,30.,40.).x+vec3(20.,30.,40.).y,y=(g+10.1)*vec3(20.1,30.1,40.1).x+vec3(20.1,30.1,40.1).y; | ||
return x+y; | ||
} | ||
float c() | ||
{ | ||
return 154.; | ||
} | ||
float d() | ||
{ | ||
return 54.; | ||
} | ||
float e() | ||
{ | ||
return 84.; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
float a() | ||
{ | ||
return vec3(2.,3.,4.).x+vec3(2.,3.,4.).y; | ||
} | ||
float b(float g) | ||
{ | ||
float x=(g+10.)*vec3(20.,30.,40.).x+vec3(20.,30.,40.).y,y=(g+10.1)*vec3(20.1,30.1,40.1).x+vec3(20.1,30.1,40.1).y; | ||
return x+y; | ||
} | ||
float c() | ||
{ | ||
return 154.; | ||
} | ||
float d() | ||
{ | ||
float f=7.,g=f*f+1.; | ||
return g+4.; | ||
} | ||
float e() | ||
{ | ||
return 84.; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
float i_foo(float f, vec3 g) { | ||
return f*g.x + g.y; | ||
} | ||
|
||
float a() { | ||
return i_foo(1.0, vec3(2.0, 3.0, 4.0)); | ||
} | ||
|
||
float b(float g) { | ||
float x = i_foo(g + 10.0, vec3(20.0, 30.0, 40.0)); | ||
float y = i_foo(g + 10.1, vec3(20.1, 30.1, 40.1)); | ||
return x + y; | ||
} | ||
|
||
float i_bar(float f, float g) { | ||
return f*g + 1.0; | ||
} | ||
|
||
float c() { | ||
return i_bar(i_bar(2.0, 3.0), i_bar(4.0, 5.0)) + 6.0; | ||
} | ||
|
||
float d() { | ||
float f = i_bar(2.0, 3.0); | ||
float g = i_bar(f, f); | ||
return g + 4.0; | ||
} | ||
|
||
float i_multipass(float x) { | ||
float f = 42.0; | ||
float g = 2.0; | ||
return f*g*x; | ||
} | ||
|
||
float e() { | ||
return i_multipass(1.0); | ||
} |