diff options
Diffstat (limited to 'src/sksl/ir')
45 files changed, 21 insertions, 310 deletions
diff --git a/src/sksl/ir/SkSLAppendStage.h b/src/sksl/ir/SkSLAppendStage.h index 268ae979d2..87a8210a83 100644 --- a/src/sksl/ir/SkSLAppendStage.h +++ b/src/sksl/ir/SkSLAppendStage.h @@ -23,16 +23,7 @@ struct AppendStage : public Expression { , fStage(stage) , fArguments(std::move(arguments)) {} - std::unique_ptr<Expression> clone() const override { - std::vector<std::unique_ptr<Expression>> cloned; - for (const auto& arg : fArguments) { - cloned.push_back(arg->clone()); - } - return std::unique_ptr<Expression>(new AppendStage(fOffset, fStage, std::move(cloned), - &fType)); - } - - String description() const override { + String description() const { String result = "append("; const char* separator = ""; for (const auto& a : fArguments) { @@ -44,7 +35,7 @@ struct AppendStage : public Expression { return result; } - bool hasSideEffects() const override { + bool hasSideEffects() const { return true; } @@ -53,14 +44,6 @@ struct AppendStage : public Expression { std::vector<std::unique_ptr<Expression>> fArguments; typedef Expression INHERITED; - -private: - AppendStage(int offset, SkRasterPipeline::StockStage stage, - std::vector<std::unique_ptr<Expression>> arguments, const Type* type) - : INHERITED(offset, kAppendStage_Kind, *type) - , fStage(stage) - , fArguments(std::move(arguments)) {} - }; } // namespace diff --git a/src/sksl/ir/SkSLBinaryExpression.h b/src/sksl/ir/SkSLBinaryExpression.h index ed1a5cc181..c26994edf2 100644 --- a/src/sksl/ir/SkSLBinaryExpression.h +++ b/src/sksl/ir/SkSLBinaryExpression.h @@ -38,11 +38,6 @@ struct BinaryExpression : public Expression { fRight->hasSideEffects(); } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new BinaryExpression(fOffset, fLeft->clone(), fOperator, - fRight->clone(), fType)); - } - String description() const override { return "(" + fLeft->description() + " " + Compiler::OperatorName(fOperator) + " " + fRight->description() + ")"; diff --git a/src/sksl/ir/SkSLBlock.h b/src/sksl/ir/SkSLBlock.h index 0a03654488..af1975396e 100644 --- a/src/sksl/ir/SkSLBlock.h +++ b/src/sksl/ir/SkSLBlock.h @@ -32,14 +32,6 @@ struct Block : public Statement { return true; } - std::unique_ptr<Statement> clone() const override { - std::vector<std::unique_ptr<Statement>> cloned; - for (const auto& s : fStatements) { - cloned.push_back(s->clone()); - } - return std::unique_ptr<Statement>(new Block(fOffset, std::move(cloned), fSymbols)); - } - String description() const override { String result("{"); for (size_t i = 0; i < fStatements.size(); i++) { diff --git a/src/sksl/ir/SkSLBoolLiteral.h b/src/sksl/ir/SkSLBoolLiteral.h index d979ed3939..9a69f0f138 100644 --- a/src/sksl/ir/SkSLBoolLiteral.h +++ b/src/sksl/ir/SkSLBoolLiteral.h @@ -38,18 +38,9 @@ struct BoolLiteral : public Expression { return fValue == b.fValue; } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new BoolLiteral(fOffset, fValue, &fType)); - } - const bool fValue; typedef Expression INHERITED; - -private: - BoolLiteral(int offset, bool value, const Type* type) - : INHERITED(offset, kBoolLiteral_Kind, *type) - , fValue(value) {} }; } // namespace diff --git a/src/sksl/ir/SkSLBreakStatement.h b/src/sksl/ir/SkSLBreakStatement.h index 272deb65cd..da392f5960 100644 --- a/src/sksl/ir/SkSLBreakStatement.h +++ b/src/sksl/ir/SkSLBreakStatement.h @@ -20,10 +20,6 @@ struct BreakStatement : public Statement { BreakStatement(int offset) : INHERITED(offset, kBreak_Kind) {} - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new BreakStatement(fOffset)); - } - String description() const override { return String("break;"); } diff --git a/src/sksl/ir/SkSLConstructor.h b/src/sksl/ir/SkSLConstructor.h index 145e117453..5e7c3d0d79 100644 --- a/src/sksl/ir/SkSLConstructor.h +++ b/src/sksl/ir/SkSLConstructor.h @@ -43,7 +43,8 @@ struct Constructor : public Expression { fType == *irGenerator.fContext.fUShort_Type) { // promote uint(1) to 1u int64_t intValue = ((IntLiteral&) *fArguments[0]).fValue; - return std::unique_ptr<Expression>(new IntLiteral(fOffset, + return std::unique_ptr<Expression>(new IntLiteral(irGenerator.fContext, + fOffset, intValue, &fType)); } @@ -60,14 +61,6 @@ struct Constructor : public Expression { return false; } - std::unique_ptr<Expression> clone() const override { - std::vector<std::unique_ptr<Expression>> cloned; - for (const auto& arg : fArguments) { - cloned.push_back(arg->clone()); - } - return std::unique_ptr<Expression>(new Constructor(fOffset, fType, std::move(cloned))); - } - String description() const override { String result = fType.description() + "("; String separator; diff --git a/src/sksl/ir/SkSLContinueStatement.h b/src/sksl/ir/SkSLContinueStatement.h index 9977fbecaf..6ed40c404f 100644 --- a/src/sksl/ir/SkSLContinueStatement.h +++ b/src/sksl/ir/SkSLContinueStatement.h @@ -20,10 +20,6 @@ struct ContinueStatement : public Statement { ContinueStatement(int offset) : INHERITED(offset, kContinue_Kind) {} - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new ContinueStatement(fOffset)); - } - String description() const override { return String("continue;"); } diff --git a/src/sksl/ir/SkSLDiscardStatement.h b/src/sksl/ir/SkSLDiscardStatement.h index 8c406e9353..b62530e6f3 100644 --- a/src/sksl/ir/SkSLDiscardStatement.h +++ b/src/sksl/ir/SkSLDiscardStatement.h @@ -20,10 +20,6 @@ struct DiscardStatement : public Statement { DiscardStatement(int offset) : INHERITED(offset, kDiscard_Kind) {} - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new DiscardStatement(fOffset)); - } - String description() const override { return String("discard;"); } diff --git a/src/sksl/ir/SkSLDoStatement.h b/src/sksl/ir/SkSLDoStatement.h index af0fc5951b..3abec550eb 100644 --- a/src/sksl/ir/SkSLDoStatement.h +++ b/src/sksl/ir/SkSLDoStatement.h @@ -23,11 +23,6 @@ struct DoStatement : public Statement { , fStatement(std::move(statement)) , fTest(std::move(test)) {} - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new DoStatement(fOffset, fStatement->clone(), - fTest->clone())); - } - String description() const override { return "do " + fStatement->description() + " while (" + fTest->description() + ");"; } diff --git a/src/sksl/ir/SkSLEnum.h b/src/sksl/ir/SkSLEnum.h index eea7e5c3a5..6c44a67678 100644 --- a/src/sksl/ir/SkSLEnum.h +++ b/src/sksl/ir/SkSLEnum.h @@ -17,10 +17,6 @@ struct Enum : public ProgramElement { , fTypeName(typeName) , fSymbols(std::move(symbols)) {} - std::unique_ptr<ProgramElement> clone() const override { - return std::unique_ptr<ProgramElement>(new Enum(fOffset, fTypeName, fSymbols)); - } - String description() const override { String result = "enum class " + fTypeName + " {\n"; String separator; diff --git a/src/sksl/ir/SkSLExpression.h b/src/sksl/ir/SkSLExpression.h index ddeed448a2..c8ad1380e7 100644 --- a/src/sksl/ir/SkSLExpression.h +++ b/src/sksl/ir/SkSLExpression.h @@ -106,8 +106,6 @@ struct Expression : public IRNode { return fType.coercionCost(target); } - virtual std::unique_ptr<Expression> clone() const = 0; - const Kind fKind; const Type& fType; diff --git a/src/sksl/ir/SkSLExpressionStatement.h b/src/sksl/ir/SkSLExpressionStatement.h index 90aa5415cc..215763b8fd 100644 --- a/src/sksl/ir/SkSLExpressionStatement.h +++ b/src/sksl/ir/SkSLExpressionStatement.h @@ -21,10 +21,6 @@ struct ExpressionStatement : public Statement { : INHERITED(expression->fOffset, kExpression_Kind) , fExpression(std::move(expression)) {} - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new ExpressionStatement(fExpression->clone())); - } - String description() const override { return fExpression->description() + ";"; } diff --git a/src/sksl/ir/SkSLExtension.h b/src/sksl/ir/SkSLExtension.h index 3a103a63c6..b5a48b94ab 100644 --- a/src/sksl/ir/SkSLExtension.h +++ b/src/sksl/ir/SkSLExtension.h @@ -20,10 +20,6 @@ struct Extension : public ProgramElement { : INHERITED(offset, kExtension_Kind) , fName(std::move(name)) {} - std::unique_ptr<ProgramElement> clone() const override { - return std::unique_ptr<ProgramElement>(new Extension(fOffset, fName)); - } - String description() const override { return "#extension " + fName + " : enable"; } diff --git a/src/sksl/ir/SkSLFieldAccess.h b/src/sksl/ir/SkSLFieldAccess.h index b3bd05096e..0f66dec5a4 100644 --- a/src/sksl/ir/SkSLFieldAccess.h +++ b/src/sksl/ir/SkSLFieldAccess.h @@ -35,11 +35,6 @@ struct FieldAccess : public Expression { return fBase->hasSideEffects(); } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new FieldAccess(fBase->clone(), fFieldIndex, - fOwnerKind)); - } - String description() const override { return fBase->description() + "." + fBase->fType.fields()[fFieldIndex].fName; } diff --git a/src/sksl/ir/SkSLFloatLiteral.h b/src/sksl/ir/SkSLFloatLiteral.h index e995e4c6e1..82c15c032b 100644 --- a/src/sksl/ir/SkSLFloatLiteral.h +++ b/src/sksl/ir/SkSLFloatLiteral.h @@ -17,12 +17,9 @@ namespace SkSL { * A literal floating point number. */ struct FloatLiteral : public Expression { - FloatLiteral(const Context& context, int offset, double value) - : INHERITED(offset, kFloatLiteral_Kind, *context.fFloat_Type) - , fValue(value) {} - - FloatLiteral(int offset, double value, const Type* type) - : INHERITED(offset, kFloatLiteral_Kind, *type) + FloatLiteral(const Context& context, int offset, double value, + const Type* type = nullptr) + : INHERITED(offset, kFloatLiteral_Kind, type ? *type : *context.fFloat_Type) , fValue(value) {} String description() const override { @@ -46,10 +43,6 @@ struct FloatLiteral : public Expression { return fValue; } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new FloatLiteral(fOffset, fValue, &fType)); - } - const double fValue; typedef Expression INHERITED; diff --git a/src/sksl/ir/SkSLForStatement.h b/src/sksl/ir/SkSLForStatement.h index 220be9855b..6896ceb902 100644 --- a/src/sksl/ir/SkSLForStatement.h +++ b/src/sksl/ir/SkSLForStatement.h @@ -28,12 +28,6 @@ struct ForStatement : public Statement { , fNext(std::move(next)) , fStatement(std::move(statement)) {} - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new ForStatement(fOffset, fInitializer->clone(), - fTest->clone(), fNext->clone(), - fStatement->clone(), fSymbols)); - } - String description() const override { String result("for ("); if (fInitializer) { diff --git a/src/sksl/ir/SkSLFunctionCall.h b/src/sksl/ir/SkSLFunctionCall.h index 7047c37067..115281d63d 100644 --- a/src/sksl/ir/SkSLFunctionCall.h +++ b/src/sksl/ir/SkSLFunctionCall.h @@ -32,15 +32,6 @@ struct FunctionCall : public Expression { return fFunction.fModifiers.fFlags & Modifiers::kHasSideEffects_Flag; } - std::unique_ptr<Expression> clone() const override { - std::vector<std::unique_ptr<Expression>> cloned; - for (const auto& arg : fArguments) { - cloned.push_back(arg->clone()); - } - return std::unique_ptr<Expression>(new FunctionCall(fOffset, fType, fFunction, - std::move(cloned))); - } - String description() const override { String result = String(fFunction.fName) + "("; String separator; diff --git a/src/sksl/ir/SkSLFunctionDefinition.h b/src/sksl/ir/SkSLFunctionDefinition.h index 4ec559756c..e0dabc5791 100644 --- a/src/sksl/ir/SkSLFunctionDefinition.h +++ b/src/sksl/ir/SkSLFunctionDefinition.h @@ -24,11 +24,6 @@ struct FunctionDefinition : public ProgramElement { , fDeclaration(declaration) , fBody(std::move(body)) {} - std::unique_ptr<ProgramElement> clone() const override { - return std::unique_ptr<ProgramElement>(new FunctionDefinition(fOffset, fDeclaration, - fBody->clone())); - } - String description() const override { return fDeclaration.description() + " " + fBody->description(); } diff --git a/src/sksl/ir/SkSLFunctionReference.h b/src/sksl/ir/SkSLFunctionReference.h index 4c7f7670d0..58fefce801 100644 --- a/src/sksl/ir/SkSLFunctionReference.h +++ b/src/sksl/ir/SkSLFunctionReference.h @@ -28,10 +28,6 @@ struct FunctionReference : public Expression { return false; } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new FunctionReference(fOffset, fFunctions, &fType)); - } - String description() const override { return String("<function>"); } @@ -39,12 +35,7 @@ struct FunctionReference : public Expression { const std::vector<const FunctionDeclaration*> fFunctions; typedef Expression INHERITED; - -private: - FunctionReference(int offset, std::vector<const FunctionDeclaration*> function, - const Type* type) - : INHERITED(offset, kFunctionReference_Kind, *type) - , fFunctions(function) {}}; +}; } // namespace diff --git a/src/sksl/ir/SkSLIfStatement.h b/src/sksl/ir/SkSLIfStatement.h index 9d35fe8f7d..4c2ca0b1fa 100644 --- a/src/sksl/ir/SkSLIfStatement.h +++ b/src/sksl/ir/SkSLIfStatement.h @@ -25,11 +25,6 @@ struct IfStatement : public Statement { , fIfTrue(std::move(ifTrue)) , fIfFalse(std::move(ifFalse)) {} - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new IfStatement(fOffset, fIsStatic, fTest->clone(), - fIfTrue->clone(), fIfFalse ? fIfFalse->clone() : nullptr)); - } - String description() const override { String result; if (fIsStatic) { diff --git a/src/sksl/ir/SkSLIndexExpression.h b/src/sksl/ir/SkSLIndexExpression.h index 74288e5171..de44b1adb2 100644 --- a/src/sksl/ir/SkSLIndexExpression.h +++ b/src/sksl/ir/SkSLIndexExpression.h @@ -62,11 +62,6 @@ struct IndexExpression : public Expression { return fBase->hasSideEffects() || fIndex->hasSideEffects(); } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new IndexExpression(fBase->clone(), fIndex->clone(), - &fType)); - } - String description() const override { return fBase->description() + "[" + fIndex->description() + "]"; } @@ -75,13 +70,6 @@ struct IndexExpression : public Expression { std::unique_ptr<Expression> fIndex; typedef Expression INHERITED; - -private: - IndexExpression(std::unique_ptr<Expression> base, std::unique_ptr<Expression> index, - const Type* type) - : INHERITED(base->fOffset, kIndex_Kind, *type) - , fBase(std::move(base)) - , fIndex(std::move(index)) {} }; } // namespace diff --git a/src/sksl/ir/SkSLIntLiteral.h b/src/sksl/ir/SkSLIntLiteral.h index 116796c16d..50337bfe6f 100644 --- a/src/sksl/ir/SkSLIntLiteral.h +++ b/src/sksl/ir/SkSLIntLiteral.h @@ -19,12 +19,8 @@ namespace SkSL { struct IntLiteral : public Expression { // FIXME: we will need to revisit this if/when we add full support for both signed and unsigned // 64-bit integers, but for right now an int64_t will hold every value we care about - IntLiteral(const Context& context, int offset, int64_t value) - : INHERITED(offset, kIntLiteral_Kind, *context.fInt_Type) - , fValue(value) {} - - IntLiteral(int offset, int64_t value, const Type* type = nullptr) - : INHERITED(offset, kIntLiteral_Kind, *type) + IntLiteral(const Context& context, int offset, int64_t value, const Type* type = nullptr) + : INHERITED(offset, kIntLiteral_Kind, type ? *type : *context.fInt_Type) , fValue(value) {} String description() const override { @@ -55,10 +51,6 @@ struct IntLiteral : public Expression { return fValue; } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new IntLiteral(fOffset, fValue, &fType)); - } - const int64_t fValue; typedef Expression INHERITED; diff --git a/src/sksl/ir/SkSLInterfaceBlock.h b/src/sksl/ir/SkSLInterfaceBlock.h index 08bf9d0f75..4a7bf9307b 100644 --- a/src/sksl/ir/SkSLInterfaceBlock.h +++ b/src/sksl/ir/SkSLInterfaceBlock.h @@ -35,17 +35,6 @@ struct InterfaceBlock : public ProgramElement { , fSizes(std::move(sizes)) , fTypeOwner(typeOwner) {} - std::unique_ptr<ProgramElement> clone() const override { - std::vector<std::unique_ptr<Expression>> sizesClone; - for (const auto& s : fSizes) { - sizesClone.push_back(s->clone()); - } - return std::unique_ptr<ProgramElement>(new InterfaceBlock(fOffset, &fVariable, fTypeName, - fInstanceName, - std::move(sizesClone), - fTypeOwner)); - } - String description() const override { String result = fVariable.fModifiers.description() + fTypeName + " {\n"; const Type* structType = &fVariable.fType; diff --git a/src/sksl/ir/SkSLLayout.h b/src/sksl/ir/SkSLLayout.h index 5c99807ab5..3082b34133 100644 --- a/src/sksl/ir/SkSLLayout.h +++ b/src/sksl/ir/SkSLLayout.h @@ -311,9 +311,6 @@ struct Layout { if (result.size() > 0) { result = "layout (" + result + ")"; } - if (fKey) { - result += "/* key */"; - } return result; } diff --git a/src/sksl/ir/SkSLModifiersDeclaration.h b/src/sksl/ir/SkSLModifiersDeclaration.h index 1f31926a30..5c9608f02f 100644 --- a/src/sksl/ir/SkSLModifiersDeclaration.h +++ b/src/sksl/ir/SkSLModifiersDeclaration.h @@ -23,11 +23,7 @@ struct ModifiersDeclaration : public ProgramElement { : INHERITED(-1, kModifiers_Kind) , fModifiers(modifiers) {} - std::unique_ptr<ProgramElement> clone() const override { - return std::unique_ptr<ProgramElement>(new ModifiersDeclaration(fModifiers)); - } - - String description() const override { + String description() const { return fModifiers.description() + ";"; } diff --git a/src/sksl/ir/SkSLNop.h b/src/sksl/ir/SkSLNop.h index 954fedb13b..e7aae9b7b8 100644 --- a/src/sksl/ir/SkSLNop.h +++ b/src/sksl/ir/SkSLNop.h @@ -28,10 +28,6 @@ struct Nop : public Statement { return String(";"); } - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new Nop()); - } - typedef Statement INHERITED; }; diff --git a/src/sksl/ir/SkSLPostfixExpression.h b/src/sksl/ir/SkSLPostfixExpression.h index dd20efd3e7..c53f1de507 100644 --- a/src/sksl/ir/SkSLPostfixExpression.h +++ b/src/sksl/ir/SkSLPostfixExpression.h @@ -26,10 +26,6 @@ struct PostfixExpression : public Expression { return true; } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new PostfixExpression(fOperand->clone(), fOperator)); - } - String description() const override { return fOperand->description() + Compiler::OperatorName(fOperator); } diff --git a/src/sksl/ir/SkSLPrefixExpression.h b/src/sksl/ir/SkSLPrefixExpression.h index 366f714fa3..d5d97b2517 100644 --- a/src/sksl/ir/SkSLPrefixExpression.h +++ b/src/sksl/ir/SkSLPrefixExpression.h @@ -45,10 +45,6 @@ struct PrefixExpression : public Expression { return nullptr; } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new PrefixExpression(fOperator, fOperand->clone())); - } - String description() const override { return Compiler::OperatorName(fOperator) + fOperand->description(); } diff --git a/src/sksl/ir/SkSLProgram.h b/src/sksl/ir/SkSLProgram.h index 59c91229f8..9f140877b7 100644 --- a/src/sksl/ir/SkSLProgram.h +++ b/src/sksl/ir/SkSLProgram.h @@ -39,10 +39,6 @@ struct Program { : fKind(kInt_Kind) , fValue(i) {} - Value(unsigned int i) - : fKind(kInt_Kind) - , fValue(i) {} - std::unique_ptr<Expression> literal(const Context& context, int offset) const { switch (fKind) { case Program::Settings::Value::kBool_Kind: @@ -196,7 +192,7 @@ struct Program { kVertex_Kind, kGeometry_Kind, kFragmentProcessor_Kind, - kPipelineStage_Kind + kCPU_Kind }; Program(Kind kind, @@ -256,13 +252,10 @@ struct Program { // because destroying elements can modify reference counts in symbols std::shared_ptr<SymbolTable> fSymbols; Inputs fInputs; - bool fIsOptimized = false; private: std::vector<std::unique_ptr<ProgramElement>>* fInheritedElements; std::vector<std::unique_ptr<ProgramElement>> fElements; - - friend class Compiler; }; } // namespace diff --git a/src/sksl/ir/SkSLProgramElement.h b/src/sksl/ir/SkSLProgramElement.h index b14836ffb1..9d1bdfe885 100644 --- a/src/sksl/ir/SkSLProgramElement.h +++ b/src/sksl/ir/SkSLProgramElement.h @@ -32,8 +32,6 @@ struct ProgramElement : public IRNode { Kind fKind; - virtual std::unique_ptr<ProgramElement> clone() const = 0; - typedef IRNode INHERITED; }; diff --git a/src/sksl/ir/SkSLReturnStatement.h b/src/sksl/ir/SkSLReturnStatement.h index 774d803011..1b479b8097 100644 --- a/src/sksl/ir/SkSLReturnStatement.h +++ b/src/sksl/ir/SkSLReturnStatement.h @@ -24,13 +24,6 @@ struct ReturnStatement : public Statement { : INHERITED(expression->fOffset, kReturn_Kind) , fExpression(std::move(expression)) {} - std::unique_ptr<Statement> clone() const override { - if (fExpression) { - return std::unique_ptr<Statement>(new ReturnStatement(fExpression->clone())); - } - return std::unique_ptr<Statement>(new ReturnStatement(fOffset)); - } - String description() const override { if (fExpression) { return "return " + fExpression->description() + ";"; diff --git a/src/sksl/ir/SkSLSection.h b/src/sksl/ir/SkSLSection.h index d06b979c17..96c257b1f8 100644 --- a/src/sksl/ir/SkSLSection.h +++ b/src/sksl/ir/SkSLSection.h @@ -22,10 +22,6 @@ struct Section : public ProgramElement { , fArgument(std::move(arg)) , fText(std::move(text)) {} - std::unique_ptr<ProgramElement> clone() const override { - return std::unique_ptr<ProgramElement>(new Section(fOffset, fName, fArgument, fText)); - } - String description() const override { String result = "@" + fName; if (fArgument.size()) { diff --git a/src/sksl/ir/SkSLSetting.cpp b/src/sksl/ir/SkSLSetting.cpp index 9885a2873f..2d4a8ba151 100644 --- a/src/sksl/ir/SkSLSetting.cpp +++ b/src/sksl/ir/SkSLSetting.cpp @@ -13,10 +13,10 @@ namespace SkSL { std::unique_ptr<Expression> Setting::constantPropagate(const IRGenerator& irGenerator, const DefinitionMap& definitions) { - if (irGenerator.fSettings->fReplaceSettings) { - return VariableReference::copy_constant(irGenerator, fValue.get()); + if (irGenerator.fSettings->fReplaceSettings) { + return VariableReference::copy_constant(irGenerator, fValue.get()); + } + return nullptr; } - return nullptr; -} - } // namespace + diff --git a/src/sksl/ir/SkSLSetting.h b/src/sksl/ir/SkSLSetting.h index cc1c551077..1396099102 100644 --- a/src/sksl/ir/SkSLSetting.h +++ b/src/sksl/ir/SkSLSetting.h @@ -28,10 +28,6 @@ struct Setting : public Expression { std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator, const DefinitionMap& definitions) override; - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new Setting(fOffset, fName, fValue->clone())); - } - String description() const override { return fName; } diff --git a/src/sksl/ir/SkSLStatement.h b/src/sksl/ir/SkSLStatement.h index 99aab19208..a116cc1c4c 100644 --- a/src/sksl/ir/SkSLStatement.h +++ b/src/sksl/ir/SkSLStatement.h @@ -43,8 +43,6 @@ struct Statement : public IRNode { return false; } - virtual std::unique_ptr<Statement> clone() const = 0; - const Kind fKind; typedef IRNode INHERITED; diff --git a/src/sksl/ir/SkSLSwitchCase.h b/src/sksl/ir/SkSLSwitchCase.h index b9e52180f3..c33224bdbb 100644 --- a/src/sksl/ir/SkSLSwitchCase.h +++ b/src/sksl/ir/SkSLSwitchCase.h @@ -23,16 +23,6 @@ struct SwitchCase : public Statement { , fValue(std::move(value)) , fStatements(std::move(statements)) {} - std::unique_ptr<Statement> clone() const override { - std::vector<std::unique_ptr<Statement>> cloned; - for (const auto& s : fStatements) { - cloned.push_back(s->clone()); - } - return std::unique_ptr<Statement>(new SwitchCase(fOffset, - fValue ? fValue->clone() : nullptr, - std::move(cloned))); - } - String description() const override { String result; if (fValue) { diff --git a/src/sksl/ir/SkSLSwitchStatement.h b/src/sksl/ir/SkSLSwitchStatement.h index 2c48bad1ba..68d0ef02df 100644 --- a/src/sksl/ir/SkSLSwitchStatement.h +++ b/src/sksl/ir/SkSLSwitchStatement.h @@ -26,15 +26,6 @@ struct SwitchStatement : public Statement { , fSymbols(std::move(symbols)) , fCases(std::move(cases)) {} - std::unique_ptr<Statement> clone() const override { - std::vector<std::unique_ptr<SwitchCase>> cloned; - for (const auto& s : fCases) { - cloned.push_back(std::unique_ptr<SwitchCase>((SwitchCase*) s->clone().release())); - } - return std::unique_ptr<Statement>(new SwitchStatement(fOffset, fIsStatic, fValue->clone(), - std::move(cloned), fSymbols)); - } - String description() const override { String result; if (fIsStatic) { diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h index 412ed903bb..e713a323b3 100644 --- a/src/sksl/ir/SkSLSwizzle.h +++ b/src/sksl/ir/SkSLSwizzle.h @@ -127,10 +127,6 @@ struct Swizzle : public Expression { return fBase->hasSideEffects(); } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new Swizzle(fType, fBase->clone(), fComponents)); - } - String description() const override { String result = fBase->description() + "."; for (int x : fComponents) { @@ -143,16 +139,6 @@ struct Swizzle : public Expression { const std::vector<int> fComponents; typedef Expression INHERITED; - -private: - Swizzle(const Type& type, std::unique_ptr<Expression> base, std::vector<int> components) - : INHERITED(base->fOffset, kSwizzle_Kind, type) - , fBase(std::move(base)) - , fComponents(std::move(components)) { - SkASSERT(fComponents.size() >= 1 && fComponents.size() <= 4); - } - - }; } // namespace diff --git a/src/sksl/ir/SkSLTernaryExpression.h b/src/sksl/ir/SkSLTernaryExpression.h index f7e4ea0be6..b77e0e07f2 100644 --- a/src/sksl/ir/SkSLTernaryExpression.h +++ b/src/sksl/ir/SkSLTernaryExpression.h @@ -30,12 +30,6 @@ struct TernaryExpression : public Expression { return fTest->hasSideEffects() || fIfTrue->hasSideEffects() || fIfFalse->hasSideEffects(); } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new TernaryExpression(fOffset, fTest->clone(), - fIfTrue->clone(), - fIfFalse->clone())); - } - String description() const override { return "(" + fTest->description() + " ? " + fIfTrue->description() + " : " + fIfFalse->description() + ")"; diff --git a/src/sksl/ir/SkSLTypeReference.h b/src/sksl/ir/SkSLTypeReference.h index df3dc15abd..f7065b7c3f 100644 --- a/src/sksl/ir/SkSLTypeReference.h +++ b/src/sksl/ir/SkSLTypeReference.h @@ -18,9 +18,9 @@ namespace SkSL { * always eventually replaced by Constructors in valid programs. */ struct TypeReference : public Expression { - TypeReference(const Context& context, int offset, const Type& value) + TypeReference(const Context& context, int offset, const Type& type) : INHERITED(offset, kTypeReference_Kind, *context.fInvalid_Type) - , fValue(value) {} + , fValue(type) {} bool hasSideEffects() const override { return false; @@ -30,18 +30,9 @@ struct TypeReference : public Expression { return String(fValue.fName); } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new TypeReference(fOffset, fValue, &fType)); - } - const Type& fValue; typedef Expression INHERITED; - -private: - TypeReference(int offset, const Type& value, const Type* type) - : INHERITED(offset, kTypeReference_Kind, *type) - , fValue(value) {} }; } // namespace diff --git a/src/sksl/ir/SkSLVarDeclarations.h b/src/sksl/ir/SkSLVarDeclarations.h index b98e959ff0..707715f6dc 100644 --- a/src/sksl/ir/SkSLVarDeclarations.h +++ b/src/sksl/ir/SkSLVarDeclarations.h @@ -29,20 +29,7 @@ struct VarDeclaration : public Statement { , fSizes(std::move(sizes)) , fValue(std::move(value)) {} - std::unique_ptr<Statement> clone() const override { - std::vector<std::unique_ptr<Expression>> sizesClone; - for (const auto& s : fSizes) { - if (s) { - sizesClone.push_back(s->clone()); - } else { - sizesClone.push_back(nullptr); - } - } - return std::unique_ptr<Statement>(new VarDeclaration(fVar, std::move(sizesClone), - fValue ? fValue->clone() : nullptr)); - } - - String description() const override { + String description() const { String result = fVar->fName; for (const auto& size : fSizes) { if (size) { @@ -77,16 +64,6 @@ struct VarDeclarations : public ProgramElement { } } - std::unique_ptr<ProgramElement> clone() const override { - std::vector<std::unique_ptr<VarDeclaration>> cloned; - for (const auto& v : fVars) { - cloned.push_back(std::unique_ptr<VarDeclaration>( - (VarDeclaration*) v->clone().release())); - } - return std::unique_ptr<ProgramElement>(new VarDeclarations(fOffset, &fBaseType, - std::move(cloned))); - } - String description() const override { if (!fVars.size()) { return String(); diff --git a/src/sksl/ir/SkSLVarDeclarationsStatement.h b/src/sksl/ir/SkSLVarDeclarationsStatement.h index c9c1df175b..0258e66c6e 100644 --- a/src/sksl/ir/SkSLVarDeclarationsStatement.h +++ b/src/sksl/ir/SkSLVarDeclarationsStatement.h @@ -30,16 +30,11 @@ struct VarDeclarationsStatement : public Statement { return true; } - std::unique_ptr<Statement> clone() const override { - std::unique_ptr<VarDeclarations> cloned((VarDeclarations*) fDeclaration->clone().release()); - return std::unique_ptr<Statement>(new VarDeclarationsStatement(std::move(cloned))); - } - String description() const override { return fDeclaration->description() + ";"; } - std::unique_ptr<VarDeclarations> fDeclaration; + std::shared_ptr<VarDeclarations> fDeclaration; typedef Statement INHERITED; }; diff --git a/src/sksl/ir/SkSLVariableReference.cpp b/src/sksl/ir/SkSLVariableReference.cpp index e6092c940c..fa23e4749b 100644 --- a/src/sksl/ir/SkSLVariableReference.cpp +++ b/src/sksl/ir/SkSLVariableReference.cpp @@ -93,11 +93,6 @@ std::unique_ptr<Expression> VariableReference::constantPropagate(const IRGenerat if (fRefKind != kRead_RefKind) { return nullptr; } - if (irGenerator.fKind == Program::kPipelineStage_Kind && - fVariable.fStorage == Variable::kGlobal_Storage && - (fVariable.fModifiers.fFlags & Modifiers::kIn_Flag)) { - return irGenerator.getArg(fOffset, fVariable.fName); - } if ((fVariable.fModifiers.fFlags & Modifiers::kConst_Flag) && fVariable.fInitialValue && fVariable.fInitialValue->isConstant()) { return copy_constant(irGenerator, fVariable.fInitialValue); diff --git a/src/sksl/ir/SkSLVariableReference.h b/src/sksl/ir/SkSLVariableReference.h index 405a5d1f55..14ddf796ff 100644 --- a/src/sksl/ir/SkSLVariableReference.h +++ b/src/sksl/ir/SkSLVariableReference.h @@ -49,10 +49,6 @@ struct VariableReference : public Expression { return 0 != (fVariable.fModifiers.fFlags & Modifiers::kConst_Flag); } - std::unique_ptr<Expression> clone() const override { - return std::unique_ptr<Expression>(new VariableReference(fOffset, fVariable, fRefKind)); - } - String description() const override { return fVariable.fName; } diff --git a/src/sksl/ir/SkSLWhileStatement.h b/src/sksl/ir/SkSLWhileStatement.h index 6695875c03..aed6494999 100644 --- a/src/sksl/ir/SkSLWhileStatement.h +++ b/src/sksl/ir/SkSLWhileStatement.h @@ -23,11 +23,6 @@ struct WhileStatement : public Statement { , fTest(std::move(test)) , fStatement(std::move(statement)) {} - std::unique_ptr<Statement> clone() const override { - return std::unique_ptr<Statement>(new WhileStatement(fOffset, fTest->clone(), - fStatement->clone())); - } - String description() const override { return "while (" + fTest->description() + ") " + fStatement->description(); } |