diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-11-07 14:42:10 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-07 14:42:19 +0000 |
commit | 82a62d2d4ef55e53730a4f194a82d4e5da0c4a64 (patch) | |
tree | 8cee593eec28052b9f002c537db8356175fa2874 /src/sksl/SkSLIRGenerator.cpp | |
parent | 09eba3cad93d3e7eb0c37e388086b811e4ec1512 (diff) |
Revert "refactored SkSLVarDeclaration out of existence"
This reverts commit 1ae353c887fdf447e1fe627e3cd29f8fa62c2a05.
Reason for revert: ASAN failures
Original change's description:
> refactored SkSLVarDeclaration out of existence
>
> Bug: skia:
> Change-Id: I3dbc08e6d759f6828a472246d4797babb6cc132e
> Reviewed-on: https://skia-review.googlesource.com/66147
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
TBR=egdaniel@google.com,ethannicholas@google.com
Change-Id: I8cae451de1546fe783e32dd41df00eac7da61b21
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/68280
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLIRGenerator.cpp')
-rw-r--r-- | src/sksl/SkSLIRGenerator.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp index 7bbb6da362..2fb27fcec4 100644 --- a/src/sksl/SkSLIRGenerator.cpp +++ b/src/sksl/SkSLIRGenerator.cpp @@ -219,7 +219,7 @@ std::unique_ptr<Statement> IRGenerator::convertVarDeclarationStatement( std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVarDeclarations& decl, Variable::Storage storage) { - std::vector<Variable*> variables; + std::vector<std::unique_ptr<VarDeclaration>> variables; const Type* baseType = this->convertType(*decl.fType); if (!baseType) { return nullptr; @@ -254,6 +254,8 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa sizes.push_back(nullptr); } } + auto var = std::unique_ptr<Variable>(new Variable(decl.fOffset, decl.fModifiers, + varDecl.fName, *type, storage)); std::unique_ptr<Expression> value; if (varDecl.fValue) { value = this->convertExpression(*varDecl.fValue); @@ -261,11 +263,6 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa return nullptr; } value = this->coerce(std::move(value), *type); - } - auto var = std::unique_ptr<Variable>(new Variable(decl.fOffset, decl.fModifiers, - varDecl.fName, *type, storage, - std::move(value), std::move(sizes))); - if (varDecl.fValue) { var->fWriteCount = 1; } if (storage == Variable::kGlobal_Storage && varDecl.fName == "sk_FragColor" && @@ -278,7 +275,8 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa Variable* old = (Variable*) (*fSymbolTable)[varDecl.fName]; old->fModifiers = var->fModifiers; } else { - variables.push_back(var.get()); + variables.emplace_back(new VarDeclaration(var.get(), std::move(sizes), + std::move(value))); fSymbolTable->add(varDecl.fName, std::move(var)); } } @@ -533,7 +531,7 @@ std::unique_ptr<Block> IRGenerator::applyInvocationIDWorkaround(std::unique_ptr< std::move(main)))); fSymbolTable->add(invokeDecl->fName, std::unique_ptr<FunctionDeclaration>(invokeDecl)); - std::vector<Variable*> variables; + std::vector<std::unique_ptr<VarDeclaration>> variables; Variable* loopIdx = (Variable*) (*fSymbolTable)["sk_InvocationID"]; ASSERT(loopIdx); std::unique_ptr<Expression> test(new BinaryExpression(-1, @@ -600,7 +598,7 @@ void IRGenerator::convertFunction(const ASTFunction& f, } StringFragment name = param->fName; Variable* var = new Variable(param->fOffset, param->fModifiers, name, *type, - Variable::kParameter_Storage, nullptr, {}); + Variable::kParameter_Storage); fSymbolTable->takeOwnership(var); parameters.push_back(var); } @@ -714,27 +712,29 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte if (!decl) { return nullptr; } - for (const Variable* var : decl->fVars) { + for (const auto& stmt : decl->fVars) { + VarDeclaration& vd = (VarDeclaration&) *stmt; if (haveRuntimeArray) { - fErrors.error(var->fOffset, + fErrors.error(decl->fOffset, "only the last entry in an interface block may be a runtime-sized " "array"); } - fields.push_back(Type::Field(var->fModifiers, var->fName, &var->fType)); - if (var->fInitialValue) { + fields.push_back(Type::Field(vd.fVar->fModifiers, vd.fVar->fName, + &vd.fVar->fType)); + if (vd.fValue) { fErrors.error(decl->fOffset, "initializers are not permitted on interface block fields"); } - if (var->fModifiers.fFlags & (Modifiers::kIn_Flag | - Modifiers::kOut_Flag | - Modifiers::kUniform_Flag | - Modifiers::kBuffer_Flag | - Modifiers::kConst_Flag)) { + if (vd.fVar->fModifiers.fFlags & (Modifiers::kIn_Flag | + Modifiers::kOut_Flag | + Modifiers::kUniform_Flag | + Modifiers::kBuffer_Flag | + Modifiers::kConst_Flag)) { fErrors.error(decl->fOffset, "interface block fields may not have storage qualifiers"); } - if (var->fType.kind() == Type::kArray_Kind && - var->fType.columns() == -1) { + if (vd.fVar->fType.kind() == Type::kArray_Kind && + vd.fVar->fType.columns() == -1) { haveRuntimeArray = true; } } @@ -771,7 +771,7 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte } Variable* var = new Variable(intf.fOffset, intf.fModifiers, intf.fInstanceName.fLength ? intf.fInstanceName : intf.fTypeName, - *type, Variable::kGlobal_Storage, nullptr, {}); + *type, Variable::kGlobal_Storage); old->takeOwnership(var); if (intf.fInstanceName.fLength) { old->addWithoutOwnership(intf.fInstanceName, var); |