renamed SkSL's assert macros

Since SkSL needs to run outside of Skia, it was originally using its
own ASSERT macro, which mapped to SkASSERT when inside of Skia. This is
causing conflicts with one or two other ASSERT macros defined around
Skia, so to avoid that I am switching SkSL over to just use Skia's
standard naming for these macros.

Bug: skia:
Change-Id: I115435d7282da03d076c6080f7b13d1972b9eb9f
Reviewed-on: https://skia-review.googlesource.com/134322
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Ethan Nicholas 2018-06-12 11:05:59 -04:00 committed by Skia Commit-Bot
parent 22be4c4801
commit d9d33c33de
36 changed files with 328 additions and 332 deletions

View File

@ -89,7 +89,7 @@ bool BasicBlock::tryRemoveExpressionBefore(std::vector<BasicBlock::Node>::iterat
}
bool result;
if ((*iter)->fKind == BasicBlock::Node::kExpression_Kind) {
ASSERT((*iter)->expression()->get() != e);
SkASSERT((*iter)->expression()->get() != e);
Expression* old = (*iter)->expression()->get();
do {
if ((*iter) == fNodes.begin()) {
@ -101,7 +101,7 @@ bool BasicBlock::tryRemoveExpressionBefore(std::vector<BasicBlock::Node>::iterat
result = this->tryRemoveExpression(iter);
while ((*iter)->fKind != BasicBlock::Node::kExpression_Kind ||
(*iter)->expression()->get() != old) {
ASSERT(*iter != fNodes.end());
SkASSERT(*iter != fNodes.end());
++(*iter);
}
} else {
@ -116,7 +116,7 @@ bool BasicBlock::tryRemoveExpressionBefore(std::vector<BasicBlock::Node>::iterat
result = this->tryRemoveExpression(iter);
while ((*iter)->fKind != BasicBlock::Node::kStatement_Kind ||
(*iter)->statement()->get() != old) {
ASSERT(*iter != fNodes.end());
SkASSERT(*iter != fNodes.end());
++(*iter);
}
}
@ -166,7 +166,7 @@ bool BasicBlock::tryRemoveExpression(std::vector<BasicBlock::Node>::iterator* it
if (!this->tryRemoveExpressionBefore(iter, b->fRight.get())) {
return false;
}
ASSERT((*iter)->expression()->get() == expr);
SkASSERT((*iter)->expression()->get() == expr);
*iter = fNodes.erase(*iter);
return true;
}
@ -207,7 +207,7 @@ bool BasicBlock::tryRemoveExpression(std::vector<BasicBlock::Node>::iterator* it
if (!this->tryRemoveExpressionBefore(iter, arg.get())) {
return false;
}
ASSERT((*iter)->expression()->get() == expr);
SkASSERT((*iter)->expression()->get() == expr);
}
*iter = fNodes.erase(*iter);
return true;
@ -218,7 +218,7 @@ bool BasicBlock::tryRemoveExpression(std::vector<BasicBlock::Node>::iterator* it
if (!this->tryRemoveExpressionBefore(iter, arg.get())) {
return false;
}
ASSERT((*iter)->expression()->get() == expr);
SkASSERT((*iter)->expression()->get() == expr);
}
*iter = fNodes.erase(*iter);
return true;
@ -292,7 +292,7 @@ bool BasicBlock::tryInsertExpression(std::vector<BasicBlock::Node>::iterator* it
}
void CFGGenerator::addExpression(CFG& cfg, std::unique_ptr<Expression>* e, bool constantPropagate) {
ASSERT(e);
SkASSERT(e);
switch ((*e)->fKind) {
case Expression::kBinary_Kind: {
BinaryExpression* b = (BinaryExpression*) e->get();
@ -415,7 +415,7 @@ void CFGGenerator::addExpression(CFG& cfg, std::unique_ptr<Expression>* e, bool
case Expression::kFunctionReference_Kind: // fall through
case Expression::kTypeReference_Kind: // fall through
case Expression::kDefined_Kind:
ASSERT(false);
SkASSERT(false);
break;
}
}
@ -445,7 +445,7 @@ void CFGGenerator::addLValue(CFG& cfg, std::unique_ptr<Expression>* e) {
break;
default:
// not an lvalue, can't happen
ASSERT(false);
SkASSERT(false);
break;
}
}

View File

@ -34,22 +34,22 @@ struct BasicBlock {
, fStatement(statement) {}
std::unique_ptr<Expression>* expression() const {
ASSERT(fKind == kExpression_Kind);
SkASSERT(fKind == kExpression_Kind);
return fExpression;
}
void setExpression(std::unique_ptr<Expression> expr) {
ASSERT(fKind == kExpression_Kind);
SkASSERT(fKind == kExpression_Kind);
*fExpression = std::move(expr);
}
std::unique_ptr<Statement>* statement() const {
ASSERT(fKind == kStatement_Kind);
SkASSERT(fKind == kStatement_Kind);
return fStatement;
}
void setStatement(std::unique_ptr<Statement> stmt) {
ASSERT(fKind == kStatement_Kind);
SkASSERT(fKind == kStatement_Kind);
*fStatement = std::move(stmt);
}
@ -57,7 +57,7 @@ struct BasicBlock {
if (fKind == kStatement_Kind) {
return (*fStatement)->description();
} else {
ASSERT(fKind == kExpression_Kind);
SkASSERT(fKind == kExpression_Kind);
return (*fExpression)->description();
}
}

View File

@ -185,7 +185,7 @@ void CPPCodeGenerator::writeRuntimeValue(const Type& type, const Layout& layout,
fFormatArgs.push_back(cppCode + ".bottom()");
} else {
printf("unsupported runtime value type '%s'\n", String(type.fName).c_str());
ASSERT(false);
SkASSERT(false);
}
}
@ -216,7 +216,7 @@ void CPPCodeGenerator::writeIntLiteral(const IntLiteral& i) {
void CPPCodeGenerator::writeSwizzle(const Swizzle& swizzle) {
if (fCPPMode) {
ASSERT(swizzle.fComponents.size() == 1); // no support for multiple swizzle components yet
SkASSERT(swizzle.fComponents.size() == 1); // no support for multiple swizzle components yet
this->writeExpression(*swizzle.fBase, kPostfix_Precedence);
switch (swizzle.fComponents[0]) {
case 0: this->write(".left()"); break;
@ -291,8 +291,8 @@ void CPPCodeGenerator::writeSwitchStatement(const SwitchStatement& s) {
void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fFunction.fBuiltin && c.fFunction.fName == "process") {
ASSERT(c.fArguments.size() == 1);
ASSERT(Expression::kVariableReference_Kind == c.fArguments[0]->fKind);
SkASSERT(c.fArguments.size() == 1);
SkASSERT(Expression::kVariableReference_Kind == c.fArguments[0]->fKind);
int index = 0;
bool found = false;
for (const auto& p : fProgram) {
@ -311,7 +311,7 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
break;
}
}
ASSERT(found);
SkASSERT(found);
String childName = "_child" + to_string(index);
fExtraEmitCodeCode += " SkString " + childName + "(\"" + childName + "\");\n" +
" this->emitChild(" + to_string(index) + ", &" + childName +
@ -323,8 +323,8 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
INHERITED::writeFunctionCall(c);
if (c.fFunction.fBuiltin && c.fFunction.fName == "texture") {
this->write(".%s");
ASSERT(c.fArguments.size() >= 1);
ASSERT(c.fArguments[0]->fKind == Expression::kVariableReference_Kind);
SkASSERT(c.fArguments.size() >= 1);
SkASSERT(c.fArguments[0]->fKind == Expression::kVariableReference_Kind);
String sampler = this->getSamplerHandle(((VariableReference&) *c.fArguments[0]).fVariable);
fFormatArgs.push_back("fragBuilder->getProgramBuilder()->samplerSwizzle(" + sampler +
").c_str()");

View File

@ -213,7 +213,7 @@ Compiler::Compiler(Flags flags)
if (fErrorCount) {
printf("Unexpected errors: %s\n", fErrorText.c_str());
}
ASSERT(!fErrorCount);
SkASSERT(!fErrorCount);
Program::Settings settings;
fIRGenerator->start(&settings, nullptr);
@ -289,7 +289,7 @@ void Compiler::addDefinition(const Expression* lvalue, std::unique_ptr<Expressio
break;
default:
// not an lvalue, can't happen
ASSERT(false);
SkASSERT(false);
}
}
@ -298,7 +298,7 @@ void Compiler::addDefinitions(const BasicBlock::Node& node,
DefinitionMap* definitions) {
switch (node.fKind) {
case BasicBlock::Node::kExpression_Kind: {
ASSERT(node.expression());
SkASSERT(node.expression());
const Expression* expr = (Expression*) node.expression()->get();
switch (expr->fKind) {
case Expression::kBinary_Kind: {
@ -420,7 +420,7 @@ static DefinitionMap compute_start_state(const CFG& cfg) {
for (const auto& block : cfg.fBlocks) {
for (const auto& node : block.fNodes) {
if (node.fKind == BasicBlock::Node::kStatement_Kind) {
ASSERT(node.statement());
SkASSERT(node.statement());
const Statement* s = node.statement()->get();
if (s->fKind == Statement::kVarDeclarations_Kind) {
const VarDeclarationsStatement* vd = (const VarDeclarationsStatement*) s;
@ -539,9 +539,9 @@ void delete_left(BasicBlock* b,
bool* outNeedsRescan) {
*outUpdated = true;
std::unique_ptr<Expression>* target = (*iter)->expression();
ASSERT((*target)->fKind == Expression::kBinary_Kind);
SkASSERT((*target)->fKind == Expression::kBinary_Kind);
BinaryExpression& bin = (BinaryExpression&) **target;
ASSERT(!bin.fLeft->hasSideEffects());
SkASSERT(!bin.fLeft->hasSideEffects());
bool result;
if (bin.fOperator == Token::EQ) {
result = b->tryRemoveLValueBefore(iter, bin.fLeft.get());
@ -564,7 +564,7 @@ void delete_left(BasicBlock* b,
return;
}
*iter = b->fNodes.erase(*iter);
ASSERT((*iter)->expression() == target);
SkASSERT((*iter)->expression() == target);
}
/**
@ -577,9 +577,9 @@ void delete_right(BasicBlock* b,
bool* outNeedsRescan) {
*outUpdated = true;
std::unique_ptr<Expression>* target = (*iter)->expression();
ASSERT((*target)->fKind == Expression::kBinary_Kind);
SkASSERT((*target)->fKind == Expression::kBinary_Kind);
BinaryExpression& bin = (BinaryExpression&) **target;
ASSERT(!bin.fRight->hasSideEffects());
SkASSERT(!bin.fRight->hasSideEffects());
if (!b->tryRemoveExpressionBefore(iter, bin.fRight.get())) {
*target = std::move(bin.fLeft);
*outNeedsRescan = true;
@ -597,7 +597,7 @@ void delete_right(BasicBlock* b,
return;
}
*iter = b->fNodes.erase(*iter);
ASSERT((*iter)->expression() == target);
SkASSERT((*iter)->expression() == target);
}
/**
@ -620,9 +620,9 @@ static void vectorize(BasicBlock* b,
std::unique_ptr<Expression>* otherExpression,
bool* outUpdated,
bool* outNeedsRescan) {
ASSERT((*(*iter)->expression())->fKind == Expression::kBinary_Kind);
ASSERT(type.kind() == Type::kVector_Kind);
ASSERT((*otherExpression)->fType.kind() == Type::kScalar_Kind);
SkASSERT((*(*iter)->expression())->fKind == Expression::kBinary_Kind);
SkASSERT(type.kind() == Type::kVector_Kind);
SkASSERT((*otherExpression)->fType.kind() == Type::kScalar_Kind);
*outUpdated = true;
std::unique_ptr<Expression>* target = (*iter)->expression();
if (!b->tryRemoveExpression(iter)) {
@ -689,7 +689,7 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
bool* outUpdated,
bool* outNeedsRescan) {
Expression* expr = (*iter)->expression()->get();
ASSERT(expr);
SkASSERT(expr);
if ((*iter)->fConstantPropagation) {
std::unique_ptr<Expression> optimized = expr->constantPropagate(*fIRGenerator, definitions);
if (optimized) {
@ -698,7 +698,7 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
*outNeedsRescan = true;
return;
}
ASSERT((*iter)->fKind == BasicBlock::Node::kExpression_Kind);
SkASSERT((*iter)->fKind == BasicBlock::Node::kExpression_Kind);
expr = (*iter)->expression()->get();
}
}
@ -972,7 +972,7 @@ void Compiler::simplifyStatement(DefinitionMap& definitions,
(!varDecl.fValue ||
!varDecl.fValue->hasSideEffects())) {
if (varDecl.fValue) {
ASSERT((*iter)->statement()->get() == stmt);
SkASSERT((*iter)->statement()->get() == stmt);
if (!b.tryRemoveExpressionBefore(iter, varDecl.fValue.get())) {
*outNeedsRescan = true;
}
@ -987,7 +987,7 @@ void Compiler::simplifyStatement(DefinitionMap& definitions,
if (i.fTest->fKind == Expression::kBoolLiteral_Kind) {
// constant if, collapse down to a single branch
if (((BoolLiteral&) *i.fTest).fValue) {
ASSERT(i.fIfTrue);
SkASSERT(i.fIfTrue);
(*iter)->setStatement(std::move(i.fIfTrue));
} else {
if (i.fIfFalse) {
@ -1033,7 +1033,7 @@ void Compiler::simplifyStatement(DefinitionMap& definitions,
defaultCase = c.get();
continue;
}
ASSERT(c->fValue->fKind == s.fValue->fKind);
SkASSERT(c->fValue->fKind == s.fValue->fKind);
found = c->fValue->compareConstant(*fContext, *s.fValue);
if (found) {
std::unique_ptr<Statement> newBlock = block_for_case(&s, c.get());
@ -1075,13 +1075,13 @@ void Compiler::simplifyStatement(DefinitionMap& definitions,
}
case Statement::kExpression_Kind: {
ExpressionStatement& e = (ExpressionStatement&) *stmt;
ASSERT((*iter)->statement()->get() == &e);
SkASSERT((*iter)->statement()->get() == &e);
if (!e.fExpression->hasSideEffects()) {
// Expression statement with no side effects, kill it
if (!b.tryRemoveExpressionBefore(iter, e.fExpression.get())) {
*outNeedsRescan = true;
}
ASSERT((*iter)->statement()->get() == stmt);
SkASSERT((*iter)->statement()->get() == stmt);
(*iter)->setStatement(std::unique_ptr<Statement>(new Nop()));
*outUpdated = true;
}
@ -1146,7 +1146,7 @@ void Compiler::scanCFG(FunctionDefinition& f) {
}
}
} while (updated);
ASSERT(!needsRescan);
SkASSERT(!needsRescan);
// verify static ifs & switches, clean up dead variable decls
for (BasicBlock& b : cfg.fBlocks) {
@ -1283,14 +1283,14 @@ bool Compiler::toSPIRV(const Program& program, OutputStream& out) {
if (result) {
spvtools::SpirvTools tools(SPV_ENV_VULKAN_1_0);
const String& data = buffer.str();
ASSERT(0 == data.size() % 4);
SkASSERT(0 == data.size() % 4);
auto dumpmsg = [](spv_message_level_t, const char*, const spv_position_t&, const char* m) {
SkDebugf("SPIR-V validation error: %s\n", m);
};
tools.SetMessageConsumer(dumpmsg);
// Verify that the SPIR-V we produced is valid. If this assert fails, check the logs prior
// Verify that the SPIR-V we produced is valid. If this SkASSERT fails, check the logs prior
// to the failure to see the validation errors.
ASSERT_RESULT(tools.Validate((const uint32_t*) data.c_str(), data.size() / 4));
SkAssertResult(tools.Validate((const uint32_t*) data.c_str(), data.size() / 4));
out.write(data.c_str(), data.size());
}
#else
@ -1424,7 +1424,7 @@ bool Compiler::IsAssignment(Token::Kind op) {
}
Position Compiler::position(int offset) {
ASSERT(fSource);
SkASSERT(fSource);
int line = 1;
int column = 1;
for (int i = 0; i < offset; i++) {

View File

@ -21,7 +21,7 @@ public:
}
~FileOutputStream() override {
ASSERT(!fOpen);
SkASSERT(!fOpen);
}
bool isValid() const override {
@ -29,7 +29,7 @@ public:
}
void write8(uint8_t b) override {
ASSERT(fOpen);
SkASSERT(fOpen);
if (isValid()) {
if (EOF == fputc(b, fFile)) {
fFile = nullptr;
@ -38,7 +38,7 @@ public:
}
void writeText(const char* s) override {
ASSERT(fOpen);
SkASSERT(fOpen);
if (isValid()) {
if (EOF == fputs(s, fFile)) {
fFile = nullptr;

View File

@ -233,7 +233,7 @@ static bool is_abs(Expression& expr) {
// turns min(abs(x), y) into ((tmpVar1 = abs(x)) < (tmpVar2 = y) ? tmpVar1 : tmpVar2) to avoid a
// Tegra3 compiler bug.
void GLSLCodeGenerator::writeMinAbsHack(Expression& absExpr, Expression& otherExpr) {
ASSERT(!fProgram.fSettings.fCaps->canUseMinAndAbsTogether());
SkASSERT(!fProgram.fSettings.fCaps->canUseMinAndAbsTogether());
String tmpVar1 = "minAbsHackVar" + to_string(fVarCount++);
String tmpVar2 = "minAbsHackVar" + to_string(fVarCount++);
this->fFunctionHeader += String(" ") + this->getTypePrecision(absExpr.fType) +
@ -311,7 +311,7 @@ void GLSLCodeGenerator::writeDeterminantHack(const Expression& mat) {
}
}
else {
ASSERT(false);
SkASSERT(false);
}
this->write(name + "(");
this->writeExpression(mat, kTopLevel_Precedence);
@ -398,7 +398,7 @@ void GLSLCodeGenerator::writeInverseHack(const Expression& mat) {
}
}
else {
ASSERT(false);
SkASSERT(false);
}
this->write(name + "(");
this->writeExpression(mat, kTopLevel_Precedence);
@ -435,7 +435,7 @@ void GLSLCodeGenerator::writeTransposeHack(const Expression& mat) {
void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (!fProgram.fSettings.fCaps->canUseMinAndAbsTogether() && c.fFunction.fName == "min" &&
c.fFunction.fBuiltin) {
ASSERT(c.fArguments.size() == 2);
SkASSERT(c.fArguments.size() == 2);
if (is_abs(*c.fArguments[0])) {
this->writeMinAbsHack(*c.fArguments[0], *c.fArguments[1]);
return;
@ -449,7 +449,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
if (!fProgram.fSettings.fCaps->canUseFractForNegativeValues() && c.fFunction.fName == "fract" &&
c.fFunction.fBuiltin) {
ASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments.size() == 1);
this->write("(0.5 - sign(");
this->writeExpression(*c.fArguments[0], kSequence_Precedence);
@ -475,31 +475,31 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
if (c.fFunction.fBuiltin && c.fFunction.fName == "determinant" &&
fProgram.fSettings.fCaps->generation() < k150_GrGLSLGeneration) {
ASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments.size() == 1);
this->writeDeterminantHack(*c.fArguments[0]);
return;
}
if (c.fFunction.fBuiltin && c.fFunction.fName == "inverse" &&
fProgram.fSettings.fCaps->generation() < k140_GrGLSLGeneration) {
ASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments.size() == 1);
this->writeInverseHack(*c.fArguments[0]);
return;
}
if (c.fFunction.fBuiltin && c.fFunction.fName == "inverseSqrt" &&
fProgram.fSettings.fCaps->generation() < k130_GrGLSLGeneration) {
ASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments.size() == 1);
this->writeInverseSqrtHack(*c.fArguments[0]);
return;
}
if (c.fFunction.fBuiltin && c.fFunction.fName == "transpose" &&
fProgram.fSettings.fCaps->generation() < k130_GrGLSLGeneration) {
ASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments.size() == 1);
this->writeTransposeHack(*c.fArguments[0]);
return;
}
if (!fFoundDerivatives && (c.fFunction.fName == "dFdx" || c.fFunction.fName == "dFdy") &&
c.fFunction.fBuiltin && fProgram.fSettings.fCaps->shaderDerivativeExtensionString()) {
ASSERT(fProgram.fSettings.fCaps->shaderDerivativeSupport());
SkASSERT(fProgram.fSettings.fCaps->shaderDerivativeSupport());
fHeader.writeText("#extension ");
fHeader.writeText(fProgram.fSettings.fCaps->shaderDerivativeExtensionString());
fHeader.writeText(" : require\n");
@ -516,7 +516,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fArguments[1]->fType == *fContext.fFloat_Type) {
proj = false;
} else {
ASSERT(c.fArguments[1]->fType == *fContext.fFloat2_Type);
SkASSERT(c.fArguments[1]->fType == *fContext.fFloat2_Type);
proj = true;
}
break;
@ -528,7 +528,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fArguments[1]->fType == *fContext.fFloat2_Type) {
proj = false;
} else {
ASSERT(c.fArguments[1]->fType == *fContext.fFloat3_Type);
SkASSERT(c.fArguments[1]->fType == *fContext.fFloat3_Type);
proj = true;
}
break;
@ -538,7 +538,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fArguments[1]->fType == *fContext.fFloat3_Type) {
proj = false;
} else {
ASSERT(c.fArguments[1]->fType == *fContext.fFloat4_Type);
SkASSERT(c.fArguments[1]->fType == *fContext.fFloat4_Type);
proj = true;
}
break;
@ -552,12 +552,12 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
proj = false;
break;
case SpvDimBuffer:
ASSERT(false); // doesn't exist
SkASSERT(false); // doesn't exist
dim = "Buffer";
proj = false;
break;
case SpvDimSubpassData:
ASSERT(false); // doesn't exist
SkASSERT(false); // doesn't exist
dim = "SubpassData";
proj = false;
break;

View File

@ -54,7 +54,7 @@ String HCodeGenerator::FieldType(const Context& context, const Type& type,
} else if (type == *context.fFragmentProcessor_Type) {
// we don't store fragment processors in fields, they get registered via
// registerChildProcessor instead
ASSERT(false);
SkASSERT(false);
return "<error>";
}
return ParameterType(context, type, layout);
@ -111,13 +111,13 @@ void HCodeGenerator::writeExtraConstructorParams(const char* separator) {
lastIdentifierLength = 0;
foundBreak = false;
}
ASSERT(lastIdentifierLength < BUFFER_SIZE);
SkASSERT(lastIdentifierLength < BUFFER_SIZE);
lastIdentifier[lastIdentifierLength] = c;
++lastIdentifierLength;
} else {
foundBreak = true;
if (c == ',') {
ASSERT(lastIdentifierLength < BUFFER_SIZE);
SkASSERT(lastIdentifierLength < BUFFER_SIZE);
lastIdentifier[lastIdentifierLength] = 0;
this->writef("%s%s", separator, lastIdentifier);
separator = ", ";
@ -127,7 +127,7 @@ void HCodeGenerator::writeExtraConstructorParams(const char* separator) {
}
}
if (lastIdentifierLength) {
ASSERT(lastIdentifierLength < BUFFER_SIZE);
SkASSERT(lastIdentifierLength < BUFFER_SIZE);
lastIdentifier[lastIdentifierLength] = 0;
this->writef("%s%s", separator, lastIdentifier);
}

View File

@ -67,7 +67,7 @@ public:
~AutoSymbolTable() {
fIR->popSymbolTable();
ASSERT(fPrevious == fIR->fSymbolTable);
SkASSERT(fPrevious == fIR->fSymbolTable);
}
IRGenerator* fIR;
@ -160,7 +160,7 @@ void IRGenerator::start(const Program::Settings* settings,
if (e->fKind == ProgramElement::kInterfaceBlock_Kind) {
InterfaceBlock& intf = (InterfaceBlock&) *e;
if (intf.fVariable.fName == Compiler::PERVERTEX_NAME) {
ASSERT(!fSkPerVertex);
SkASSERT(!fSkPerVertex);
fSkPerVertex = &intf.fVariable;
}
}
@ -187,7 +187,7 @@ std::unique_ptr<Statement> IRGenerator::convertStatement(const ASTStatement& sta
std::unique_ptr<Statement> result =
this->convertExpressionStatement((ASTExpressionStatement&) statement);
if (fRTAdjust && Program::kGeometry_Kind == fKind) {
ASSERT(result->fKind == Statement::kExpression_Kind);
SkASSERT(result->fKind == Statement::kExpression_Kind);
Expression& expr = *((ExpressionStatement&) *result).fExpression;
if (expr.fKind == Expression::kFunctionCall_Kind) {
FunctionCall& fc = (FunctionCall&) expr;
@ -294,8 +294,8 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa
auto var = std::unique_ptr<Variable>(new Variable(decl.fOffset, decl.fModifiers,
varDecl.fName, *type, storage));
if (var->fName == Compiler::RTADJUST_NAME) {
ASSERT(!fRTAdjust);
ASSERT(var->fType == *fContext.fFloat4_Type);
SkASSERT(!fRTAdjust);
SkASSERT(var->fType == *fContext.fFloat4_Type);
fRTAdjust = var.get();
}
std::unique_ptr<Expression> value;
@ -339,7 +339,7 @@ std::unique_ptr<ModifiersDeclaration> IRGenerator::convertModifiersDeclaration(
if (fSettings->fCaps && !fSettings->fCaps->gsInvocationsSupport()) {
modifiers.fLayout.fInvocations = -1;
Variable* invocationId = (Variable*) (*fSymbolTable)["sk_InvocationID"];
ASSERT(invocationId);
SkASSERT(invocationId);
invocationId->fModifiers.fFlags = 0;
invocationId->fModifiers.fLayout.fBuiltin = -1;
if (modifiers.fLayout.description() == "") {
@ -516,11 +516,11 @@ std::unique_ptr<Statement> IRGenerator::convertExpressionStatement(
}
std::unique_ptr<Statement> IRGenerator::convertReturn(const ASTReturnStatement& r) {
ASSERT(fCurrentFunction);
SkASSERT(fCurrentFunction);
// early returns from a vertex main function will bypass the sk_Position normalization, so
// assert that we aren't doing that. It is of course possible to fix this by adding a
// SkASSERT that we aren't doing that. It is of course possible to fix this by adding a
// normalization before each return, but it will probably never actually be necessary.
ASSERT(Program::kVertex_Kind != fKind || !fRTAdjust || "main" != fCurrentFunction->fName);
SkASSERT(Program::kVertex_Kind != fKind || !fRTAdjust || "main" != fCurrentFunction->fName);
if (r.fExpression) {
std::unique_ptr<Expression> result = this->convertExpression(*r.fExpression);
if (!result) {
@ -580,7 +580,7 @@ std::unique_ptr<Block> IRGenerator::applyInvocationIDWorkaround(std::unique_ptr<
std::vector<std::unique_ptr<VarDeclaration>> variables;
Variable* loopIdx = (Variable*) (*fSymbolTable)["sk_InvocationID"];
ASSERT(loopIdx);
SkASSERT(loopIdx);
std::unique_ptr<Expression> test(new BinaryExpression(-1,
std::unique_ptr<Expression>(new VariableReference(-1, *loopIdx)),
Token::LT,
@ -594,7 +594,7 @@ std::unique_ptr<Block> IRGenerator::applyInvocationIDWorkaround(std::unique_ptr<
Token::PLUSPLUS));
ASTIdentifier endPrimitiveID = ASTIdentifier(-1, "EndPrimitive");
std::unique_ptr<Expression> endPrimitive = this->convertExpression(endPrimitiveID);
ASSERT(endPrimitive);
SkASSERT(endPrimitive);
std::vector<std::unique_ptr<Statement>> loopBody;
std::vector<std::unique_ptr<Expression>> invokeArgs;
@ -628,7 +628,7 @@ std::unique_ptr<Statement> IRGenerator::getNormalizeSkPositionCode() {
// sk_Position = float4(sk_Position.xy * rtAdjust.xz + sk_Position.ww * rtAdjust.yw,
// 0,
// sk_Position.w);
ASSERT(fSkPerVertex && fRTAdjust);
SkASSERT(fSkPerVertex && fRTAdjust);
#define REF(var) std::unique_ptr<Expression>(\
new VariableReference(-1, *var, VariableReference::kRead_RefKind))
#define FIELD(var, idx) std::unique_ptr<Expression>(\
@ -699,7 +699,7 @@ void IRGenerator::convertFunction(const ASTFunction& f) {
return;
}
for (const auto& other : functions) {
ASSERT(other->fName == f.fName);
SkASSERT(other->fName == f.fName);
if (parameters.size() == other->fParameters.size()) {
bool match = true;
for (size_t i = 0; i < parameters.size(); i++) {
@ -747,7 +747,7 @@ void IRGenerator::convertFunction(const ASTFunction& f) {
fSymbolTable->add(decl->fName, std::move(newDecl));
}
if (f.fBody) {
ASSERT(!fCurrentFunction);
SkASSERT(!fCurrentFunction);
fCurrentFunction = decl;
decl->fDefined = true;
std::shared_ptr<SymbolTable> old = fSymbolTable;
@ -758,7 +758,7 @@ void IRGenerator::convertFunction(const ASTFunction& f) {
bool needInvocationIDWorkaround = fInvocations != -1 && f.fName == "main" &&
fSettings->fCaps &&
!fSettings->fCaps->gsInvocationsSupport();
ASSERT(!fExtraVars.size());
SkASSERT(!fExtraVars.size());
std::unique_ptr<Block> body = this->convertBlock(*f.fBody);
for (auto& v : fExtraVars) {
body->fStatements.insert(body->fStatements.begin(), std::move(v));
@ -804,7 +804,7 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte
}
if (vd.fVar == fRTAdjust) {
foundRTAdjust = true;
ASSERT(vd.fVar->fType == *fContext.fFloat4_Type);
SkASSERT(vd.fVar->fType == *fContext.fFloat4_Type);
fRTAdjustFieldIndex = fields.size();
}
fields.push_back(Type::Field(vd.fVar->fModifiers, vd.fVar->fName,
@ -1062,7 +1062,7 @@ std::unique_ptr<Expression> IRGenerator::coerce(std::unique_ptr<Expression> expr
args.push_back(std::move(expr));
ASTIdentifier id(-1, type.fName);
std::unique_ptr<Expression> ctor = this->convertIdentifier(id);
ASSERT(ctor);
SkASSERT(ctor);
return this->call(-1, std::move(ctor), std::move(args));
}
std::vector<std::unique_ptr<Expression>> args;
@ -1156,7 +1156,7 @@ static bool determine_binary_type(const Context& context,
// transpose it
rightColumns = right.rows();
rightRows = right.columns();
ASSERT(rightColumns == 1);
SkASSERT(rightColumns == 1);
} else {
rightColumns = right.columns();
rightRows = right.rows();
@ -1336,8 +1336,8 @@ std::unique_ptr<Expression> IRGenerator::constantFold(const Expression& left,
if (left.fType.kind() == Type::kVector_Kind &&
left.fType.componentType() == *fContext.fFloat_Type &&
left.fType == right.fType) {
ASSERT(left.fKind == Expression::kConstructor_Kind);
ASSERT(right.fKind == Expression::kConstructor_Kind);
SkASSERT(left.fKind == Expression::kConstructor_Kind);
SkASSERT(right.fKind == Expression::kConstructor_Kind);
std::vector<std::unique_ptr<Expression>> args;
#define RETURN_VEC_COMPONENTWISE_RESULT(op) \
for (int i = 0; i < left.fType.columns(); i++) { \
@ -1488,12 +1488,12 @@ std::unique_ptr<Expression> IRGenerator::convertTernaryExpression(
// For float3coordinates, implements the transformation:
// texture(sampler, coord) -> texture(sampler, float3textureSize(sampler), 1.0) * coord))
void IRGenerator::fixRectSampling(std::vector<std::unique_ptr<Expression>>& arguments) {
ASSERT(arguments.size() == 2);
ASSERT(arguments[0]->fType == *fContext.fSampler2DRect_Type);
ASSERT(arguments[0]->fKind == Expression::kVariableReference_Kind);
SkASSERT(arguments.size() == 2);
SkASSERT(arguments[0]->fType == *fContext.fSampler2DRect_Type);
SkASSERT(arguments[0]->fKind == Expression::kVariableReference_Kind);
const Variable& sampler = ((VariableReference&) *arguments[0]).fVariable;
const Symbol* textureSizeSymbol = (*fSymbolTable)["textureSize"];
ASSERT(textureSizeSymbol->fKind == Symbol::kFunctionDeclaration_Kind);
SkASSERT(textureSizeSymbol->fKind == Symbol::kFunctionDeclaration_Kind);
const FunctionDeclaration& textureSize = (FunctionDeclaration&) *textureSizeSymbol;
std::vector<std::unique_ptr<Expression>> sizeArguments;
sizeArguments.emplace_back(new VariableReference(-1, sampler));
@ -1503,7 +1503,7 @@ void IRGenerator::fixRectSampling(std::vector<std::unique_ptr<Expression>>& argu
if (type == *fContext.fFloat2_Type) {
scale = std::move(float2ize);
} else {
ASSERT(type == *fContext.fFloat3_Type);
SkASSERT(type == *fContext.fFloat3_Type);
std::vector<std::unique_ptr<Expression>> float3rguments;
float3rguments.push_back(std::move(float2ize));
float3rguments.emplace_back(new FloatLiteral(fContext, -1, 1.0));
@ -1632,7 +1632,7 @@ std::unique_ptr<Expression> IRGenerator::convertNumberConstructor(
int offset,
const Type& type,
std::vector<std::unique_ptr<Expression>> args) {
ASSERT(type.isNumber());
SkASSERT(type.isNumber());
if (args.size() != 1) {
fErrors.error(offset, "invalid arguments to '" + type.description() +
"' constructor, (expected exactly 1 argument, but found " +
@ -1691,7 +1691,7 @@ std::unique_ptr<Expression> IRGenerator::convertCompoundConstructor(
int offset,
const Type& type,
std::vector<std::unique_ptr<Expression>> args) {
ASSERT(type.kind() == Type::kVector_Kind || type.kind() == Type::kMatrix_Kind);
SkASSERT(type.kind() == Type::kVector_Kind || type.kind() == Type::kMatrix_Kind);
if (type.kind() == Type::kMatrix_Kind && args.size() == 1 &&
args[0]->fType.kind() == Type::kMatrix_Kind) {
// matrix from matrix is always legal
@ -1933,7 +1933,7 @@ std::unique_ptr<Expression> IRGenerator::convertSwizzle(std::unique_ptr<Expressi
return nullptr;
}
}
ASSERT(swizzleComponents.size() > 0);
SkASSERT(swizzleComponents.size() > 0);
if (swizzleComponents.size() > 4) {
fErrors.error(base->fOffset, "too many components in swizzle mask '" + fields + "'");
return nullptr;
@ -2062,7 +2062,7 @@ std::unique_ptr<Expression> IRGenerator::convertAppend(int offset,
return std::unique_ptr<Expression>(new AppendStage(fContext, offset, stage,
std::move(stageArgs)));
#else
ASSERT(false);
SkASSERT(false);
return nullptr;
#endif
}
@ -2171,7 +2171,7 @@ void IRGenerator::checkValid(const Expression& expr) {
static bool has_duplicates(const Swizzle& swizzle) {
int bits = 0;
for (int idx : swizzle.fComponents) {
ASSERT(idx >= 0 && idx <= 3);
SkASSERT(idx >= 0 && idx <= 3);
int bit = 1 << idx;
if (bits & bit) {
return true;

View File

@ -38,7 +38,7 @@ void Interpreter::run() {
}
}
}
ASSERT(false);
SkASSERT(false);
}
static int SizeOf(const Type& type) {
@ -87,7 +87,7 @@ void Interpreter::runStatement() {
if (!b.fStatements.size()) {
break;
}
ASSERT(index < b.fStatements.size());
SkASSERT(index < b.fStatements.size());
if (index < b.fStatements.size() - 1) {
fCurrentIndex.push_back({ &b, index + 1 });
}
@ -95,18 +95,18 @@ void Interpreter::runStatement() {
break;
}
case Statement::kBreak_Kind:
ASSERT(index == 0);
SkASSERT(index == 0);
abort();
case Statement::kContinue_Kind:
ASSERT(index == 0);
SkASSERT(index == 0);
abort();
case Statement::kDiscard_Kind:
ASSERT(index == 0);
SkASSERT(index == 0);
abort();
case Statement::kDo_Kind:
abort();
case Statement::kExpression_Kind:
ASSERT(index == 0);
SkASSERT(index == 0);
this->evaluate(*((const ExpressionStatement&) stmt).fExpression);
break;
case Statement::kFor_Kind: {
@ -136,7 +136,7 @@ void Interpreter::runStatement() {
fCurrentIndex.push_back({ &f, 1 });
break;
default:
ASSERT(false);
SkASSERT(false);
}
break;
}
@ -152,15 +152,15 @@ void Interpreter::runStatement() {
break;
}
case Statement::kNop_Kind:
ASSERT(index == 0);
SkASSERT(index == 0);
break;
case Statement::kReturn_Kind:
ASSERT(index == 0);
SkASSERT(index == 0);
abort();
case Statement::kSwitch_Kind:
abort();
case Statement::kVarDeclarations_Kind:
ASSERT(index == 0);
SkASSERT(index == 0);
for (const auto& decl :((const VarDeclarationsStatement&) stmt).fDeclaration->fVars) {
const Variable* var = ((VarDeclaration&) *decl).fVar;
StackIndex pos = this->stackAlloc(SizeOf(var->fType));
@ -197,8 +197,8 @@ Interpreter::StackIndex Interpreter::getLValue(const Expression& expr) {
case Expression::kSwizzle_Kind:
break;
case Expression::kVariableReference_Kind:
ASSERT(fVars.size());
ASSERT(fVars.back().find(&((VariableReference&) expr).fVariable) !=
SkASSERT(fVars.size());
SkASSERT(fVars.back().find(&((VariableReference&) expr).fVariable) !=
fVars.back().end());
return fVars.back()[&((VariableReference&) expr).fVariable];
case Expression::kTernary_Kind: {
@ -234,13 +234,13 @@ static void do_callback(SkJumper_CallbackCtx* raw, int activePixels) {
void Interpreter::appendStage(const AppendStage& a) {
switch (a.fStage) {
case SkRasterPipeline::matrix_4x5: {
ASSERT(a.fArguments.size() == 1);
SkASSERT(a.fArguments.size() == 1);
StackIndex transpose = evaluate(*a.fArguments[0]).fInt;
fPipeline.append(SkRasterPipeline::matrix_4x5, &fStack[transpose]);
break;
}
case SkRasterPipeline::callback: {
ASSERT(a.fArguments.size() == 1);
SkASSERT(a.fArguments.size() == 1);
CallbackCtx* ctx = new CallbackCtx();
ctx->fInterpreter = this;
ctx->fn = do_callback;
@ -430,7 +430,7 @@ Interpreter::Value Interpreter::evaluate(const Expression& expr) {
if (Token::PLUSPLUS == p.fOperator) {
++fStack[lvalue].fFloat;
} else {
ASSERT(Token::MINUSMINUS == p.fOperator);
SkASSERT(Token::MINUSMINUS == p.fOperator);
--fStack[lvalue].fFloat;
}
break;
@ -438,7 +438,7 @@ Interpreter::Value Interpreter::evaluate(const Expression& expr) {
if (Token::PLUSPLUS == p.fOperator) {
++fStack[lvalue].fInt;
} else {
ASSERT(Token::MINUSMINUS == p.fOperator);
SkASSERT(Token::MINUSMINUS == p.fOperator);
--fStack[lvalue].fInt;
}
break;
@ -452,8 +452,8 @@ Interpreter::Value Interpreter::evaluate(const Expression& expr) {
case Expression::kSwizzle_Kind:
break;
case Expression::kVariableReference_Kind:
ASSERT(fVars.size());
ASSERT(fVars.back().find(&((VariableReference&) expr).fVariable) !=
SkASSERT(fVars.size());
SkASSERT(fVars.back().find(&((VariableReference&) expr).fVariable) !=
fVars.back().end());
return fStack[fVars.back()[&((VariableReference&) expr).fVariable]];
case Expression::kTernary_Kind: {

View File

@ -64,7 +64,7 @@ JIT::JIT(Compiler* compiler)
LLVMInitializeNativeTarget();
LLVMInitializeNativeAsmPrinter();
LLVMLinkInMCJIT();
ASSERT(!SkCpu::Supports(SkCpu::SKX)); // not yet supported
SkASSERT(!SkCpu::Supports(SkCpu::SKX)); // not yet supported
if (SkCpu::Supports(SkCpu::HSW)) {
fVectorCount = 8;
fCPU = "haswell";
@ -144,13 +144,13 @@ uint64_t JIT::resolveSymbol(const char* name, JIT* jit) {
result = llvm::RTDyldMemoryManager::getSymbolAddressInProcess(name);
}
}
ASSERT(result);
SkASSERT(result);
return result;
}
LLVMValueRef JIT::compileFunctionCall(LLVMBuilderRef builder, const FunctionCall& fc) {
LLVMValueRef func = fFunctions[&fc.fFunction];
ASSERT(func);
SkASSERT(func);
std::vector<LLVMValueRef> parameters;
for (const auto& a : fc.fArguments) {
parameters.push_back(this->compileExpression(builder, *a));
@ -164,7 +164,7 @@ LLVMTypeRef JIT::getType(const Type& type) {
if (type.name() == "void") {
return fVoidType;
}
ASSERT(type.name() == "SkRasterPipeline");
SkASSERT(type.name() == "SkRasterPipeline");
return fInt8PtrType;
case Type::kScalar_Kind:
if (type.isSigned() || type.isUnsigned()) {
@ -176,7 +176,7 @@ LLVMTypeRef JIT::getType(const Type& type) {
if (type.isFloat()) {
return fFloat32Type;
}
ASSERT(type.name() == "bool");
SkASSERT(type.name() == "bool");
return fInt1Type;
case Type::kArray_Kind:
return LLVMPointerType(this->getType(type.componentType()), 0);
@ -348,7 +348,7 @@ std::unique_ptr<JIT::LValue> JIT::getLValue(LLVMBuilderRef builder, const Expres
}
return result;
}
ASSERT(fComponents.size() == 1);
SkASSERT(fComponents.size() == 1);
return LLVMBuildExtractElement(builder, base,
LLVMConstInt(fJIT.fInt32Type,
fComponents[0],
@ -691,14 +691,14 @@ LLVMValueRef JIT::compileVariableReference(LLVMBuilderRef builder, const Variabl
}
void JIT::appendStage(LLVMBuilderRef builder, const AppendStage& a) {
ASSERT(a.fArguments.size() >= 1);
ASSERT(a.fArguments[0]->fType == *fCompiler.context().fSkRasterPipeline_Type);
SkASSERT(a.fArguments.size() >= 1);
SkASSERT(a.fArguments[0]->fType == *fCompiler.context().fSkRasterPipeline_Type);
LLVMValueRef pipeline = this->compileExpression(builder, *a.fArguments[0]);
LLVMValueRef stage = LLVMConstInt(fInt32Type, a.fStage, 0);
switch (a.fStage) {
case SkRasterPipeline::callback: {
ASSERT(a.fArguments.size() == 2);
ASSERT(a.fArguments[1]->fKind == Expression::kFunctionReference_Kind);
SkASSERT(a.fArguments.size() == 2);
SkASSERT(a.fArguments[1]->fKind == Expression::kFunctionReference_Kind);
const FunctionDeclaration& functionDecl =
*((FunctionReference&) *a.fArguments[1]).fFunctions[0];
bool found = false;
@ -717,7 +717,7 @@ void JIT::appendStage(LLVMBuilderRef builder, const AppendStage& a) {
}
}
}
ASSERT(found);
SkASSERT(found);
break;
}
default: {
@ -726,7 +726,7 @@ void JIT::appendStage(LLVMBuilderRef builder, const AppendStage& a) {
ctx = this->compileExpression(builder, *a.fArguments[1]);
ctx = LLVMBuildBitCast(builder, ctx, fInt8PtrType, "context cast");
} else {
ASSERT(a.fArguments.size() == 1);
SkASSERT(a.fArguments.size() == 1);
ctx = LLVMConstNull(fInt8PtrType);
}
LLVMValueRef args[3] = {
@ -743,7 +743,7 @@ void JIT::appendStage(LLVMBuilderRef builder, const AppendStage& a) {
LLVMValueRef JIT::compileConstructor(LLVMBuilderRef builder, const Constructor& c) {
switch (c.fType.kind()) {
case Type::kScalar_Kind: {
ASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments.size() == 1);
TypeKind from = this->typeKind(c.fArguments[0]->fType);
TypeKind to = this->typeKind(c.fType);
LLVMValueRef base = this->compileExpression(builder, *c.fArguments[0]);
@ -783,7 +783,7 @@ LLVMValueRef JIT::compileConstructor(LLVMBuilderRef builder, const Constructor&
"vec build");
}
} else {
ASSERT(c.fArguments.size() == (size_t) c.fType.columns());
SkASSERT(c.fArguments.size() == (size_t) c.fType.columns());
for (int i = 0; i < c.fType.columns(); ++i) {
vec = LLVMBuildInsertElement(builder, vec,
this->compileExpression(builder,
@ -818,7 +818,7 @@ LLVMValueRef JIT::compileSwizzle(LLVMBuilderRef builder, const Swizzle& s) {
}
return result;
}
ASSERT(s.fComponents.size() == 1);
SkASSERT(s.fComponents.size() == 1);
return LLVMBuildExtractElement(builder, base,
LLVMConstInt(fInt32Type,
s.fComponents[0],
@ -1292,7 +1292,7 @@ bool JIT::compileVectorBinary(LLVMBuilderRef builder, const BinaryExpression& b,
out[i] = floatOp(builder, left[i], right[i], "binary"); \
break; \
case kBool_TypeKind: \
ASSERT(false); \
SkASSERT(false); \
break; \
} \
} \
@ -1336,7 +1336,7 @@ bool JIT::compileVectorConstructor(LLVMBuilderRef builder, const Constructor& c,
LLVMValueRef out[CHANNELS]) {
switch (c.fType.kind()) {
case Type::kScalar_Kind: {
ASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments.size() == 1);
TypeKind from = this->typeKind(c.fArguments[0]->fType);
TypeKind to = this->typeKind(c.fType);
LLVMValueRef base[CHANNELS];
@ -1392,7 +1392,7 @@ bool JIT::compileVectorConstructor(LLVMBuilderRef builder, const Constructor& c,
out[i] = base[0];
}
} else {
ASSERT(c.fArguments.size() == (size_t) c.fType.columns());
SkASSERT(c.fArguments.size() == (size_t) c.fType.columns());
for (int i = 0; i < c.fType.columns(); ++i) {
LLVMValueRef base[CHANNELS];
if (!this->compileVectorExpression(builder, *c.fArguments[i], base)) {
@ -1657,7 +1657,7 @@ void JIT::createModule() {
false));
for (const auto& e : fProgram->fElements) {
ASSERT(e->fKind == ProgramElement::kFunction_Kind);
SkASSERT(e->fKind == ProgramElement::kFunction_Kind);
this->compileFunction((FunctionDefinition&) *e);
}
}

View File

@ -107,11 +107,11 @@ public:
if (total % alignment != 0) {
total += alignment - total % alignment;
}
ASSERT(total % alignment == 0);
SkASSERT(total % alignment == 0);
total += this->size(*f.fType);
}
size_t alignment = this->alignment(type);
ASSERT(!type.fields().size() ||
SkASSERT(!type.fields().size() ||
(0 == alignment % this->alignment(*type.fields()[0].fType)));
return (total + alignment - 1) & ~(alignment - 1);
}

View File

@ -163,7 +163,7 @@ void MetalCodeGenerator::writeExpression(const Expression& expr, Precedence pare
void MetalCodeGenerator::writeIntrinsicCall(const FunctionCall& c) {
auto i = fIntrinsicMap.find(c.fFunction.fName);
ASSERT(i != fIntrinsicMap.end());
SkASSERT(i != fIntrinsicMap.end());
Intrinsic intrinsic = i->second;
int32_t intrinsicId = intrinsic.second;
switch (intrinsic.first) {
@ -257,7 +257,7 @@ void MetalCodeGenerator::writeSpecialIntrinsic(const FunctionCall & c, SpecialIn
if (c.fArguments[1]->fType == *fContext.fFloat3_Type) {
this->write(".xy)"); // FIXME - add projection functionality
} else {
ASSERT(c.fArguments[1]->fType == *fContext.fFloat2_Type);
SkASSERT(c.fArguments[1]->fType == *fContext.fFloat2_Type);
this->write(")");
}
break;
@ -443,7 +443,7 @@ void MetalCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
this->writeExpression(*b.fLeft, kAssignment_Precedence);
this->write(" ");
String op = Compiler::OperatorName(b.fOperator);
ASSERT(op.endsWith("="));
SkASSERT(op.endsWith("="));
this->write(op.substr(0, op.size() - 1).c_str());
this->write(" ");
} else {
@ -525,7 +525,7 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
this->write("vertex Outputs main0");
break;
default:
ASSERT(false);
SkASSERT(false);
}
this->write("(Inputs _in [[stage_in]]");
if (-1 != fUniformBuffer) {
@ -627,7 +627,7 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
}
this->writeLine(") {");
ASSERT(!fProgram.fSettings.fFragColorIsInOut);
SkASSERT(!fProgram.fSettings.fFragColorIsInOut);
if ("main" == f.fDeclaration.fName) {
if (fNeedsGlobalStructInit) {
@ -682,7 +682,7 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
this->writeLine("return *_out;"); // FIXME - detect if function already has return
break;
default:
ASSERT(false);
SkASSERT(false);
}
}
fIndentation--;
@ -793,7 +793,7 @@ void MetalCodeGenerator::writeName(const String& name) {
}
void MetalCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, bool global) {
ASSERT(decl.fVars.size() > 0);
SkASSERT(decl.fVars.size() > 0);
bool wroteType = false;
for (const auto& stmt : decl.fVars) {
VarDeclaration& var = (VarDeclaration&) *stmt;

View File

@ -133,7 +133,7 @@ Token Parser::nextToken() {
}
void Parser::pushback(Token t) {
ASSERT(fPushback.fKind == Token::INVALID);
SkASSERT(fPushback.fKind == Token::INVALID);
fPushback = std::move(t);
}
@ -1198,7 +1198,7 @@ std::unique_ptr<ASTStatement> Parser::switchStatement() {
// parts of the compiler may rely upon this assumption.
if (this->peek().fKind == Token::DEFAULT) {
Token defaultStart;
ASSERT_RESULT(this->expect(Token::DEFAULT, "'default'", &defaultStart));
SkAssertResult(this->expect(Token::DEFAULT, "'default'", &defaultStart));
if (!this->expect(Token::COLON, "':'")) {
return nullptr;
}

View File

@ -177,15 +177,15 @@ static bool is_out(const Variable& var) {
}
void SPIRVCodeGenerator::writeOpCode(SpvOp_ opCode, int length, OutputStream& out) {
ASSERT(opCode != SpvOpLoad || &out != &fConstantBuffer);
ASSERT(opCode != SpvOpUndef);
SkASSERT(opCode != SpvOpLoad || &out != &fConstantBuffer);
SkASSERT(opCode != SpvOpUndef);
switch (opCode) {
case SpvOpReturn: // fall through
case SpvOpReturnValue: // fall through
case SpvOpKill: // fall through
case SpvOpBranch: // fall through
case SpvOpBranchConditional:
ASSERT(fCurrentBlock);
SkASSERT(fCurrentBlock);
fCurrentBlock = 0;
break;
case SpvOpConstant: // fall through
@ -222,7 +222,7 @@ void SPIRVCodeGenerator::writeOpCode(SpvOp_ opCode, int length, OutputStream& ou
case SpvOpMemberDecorate:
break;
default:
ASSERT(fCurrentBlock);
SkASSERT(fCurrentBlock);
}
this->writeWord((length << 16) | opCode, out);
}
@ -474,7 +474,7 @@ SpvId SPIRVCodeGenerator::getType(const Type& rawType, const MemoryLayout& layou
} else if (type == *fContext.fDouble_Type) {
this->writeInstruction(SpvOpTypeFloat, result, 64, fConstantBuffer);
} else {
ASSERT(false);
SkASSERT(false);
}
break;
case Type::kVector_Kind:
@ -500,7 +500,7 @@ SpvId SPIRVCodeGenerator::getType(const Type& rawType, const MemoryLayout& layou
(int32_t) layout.stride(type),
fDecorationBuffer);
} else {
ASSERT(false); // we shouldn't have any runtime-sized arrays right now
SkASSERT(false); // we shouldn't have any runtime-sized arrays right now
this->writeInstruction(SpvOpTypeRuntimeArray, result,
this->getType(type.componentType(), layout),
fConstantBuffer);
@ -543,10 +543,10 @@ SpvId SPIRVCodeGenerator::getType(const Type& rawType, const MemoryLayout& layou
}
SpvId SPIRVCodeGenerator::getImageType(const Type& type) {
ASSERT(type.kind() == Type::kSampler_Kind);
SkASSERT(type.kind() == Type::kSampler_Kind);
this->getType(type);
String key = type.name() + to_string((int) fDefaultLayout.fStd);
ASSERT(fImageTypeMap.find(key) != fImageTypeMap.end());
SkASSERT(fImageTypeMap.find(key) != fImageTypeMap.end());
return fImageTypeMap[key];
}
@ -662,7 +662,7 @@ SpvId SPIRVCodeGenerator::writeExpression(const Expression& expr, OutputStream&
SpvId SPIRVCodeGenerator::writeIntrinsicCall(const FunctionCall& c, OutputStream& out) {
auto intrinsic = fIntrinsicMap.find(c.fFunction.fName);
ASSERT(intrinsic != fIntrinsicMap.end());
SkASSERT(intrinsic != fIntrinsicMap.end());
int32_t intrinsicId;
if (c.fArguments.size() > 0) {
const Type& type = c.fArguments[0]->fType;
@ -737,7 +737,7 @@ std::vector<SpvId> SPIRVCodeGenerator::vectorize(
for (const auto& a : args) {
if (a->fType.kind() == Type::kVector_Kind) {
if (vectorSize) {
ASSERT(a->fType.columns() == vectorSize);
SkASSERT(a->fType.columns() == vectorSize);
}
else {
vectorSize = a->fType.columns();
@ -779,7 +779,7 @@ void SPIRVCodeGenerator::writeGLSLExtendedInstruction(const Type& type, SpvId id
} else if (is_unsigned(fContext, type)) {
this->writeWord(unsignedInst, out);
} else {
ASSERT(false);
SkASSERT(false);
}
for (SpvId a : args) {
this->writeWord(a, out);
@ -820,7 +820,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
coords,
out);
} else {
ASSERT(2 == c.fArguments.size());
SkASSERT(2 == c.fArguments.size());
SpvId sample = this->writeExpression(*c.fArguments[1], out);
this->writeInstruction(SpvOpImageRead,
this->getType(c.fType),
@ -834,7 +834,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
break;
}
case kTexelFetch_SpecialIntrinsic: {
ASSERT(c.fArguments.size() == 2);
SkASSERT(c.fArguments.size() == 2);
SpvId image = this->nextId();
this->writeInstruction(SpvOpImage,
this->getImageType(c.fArguments[0]->fType),
@ -856,21 +856,21 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
if (c.fArguments[1]->fType == *fContext.fFloat2_Type) {
op = SpvOpImageSampleProjImplicitLod;
} else {
ASSERT(c.fArguments[1]->fType == *fContext.fFloat_Type);
SkASSERT(c.fArguments[1]->fType == *fContext.fFloat_Type);
}
break;
case SpvDim2D:
if (c.fArguments[1]->fType == *fContext.fFloat3_Type) {
op = SpvOpImageSampleProjImplicitLod;
} else {
ASSERT(c.fArguments[1]->fType == *fContext.fFloat2_Type);
SkASSERT(c.fArguments[1]->fType == *fContext.fFloat2_Type);
}
break;
case SpvDim3D:
if (c.fArguments[1]->fType == *fContext.fFloat4_Type) {
op = SpvOpImageSampleProjImplicitLod;
} else {
ASSERT(c.fArguments[1]->fType == *fContext.fFloat3_Type);
SkASSERT(c.fArguments[1]->fType == *fContext.fFloat3_Type);
}
break;
case SpvDimCube: // fall through
@ -888,7 +888,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
this->writeExpression(*c.fArguments[2], out),
out);
} else {
ASSERT(c.fArguments.size() == 2);
SkASSERT(c.fArguments.size() == 2);
if (fProgram.fSettings.fSharpenTextures) {
FloatLiteral lodBias(fContext, -1, -0.5);
this->writeInstruction(op, type, result, sampler, uv,
@ -904,7 +904,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
}
case kMod_SpecialIntrinsic: {
std::vector<SpvId> args = this->vectorize(c.fArguments, out);
ASSERT(args.size() == 2);
SkASSERT(args.size() == 2);
const Type& operandType = c.fArguments[0]->fType;
SpvOp_ op;
if (is_float(fContext, operandType)) {
@ -914,7 +914,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
} else if (is_unsigned(fContext, operandType)) {
op = SpvOpUMod;
} else {
ASSERT(false);
SkASSERT(false);
return 0;
}
this->writeOpCode(op, 5, out);
@ -926,28 +926,28 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
}
case kClamp_SpecialIntrinsic: {
std::vector<SpvId> args = this->vectorize(c.fArguments, out);
ASSERT(args.size() == 3);
SkASSERT(args.size() == 3);
this->writeGLSLExtendedInstruction(c.fType, result, GLSLstd450FClamp, GLSLstd450SClamp,
GLSLstd450UClamp, args, out);
break;
}
case kMax_SpecialIntrinsic: {
std::vector<SpvId> args = this->vectorize(c.fArguments, out);
ASSERT(args.size() == 2);
SkASSERT(args.size() == 2);
this->writeGLSLExtendedInstruction(c.fType, result, GLSLstd450FMax, GLSLstd450SMax,
GLSLstd450UMax, args, out);
break;
}
case kMin_SpecialIntrinsic: {
std::vector<SpvId> args = this->vectorize(c.fArguments, out);
ASSERT(args.size() == 2);
SkASSERT(args.size() == 2);
this->writeGLSLExtendedInstruction(c.fType, result, GLSLstd450FMin, GLSLstd450SMin,
GLSLstd450UMin, args, out);
break;
}
case kMix_SpecialIntrinsic: {
std::vector<SpvId> args = this->vectorize(c.fArguments, out);
ASSERT(args.size() == 3);
SkASSERT(args.size() == 3);
this->writeGLSLExtendedInstruction(c.fType, result, GLSLstd450FMix, SpvOpUndef,
SpvOpUndef, args, out);
break;
@ -1018,7 +1018,7 @@ SpvId SPIRVCodeGenerator::writeFunctionCall(const FunctionCall& c, OutputStream&
}
SpvId SPIRVCodeGenerator::writeConstantVector(const Constructor& c) {
ASSERT(c.fType.kind() == Type::kVector_Kind && c.isConstant());
SkASSERT(c.fType.kind() == Type::kVector_Kind && c.isConstant());
SpvId result = this->nextId();
std::vector<SpvId> arguments;
for (size_t i = 0; i < c.fArguments.size(); i++) {
@ -1046,16 +1046,16 @@ SpvId SPIRVCodeGenerator::writeConstantVector(const Constructor& c) {
}
SpvId SPIRVCodeGenerator::writeFloatConstructor(const Constructor& c, OutputStream& out) {
ASSERT(c.fType.isFloat());
ASSERT(c.fArguments.size() == 1);
ASSERT(c.fArguments[0]->fType.isNumber());
SkASSERT(c.fType.isFloat());
SkASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments[0]->fType.isNumber());
SpvId result = this->nextId();
SpvId parameter = this->writeExpression(*c.fArguments[0], out);
if (c.fArguments[0]->fType.isSigned()) {
this->writeInstruction(SpvOpConvertSToF, this->getType(c.fType), result, parameter,
out);
} else {
ASSERT(c.fArguments[0]->fType.isUnsigned());
SkASSERT(c.fArguments[0]->fType.isUnsigned());
this->writeInstruction(SpvOpConvertUToF, this->getType(c.fType), result, parameter,
out);
}
@ -1063,9 +1063,9 @@ SpvId SPIRVCodeGenerator::writeFloatConstructor(const Constructor& c, OutputStre
}
SpvId SPIRVCodeGenerator::writeIntConstructor(const Constructor& c, OutputStream& out) {
ASSERT(c.fType.isSigned());
ASSERT(c.fArguments.size() == 1);
ASSERT(c.fArguments[0]->fType.isNumber());
SkASSERT(c.fType.isSigned());
SkASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments[0]->fType.isNumber());
SpvId result = this->nextId();
SpvId parameter = this->writeExpression(*c.fArguments[0], out);
if (c.fArguments[0]->fType.isFloat()) {
@ -1073,7 +1073,7 @@ SpvId SPIRVCodeGenerator::writeIntConstructor(const Constructor& c, OutputStream
out);
}
else {
ASSERT(c.fArguments[0]->fType.isUnsigned());
SkASSERT(c.fArguments[0]->fType.isUnsigned());
this->writeInstruction(SpvOpBitcast, this->getType(c.fType), result, parameter,
out);
}
@ -1081,16 +1081,16 @@ SpvId SPIRVCodeGenerator::writeIntConstructor(const Constructor& c, OutputStream
}
SpvId SPIRVCodeGenerator::writeUIntConstructor(const Constructor& c, OutputStream& out) {
ASSERT(c.fType.isUnsigned());
ASSERT(c.fArguments.size() == 1);
ASSERT(c.fArguments[0]->fType.isNumber());
SkASSERT(c.fType.isUnsigned());
SkASSERT(c.fArguments.size() == 1);
SkASSERT(c.fArguments[0]->fType.isNumber());
SpvId result = this->nextId();
SpvId parameter = this->writeExpression(*c.fArguments[0], out);
if (c.fArguments[0]->fType.isFloat()) {
this->writeInstruction(SpvOpConvertFToU, this->getType(c.fType), result, parameter,
out);
} else {
ASSERT(c.fArguments[0]->fType.isSigned());
SkASSERT(c.fArguments[0]->fType.isSigned());
this->writeInstruction(SpvOpBitcast, this->getType(c.fType), result, parameter,
out);
}
@ -1125,9 +1125,9 @@ void SPIRVCodeGenerator::writeUniformScaleMatrix(SpvId id, SpvId diagonal, const
void SPIRVCodeGenerator::writeMatrixCopy(SpvId id, SpvId src, const Type& srcType,
const Type& dstType, OutputStream& out) {
ASSERT(srcType.kind() == Type::kMatrix_Kind);
ASSERT(dstType.kind() == Type::kMatrix_Kind);
ASSERT(srcType.componentType() == dstType.componentType());
SkASSERT(srcType.kind() == Type::kMatrix_Kind);
SkASSERT(dstType.kind() == Type::kMatrix_Kind);
SkASSERT(srcType.componentType() == dstType.componentType());
SpvId srcColumnType = this->getType(srcType.componentType().toCompound(fContext,
srcType.rows(),
1));
@ -1205,7 +1205,7 @@ void SPIRVCodeGenerator::writeMatrixCopy(SpvId id, SpvId src, const Type& srcTyp
}
SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, OutputStream& out) {
ASSERT(c.fType.kind() == Type::kMatrix_Kind);
SkASSERT(c.fType.kind() == Type::kMatrix_Kind);
// go ahead and write the arguments so we don't try to write new instructions in the middle of
// an instruction
std::vector<SpvId> arguments;
@ -1220,8 +1220,8 @@ SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, OutputStr
} else if (arguments.size() == 1 && c.fArguments[0]->fType.kind() == Type::kMatrix_Kind) {
this->writeMatrixCopy(result, arguments[0], c.fArguments[0]->fType, c.fType, out);
} else if (arguments.size() == 1 && c.fArguments[0]->fType.kind() == Type::kVector_Kind) {
ASSERT(c.fType.rows() == 2 && c.fType.columns() == 2);
ASSERT(c.fArguments[0]->fType.columns() == 4);
SkASSERT(c.fType.rows() == 2 && c.fType.columns() == 2);
SkASSERT(c.fArguments[0]->fType.columns() == 4);
SpvId componentType = this->getType(c.fType.componentType());
SpvId v[4];
for (int i = 0; i < 4; ++i) {
@ -1245,7 +1245,7 @@ SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, OutputStr
if (c.fArguments[i]->fType.kind() == Type::kVector_Kind &&
c.fArguments[i]->fType.columns() == c.fType.rows()) {
// this is a complete column by itself
ASSERT(currentCount == 0);
SkASSERT(currentCount == 0);
columnIds.push_back(arguments[i]);
} else {
if (c.fArguments[i]->fType.columns() == 1) {
@ -1274,10 +1274,10 @@ SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, OutputStr
}
currentColumn.clear();
}
ASSERT(currentCount < rows);
SkASSERT(currentCount < rows);
}
}
ASSERT(columnIds.size() == (size_t) columns);
SkASSERT(columnIds.size() == (size_t) columns);
this->writeOpCode(SpvOpCompositeConstruct, 3 + columns, out);
this->writeWord(this->getType(c.fType), out);
this->writeWord(result, out);
@ -1289,7 +1289,7 @@ SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, OutputStr
}
SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStream& out) {
ASSERT(c.fType.kind() == Type::kVector_Kind);
SkASSERT(c.fType.kind() == Type::kVector_Kind);
if (c.isConstant()) {
return this->writeConstantVector(c);
}
@ -1317,7 +1317,7 @@ SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStr
} else if (src == *fContext.fUInt_Type || src == *fContext.fUShort_Type) {
op = SpvOpConvertUToF;
} else {
ASSERT(false);
SkASSERT(false);
}
} else if (dst == *fContext.fInt_Type || dst == *fContext.fShort_Type) {
if (src == *fContext.fFloat_Type || src == *fContext.fHalf_Type) {
@ -1329,7 +1329,7 @@ SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStr
} else if (src == *fContext.fUInt_Type || src == *fContext.fUShort_Type) {
op = SpvOpBitcast;
} else {
ASSERT(false);
SkASSERT(false);
}
} else if (dst == *fContext.fUInt_Type || dst == *fContext.fUShort_Type) {
if (src == *fContext.fFloat_Type || src == *fContext.fHalf_Type) {
@ -1341,7 +1341,7 @@ SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStr
return vec;
}
} else {
ASSERT(false);
SkASSERT(false);
}
}
for (int j = 0; j < c.fArguments[i]->fType.columns(); j++) {
@ -1369,7 +1369,7 @@ SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStr
this->writeWord(arguments[0], out);
}
} else {
ASSERT(arguments.size() > 1);
SkASSERT(arguments.size() > 1);
this->writeOpCode(SpvOpCompositeConstruct, 3 + (int32_t) arguments.size(), out);
this->writeWord(this->getType(c.fType), out);
this->writeWord(result, out);
@ -1381,7 +1381,7 @@ SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStr
}
SpvId SPIRVCodeGenerator::writeArrayConstructor(const Constructor& c, OutputStream& out) {
ASSERT(c.fType.kind() == Type::kArray_Kind);
SkASSERT(c.fType.kind() == Type::kArray_Kind);
// go ahead and write the arguments so we don't try to write new instructions in the middle of
// an instruction
std::vector<SpvId> arguments;
@ -1424,10 +1424,10 @@ SpvId SPIRVCodeGenerator::writeConstructor(const Constructor& c, OutputStream& o
SpvStorageClass_ get_storage_class(const Modifiers& modifiers) {
if (modifiers.fFlags & Modifiers::kIn_Flag) {
ASSERT(!(modifiers.fLayout.fFlags & Layout::kPushConstant_Flag));
SkASSERT(!(modifiers.fLayout.fFlags & Layout::kPushConstant_Flag));
return SpvStorageClassInput;
} else if (modifiers.fFlags & Modifiers::kOut_Flag) {
ASSERT(!(modifiers.fLayout.fFlags & Layout::kPushConstant_Flag));
SkASSERT(!(modifiers.fLayout.fFlags & Layout::kPushConstant_Flag));
return SpvStorageClassOutput;
} else if (modifiers.fFlags & Modifiers::kUniform_Flag) {
if (modifiers.fLayout.fFlags & Layout::kPushConstant_Flag) {
@ -1598,7 +1598,7 @@ std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const
type = this->getType(expr.fType);
}
auto entry = fVariableMap.find(&var);
ASSERT(entry != fVariableMap.end());
SkASSERT(entry != fVariableMap.end());
return std::unique_ptr<SPIRVCodeGenerator::LValue>(new PointerLValue(*this,
entry->second,
type));
@ -1622,7 +1622,7 @@ std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const
Swizzle& swizzle = (Swizzle&) expr;
size_t count = swizzle.fComponents.size();
SpvId base = this->getLValue(*swizzle.fBase, out)->getPointer();
ASSERT(base);
SkASSERT(base);
if (count == 1) {
IntLiteral index(fContext, -1, swizzle.fComponents[0]);
SpvId member = this->nextId();
@ -1656,11 +1656,11 @@ std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const
this->writeInstruction(SpvOpBranchConditional, test, ifTrueLabel, ifFalseLabel, out);
this->writeLabel(ifTrueLabel, out);
SpvId ifTrue = this->getLValue(*t.fIfTrue, out)->getPointer();
ASSERT(ifTrue);
SkASSERT(ifTrue);
this->writeInstruction(SpvOpBranch, end, out);
ifTrueLabel = fCurrentBlock;
SpvId ifFalse = this->getLValue(*t.fIfFalse, out)->getPointer();
ASSERT(ifFalse);
SkASSERT(ifFalse);
ifFalseLabel = fCurrentBlock;
this->writeInstruction(SpvOpBranch, end, out);
SpvId result = this->nextId();
@ -1691,7 +1691,7 @@ std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const
SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, OutputStream& out) {
SpvId result = this->nextId();
auto entry = fVariableMap.find(&ref.fVariable);
ASSERT(entry != fVariableMap.end());
SkASSERT(entry != fVariableMap.end());
SpvId var = entry->second;
this->writeInstruction(SpvOpLoad, this->getType(ref.fVariable.fType), result, var, out);
if (ref.fVariable.fModifiers.fLayout.fBuiltin == SK_FRAGCOORD_BUILTIN &&
@ -1700,7 +1700,7 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
if (fRTHeightStructId == (SpvId) -1) {
// height variable hasn't been written yet
std::shared_ptr<SymbolTable> st(new SymbolTable(&fErrors));
ASSERT(fRTHeightFieldIndex == (SpvId) -1);
SkASSERT(fRTHeightFieldIndex == (SpvId) -1);
std::vector<Type::Field> fields;
fields.emplace_back(Modifiers(), SKSL_RTHEIGHT_NAME, fContext.fFloat_Type.get());
StringFragment name("sksl_synthetic_uniforms");
@ -1719,7 +1719,7 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
fRTHeightStructId = this->writeInterfaceBlock(intf);
fRTHeightFieldIndex = 0;
}
ASSERT(fRTHeightFieldIndex != (SpvId) -1);
SkASSERT(fRTHeightFieldIndex != (SpvId) -1);
// write float4(gl_FragCoord.x, u_skRTHeight - gl_FragCoord.y, 0.0, 1.0)
SpvId xId = this->nextId();
this->writeInstruction(SpvOpCompositeExtract, this->getType(*fContext.fFloat_Type), xId,
@ -1841,7 +1841,7 @@ SpvId SPIRVCodeGenerator::writeMatrixComparison(const Type& operandType, SpvId l
SpvOp_ floatOperator, SpvOp_ intOperator,
OutputStream& out) {
SpvOp_ compareOp = is_float(fContext, operandType) ? floatOperator : intOperator;
ASSERT(operandType.kind() == Type::kMatrix_Kind);
SkASSERT(operandType.kind() == Type::kMatrix_Kind);
SpvId rowType = this->getType(operandType.componentType().toCompound(fContext,
operandType.columns(),
1));
@ -1933,7 +1933,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
this->writeWord(lhs, out);
}
lhs = vec;
ASSERT(!lvalue);
SkASSERT(!lvalue);
operandType = &b.fRight->fType;
} else if (b.fLeft->fType.kind() == Type::kMatrix_Kind) {
SpvOp_ op;
@ -1942,7 +1942,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
} else if (b.fRight->fType.kind() == Type::kVector_Kind) {
op = SpvOpMatrixTimesVector;
} else {
ASSERT(b.fRight->fType.kind() == Type::kScalar_Kind);
SkASSERT(b.fRight->fType.kind() == Type::kScalar_Kind);
op = SpvOpMatrixTimesScalar;
}
SpvId result = this->nextId();
@ -1950,7 +1950,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
if (b.fOperator == Token::STAREQ) {
lvalue->store(result, out);
} else {
ASSERT(b.fOperator == Token::STAR);
SkASSERT(b.fOperator == Token::STAR);
}
return result;
} else if (b.fRight->fType.kind() == Type::kMatrix_Kind) {
@ -1959,14 +1959,14 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
this->writeInstruction(SpvOpVectorTimesMatrix, this->getType(b.fType), result,
lhs, rhs, out);
} else {
ASSERT(b.fLeft->fType.kind() == Type::kScalar_Kind);
SkASSERT(b.fLeft->fType.kind() == Type::kScalar_Kind);
this->writeInstruction(SpvOpMatrixTimesScalar, this->getType(b.fType), result, rhs,
lhs, out);
}
if (b.fOperator == Token::STAREQ) {
lvalue->store(result, out);
} else {
ASSERT(b.fOperator == Token::STAR);
SkASSERT(b.fOperator == Token::STAR);
}
return result;
} else {
@ -1975,7 +1975,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
} else {
tmp = this->getActualType(b.fLeft->fType);
operandType = &tmp;
ASSERT(*operandType == this->getActualType(b.fRight->fType));
SkASSERT(*operandType == this->getActualType(b.fRight->fType));
}
switch (b.fOperator) {
case Token::EQEQ: {
@ -1983,7 +1983,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
return this->writeMatrixComparison(*operandType, lhs, rhs, SpvOpFOrdEqual,
SpvOpIEqual, out);
}
ASSERT(resultType == *fContext.fBool_Type);
SkASSERT(resultType == *fContext.fBool_Type);
const Type* tmpType;
if (operandType->kind() == Type::kVector_Kind) {
tmpType = &fContext.fBool_Type->toCompound(fContext,
@ -2002,7 +2002,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
return this->writeMatrixComparison(*operandType, lhs, rhs, SpvOpFOrdNotEqual,
SpvOpINotEqual, out);
}
ASSERT(resultType == *fContext.fBool_Type);
SkASSERT(resultType == *fContext.fBool_Type);
const Type* tmpType;
if (operandType->kind() == Type::kVector_Kind) {
tmpType = &fContext.fBool_Type->toCompound(fContext,
@ -2017,21 +2017,21 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
out),
*operandType, SpvOpAny, out);
case Token::GT:
ASSERT(resultType == *fContext.fBool_Type);
SkASSERT(resultType == *fContext.fBool_Type);
return this->writeBinaryOperation(resultType, *operandType, lhs, rhs,
SpvOpFOrdGreaterThan, SpvOpSGreaterThan,
SpvOpUGreaterThan, SpvOpUndef, out);
case Token::LT:
ASSERT(resultType == *fContext.fBool_Type);
SkASSERT(resultType == *fContext.fBool_Type);
return this->writeBinaryOperation(resultType, *operandType, lhs, rhs, SpvOpFOrdLessThan,
SpvOpSLessThan, SpvOpULessThan, SpvOpUndef, out);
case Token::GTEQ:
ASSERT(resultType == *fContext.fBool_Type);
SkASSERT(resultType == *fContext.fBool_Type);
return this->writeBinaryOperation(resultType, *operandType, lhs, rhs,
SpvOpFOrdGreaterThanEqual, SpvOpSGreaterThanEqual,
SpvOpUGreaterThanEqual, SpvOpUndef, out);
case Token::LTEQ:
ASSERT(resultType == *fContext.fBool_Type);
SkASSERT(resultType == *fContext.fBool_Type);
return this->writeBinaryOperation(resultType, *operandType, lhs, rhs,
SpvOpFOrdLessThanEqual, SpvOpSLessThanEqual,
SpvOpULessThanEqual, SpvOpUndef, out);
@ -2078,14 +2078,14 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
case Token::PLUSEQ: {
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs, SpvOpFAdd,
SpvOpIAdd, SpvOpIAdd, SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
case Token::MINUSEQ: {
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs, SpvOpFSub,
SpvOpISub, SpvOpISub, SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
@ -2096,27 +2096,27 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
SpvId result = this->nextId();
this->writeInstruction(SpvOpMatrixTimesMatrix, this->getType(resultType), result,
lhs, rhs, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs, SpvOpFMul,
SpvOpIMul, SpvOpIMul, SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
case Token::SLASHEQ: {
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs, SpvOpFDiv,
SpvOpSDiv, SpvOpUDiv, SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
case Token::PERCENTEQ: {
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs, SpvOpFMod,
SpvOpSMod, SpvOpUMod, SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
@ -2124,7 +2124,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs,
SpvOpUndef, SpvOpShiftLeftLogical,
SpvOpShiftLeftLogical, SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
@ -2132,7 +2132,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs,
SpvOpUndef, SpvOpShiftRightArithmetic,
SpvOpShiftRightLogical, SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
@ -2140,7 +2140,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs,
SpvOpUndef, SpvOpBitwiseAnd, SpvOpBitwiseAnd,
SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
@ -2148,7 +2148,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs,
SpvOpUndef, SpvOpBitwiseOr, SpvOpBitwiseOr,
SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
@ -2156,7 +2156,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
SpvId result = this->writeBinaryOperation(resultType, *operandType, lhs, rhs,
SpvOpUndef, SpvOpBitwiseXor, SpvOpBitwiseXor,
SpvOpUndef, out);
ASSERT(lvalue);
SkASSERT(lvalue);
lvalue->store(result, out);
return result;
}
@ -2166,7 +2166,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
}
SpvId SPIRVCodeGenerator::writeLogicalAnd(const BinaryExpression& a, OutputStream& out) {
ASSERT(a.fOperator == Token::LOGICALAND);
SkASSERT(a.fOperator == Token::LOGICALAND);
BoolLiteral falseLiteral(fContext, -1, false);
SpvId falseConstant = this->writeBoolLiteral(falseLiteral);
SpvId lhs = this->writeExpression(*a.fLeft, out);
@ -2187,7 +2187,7 @@ SpvId SPIRVCodeGenerator::writeLogicalAnd(const BinaryExpression& a, OutputStrea
}
SpvId SPIRVCodeGenerator::writeLogicalOr(const BinaryExpression& o, OutputStream& out) {
ASSERT(o.fOperator == Token::LOGICALOR);
SkASSERT(o.fOperator == Token::LOGICALOR);
BoolLiteral trueLiteral(fContext, -1, true);
SpvId trueConstant = this->writeBoolLiteral(trueLiteral);
SpvId lhs = this->writeExpression(*o.fLeft, out);
@ -2287,7 +2287,7 @@ SpvId SPIRVCodeGenerator::writePrefixExpression(const PrefixExpression& p, Outpu
return result;
}
case Token::LOGICALNOT: {
ASSERT(p.fOperand->fType == *fContext.fBool_Type);
SkASSERT(p.fOperand->fType == *fContext.fBool_Type);
SpvId result = this->nextId();
this->writeInstruction(SpvOpLogicalNot, this->getType(p.fOperand->fType), result,
this->writeExpression(*p.fOperand, out), out);
@ -2356,7 +2356,7 @@ SpvId SPIRVCodeGenerator::writeIntLiteral(const IntLiteral& i) {
}
return entry->second;
} else {
ASSERT(i.fType == *fContext.fUInt_Type);
SkASSERT(i.fType == *fContext.fUInt_Type);
auto entry = fUIntConstants.find(i.fValue);
if (entry == fUIntConstants.end()) {
SpvId result = this->nextId();
@ -2376,7 +2376,7 @@ SpvId SPIRVCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
if (entry == fFloatConstants.end()) {
SpvId result = this->nextId();
uint32_t bits;
ASSERT(sizeof(bits) == sizeof(value));
SkASSERT(sizeof(bits) == sizeof(value));
memcpy(&bits, &value, sizeof(bits));
this->writeInstruction(SpvOpConstant, this->getType(f.fType), result, bits,
fConstantBuffer);
@ -2385,12 +2385,12 @@ SpvId SPIRVCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
}
return entry->second;
} else {
ASSERT(f.fType == *fContext.fDouble_Type);
SkASSERT(f.fType == *fContext.fDouble_Type);
auto entry = fDoubleConstants.find(f.fValue);
if (entry == fDoubleConstants.end()) {
SpvId result = this->nextId();
uint64_t bits;
ASSERT(sizeof(bits) == sizeof(f.fValue));
SkASSERT(sizeof(bits) == sizeof(f.fValue));
memcpy(&bits, &f.fValue, sizeof(bits));
this->writeInstruction(SpvOpConstant, this->getType(f.fType), result,
bits & 0xffffffff, bits >> 32, fConstantBuffer);
@ -2504,8 +2504,8 @@ SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
SpvId result = this->nextId();
const Type* type = &intf.fVariable.fType;
if (fProgram.fInputs.fRTHeight) {
ASSERT(fRTHeightStructId == (SpvId) -1);
ASSERT(fRTHeightFieldIndex == (SpvId) -1);
SkASSERT(fRTHeightStructId == (SpvId) -1);
SkASSERT(fRTHeightFieldIndex == (SpvId) -1);
std::vector<Type::Field> fields = type->fields();
fRTHeightStructId = result;
fRTHeightFieldIndex = fields.size();
@ -2569,7 +2569,7 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
const Variable* var = varDecl.fVar;
// These haven't been implemented in our SPIR-V generator yet and we only currently use them
// in the OpenGL backend.
ASSERT(!(var->fModifiers.fFlags & (Modifiers::kReadOnly_Flag |
SkASSERT(!(var->fModifiers.fFlags & (Modifiers::kReadOnly_Flag |
Modifiers::kWriteOnly_Flag |
Modifiers::kCoherent_Flag |
Modifiers::kVolatile_Flag |
@ -2579,7 +2579,7 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
}
if (var->fModifiers.fLayout.fBuiltin == SK_FRAGCOLOR_BUILTIN &&
kind != Program::kFragment_Kind) {
ASSERT(!fProgram.fSettings.fFragColorIsInOut);
SkASSERT(!fProgram.fSettings.fFragColorIsInOut);
continue;
}
if (!var->fReadCount && !var->fWriteCount &&
@ -2619,7 +2619,7 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
this->writeInstruction(SpvOpName, id, var->fName, fNameBuffer);
this->writePrecisionModifier(var->fModifiers, id);
if (varDecl.fValue) {
ASSERT(!fCurrentBlock);
SkASSERT(!fCurrentBlock);
fCurrentBlock = -1;
SpvId value = this->writeExpression(*varDecl.fValue, fGlobalInitializersBuffer);
this->writeInstruction(SpvOpStore, id, value, fGlobalInitializersBuffer);
@ -2638,12 +2638,12 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
void SPIRVCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, OutputStream& out) {
for (const auto& stmt : decl.fVars) {
ASSERT(stmt->fKind == Statement::kVarDeclaration_Kind);
SkASSERT(stmt->fKind == Statement::kVarDeclaration_Kind);
VarDeclaration& varDecl = (VarDeclaration&) *stmt;
const Variable* var = varDecl.fVar;
// These haven't been implemented in our SPIR-V generator yet and we only currently use them
// in the OpenGL backend.
ASSERT(!(var->fModifiers.fFlags & (Modifiers::kReadOnly_Flag |
SkASSERT(!(var->fModifiers.fFlags & (Modifiers::kReadOnly_Flag |
Modifiers::kWriteOnly_Flag |
Modifiers::kCoherent_Flag |
Modifiers::kVolatile_Flag |
@ -2866,7 +2866,7 @@ void SPIRVCodeGenerator::writeSwitchStatement(const SwitchStatement& s, OutputSt
if (!s.fCases[i]->fValue) {
continue;
}
ASSERT(s.fCases[i]->fValue->fKind == Expression::kIntLiteral_Kind);
SkASSERT(s.fCases[i]->fValue->fKind == Expression::kIntLiteral_Kind);
this->writeWord(((IntLiteral&) *s.fCases[i]->fValue).fValue, out);
this->writeWord(labels[i], out);
}
@ -2893,7 +2893,7 @@ void SPIRVCodeGenerator::writeReturnStatement(const ReturnStatement& r, OutputSt
}
void SPIRVCodeGenerator::writeGeometryShaderExecutionMode(SpvId entryPoint, OutputStream& out) {
ASSERT(fProgram.fKind == Program::kGeometry_Kind);
SkASSERT(fProgram.fKind == Program::kGeometry_Kind);
int invocations = 1;
for (const auto& e : fProgram) {
if (e.fKind == ProgramElement::kModifiers_Kind) {
@ -3000,7 +3000,7 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream&
if (e.fKind == ProgramElement::kInterfaceBlock_Kind) {
InterfaceBlock& intf = (InterfaceBlock&) e;
if (SK_IN_BUILTIN == intf.fVariable.fModifiers.fLayout.fBuiltin) {
ASSERT(skInSize != -1);
SkASSERT(skInSize != -1);
intf.fSizes.emplace_back(new IntLiteral(fContext, -1, skInSize));
}
SpvId id = this->writeInterfaceBlock(intf);
@ -3027,7 +3027,7 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream&
main = entry.first;
}
}
ASSERT(main);
SkASSERT(main);
for (auto entry : fVariableMap) {
const Variable* var = entry.first;
if (var->fStorage == Variable::kGlobal_Storage &&
@ -3084,7 +3084,7 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream&
}
bool SPIRVCodeGenerator::generateCode() {
ASSERT(!fErrors.errorCount());
SkASSERT(!fErrors.errorCount());
this->writeWord(SpvMagicNumber, *fOut);
this->writeWord(SpvVersion, *fOut);
this->writeWord(SKSL_MAGIC, *fOut);

View File

@ -83,12 +83,12 @@ public:
}
const Section* getSection(const char* name) {
ASSERT(!SectionPermitsDuplicates(name));
SkASSERT(!SectionPermitsDuplicates(name));
auto found = fSections.find(name);
if (found == fSections.end()) {
return nullptr;
}
ASSERT(found->second.size() == 1);
SkASSERT(found->second.size() == 1);
return found->second[0];
}

View File

@ -210,8 +210,8 @@ String to_string(double value) {
#endif
#define MAX_DOUBLE_CHARS 25
char buffer[MAX_DOUBLE_CHARS];
SKSL_DEBUGCODE(int len = )SNPRINTF(buffer, sizeof(buffer), "%.17g", value);
ASSERT(len < MAX_DOUBLE_CHARS);
SkDEBUGCODE(int len = )SNPRINTF(buffer, sizeof(buffer), "%.17g", value);
SkASSERT(len < MAX_DOUBLE_CHARS);
String result(buffer);
if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
result += ".0";
@ -223,10 +223,10 @@ String to_string(double value) {
int stoi(const String& s) {
char* p;
SKSL_DEBUGCODE(errno = 0;)
SkDEBUGCODE(errno = 0;)
long result = strtoul(s.c_str(), &p, 0);
ASSERT(*p == 0);
ASSERT(!errno);
SkASSERT(*p == 0);
SkASSERT(!errno);
return (int) result;
}
@ -236,16 +236,16 @@ double stod(const String& s) {
std::stringstream buffer(str);
buffer.imbue(std::locale::classic());
buffer >> result;
ASSERT(!buffer.fail());
SkASSERT(!buffer.fail());
return result;
}
long stol(const String& s) {
char* p;
SKSL_DEBUGCODE(errno = 0;)
SkDEBUGCODE(errno = 0;)
long result = strtoul(s.c_str(), &p, 0);
ASSERT(*p == 0);
ASSERT(!errno);
SkASSERT(*p == 0);
SkASSERT(!errno);
return result;
}

View File

@ -341,13 +341,9 @@ NORETURN void sksl_abort();
} // namespace
#ifdef SKSL_STANDALONE
#define ASSERT(x) (void)((x) || (ABORT("failed assert(%s): %s:%d\n", #x, __FILE__, __LINE__), 0))
#define ASSERT_RESULT(x) ASSERT(x)
#define SKSL_DEBUGCODE(x) x
#else
#define ASSERT SkASSERT
#define ASSERT_RESULT(x) SkAssertResult(x)
#define SKSL_DEBUGCODE(x) SkDEBUGCODE(x)
#define SkASSERT(x)
#define SkAssertResult(x) x
#define SkDEBUGCODE(x)
#endif
#define SKSL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

View File

@ -18,7 +18,7 @@ struct ASTEnum : public ASTDeclaration {
, fTypeName(typeName)
, fNames(std::move(names))
, fValues(std::move(values)) {
ASSERT(fNames.size() == fValues.size());
SkASSERT(fNames.size() == fValues.size());
}
String description() const override {

View File

@ -28,10 +28,10 @@ struct ASTPrecision : public ASTDeclaration {
case Modifiers::kMediump_Flag: return String("precision mediump float;");
case Modifiers::kHighp_Flag: return String("precision highp float;");
default:
ASSERT(false);
SkASSERT(false);
return String("<error>");
}
ASSERT(false);
SkASSERT(false);
return String("<error>");
}

View File

@ -83,7 +83,7 @@ struct Constructor : public Expression {
}
bool compareConstant(const Context& context, const Expression& other) const override {
ASSERT(other.fKind == Expression::kConstructor_Kind && other.fType == fType);
SkASSERT(other.fKind == Expression::kConstructor_Kind && other.fType == fType);
Constructor& c = (Constructor&) other;
if (c.fType.kind() == Type::kVector_Kind) {
for (int i = 0; i < fType.columns(); i++) {
@ -96,14 +96,14 @@ struct Constructor : public Expression {
// shouldn't be possible to have a constant constructor that isn't a vector or matrix;
// a constant scalar constructor should have been collapsed down to the appropriate
// literal
ASSERT(fType.kind() == Type::kMatrix_Kind);
SkASSERT(fType.kind() == Type::kMatrix_Kind);
const FloatLiteral fzero(context, -1, 0);
const IntLiteral izero(context, -1, 0);
const Expression* zero;
if (fType.componentType() == *context.fFloat_Type) {
zero = &fzero;
} else {
ASSERT(fType.componentType() == *context.fInt_Type);
SkASSERT(fType.componentType() == *context.fInt_Type);
zero = &izero;
}
for (int col = 0; col < fType.columns(); col++) {
@ -121,21 +121,21 @@ struct Constructor : public Expression {
}
const Expression& getVecComponent(int index) const {
ASSERT(fType.kind() == Type::kVector_Kind);
SkASSERT(fType.kind() == Type::kVector_Kind);
if (fArguments.size() == 1 && fArguments[0]->fType.kind() == Type::kScalar_Kind) {
return *fArguments[0];
}
int current = 0;
for (const auto& arg : fArguments) {
ASSERT(current <= index);
SkASSERT(current <= index);
if (arg->fType.kind() == Type::kScalar_Kind) {
if (index == current) {
return *arg;
}
current++;
} else {
ASSERT(arg->fType.kind() == Type::kVector_Kind);
ASSERT(arg->fKind == Expression::kConstructor_Kind);
SkASSERT(arg->fType.kind() == Type::kVector_Kind);
SkASSERT(arg->fKind == Expression::kConstructor_Kind);
if (current + arg->fType.columns() > index) {
return ((const Constructor&) *arg).getVecComponent(index - current);
}
@ -155,9 +155,9 @@ struct Constructor : public Expression {
// null return should be interpreted as zero
const Expression* getMatComponent(int col, int row) const {
ASSERT(this->isConstant());
ASSERT(fType.kind() == Type::kMatrix_Kind);
ASSERT(col < fType.columns() && row < fType.rows());
SkASSERT(this->isConstant());
SkASSERT(fType.kind() == Type::kMatrix_Kind);
SkASSERT(col < fType.columns() && row < fType.rows());
if (fArguments.size() == 1) {
if (fArguments[0]->fType.kind() == Type::kScalar_Kind) {
// single scalar argument, so matrix is of the form:
@ -168,7 +168,7 @@ struct Constructor : public Expression {
return col == row ? fArguments[0].get() : nullptr;
}
if (fArguments[0]->fType.kind() == Type::kMatrix_Kind) {
ASSERT(fArguments[0]->fKind == Expression::kConstructor_Kind);
SkASSERT(fArguments[0]->fKind == Expression::kConstructor_Kind);
// single matrix argument. make sure we're within the argument's bounds.
const Type& argType = ((Constructor&) *fArguments[0]).fType;
if (col < argType.columns() && row < argType.rows()) {
@ -182,14 +182,14 @@ struct Constructor : public Expression {
int currentIndex = 0;
int targetIndex = col * fType.rows() + row;
for (const auto& arg : fArguments) {
ASSERT(targetIndex >= currentIndex);
ASSERT(arg->fType.rows() == 1);
SkASSERT(targetIndex >= currentIndex);
SkASSERT(arg->fType.rows() == 1);
if (currentIndex + arg->fType.columns() > targetIndex) {
if (arg->fType.columns() == 1) {
return arg.get();
} else {
ASSERT(arg->fType.kind() == Type::kVector_Kind);
ASSERT(arg->fKind == Expression::kConstructor_Kind);
SkASSERT(arg->fType.kind() == Type::kVector_Kind);
SkASSERT(arg->fKind == Expression::kConstructor_Kind);
return &((Constructor&) *arg).getVecComponent(targetIndex - currentIndex);
}
}

View File

@ -71,7 +71,7 @@ struct FunctionDeclaration : public Symbol {
bool determineFinalTypes(const std::vector<std::unique_ptr<Expression>>& arguments,
std::vector<const Type*>* outParameterTypes,
const Type** outReturnType) const {
ASSERT(arguments.size() == fParameters.size());
SkASSERT(arguments.size() == fParameters.size());
int genericIndex = -1;
for (size_t i = 0; i < arguments.size(); i++) {
if (fParameters[i]->fType.kind() == Type::kGeneric_Kind) {
@ -93,7 +93,7 @@ struct FunctionDeclaration : public Symbol {
}
}
if (fReturnType.kind() == Type::kGeneric_Kind) {
ASSERT(genericIndex != -1);
SkASSERT(genericIndex != -1);
*outReturnType = fReturnType.coercibleTypes()[genericIndex];
} else {
*outReturnType = &fReturnType;

View File

@ -24,22 +24,22 @@ static const Type& index_type(const Context& context, const Type& type) {
case 2: return *context.fFloat2_Type;
case 3: return *context.fFloat3_Type;
case 4: return *context.fFloat4_Type;
default: ASSERT(false);
default: SkASSERT(false);
}
} else if (type.componentType() == *context.fHalf_Type) {
switch (type.rows()) {
case 2: return *context.fHalf2_Type;
case 3: return *context.fHalf3_Type;
case 4: return *context.fHalf4_Type;
default: ASSERT(false);
default: SkASSERT(false);
}
} else {
ASSERT(type.componentType() == *context.fDouble_Type);
SkASSERT(type.componentType() == *context.fDouble_Type);
switch (type.rows()) {
case 2: return *context.fDouble2_Type;
case 3: return *context.fDouble3_Type;
case 4: return *context.fDouble4_Type;
default: ASSERT(false);
default: SkASSERT(false);
}
}
}
@ -55,7 +55,7 @@ struct IndexExpression : public Expression {
: INHERITED(base->fOffset, kIndex_Kind, index_type(context, base->fType))
, fBase(std::move(base))
, fIndex(std::move(index)) {
ASSERT(fIndex->fType == *context.fInt_Type || fIndex->fType == *context.fUInt_Type);
SkASSERT(fIndex->fType == *context.fInt_Type || fIndex->fType == *context.fUInt_Type);
}
bool hasSideEffects() const override {

View File

@ -50,7 +50,7 @@ struct Program {
offset,
fValue));
default:
ASSERT(false);
SkASSERT(false);
return nullptr;
}
}

View File

@ -22,7 +22,7 @@ struct Setting : public Expression {
: INHERITED(offset, kSetting_Kind, value->fType)
, fName(std::move(name))
, fValue(std::move(value)) {
ASSERT(fValue->isConstant());
SkASSERT(fValue->isConstant());
}
std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator,

View File

@ -86,22 +86,22 @@ struct Swizzle : public Expression {
: INHERITED(base->fOffset, kSwizzle_Kind, get_type(context, *base, components.size()))
, fBase(std::move(base))
, fComponents(std::move(components)) {
ASSERT(fComponents.size() >= 1 && fComponents.size() <= 4);
SkASSERT(fComponents.size() >= 1 && fComponents.size() <= 4);
}
std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator,
const DefinitionMap& definitions) override {
if (fBase->fKind == Expression::kConstructor_Kind && fBase->isConstant()) {
// we're swizzling a constant vector, e.g. float4(1).x. Simplify it.
ASSERT(fBase->fKind == Expression::kConstructor_Kind);
SkASSERT(fBase->fKind == Expression::kConstructor_Kind);
if (fType == *irGenerator.fContext.fInt_Type) {
ASSERT(fComponents.size() == 1);
SkASSERT(fComponents.size() == 1);
int64_t value = ((Constructor&) *fBase).getIVecComponent(fComponents[0]);
return std::unique_ptr<Expression>(new IntLiteral(irGenerator.fContext,
-1,
value));
} else if (fType == *irGenerator.fContext.fFloat_Type) {
ASSERT(fComponents.size() == 1);
SkASSERT(fComponents.size() == 1);
double value = ((Constructor&) *fBase).getFVecComponent(fComponents[0]);
return std::unique_ptr<Expression>(new FloatLiteral(irGenerator.fContext,
-1,

View File

@ -50,7 +50,7 @@ const Symbol* SymbolTable::operator[](StringFragment name) {
}
}
if (modified) {
ASSERT(functions.size() > 1);
SkASSERT(functions.size() > 1);
return this->takeOwnership(new UnresolvedFunction(functions));
}
}

View File

@ -23,7 +23,7 @@ struct TernaryExpression : public Expression {
, fTest(std::move(test))
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse)) {
ASSERT(fIfTrue->fType == fIfFalse->fType);
SkASSERT(fIfTrue->fType == fIfFalse->fType);
}
bool hasSideEffects() const override {

View File

@ -47,7 +47,7 @@ int Type::coercionCost(const Type& other) const {
}
const Type& Type::toCompound(const Context& context, int columns, int rows) const {
ASSERT(this->kind() == Type::kScalar_Kind);
SkASSERT(this->kind() == Type::kScalar_Kind);
if (columns == 1 && rows == 1) {
return *this;
}

View File

@ -261,35 +261,35 @@ public:
/**
* For matrices and vectors, returns the type of individual cells (e.g. mat2 has a component
* type of kFloat_Type). For all other types, causes an assertion failure.
* type of kFloat_Type). For all other types, causes an SkASSERTion failure.
*/
const Type& componentType() const {
ASSERT(fComponentType);
SkASSERT(fComponentType);
return *fComponentType;
}
/**
* For matrices and vectors, returns the number of columns (e.g. both mat3 and float3return 3).
* For scalars, returns 1. For arrays, returns either the size of the array (if known) or -1.
* For all other types, causes an assertion failure.
* For all other types, causes an SkASSERTion failure.
*/
int columns() const {
ASSERT(fTypeKind == kScalar_Kind || fTypeKind == kVector_Kind ||
SkASSERT(fTypeKind == kScalar_Kind || fTypeKind == kVector_Kind ||
fTypeKind == kMatrix_Kind || fTypeKind == kArray_Kind);
return fColumns;
}
/**
* For matrices, returns the number of rows (e.g. mat2x4 returns 4). For vectors and scalars,
* returns 1. For all other types, causes an assertion failure.
* returns 1. For all other types, causes an SkASSERTion failure.
*/
int rows() const {
ASSERT(fRows > 0);
SkASSERT(fRows > 0);
return fRows;
}
const std::vector<Field>& fields() const {
ASSERT(fTypeKind == kStruct_Kind);
SkASSERT(fTypeKind == kStruct_Kind);
return fFields;
}
@ -298,32 +298,32 @@ public:
* types, returns a list of other types that this type can be coerced into.
*/
const std::vector<const Type*>& coercibleTypes() const {
ASSERT(fCoercibleTypes.size() > 0);
SkASSERT(fCoercibleTypes.size() > 0);
return fCoercibleTypes;
}
SpvDim_ dimensions() const {
ASSERT(kSampler_Kind == fTypeKind);
SkASSERT(kSampler_Kind == fTypeKind);
return fDimensions;
}
bool isDepth() const {
ASSERT(kSampler_Kind == fTypeKind);
SkASSERT(kSampler_Kind == fTypeKind);
return fIsDepth;
}
bool isArrayed() const {
ASSERT(kSampler_Kind == fTypeKind);
SkASSERT(kSampler_Kind == fTypeKind);
return fIsArrayed;
}
bool isMultisampled() const {
ASSERT(kSampler_Kind == fTypeKind);
SkASSERT(kSampler_Kind == fTypeKind);
return fIsMultisampled;
}
bool isSampled() const {
ASSERT(kSampler_Kind == fTypeKind);
SkASSERT(kSampler_Kind == fTypeKind);
return fIsSampled;
}

View File

@ -21,7 +21,7 @@ struct UnresolvedFunction : public Symbol {
, fFunctions(std::move(funcs)) {
#ifdef DEBUG
for (auto func : funcs) {
ASSERT(func->fName == fName);
SkASSERT(func->fName == fName);
}
#endif
}

View File

@ -44,7 +44,7 @@ struct Variable : public Symbol {
if (fInitialValue) {
--fWriteCount;
}
ASSERT(!fReadCount && !fWriteCount);
SkASSERT(!fReadCount && !fWriteCount);
}
virtual String description() const override {

View File

@ -53,7 +53,7 @@ void VariableReference::setRefKind(RefKind refKind) {
std::unique_ptr<Expression> VariableReference::copy_constant(const IRGenerator& irGenerator,
const Expression* expr) {
ASSERT(expr->isConstant());
SkASSERT(expr->isConstant());
switch (expr->fKind) {
case Expression::kIntLiteral_Kind:
return std::unique_ptr<Expression>(new IntLiteral(irGenerator.fContext,

View File

@ -13,6 +13,6 @@
#define INVALID -1
#define ABORT(...) (fprintf(stderr, __VA_ARGS__), abort())
#define ASSERT(x) (void)((x) || (ABORT("failed assert(%s): %s:%d\n", #x, __FILE__, __LINE__), 0))
#define SkASSERT(x) (void)((x) || (ABORT("failed SkASSERT(%s): %s:%d\n", #x, __FILE__, __LINE__), 0))
#endif

View File

@ -33,7 +33,7 @@ static constexpr const char* HEADER =
void writeH(const DFA& dfa, const char* lexer, const char* token,
const std::vector<std::string>& tokens, const char* hPath) {
std::ofstream out(hPath);
ASSERT(out.good());
SkASSERT(out.good());
out << HEADER;
out << "#ifndef SKSL_" << lexer << "\n";
out << "#define SKSL_" << lexer << "\n";
@ -87,7 +87,7 @@ void writeH(const DFA& dfa, const char* lexer, const char* token,
void writeCPP(const DFA& dfa, const char* lexer, const char* token, const char* include,
const char* cppPath) {
std::ofstream out(cppPath);
ASSERT(out.good());
SkASSERT(out.good());
out << HEADER;
out << "#include \"" << include << "\"\n";
out << "\n";
@ -172,13 +172,13 @@ void process(const char* inPath, const char* lexer, const char* token, const cha
std::istringstream split(line);
std::string name, delimiter, pattern;
if (split >> name >> delimiter >> pattern) {
ASSERT(split.eof());
ASSERT(name != "");
ASSERT(delimiter == "=");
ASSERT(pattern != "");
SkASSERT(split.eof());
SkASSERT(name != "");
SkASSERT(delimiter == "=");
SkASSERT(pattern != "");
tokens.push_back(name);
if (pattern[0] == '"') {
ASSERT(pattern.size() > 2 && pattern[pattern.size() - 1] == '"');
SkASSERT(pattern.size() > 2 && pattern[pattern.size() - 1] == '"');
RegexNode node = RegexNode(RegexNode::kChar_Kind, pattern[1]);
for (size_t i = 2; i < pattern.size() - 1; ++i) {
node = RegexNode(RegexNode::kConcat_Kind, node,

View File

@ -24,7 +24,7 @@ std::vector<int> RegexNode::createStates(NFA* nfa, const std::vector<int>& accep
}
chars[child.fPayload.fChar] = true;
} else {
ASSERT(child.fKind == kRange_Kind);
SkASSERT(child.fKind == kRange_Kind);
while (chars.size() <= (size_t) child.fChildren[1].fPayload.fChar) {
chars.push_back(false);
}

View File

@ -12,10 +12,10 @@
RegexNode RegexParser::parse(std::string source) {
fSource = source;
fIndex = 0;
ASSERT(fStack.size() == 0);
SkASSERT(fStack.size() == 0);
this->regex();
ASSERT(fStack.size() == 1);
ASSERT(fIndex == source.size());
SkASSERT(fStack.size() == 1);
SkASSERT(fIndex == source.size());
return this->pop();
}
@ -119,9 +119,9 @@ void RegexParser::setItem() {
else {
literal();
RegexNode end = this->pop();
ASSERT(end.fKind == RegexNode::kChar_Kind);
SkASSERT(end.fKind == RegexNode::kChar_Kind);
RegexNode start = this->pop();
ASSERT(start.fKind == RegexNode::kChar_Kind);
SkASSERT(start.fKind == RegexNode::kChar_Kind);
fStack.push(RegexNode(RegexNode::kRange_Kind, std::move(start), std::move(end)));
}
}
@ -171,6 +171,6 @@ void RegexParser::regex() {
case ')':
return;
default:
ASSERT(false);
SkASSERT(false);
}
}