Using platform-neutral osinclude.h makes it easier to substitute
implementation when necessary and eliminates some variability between
build configurations.
Handles the case of
float[] x = float[] (1.0, 2.0, 3.0),
y = float[] (1.0, 2.0, 3.0, 4.0);
where a shallow copy of the type arrayness from the left-most float[]
was getting used twice.
* Linux folder has been renamed to Unix, to match defines and so that it
compiles on OS X.
* This removes the need for a per-platform include search path for the
right OS folder
* This also moves bison generated files into the source tree, so that
include of glslang_tab.cpp.h and includes from glslang_tab.cpp work
the same way.
There is no calls to the TPpContext that could change the current input,
so every calls to pp->getChar and pp->ungetChar ultimately call this->getch
and this->ungetch while adding overhead of virtual calls and vector::back.
The gl_in array has a special path due to context-specific
gl_MaxPatchVertices, making the code out of order for tagging built-ins.
This commit moves the tagging to the correct location.
This also fixes issue #80.
This fixes a bug where a token that could be a keyword in one version
is not a keyword in another version, but treated like a non-member after
a "." dereference.
4 components are needed when used a texture, but not an image, which multiplies
layers and faces into the same coordinate. This fixes it from using 4 everywhere,
to only using 4 for textures and 3 for images.
Structured control-flow rules allow leaving the middle of a construct through
a return, but not through a jump to a block that does a return.
Addresses issue #58.
If this breaks your AST consumer, best is to modify it to test
against the enum values instead of doing string comparisons on
built-in function names. This is the reason the change was made.
If you need the old behavior, you should be able to get it back by changing
PureOperatorBuiltins to be false instead of true. This path will work for
a while, but is marked deprecated.
Also, the old behavior is tagged as release 2.4.
This is to avoid all need to do text comparison of built-in function names
when consuming the AST. All built-in functions get enumerants.
Will want to turn on soon. See PureOperatorBuiltins. See issue #8.
There will be subsequent commits to refine semantics, esp. version-specific semantics,
as well as I/O functionality and restrictions.
Note: I'm getting white-space differences in the preprocessor test results,
which I'm not checking in. I think they need to be tagged as binary or something.
Added some const as well. This will remove camouflage of the next commit,
which will add the bulk of Array of Array semantics and functionality.
(Note the basic grammar and data structure is already in place.)
Now extensions required by preprocessor should be checked via
the ppRequireExtensions method. This is more clear and coherent
with the rest of the code.
The new make-revision script regenerates glslang/Include/revision.h,
used as it always has been, but made with a git-tag version and the
the number of commits on master.
I have a pre-commit hook that will automatically do this on master,
likely often enough to work in practice, without needing pull requests
to include it.
After parsing a #include directive, we push a TokenizableString
which contains the content of the included file into the input
stack. Henceforth, tokens will be read from the newly pushed
TokenizableString. However, the scanner in TParseContext still
points to the previous input stream. We need to update the scanner
to point to the new input stream inside TokenizableString. Thus,
the setCurrent{String|Line|..} method in TParseContext updates
the status of the correct input stream. After finishing the newly
pushed TokenizableString, we need to restore the scanner to the
previous input stream.
This patch introduces a new extension, GL_GOOGLE_include_directive,
to enable support #include directives. It depends on the extension
GL_GOOGLE_cpp_style_line_directive.
When an include directive is recognized by the preprocessor, it
executes a callback on the filepath argument to obtain the file
contents. That way the compilation client can deal with the file
system, include paths, etc.
Currently only accepts quoted filepaths -- no angle brackets yet.
Expose a new method setStringsWithLengthsAndNames() in the interface
which allows the caller to set descriptive names for source strings.
These names can be used in error messages.
According to the GLSL spec, the second parameter to #line should be
an integer source string number and __FILE__ will be substituted
with the integer source string number currently processed. This
patch extends the syntax of #line and __FILE__. Now #line accepts
as the second parameter a filename string quoted by double quotation
marks. And if such a #line is set, __FILE__ will be substituted with
the currently set filename string. The implementation is done via
introducing a new extension GL_GOOGLE_cpp_style_line_directive using
the extension framework.
The purpose is to support cpp-style #line directives, which is
required by #include.
Fixes issue #25. (char 255 aliased to -1 and missing tests for end of input).
1) All layers of input scanning now share a single EndOfInput value.
This avoids translation of it across layers of encapsulation.
2) Some places looking for end of line were not stopping on EndOfInput.
3) Use of "char" for the input made char values > 127 be negative numbers.
This allowed for aliasing of 255 to -1, etc. This is fixed by using
unsigned char.
This is just for '\' that's not before a new line.
Note the specification says it has no use other than as line continuation,
but #error is a grey area. (There are no escape sequences.)
SourceLineSynchronizer is added for keeping track of the last
line number and output newlines appropriately if we switch to
a new line in the preprocessor.
It also removes some old code that ancient compilers used to need.
However, the main issue is getting access to hash functions for
unordered_map in portable way.
This simplification is a prelude to eliminating what I appear unnecessary
symbol inserts into tables when tokenizing in the preprecessor, which
show up as taking notable time. (Performance issue.) It also simply makes
the preprocessor easier to understand, which it is badly in need of.
TInputScanner advances its internal indices to the next character at
the end of get(), which means, after reading in the last character
in the user-provided shader string, internal index (currentSource)
will point to the next shader string (currentSource == numSources),
which doesn't exist. Then if a location setting method is called,
we will write to some out-of-bound memory.
A test case for this is "#line 10000\n". The eval() method in CPPline()
will evaluate 10000, but at the same time it reads in the next
token, '\n', and the currentSource will be numSources in TInputScanner.
Then a parseContext.setCurrentLine() is called, we are writing to
out-of-bound memory. Another test case will be "#line 10000 0\n".
Added error output to the preprocessor.
This patch distinguishes preprocessing errors with normal parsing
errors and gives glslangValidator the ability to output preprocessing
errors.
The current line number for the #line directive should be passed
in as parameter to the line directive callback. Without it, we
don't know how many empty lines we should output.
The line argument passed into the lineCallback function is the
literal value of the first argument of the #line directive.
lastLine in DoPreprocessing() should be updated taking into
consideration the different definitions for #line between specs.
Add a test to reveal the bug.
Simplify function calls for extensionsTurnedOn().
Lots of places in the code use extensionsTurnedOn(1, ...). This
patch introduces a new method, extensionTurnedOn(), for testing
if a single extension is turned on.