Commit 8e77853d by kbr@chromium.org

Fixed 64-bit integer truncation issues in shader translator.

This is an incompatible API change, but one which is necessary in order to improve correctness of the code. The API version in ShaderLang.h is updated and, unfortunately, the define renamed to something less ambiguous due to conflicts on some Android buildbots. Temporary patches in Chromium and WebKit will be landed separately to support this upgrade. BUG=403,404,405,406,407,408,409 Review URL: https://codereview.appspot.com/7300058 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1826 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent d64a53fe
......@@ -24,6 +24,7 @@
#endif
#include "KHR/khrplatform.h"
#include <stddef.h>
//
// This is the platform independent interface between an OGL driver
......@@ -36,7 +37,7 @@ extern "C" {
// Version number for shader translation API.
// It is incremented everytime the API changes.
#define SH_VERSION 107
#define ANGLE_SH_VERSION 108
//
// The names of the following enums have been derived by replacing GL prefix
......@@ -184,7 +185,7 @@ COMPILER_EXPORT int ShFinalize();
// The 64 bits hash function. The first parameter is the input string; the
// second parameter is the string length.
typedef khronos_uint64_t (*ShHashFunction64)(const char*, unsigned int);
typedef khronos_uint64_t (*ShHashFunction64)(const char*, size_t);
//
// Implementation dependent built-in resources (constants and extensions).
......@@ -279,7 +280,7 @@ COMPILER_EXPORT void ShDestruct(ShHandle handle);
COMPILER_EXPORT int ShCompile(
const ShHandle handle,
const char* const shaderStrings[],
const int numStrings,
size_t numStrings,
int compileOptions
);
......@@ -307,11 +308,11 @@ COMPILER_EXPORT int ShCompile(
// SH_HASHED_NAME_MAX_LENGTH: the max length of a hashed name including the
// null termination character.
// SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile.
//
//
// params: Requested parameter
COMPILER_EXPORT void ShGetInfo(const ShHandle handle,
ShShaderInfo pname,
int* params);
size_t* params);
// Returns nul-terminated information log for a compiled shader.
// Parameters:
......@@ -354,7 +355,7 @@ COMPILER_EXPORT void ShGetObjectCode(const ShHandle handle, char* objCode);
// mappedName are the same.
COMPILER_EXPORT void ShGetActiveAttrib(const ShHandle handle,
int index,
int* length,
size_t* length,
int* size,
ShDataType* type,
char* name,
......@@ -381,7 +382,7 @@ COMPILER_EXPORT void ShGetActiveAttrib(const ShHandle handle,
// mappedName are the same.
COMPILER_EXPORT void ShGetActiveUniform(const ShHandle handle,
int index,
int* length,
size_t* length,
int* size,
ShDataType* type,
char* name,
......
#define MAJOR_VERSION 1
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 1825
#define BUILD_REVISION 1826
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -135,7 +135,7 @@ bool TCompiler::Init(const ShBuiltInResources& resources)
}
bool TCompiler::compile(const char* const shaderStrings[],
const int numStrings,
size_t numStrings,
int compileOptions)
{
TScopedPoolAllocator scopedAlloc(&allocator, true);
......@@ -150,7 +150,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
// First string is path of source file if flag is set. The actual source follows.
const char* sourcePath = NULL;
int firstSource = 0;
size_t firstSource = 0;
if (compileOptions & SH_SOURCE_PATH)
{
sourcePath = shaderStrings[0];
......
......@@ -8,7 +8,7 @@
namespace {
TString mapLongName(int id, const TString& name, bool isGlobal)
TString mapLongName(size_t id, const TString& name, bool isGlobal)
{
ASSERT(name.size() > MAX_SHORTENED_IDENTIFIER_SIZE);
TStringStream stream;
......@@ -70,7 +70,7 @@ void LongNameMap::Insert(const char* originalName, const char* mappedName)
originalName, mappedName));
}
int LongNameMap::Size() const
size_t LongNameMap::Size() const
{
return mLongNameMap.size();
}
......@@ -115,7 +115,7 @@ TString MapLongVariableNames::mapGlobalLongName(const TString& name)
const char* mappedName = mGlobalMap->Find(name.c_str());
if (mappedName != NULL)
return mappedName;
int id = mGlobalMap->Size();
size_t id = mGlobalMap->Size();
TString rt = mapLongName(id, name, true);
mGlobalMap->Insert(name.c_str(), rt.c_str());
return rt;
......
......@@ -31,7 +31,7 @@ public:
void Insert(const char* originalName, const char* mappedName);
// Return the number of entries in the map.
int Size() const;
size_t Size() const;
private:
LongNameMap();
......
......@@ -493,7 +493,7 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction
bool overFull = false;
bool matrixInMatrix = false;
bool arrayArg = false;
for (int i = 0; i < function.getParamCount(); ++i) {
for (size_t i = 0; i < function.getParamCount(); ++i) {
const TParameter& param = function.getParam(i);
size += param.type->getObjectSize();
......@@ -1507,7 +1507,7 @@ bool TParseContext::structNestingErrorCheck(TSourceLoc line, const TType& fieldT
//
// Returns 0 for success.
//
int PaParseStrings(int count, const char* const string[], const int length[],
int PaParseStrings(size_t count, const char* const string[], const int length[],
TParseContext* context) {
if ((count == 0) || (string == NULL))
return 1;
......
......@@ -134,7 +134,7 @@ struct TParseContext {
bool structNestingErrorCheck(TSourceLoc line, const TType& fieldType);
};
int PaParseStrings(int count, const char* const string[], const int length[],
int PaParseStrings(size_t count, const char* const string[], const int length[],
TParseContext* context);
#endif // _PARSER_HELPER_INCLUDED_
......@@ -61,7 +61,7 @@ public:
bool Init(const ShBuiltInResources& resources);
bool compile(const char* const shaderStrings[],
const int numStrings,
size_t numStrings,
int compileOptions);
// Get results of the last compilation.
......
......@@ -21,18 +21,18 @@
//
static bool checkActiveUniformAndAttribMaxLengths(const ShHandle handle,
int expectedValue)
size_t expectedValue)
{
int activeUniformLimit = 0;
size_t activeUniformLimit = 0;
ShGetInfo(handle, SH_ACTIVE_UNIFORM_MAX_LENGTH, &activeUniformLimit);
int activeAttribLimit = 0;
size_t activeAttribLimit = 0;
ShGetInfo(handle, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &activeAttribLimit);
return (expectedValue == activeUniformLimit && expectedValue == activeAttribLimit);
}
static bool checkMappedNameMaxLength(const ShHandle handle, int expectedValue)
static bool checkMappedNameMaxLength(const ShHandle handle, size_t expectedValue)
{
int mappedNameMaxLength = 0;
size_t mappedNameMaxLength = 0;
ShGetInfo(handle, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameMaxLength);
return (expectedValue == mappedNameMaxLength);
}
......@@ -40,7 +40,7 @@ static bool checkMappedNameMaxLength(const ShHandle handle, int expectedValue)
static void getVariableInfo(ShShaderInfo varType,
const ShHandle handle,
int index,
int* length,
size_t* length,
int* size,
ShDataType* type,
char* name,
......@@ -69,14 +69,14 @@ static void getVariableInfo(ShShaderInfo varType,
// This size must match that queried by
// SH_ACTIVE_UNIFORM_MAX_LENGTH and SH_ACTIVE_ATTRIBUTE_MAX_LENGTH
// in ShGetInfo, below.
int activeUniformAndAttribLength = 1 + MAX_SYMBOL_NAME_LEN;
size_t activeUniformAndAttribLength = 1 + MAX_SYMBOL_NAME_LEN;
ASSERT(checkActiveUniformAndAttribMaxLengths(handle, activeUniformAndAttribLength));
strncpy(name, varInfo.name.c_str(), activeUniformAndAttribLength);
name[activeUniformAndAttribLength - 1] = 0;
if (mappedName) {
// This size must match that queried by
// SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below.
int maxMappedNameLength = 1 + MAX_SYMBOL_NAME_LEN;
size_t maxMappedNameLength = 1 + MAX_SYMBOL_NAME_LEN;
ASSERT(checkMappedNameMaxLength(handle, maxMappedNameLength));
strncpy(mappedName, varInfo.mappedName.c_str(), maxMappedNameLength);
mappedName[maxMappedNameLength - 1] = 0;
......@@ -177,7 +177,7 @@ void ShDestruct(ShHandle handle)
int ShCompile(
const ShHandle handle,
const char* const shaderStrings[],
const int numStrings,
size_t numStrings,
int compileOptions)
{
if (!InitThread())
......@@ -195,7 +195,7 @@ int ShCompile(
return success ? 1 : 0;
}
void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params)
void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params)
{
if (!handle || !params)
return;
......@@ -283,7 +283,7 @@ void ShGetObjectCode(const ShHandle handle, char* objCode)
void ShGetActiveAttrib(const ShHandle handle,
int index,
int* length,
size_t* length,
int* size,
ShDataType* type,
char* name,
......@@ -295,7 +295,7 @@ void ShGetActiveAttrib(const ShHandle handle,
void ShGetActiveUniform(const ShHandle handle,
int index,
int* length,
size_t* length,
int* size,
ShDataType* type,
char* name,
......@@ -326,9 +326,9 @@ void ShGetNameHashingEntry(const ShHandle handle,
++it;
size_t len = it->first.length() + 1;
int max_len = 0;
size_t max_len = 0;
ShGetInfo(handle, SH_NAME_MAX_LENGTH, &max_len);
if (static_cast<int>(len) > max_len) {
if (len > max_len) {
ASSERT(false);
len = max_len;
}
......@@ -339,7 +339,7 @@ void ShGetNameHashingEntry(const ShHandle handle,
len = it->second.length() + 1;
max_len = 0;
ShGetInfo(handle, SH_HASHED_NAME_MAX_LENGTH, &max_len);
if (static_cast<int>(len) > max_len) {
if (len > max_len) {
ASSERT(false);
len = max_len;
}
......
......@@ -169,8 +169,8 @@ public:
void setDefined() { defined = true; }
bool isDefined() { return defined; }
int getParamCount() const { return static_cast<int>(parameters.size()); }
const TParameter& getParam(int i) const { return parameters[i]; }
size_t getParamCount() const { return parameters.size(); }
const TParameter& getParam(size_t i) const { return parameters[i]; }
virtual void dump(TInfoSink &infoSink) const;
TFunction(const TFunction&, TStructureMap& remapper);
......
......@@ -421,7 +421,7 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node)
return true;
// List of param indices for which loop indices are used as argument.
typedef std::vector<int> ParamIndex;
typedef std::vector<size_t> ParamIndex;
ParamIndex pIndex;
TIntermSequence& params = node->getSequence();
for (TIntermSequence::size_type i = 0; i < params.size(); ++i) {
......
......@@ -8,7 +8,7 @@ struct TParseContext;
extern int glslang_initialize(TParseContext* context);
extern int glslang_finalize(TParseContext* context);
extern int glslang_scan(int count,
extern int glslang_scan(size_t count,
const char* const string[],
const int length[],
TParseContext* context);
......
......@@ -51,7 +51,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
#define YY_INPUT(buf, result, max_size) \
result = string_input(buf, max_size, yyscanner);
static int string_input(char* buf, int max_size, yyscan_t yyscanner);
static yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner);
static int check_type(yyscan_t yyscanner);
static int reserved_word(yyscan_t yyscanner);
%}
......@@ -203,10 +203,10 @@ O [0-7]
return check_type(yyscanner);
}
0[xX]{H}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
0{O}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
0[xX]{H}+ { yylval->lex.i = static_cast<int>(strtol(yytext, 0, 0)); return(INTCONSTANT); }
0{O}+ { yylval->lex.i = static_cast<int>(strtol(yytext, 0, 0)); return(INTCONSTANT); }
0{D}+ { context->error(yylineno, "Invalid Octal number.", yytext); context->recover(); return 0;}
{D}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
{D}+ { yylval->lex.i = static_cast<int>(strtol(yytext, 0, 0)); return(INTCONSTANT); }
{D}+{E} { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
{D}+"."{D}*({E})? { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
......@@ -272,11 +272,11 @@ O [0-7]
%%
int string_input(char* buf, int max_size, yyscan_t yyscanner) {
yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) {
pp::Token token;
yyget_extra(yyscanner)->preprocessor.lex(&token);
int len = token.type == pp::Token::LAST ? 0 : token.text.size();
if ((len > 0) && (len < max_size))
yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size();
if (len < max_size)
memcpy(buf, token.text.c_str(), len);
yyset_lineno(EncodeSourceLoc(token.location.file, token.location.line), yyscanner);
......@@ -341,7 +341,7 @@ int glslang_finalize(TParseContext* context) {
return 0;
}
int glslang_scan(int count, const char* const string[], const int length[],
int glslang_scan(size_t count, const char* const string[], const int length[],
TParseContext* context) {
yyrestart(NULL, context->scanner);
yyset_lineno(EncodeSourceLoc(0, 1), context->scanner);
......
......@@ -524,7 +524,7 @@ function_call
$$->getAsAggregate()->setName(fnCandidate->getMangledName());
TQualifier qual;
for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
for (size_t i = 0; i < fnCandidate->getParamCount(); ++i) {
qual = fnCandidate->getParam(i).type->getQualifier();
if (qual == EvqOut || qual == EvqInOut) {
if (context->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) {
......@@ -965,7 +965,7 @@ declaration
prototype->setType(function.getReturnType());
prototype->setName(function.getName());
for (int i = 0; i < function.getParamCount(); i++)
for (size_t i = 0; i < function.getParamCount(); i++)
{
const TParameter &param = function.getParam(i);
if (param.name != 0)
......@@ -1015,7 +1015,7 @@ function_prototype
context->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString());
context->recover();
}
for (int i = 0; i < prevDec->getParamCount(); ++i) {
for (size_t i = 0; i < prevDec->getParamCount(); ++i) {
if (prevDec->getParam(i).type->getQualifier() != $1->getParam(i).type->getQualifier()) {
context->error($2.line, "overloaded functions must have the same parameter qualifiers", $1->getParam(i).type->getQualifierString());
context->recover();
......@@ -2085,7 +2085,7 @@ function_definition
// knows where to find parameters.
//
TIntermAggregate* paramNodes = new TIntermAggregate;
for (int i = 0; i < function->getParamCount(); i++) {
for (size_t i = 0; i < function->getParamCount(); i++) {
const TParameter& param = function->getParam(i);
if (param.name != 0) {
TVariable *variable = new TVariable(param.name, *param.type);
......
......@@ -821,7 +821,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
#define YY_INPUT(buf, result, max_size) \
result = string_input(buf, max_size, yyscanner);
static int string_input(char* buf, int max_size, yyscan_t yyscanner);
static yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner);
static int check_type(yyscan_t yyscanner);
static int reserved_word(yyscan_t yyscanner);
......@@ -1543,11 +1543,11 @@ YY_RULE_SETUP
YY_BREAK
case 99:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
{ yylval->lex.i = static_cast<int>(strtol(yytext, 0, 0)); return(INTCONSTANT); }
YY_BREAK
case 100:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
{ yylval->lex.i = static_cast<int>(strtol(yytext, 0, 0)); return(INTCONSTANT); }
YY_BREAK
case 101:
YY_RULE_SETUP
......@@ -1555,7 +1555,7 @@ YY_RULE_SETUP
YY_BREAK
case 102:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
{ yylval->lex.i = static_cast<int>(strtol(yytext, 0, 0)); return(INTCONSTANT); }
YY_BREAK
case 103:
YY_RULE_SETUP
......@@ -2948,13 +2948,13 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
int string_input(char* buf, int max_size, yyscan_t yyscanner) {
yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) {
pp::Token token;
yyget_extra(yyscanner)->preprocessor.lex(&token);
int len = token.type == pp::Token::LAST ? 0 : token.text.size();
if ((len > 0) && (len < max_size))
yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size();
if (len < max_size)
memcpy(buf, token.text.c_str(), len);
yyset_lineno(EncodeSourceLoc(token.location.file, token.location.line),yyscanner);
yyset_lineno(EncodeSourceLoc(token.location.file, token.location.line), yyscanner);
if (len >= max_size)
YY_FATAL_ERROR("Input buffer overflow");
......@@ -3017,7 +3017,7 @@ int glslang_finalize(TParseContext* context) {
return 0;
}
int glslang_scan(int count, const char* const string[], const int length[],
int glslang_scan(size_t count, const char* const string[], const int length[],
TParseContext* context) {
yyrestart(NULL,context->scanner);
yyset_lineno(EncodeSourceLoc(0, 1),context->scanner);
......
......@@ -2468,7 +2468,7 @@ yyreduce:
(yyval.interm.intermTypedNode)->getAsAggregate()->setName(fnCandidate->getMangledName());
TQualifier qual;
for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
for (size_t i = 0; i < fnCandidate->getParamCount(); ++i) {
qual = fnCandidate->getParam(i).type->getQualifier();
if (qual == EvqOut || qual == EvqInOut) {
if (context->lValueErrorCheck((yyval.interm.intermTypedNode)->getLine(), "assign", (yyval.interm.intermTypedNode)->getAsAggregate()->getSequence()[i]->getAsTyped())) {
......@@ -3054,7 +3054,7 @@ yyreduce:
prototype->setType(function.getReturnType());
prototype->setName(function.getName());
for (int i = 0; i < function.getParamCount(); i++)
for (size_t i = 0; i < function.getParamCount(); i++)
{
const TParameter &param = function.getParam(i);
if (param.name != 0)
......@@ -3113,7 +3113,7 @@ yyreduce:
context->error((yyvsp[(2) - (2)].lex).line, "overloaded functions must have the same return type", (yyvsp[(1) - (2)].interm.function)->getReturnType().getBasicString());
context->recover();
}
for (int i = 0; i < prevDec->getParamCount(); ++i) {
for (size_t i = 0; i < prevDec->getParamCount(); ++i) {
if (prevDec->getParam(i).type->getQualifier() != (yyvsp[(1) - (2)].interm.function)->getParam(i).type->getQualifier()) {
context->error((yyvsp[(2) - (2)].lex).line, "overloaded functions must have the same parameter qualifiers", (yyvsp[(1) - (2)].interm.function)->getParam(i).type->getQualifierString());
context->recover();
......
......@@ -17,25 +17,24 @@ Input::Input() : mCount(0), mString(0)
{
}
Input::Input(int count, const char* const string[], const int length[]) :
Input::Input(size_t count, const char* const string[], const int length[]) :
mCount(count),
mString(string)
{
assert(mCount >= 0);
mLength.reserve(mCount);
for (int i = 0; i < mCount; ++i)
for (size_t i = 0; i < mCount; ++i)
{
int len = length ? length[i] : -1;
mLength.push_back(len < 0 ? std::strlen(mString[i]) : len);
}
}
int Input::read(char* buf, int maxSize)
size_t Input::read(char* buf, size_t maxSize)
{
int nRead = 0;
size_t nRead = 0;
while ((nRead < maxSize) && (mReadLoc.sIndex < mCount))
{
int size = mLength[mReadLoc.sIndex] - mReadLoc.cIndex;
size_t size = mLength[mReadLoc.sIndex] - mReadLoc.cIndex;
size = std::min(size, maxSize);
std::memcpy(buf + nRead, mString[mReadLoc.sIndex] + mReadLoc.cIndex, size);
nRead += size;
......
......@@ -7,6 +7,7 @@
#ifndef COMPILER_PREPROCESSOR_INPUT_H_
#define COMPILER_PREPROCESSOR_INPUT_H_
#include <stddef.h>
#include <vector>
namespace pp
......@@ -17,18 +18,18 @@ class Input
{
public:
Input();
Input(int count, const char* const string[], const int length[]);
Input(size_t count, const char* const string[], const int length[]);
int count() const { return mCount; }
const char* string(int index) const { return mString[index]; }
int length(int index) const { return mLength[index]; }
size_t count() const { return mCount; }
const char* string(size_t index) const { return mString[index]; }
size_t length(size_t index) const { return mLength[index]; }
int read(char* buf, int maxSize);
size_t read(char* buf, size_t maxSize);
struct Location
{
int sIndex; // String index;
int cIndex; // Char index.
size_t sIndex; // String index;
size_t cIndex; // Char index.
Location() : sIndex(0), cIndex(0) { }
};
......@@ -36,9 +37,9 @@ class Input
private:
// Input.
int mCount;
size_t mCount;
const char* const* mString;
std::vector<int> mLength;
std::vector<size_t> mLength;
Location mReadLoc;
};
......
......@@ -48,7 +48,7 @@ Preprocessor::~Preprocessor()
delete mImpl;
}
bool Preprocessor::init(int count,
bool Preprocessor::init(size_t count,
const char* const string[],
const int length[])
{
......
......@@ -7,6 +7,8 @@
#ifndef COMPILER_PREPROCESSOR_PREPROCESSOR_H_
#define COMPILER_PREPROCESSOR_PREPROCESSOR_H_
#include <stddef.h>
#include "pp_utils.h"
namespace pp
......@@ -32,7 +34,7 @@ class Preprocessor
// Each element in the length array may contain the length of the
// corresponding string or a value less than 0 to indicate that the string
// is null terminated.
bool init(int count, const char* const string[], const int length[]);
bool init(size_t count, const char* const string[], const int length[]);
// Adds a pre-defined macro.
void predefineMacro(const char* name, int value);
......
......@@ -1119,13 +1119,14 @@ case YY_STATE_EOF(COMMENT):
// Set the location for EOF token manually.
pp::Input* input = &yyextra->input;
pp::Input::Location* scanLoc = &yyextra->scanLoc;
int sIndexMax = std::max(0, input->count() - 1);
yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;
if (scanLoc->sIndex != sIndexMax)
{
// We can only reach here if there are empty strings at the
// end of the input.
scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0;
yyfileno = sIndexMax; yylineno = 1;
// FIXME: this is not 64-bit clean.
yyfileno = static_cast<int>(sIndexMax); yylineno = 1;
}
yylloc->file = yyfileno;
yylloc->line = yylineno;
......@@ -2294,9 +2295,8 @@ Tokenizer::~Tokenizer()
destroyScanner();
}
bool Tokenizer::init(int count, const char* const string[], const int length[])
bool Tokenizer::init(size_t count, const char* const string[], const int length[])
{
if (count < 0) return false;
if ((count > 0) && (string == 0)) return false;
mContext.input = Input(count, string, length);
......
......@@ -37,7 +37,7 @@ class Tokenizer : public Lexer
Tokenizer(Diagnostics* diagnostics);
~Tokenizer();
bool init(int count, const char* const string[], const int length[]);
bool init(size_t count, const char* const string[], const int length[]);
void setFileNumber(int file);
void setLineNumber(int line);
......
......@@ -239,13 +239,14 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
// Set the location for EOF token manually.
pp::Input* input = &yyextra->input;
pp::Input::Location* scanLoc = &yyextra->scanLoc;
int sIndexMax = std::max(0, input->count() - 1);
yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;
if (scanLoc->sIndex != sIndexMax)
{
// We can only reach here if there are empty strings at the
// end of the input.
scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0;
yyfileno = sIndexMax; yylineno = 1;
// FIXME: this is not 64-bit clean.
yyfileno = static_cast<int>(sIndexMax); yylineno = 1;
}
yylloc->file = yyfileno;
yylloc->line = yylineno;
......
......@@ -351,14 +351,14 @@ void Shader::compileToHLSL(void *compiler)
if (result)
{
int objCodeLen = 0;
size_t objCodeLen = 0;
ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &objCodeLen);
mHlsl = new char[objCodeLen];
ShGetObjectCode(compiler, mHlsl);
}
else
{
int infoLogLen = 0;
size_t infoLogLen = 0;
ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &infoLogLen);
mInfoLog = new char[infoLogLen];
ShGetInfoLog(compiler, mInfoLog);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment