Revert "moved SkSL Field data into IRNode"
This reverts commit 556b8bef61
.
Reason for revert: TSAN (& ASAN?) bots unhappy
Original change's description:
> moved SkSL Field data into IRNode
>
> Change-Id: Ib119035466a9d5dbd870e5b4e22f45f3b56455c4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321120
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
Change-Id: Ibc6b41c8cfc13d1d7fafc43ff643483da5a5f368
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321980
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
556b8bef61
commit
58384ad0a7
@ -162,20 +162,20 @@ SkRuntimeEffect::EffectResult SkRuntimeEffect::Make(SkString sksl) {
|
||||
|
||||
// Varyings (only used in conjunction with drawVertices)
|
||||
if (var.fModifiers.fFlags & SkSL::Modifiers::kVarying_Flag) {
|
||||
varyings.push_back({var.name(),
|
||||
varyings.push_back({var.fName,
|
||||
varType.typeKind() == SkSL::Type::TypeKind::kVector
|
||||
? varType.columns()
|
||||
: 1});
|
||||
}
|
||||
// Fragment Processors (aka 'shader'): These are child effects
|
||||
else if (&varType == ctx.fFragmentProcessor_Type.get()) {
|
||||
children.push_back(var.name());
|
||||
children.push_back(var.fName);
|
||||
sampleUsages.push_back(SkSL::Analysis::GetSampleUsage(*program, var));
|
||||
}
|
||||
// 'uniform' variables
|
||||
else if (var.fModifiers.fFlags & SkSL::Modifiers::kUniform_Flag) {
|
||||
Uniform uni;
|
||||
uni.fName = var.name();
|
||||
uni.fName = var.fName;
|
||||
uni.fFlags = 0;
|
||||
uni.fCount = 1;
|
||||
|
||||
@ -216,7 +216,7 @@ SkRuntimeEffect::EffectResult SkRuntimeEffect::Make(SkString sksl) {
|
||||
else if (elem.kind() == SkSL::ProgramElement::Kind::kFunction) {
|
||||
const auto& func = static_cast<const SkSL::FunctionDefinition&>(elem);
|
||||
const SkSL::FunctionDeclaration& decl = func.fDeclaration;
|
||||
if (decl.name() == "main") {
|
||||
if (decl.fName == "main") {
|
||||
hasMain = true;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace {
|
||||
|
||||
static bool is_sample_call_to_fp(const FunctionCall& fc, const Variable& fp) {
|
||||
const FunctionDeclaration& f = fc.fFunction;
|
||||
return f.fBuiltin && f.name() == "sample" && fc.fArguments.size() >= 1 &&
|
||||
return f.fBuiltin && f.fName == "sample" && fc.fArguments.size() >= 1 &&
|
||||
fc.fArguments[0]->is<VariableReference>() &&
|
||||
fc.fArguments[0]->as<VariableReference>().fVariable == &fp;
|
||||
}
|
||||
@ -244,7 +244,7 @@ public:
|
||||
if (var->fModifiers.fFlags & (Modifiers::kConst_Flag | Modifiers::kUniform_Flag |
|
||||
Modifiers::kVarying_Flag)) {
|
||||
fErrors->error(expr.fOffset,
|
||||
"cannot modify immutable variable '" + var->name() + "'");
|
||||
"cannot modify immutable variable '" + var->fName + "'");
|
||||
} else if (fAssignableVar) {
|
||||
SkASSERT(*fAssignableVar == nullptr);
|
||||
*fAssignableVar = &varRef;
|
||||
@ -269,7 +269,7 @@ public:
|
||||
const ExternalValue* var = expr.as<ExternalValueReference>().fValue;
|
||||
if (!var->canWrite()) {
|
||||
fErrors->error(expr.fOffset,
|
||||
"cannot modify immutable external value '" + var->name() + "'");
|
||||
"cannot modify immutable external value '" + var->fName + "'");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -17,20 +17,19 @@ static TypeCategory type_category(const Type& type) {
|
||||
case Type::TypeKind::kMatrix:
|
||||
return type_category(type.componentType());
|
||||
default:
|
||||
const StringFragment& name = type.name();
|
||||
if (name == "bool") {
|
||||
if (type.fName == "bool") {
|
||||
return TypeCategory::kBool;
|
||||
} else if (name == "int" ||
|
||||
name == "short" ||
|
||||
name == "$intLiteral") {
|
||||
} else if (type.fName == "int" ||
|
||||
type.fName == "short" ||
|
||||
type.fName == "$intLiteral") {
|
||||
return TypeCategory::kSigned;
|
||||
} else if (name == "uint" ||
|
||||
name == "ushort") {
|
||||
} else if (type.fName == "uint" ||
|
||||
type.fName == "ushort") {
|
||||
return TypeCategory::kUnsigned;
|
||||
} else {
|
||||
SkASSERT(name == "float" ||
|
||||
name == "half" ||
|
||||
name == "$floatLiteral");
|
||||
SkASSERT(type.fName == "float" ||
|
||||
type.fName == "half" ||
|
||||
type.fName == "$floatLiteral");
|
||||
return TypeCategory::kFloat;
|
||||
}
|
||||
ABORT("unsupported type: %s\n", type.displayName().c_str());
|
||||
@ -170,7 +169,7 @@ bool ByteCodeGenerator::generateCode() {
|
||||
continue;
|
||||
}
|
||||
if (is_uniform(*declVar)) {
|
||||
this->gatherUniforms(declVar->type(), declVar->name());
|
||||
this->gatherUniforms(declVar->type(), declVar->fName);
|
||||
} else {
|
||||
fOutput->fGlobalSlotCount += SlotCount(declVar->type());
|
||||
}
|
||||
@ -1032,10 +1031,10 @@ static bool is_generic_type(const Type* type, const Type* generic) {
|
||||
}
|
||||
|
||||
void ByteCodeGenerator::writeIntrinsicCall(const FunctionCall& c) {
|
||||
auto found = fIntrinsics.find(c.fFunction.name());
|
||||
auto found = fIntrinsics.find(c.fFunction.fName);
|
||||
if (found == fIntrinsics.end()) {
|
||||
fErrors.error(c.fOffset, String::printf("Unsupported intrinsic: '%s'",
|
||||
String(c.fFunction.name()).c_str()));
|
||||
String(c.fFunction.fName).c_str()));
|
||||
return;
|
||||
}
|
||||
Intrinsic intrin = found->second;
|
||||
@ -1839,7 +1838,7 @@ void ByteCodeGenerator::writeStatement(const Statement& s) {
|
||||
}
|
||||
|
||||
ByteCodeFunction::ByteCodeFunction(const FunctionDeclaration* declaration)
|
||||
: fName(declaration->name()) {
|
||||
: fName(declaration->fName) {
|
||||
fParameterCount = 0;
|
||||
for (const auto& p : declaration->fParameters) {
|
||||
int slots = ByteCodeGenerator::SlotCount(p->type());
|
||||
|
@ -116,7 +116,7 @@ void CPPCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
|
||||
}
|
||||
|
||||
static String default_value(const Type& type) {
|
||||
if (type.name() == "bool") {
|
||||
if (type.fName == "bool") {
|
||||
return "false";
|
||||
}
|
||||
switch (type.typeKind()) {
|
||||
@ -249,7 +249,7 @@ String CPPCodeGenerator::formatRuntimeValue(const Type& type,
|
||||
return type.name() + "(%d, %d, %d, %d)";
|
||||
}
|
||||
|
||||
SkDEBUGFAILF("unsupported runtime value type '%s'\n", String(type.name()).c_str());
|
||||
SkDEBUGFAILF("unsupported runtime value type '%s'\n", String(type.fName).c_str());
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ void CPPCodeGenerator::writeRuntimeValue(const Type& type, const Layout& layout,
|
||||
|
||||
void CPPCodeGenerator::writeVarInitializer(const Variable& var, const Expression& value) {
|
||||
if (is_private(var)) {
|
||||
this->writeRuntimeValue(var.type(), var.fModifiers.fLayout, var.name());
|
||||
this->writeRuntimeValue(var.type(), var.fModifiers.fLayout, var.fName);
|
||||
} else {
|
||||
this->writeExpression(value, kTopLevel_Precedence);
|
||||
}
|
||||
@ -309,7 +309,7 @@ void CPPCodeGenerator::setReturnType(int offset, ReturnType typeToSet) {
|
||||
|
||||
void CPPCodeGenerator::writeVariableReference(const VariableReference& ref) {
|
||||
if (fCPPMode) {
|
||||
this->write(ref.fVariable->name());
|
||||
this->write(ref.fVariable->fName);
|
||||
return;
|
||||
}
|
||||
switch (ref.fVariable->fModifiers.fLayout.fBuiltin) {
|
||||
@ -338,7 +338,7 @@ void CPPCodeGenerator::writeVariableReference(const VariableReference& ref) {
|
||||
}
|
||||
if (ref.fVariable->fModifiers.fFlags & Modifiers::kUniform_Flag) {
|
||||
this->write("%s");
|
||||
String name = ref.fVariable->name();
|
||||
String name = ref.fVariable->fName;
|
||||
String var = String::printf("args.fUniformHandler->getUniformCStr(%sVar)",
|
||||
HCodeGenerator::FieldName(name.c_str()).c_str());
|
||||
String code;
|
||||
@ -352,11 +352,11 @@ void CPPCodeGenerator::writeVariableReference(const VariableReference& ref) {
|
||||
}
|
||||
fFormatArgs.push_back(code);
|
||||
} else if (SectionAndParameterHelper::IsParameter(*ref.fVariable)) {
|
||||
String name(ref.fVariable->name());
|
||||
String name(ref.fVariable->fName);
|
||||
this->writeRuntimeValue(ref.fVariable->type(), ref.fVariable->fModifiers.fLayout,
|
||||
String::printf("_outer.%s", name.c_str()).c_str());
|
||||
} else {
|
||||
this->write(ref.fVariable->name());
|
||||
this->write(ref.fVariable->fName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -431,7 +431,7 @@ int CPPCodeGenerator::getChildFPIndex(const Variable& var) const {
|
||||
}
|
||||
|
||||
void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
if (c.fFunction.fBuiltin && c.fFunction.name() == "sample" &&
|
||||
if (c.fFunction.fBuiltin && c.fFunction.fName == "sample" &&
|
||||
c.fArguments[0]->type().typeKind() != Type::TypeKind::kSampler) {
|
||||
// Validity checks that are detected by function definition in sksl_fp.inc
|
||||
SkASSERT(c.fArguments.size() >= 1 && c.fArguments.size() <= 3);
|
||||
@ -501,7 +501,7 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
INHERITED::writeFunctionCall(c);
|
||||
} else {
|
||||
this->write("%s");
|
||||
fFormatArgs.push_back((String(c.fFunction.name()) + "_name.c_str()").c_str());
|
||||
fFormatArgs.push_back((String(c.fFunction.fName) + "_name.c_str()").c_str());
|
||||
this->write("(");
|
||||
const char* separator = "";
|
||||
for (const auto& arg : c.fArguments) {
|
||||
@ -511,7 +511,7 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
}
|
||||
this->write(")");
|
||||
}
|
||||
if (c.fFunction.fBuiltin && c.fFunction.name() == "sample") {
|
||||
if (c.fFunction.fBuiltin && c.fFunction.fName == "sample") {
|
||||
this->write(".%s");
|
||||
SkASSERT(c.fArguments.size() >= 1);
|
||||
SkASSERT(c.fArguments[0]->is<VariableReference>());
|
||||
@ -603,7 +603,7 @@ void CPPCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
OutputStream* oldOut = fOut;
|
||||
StringStream buffer;
|
||||
fOut = &buffer;
|
||||
if (decl.name() == "main") {
|
||||
if (decl.fName == "main") {
|
||||
fInMain = true;
|
||||
for (const std::unique_ptr<Statement>& s : f.fBody->as<Block>().children()) {
|
||||
this->writeStatement(*s);
|
||||
@ -615,11 +615,11 @@ void CPPCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
this->write(fFunctionHeader);
|
||||
this->write(buffer.str());
|
||||
} else {
|
||||
this->addExtraEmitCodeLine("SkString " + decl.name() + "_name;");
|
||||
String args = "const GrShaderVar " + decl.name() + "_args[] = { ";
|
||||
this->addExtraEmitCodeLine("SkString " + decl.fName + "_name;");
|
||||
String args = "const GrShaderVar " + decl.fName + "_args[] = { ";
|
||||
const char* separator = "";
|
||||
for (const Variable* param : decl.fParameters) {
|
||||
args += String(separator) + "GrShaderVar(\"" + param->name() + "\", " +
|
||||
args += String(separator) + "GrShaderVar(\"" + param->fName + "\", " +
|
||||
glsltype_string(fContext, param->type()) + ")";
|
||||
separator = ", ";
|
||||
}
|
||||
@ -633,11 +633,11 @@ void CPPCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
fOut = oldOut;
|
||||
String emit = "fragBuilder->emitFunction(";
|
||||
emit += glsltype_string(fContext, decl.fReturnType);
|
||||
emit += ", \"" + decl.name() + "\"";
|
||||
emit += ", \"" + decl.fName + "\"";
|
||||
emit += ", " + to_string((int64_t) decl.fParameters.size());
|
||||
emit += ", " + decl.name() + "_args";
|
||||
emit += ", " + decl.fName + "_args";
|
||||
emit += ",\nR\"SkSL(" + buffer.str() + ")SkSL\"";
|
||||
emit += ", &" + decl.name() + "_name);";
|
||||
emit += ", &" + decl.fName + "_name);";
|
||||
this->addExtraEmitCodeLine(emit.c_str());
|
||||
}
|
||||
}
|
||||
@ -684,7 +684,7 @@ void CPPCodeGenerator::addUniform(const Variable& var) {
|
||||
if (var.fModifiers.fLayout.fWhen.fLength) {
|
||||
this->writef(" if (%s) {\n ", String(var.fModifiers.fLayout.fWhen).c_str());
|
||||
}
|
||||
String name(var.name());
|
||||
String name(var.fName);
|
||||
if (var.type().typeKind() != Type::TypeKind::kArray) {
|
||||
this->writef(" %sVar = args.fUniformHandler->addUniform(&_outer, "
|
||||
"kFragment_GrShaderFlag, %s, \"%s\");\n",
|
||||
@ -722,7 +722,7 @@ void CPPCodeGenerator::writePrivateVars() {
|
||||
this->writef("%s %s = %s;\n",
|
||||
HCodeGenerator::FieldType(fContext, decl.fVar->type(),
|
||||
decl.fVar->fModifiers.fLayout).c_str(),
|
||||
String(decl.fVar->name()).c_str(),
|
||||
String(decl.fVar->fName).c_str(),
|
||||
default_value(*decl.fVar).c_str());
|
||||
} else if (decl.fVar->fModifiers.fLayout.fFlags & Layout::kTracked_Flag) {
|
||||
// An auto-tracked uniform in variable, so add a field to hold onto the prior
|
||||
@ -731,7 +731,7 @@ void CPPCodeGenerator::writePrivateVars() {
|
||||
const UniformCTypeMapper* mapper = UniformCTypeMapper::Get(fContext, *decl.fVar);
|
||||
SkASSERT(mapper && mapper->supportsTracking());
|
||||
|
||||
String name = HCodeGenerator::FieldName(String(decl.fVar->name()).c_str());
|
||||
String name = HCodeGenerator::FieldName(String(decl.fVar->fName).c_str());
|
||||
// The member statement is different if the mapper reports a default value
|
||||
if (mapper->defaultValue().size() > 0) {
|
||||
this->writef("%s %sPrev = %s;\n",
|
||||
@ -754,7 +754,7 @@ void CPPCodeGenerator::writePrivateVarValues() {
|
||||
for (const auto& raw : decls.fVars) {
|
||||
VarDeclaration& decl = raw->as<VarDeclaration>();
|
||||
if (is_private(*decl.fVar) && decl.fValue) {
|
||||
this->writef("%s = ", String(decl.fVar->name()).c_str());
|
||||
this->writef("%s = ", String(decl.fVar->fName).c_str());
|
||||
fCPPMode = true;
|
||||
this->writeExpression(*decl.fValue, kAssignment_Precedence);
|
||||
fCPPMode = false;
|
||||
@ -970,7 +970,7 @@ bool CPPCodeGenerator::writeEmitCode(std::vector<const Variable*>& uniforms) {
|
||||
const VarDeclarations& decls = p.as<VarDeclarations>();
|
||||
for (const auto& raw : decls.fVars) {
|
||||
VarDeclaration& decl = raw->as<VarDeclaration>();
|
||||
String nameString(decl.fVar->name());
|
||||
String nameString(decl.fVar->fName);
|
||||
const char* name = nameString.c_str();
|
||||
if (SectionAndParameterHelper::IsParameter(*decl.fVar) &&
|
||||
is_accessible(*decl.fVar)) {
|
||||
@ -1022,7 +1022,7 @@ void CPPCodeGenerator::writeSetData(std::vector<const Variable*>& uniforms) {
|
||||
const UniformCTypeMapper* mapper = UniformCTypeMapper::Get(fContext, *u);
|
||||
SkASSERT(mapper);
|
||||
|
||||
String nameString(u->name());
|
||||
String nameString(u->fName);
|
||||
const char* name = nameString.c_str();
|
||||
|
||||
// Switches for setData behavior in the generated code
|
||||
@ -1087,7 +1087,7 @@ void CPPCodeGenerator::writeSetData(std::vector<const Variable*>& uniforms) {
|
||||
for (const std::unique_ptr<Statement>& raw : decls.fVars) {
|
||||
const VarDeclaration& decl = raw->as<VarDeclaration>();
|
||||
const Variable& variable = *decl.fVar;
|
||||
String nameString(variable.name());
|
||||
String nameString(variable.fName);
|
||||
const char* name = nameString.c_str();
|
||||
if (variable.type().typeKind() == Type::TypeKind::kSampler) {
|
||||
this->writef(" const GrSurfaceProxyView& %sView = "
|
||||
@ -1133,11 +1133,11 @@ void CPPCodeGenerator::writeOnTextureSampler() {
|
||||
"index) const {\n",
|
||||
fFullName.c_str());
|
||||
this->writef(" return IthTextureSampler(index, %s",
|
||||
HCodeGenerator::FieldName(String(param->name()).c_str()).c_str());
|
||||
HCodeGenerator::FieldName(String(param->fName).c_str()).c_str());
|
||||
foundSampler = true;
|
||||
} else {
|
||||
this->writef(", %s",
|
||||
HCodeGenerator::FieldName(String(param->name()).c_str()).c_str());
|
||||
HCodeGenerator::FieldName(String(param->fName).c_str()).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1156,7 +1156,7 @@ void CPPCodeGenerator::writeClone() {
|
||||
": INHERITED(k%s_ClassID, src.optimizationFlags())", fFullName.c_str(),
|
||||
fFullName.c_str(), fFullName.c_str(), fFullName.c_str());
|
||||
for (const Variable* param : fSectionAndParameterHelper.getParameters()) {
|
||||
String fieldName = HCodeGenerator::FieldName(String(param->name()).c_str());
|
||||
String fieldName = HCodeGenerator::FieldName(String(param->fName).c_str());
|
||||
if (param->type().nonnullable() != *fContext.fFragmentProcessor_Type) {
|
||||
this->writef("\n, %s(src.%s)",
|
||||
fieldName.c_str(),
|
||||
@ -1206,10 +1206,10 @@ void CPPCodeGenerator::writeDumpInfo() {
|
||||
}
|
||||
|
||||
// Add this field onto the format string and argument list.
|
||||
String fieldName = HCodeGenerator::FieldName(String(param->name()).c_str());
|
||||
String fieldName = HCodeGenerator::FieldName(String(param->fName).c_str());
|
||||
String runtimeValue = this->formatRuntimeValue(param->type(),
|
||||
param->fModifiers.fLayout,
|
||||
param->name(),
|
||||
param->fName,
|
||||
&argumentList);
|
||||
formatString.appendf("%s%s=%s",
|
||||
formatString.empty() ? "" : ", ",
|
||||
@ -1264,7 +1264,7 @@ void CPPCodeGenerator::writeGetKey() {
|
||||
const VarDeclaration& decl = raw->as<VarDeclaration>();
|
||||
const Variable& var = *decl.fVar;
|
||||
const Type& varType = var.type();
|
||||
String nameString(var.name());
|
||||
String nameString(var.fName);
|
||||
const char* name = nameString.c_str();
|
||||
if (var.fModifiers.fLayout.fKey != Layout::kNo_Key &&
|
||||
(var.fModifiers.fFlags & Modifiers::kUniform_Flag)) {
|
||||
@ -1277,7 +1277,7 @@ void CPPCodeGenerator::writeGetKey() {
|
||||
this->writef("%s %s =",
|
||||
HCodeGenerator::FieldType(fContext, varType,
|
||||
var.fModifiers.fLayout).c_str(),
|
||||
String(var.name()).c_str());
|
||||
String(var.fName).c_str());
|
||||
if (decl.fValue) {
|
||||
fCPPMode = true;
|
||||
this->writeExpression(*decl.fValue, kAssignment_Precedence);
|
||||
@ -1352,13 +1352,13 @@ bool CPPCodeGenerator::generateCode() {
|
||||
const UniformCTypeMapper* mapper =
|
||||
UniformCTypeMapper::Get(fContext, *decl.fVar);
|
||||
if (mapper == nullptr) {
|
||||
fErrors.error(decl.fOffset, String(decl.fVar->name())
|
||||
fErrors.error(decl.fOffset, String(decl.fVar->fName)
|
||||
+ "'s type is not supported for use as a 'uniform in'");
|
||||
return false;
|
||||
}
|
||||
if (decl.fVar->fModifiers.fLayout.fFlags & Layout::kTracked_Flag) {
|
||||
if (!mapper->supportsTracking()) {
|
||||
fErrors.error(decl.fOffset, String(decl.fVar->name())
|
||||
fErrors.error(decl.fOffset, String(decl.fVar->fName)
|
||||
+ "'s type does not support state tracking");
|
||||
return false;
|
||||
}
|
||||
@ -1398,13 +1398,13 @@ bool CPPCodeGenerator::generateCode() {
|
||||
for (const auto& u : uniforms) {
|
||||
if (needs_uniform_var(*u) && !(u->fModifiers.fFlags & Modifiers::kIn_Flag)) {
|
||||
this->writef(" UniformHandle %sVar;\n",
|
||||
HCodeGenerator::FieldName(String(u->name()).c_str()).c_str());
|
||||
HCodeGenerator::FieldName(String(u->fName).c_str()).c_str());
|
||||
}
|
||||
}
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (needs_uniform_var(*param)) {
|
||||
this->writef(" UniformHandle %sVar;\n",
|
||||
HCodeGenerator::FieldName(String(param->name()).c_str()).c_str());
|
||||
HCodeGenerator::FieldName(String(param->fName).c_str()).c_str());
|
||||
}
|
||||
}
|
||||
this->writef("};\n"
|
||||
@ -1421,7 +1421,7 @@ bool CPPCodeGenerator::generateCode() {
|
||||
if (param->type().nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
continue;
|
||||
}
|
||||
String nameString(param->name());
|
||||
String nameString(param->fName);
|
||||
const char* name = nameString.c_str();
|
||||
this->writef(" if (%s != that.%s) return false;\n",
|
||||
HCodeGenerator::FieldName(name).c_str(),
|
||||
|
@ -95,7 +95,7 @@ static void grab_intrinsics(std::vector<std::unique_ptr<ProgramElement>>* src,
|
||||
const VarDeclarations& vd = element->as<VarDeclarations>();
|
||||
SkASSERT(vd.fVars.size() == 1);
|
||||
const Variable* var = vd.fVars[0]->as<VarDeclaration>().fVar;
|
||||
target->insertOrDie(var->name(), std::move(element));
|
||||
target->insertOrDie(var->fName, std::move(element));
|
||||
iter = src->erase(iter);
|
||||
break;
|
||||
}
|
||||
@ -126,7 +126,7 @@ Compiler::Compiler(Flags flags)
|
||||
fRootSymbolTable = std::make_shared<SymbolTable>(this);
|
||||
fIRGenerator =
|
||||
std::make_unique<IRGenerator>(fContext.get(), &fInliner, fRootSymbolTable, *this);
|
||||
#define ADD_TYPE(t) fRootSymbolTable->addWithoutOwnership(fContext->f ## t ## _Type->name(), \
|
||||
#define ADD_TYPE(t) fRootSymbolTable->addWithoutOwnership(fContext->f ## t ## _Type->fName, \
|
||||
fContext->f ## t ## _Type.get())
|
||||
ADD_TYPE(Void);
|
||||
ADD_TYPE(Float);
|
||||
@ -919,7 +919,7 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
|
||||
(*undefinedVariables).find(var) == (*undefinedVariables).end()) {
|
||||
(*undefinedVariables).insert(var);
|
||||
this->error(expr->fOffset,
|
||||
"'" + var->name() + "' has not been assigned");
|
||||
"'" + var->fName + "' has not been assigned");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1596,7 +1596,7 @@ bool Compiler::scanCFG(FunctionDefinition& f) {
|
||||
// check for missing return
|
||||
if (f.fDeclaration.fReturnType != *fContext->fVoid_Type) {
|
||||
if (cfg.fBlocks[cfg.fExit].fIsReachable) {
|
||||
this->error(f.fOffset, String("function '" + String(f.fDeclaration.name()) +
|
||||
this->error(f.fOffset, String("function '" + String(f.fDeclaration.fName) +
|
||||
"' can exit without returning a value"));
|
||||
}
|
||||
}
|
||||
@ -1656,7 +1656,7 @@ std::unique_ptr<Program> Compiler::convertProgram(
|
||||
// Add any external values to the symbol table. IRGenerator::start() has pushed a table, so
|
||||
// we're only making these visible to the current Program.
|
||||
for (const auto& ev : *externalValues) {
|
||||
fIRGenerator->fSymbolTable->addWithoutOwnership(ev->name(), ev.get());
|
||||
fIRGenerator->fSymbolTable->addWithoutOwnership(ev->fName, ev.get());
|
||||
}
|
||||
}
|
||||
std::unique_ptr<String> textPtr(new String(std::move(text)));
|
||||
@ -1710,7 +1710,7 @@ bool Compiler::optimize(Program& program) {
|
||||
}
|
||||
const auto& fn = element->as<FunctionDefinition>();
|
||||
bool dead = fn.fDeclaration.fCallCount == 0 &&
|
||||
fn.fDeclaration.name() != "main";
|
||||
fn.fDeclaration.fName != "main";
|
||||
madeChanges |= dead;
|
||||
return dead;
|
||||
}),
|
||||
|
@ -149,7 +149,7 @@ void Dehydrator::write(const Symbol& s) {
|
||||
this->writeU8(Rehydrator::kFunctionDeclaration_Command);
|
||||
this->writeId(&f);
|
||||
this->write(f.fModifiers);
|
||||
this->write(f.name());
|
||||
this->write(f.fName);
|
||||
this->writeU8(f.fParameters.size());
|
||||
for (const Variable* p : f.fParameters) {
|
||||
this->writeU16(this->symbolId(p));
|
||||
@ -179,7 +179,7 @@ void Dehydrator::write(const Symbol& s) {
|
||||
case Type::TypeKind::kEnum:
|
||||
this->writeU8(Rehydrator::kEnumType_Command);
|
||||
this->writeId(&t);
|
||||
this->write(t.name());
|
||||
this->write(t.fName);
|
||||
break;
|
||||
case Type::TypeKind::kNullable:
|
||||
this->writeU8(Rehydrator::kNullableType_Command);
|
||||
@ -189,7 +189,7 @@ void Dehydrator::write(const Symbol& s) {
|
||||
case Type::TypeKind::kStruct:
|
||||
this->writeU8(Rehydrator::kStructType_Command);
|
||||
this->writeId(&t);
|
||||
this->write(t.name());
|
||||
this->write(t.fName);
|
||||
this->writeU8(t.fields().size());
|
||||
for (const Type::Field& f : t.fields()) {
|
||||
this->write(f.fModifiers);
|
||||
@ -200,7 +200,7 @@ void Dehydrator::write(const Symbol& s) {
|
||||
default:
|
||||
this->writeU8(Rehydrator::kSystemType_Command);
|
||||
this->writeId(&t);
|
||||
this->write(t.name());
|
||||
this->write(t.fName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -209,7 +209,7 @@ void Dehydrator::write(const Symbol& s) {
|
||||
this->writeU8(Rehydrator::kVariable_Command);
|
||||
this->writeId(&v);
|
||||
this->write(v.fModifiers);
|
||||
this->write(v.name());
|
||||
this->write(v.fName);
|
||||
this->write(v.type());
|
||||
this->writeU8(v.fStorage);
|
||||
break;
|
||||
@ -217,8 +217,8 @@ void Dehydrator::write(const Symbol& s) {
|
||||
case Symbol::Kind::kField: {
|
||||
const Field& f = s.as<Field>();
|
||||
this->writeU8(Rehydrator::kField_Command);
|
||||
this->writeU16(this->symbolId(&f.owner()));
|
||||
this->writeU8(f.fieldIndex());
|
||||
this->writeU16(this->symbolId(&f.fOwner));
|
||||
this->writeU8(f.fFieldIndex);
|
||||
break;
|
||||
}
|
||||
case Symbol::Kind::kExternal:
|
||||
|
@ -24,7 +24,7 @@ namespace SkSL {
|
||||
struct Expression;
|
||||
struct ProgramElement;
|
||||
struct Statement;
|
||||
class Symbol;
|
||||
struct Symbol;
|
||||
class SymbolTable;
|
||||
|
||||
// The file has the structure:
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
return String("external<") + this->name() + ">";
|
||||
return String("external<") + fName + ">";
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -161,13 +161,13 @@ void GLSLCodeGenerator::writeType(const Type& type) {
|
||||
for (const Type* search : fWrittenStructs) {
|
||||
if (*search == type) {
|
||||
// already written
|
||||
this->write(type.name());
|
||||
this->write(type.fName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
fWrittenStructs.push_back(&type);
|
||||
this->write("struct ");
|
||||
this->write(type.name());
|
||||
this->write(type.fName);
|
||||
this->writeLine(" {");
|
||||
fIndentation++;
|
||||
for (const auto& f : type.fields()) {
|
||||
@ -242,7 +242,7 @@ static bool is_abs(Expression& expr) {
|
||||
if (expr.kind() != Expression::Kind::kFunctionCall) {
|
||||
return false;
|
||||
}
|
||||
return expr.as<FunctionCall>().fFunction.name() == "abs";
|
||||
return expr.as<FunctionCall>().fFunction.fName == "abs";
|
||||
}
|
||||
|
||||
// turns min(abs(x), y) into ((tmpVar1 = abs(x)) < (tmpVar2 = y) ? tmpVar1 : tmpVar2) to avoid a
|
||||
@ -480,7 +480,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
#ifndef SKSL_STANDALONE
|
||||
);
|
||||
#endif
|
||||
const auto found = c.fFunction.fBuiltin ? fFunctionClasses->find(c.fFunction.name()) :
|
||||
const auto found = c.fFunction.fBuiltin ? fFunctionClasses->find(c.fFunction.fName) :
|
||||
fFunctionClasses->end();
|
||||
bool isTextureFunctionWithBias = false;
|
||||
bool nameWritten = false;
|
||||
@ -700,7 +700,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
}
|
||||
}
|
||||
if (!nameWritten) {
|
||||
this->write(c.fFunction.name());
|
||||
this->write(c.fFunction.fName);
|
||||
}
|
||||
this->write("(");
|
||||
const char* separator = "";
|
||||
@ -822,7 +822,7 @@ void GLSLCodeGenerator::writeVariableReference(const VariableReference& ref) {
|
||||
this->write(fProgram.fSettings.fCaps->fbFetchColorName());
|
||||
break;
|
||||
default:
|
||||
this->write(ref.fVariable->name());
|
||||
this->write(ref.fVariable->fName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1042,7 +1042,7 @@ void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
|
||||
this->writeTypePrecision(f.fDeclaration.fReturnType);
|
||||
this->writeType(f.fDeclaration.fReturnType);
|
||||
this->write(" " + f.fDeclaration.name() + "(");
|
||||
this->write(" " + f.fDeclaration.fName + "(");
|
||||
const char* separator = "";
|
||||
for (const auto& param : f.fDeclaration.fParameters) {
|
||||
this->write(separator);
|
||||
@ -1056,7 +1056,7 @@ void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
}
|
||||
this->writeTypePrecision(*type);
|
||||
this->writeType(*type);
|
||||
this->write(" " + param->name());
|
||||
this->write(" " + param->fName);
|
||||
for (int s : sizes) {
|
||||
if (s == Type::kUnsizedArray) {
|
||||
this->write("[]");
|
||||
@ -1257,7 +1257,7 @@ void GLSLCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, bool g
|
||||
this->write(" ");
|
||||
wroteType = true;
|
||||
}
|
||||
this->write(var.fVar->name());
|
||||
this->write(var.fVar->fName);
|
||||
for (const auto& size : var.fSizes) {
|
||||
this->write("[");
|
||||
if (size) {
|
||||
|
@ -191,7 +191,7 @@ void HCodeGenerator::writeMake() {
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
this->writef("%s%s %s", separator, ParameterType(fContext, param->type(),
|
||||
param->fModifiers.fLayout).c_str(),
|
||||
String(param->name()).c_str());
|
||||
String(param->fName).c_str());
|
||||
separator = ", ";
|
||||
}
|
||||
this->writeSection(kConstructorParamsSection, separator);
|
||||
@ -202,9 +202,9 @@ void HCodeGenerator::writeMake() {
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (param->type().nonnullable() == *fContext.fFragmentProcessor_Type ||
|
||||
param->type().nonnullable().typeKind() == Type::TypeKind::kSampler) {
|
||||
this->writef("%sstd::move(%s)", separator, String(param->name()).c_str());
|
||||
this->writef("%sstd::move(%s)", separator, String(param->fName).c_str());
|
||||
} else {
|
||||
this->writef("%s%s", separator, String(param->name()).c_str());
|
||||
this->writef("%s%s", separator, String(param->fName).c_str());
|
||||
}
|
||||
separator = ", ";
|
||||
}
|
||||
@ -235,7 +235,7 @@ void HCodeGenerator::writeConstructor() {
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
this->writef("%s%s %s", separator, ParameterType(fContext, param->type(),
|
||||
param->fModifiers.fLayout).c_str(),
|
||||
String(param->name()).c_str());
|
||||
String(param->fName).c_str());
|
||||
separator = ", ";
|
||||
}
|
||||
this->writeSection(kConstructorParamsSection, separator);
|
||||
@ -247,7 +247,7 @@ void HCodeGenerator::writeConstructor() {
|
||||
this->writef(")");
|
||||
this->writeSection(kInitializersSection, "\n , ");
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String nameString(param->name());
|
||||
String nameString(param->fName);
|
||||
const char* name = nameString.c_str();
|
||||
const Type& type = param->type().nonnullable();
|
||||
if (type.typeKind() == Type::TypeKind::kSampler) {
|
||||
@ -279,7 +279,7 @@ void HCodeGenerator::writeConstructor() {
|
||||
++samplerCount;
|
||||
} else if (paramType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
if (paramType.typeKind() != Type::TypeKind::kNullable) {
|
||||
this->writef(" SkASSERT(%s);", String(param->name()).c_str());
|
||||
this->writef(" SkASSERT(%s);", String(param->fName).c_str());
|
||||
}
|
||||
|
||||
SampleUsage usage = Analysis::GetSampleUsage(fProgram, *param);
|
||||
@ -288,7 +288,7 @@ void HCodeGenerator::writeConstructor() {
|
||||
if (usage.hasUniformMatrix()) {
|
||||
for (const Variable* p : fSectionAndParameterHelper.getParameters()) {
|
||||
if ((p->fModifiers.fFlags & Modifiers::kIn_Flag) &&
|
||||
usage.fExpression == String(p->name())) {
|
||||
usage.fExpression == String(p->fName)) {
|
||||
perspExpression = usage.fExpression + ".hasPerspective()";
|
||||
break;
|
||||
}
|
||||
@ -297,7 +297,7 @@ void HCodeGenerator::writeConstructor() {
|
||||
std::string usageArg = usage.constructor(std::move(perspExpression));
|
||||
|
||||
this->writef(" this->registerChild(std::move(%s), %s);",
|
||||
String(param->name()).c_str(),
|
||||
String(param->fName).c_str(),
|
||||
usageArg.c_str());
|
||||
}
|
||||
}
|
||||
@ -310,7 +310,7 @@ void HCodeGenerator::writeConstructor() {
|
||||
void HCodeGenerator::writeFields() {
|
||||
this->writeSection(kFieldsSection);
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String name = FieldName(String(param->name()).c_str());
|
||||
String name = FieldName(String(param->fName).c_str());
|
||||
if (param->type().nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
// Don't need to write any fields, FPs are held as children
|
||||
} else {
|
||||
|
@ -186,7 +186,7 @@ void IRGenerator::start(const Program::Settings* settings,
|
||||
for (const auto& e : *inherited) {
|
||||
if (e->kind() == ProgramElement::Kind::kInterfaceBlock) {
|
||||
InterfaceBlock& intf = e->as<InterfaceBlock>();
|
||||
if (intf.fVariable.name() == Compiler::PERVERTEX_NAME) {
|
||||
if (intf.fVariable.fName == Compiler::PERVERTEX_NAME) {
|
||||
SkASSERT(!fSkPerVertex);
|
||||
fSkPerVertex = &intf.fVariable;
|
||||
}
|
||||
@ -245,7 +245,7 @@ std::unique_ptr<Statement> IRGenerator::convertSingleStatement(const ASTNode& st
|
||||
Expression& expr = *result->as<ExpressionStatement>().expression();
|
||||
if (expr.kind() == Expression::Kind::kFunctionCall) {
|
||||
FunctionCall& fc = expr.as<FunctionCall>();
|
||||
if (fc.fFunction.fBuiltin && fc.fFunction.name() == "EmitVertex") {
|
||||
if (fc.fFunction.fBuiltin && fc.fFunction.fName == "EmitVertex") {
|
||||
std::vector<std::unique_ptr<Statement>> statements;
|
||||
statements.push_back(getNormalizeSkPositionCode());
|
||||
statements.push_back(std::move(result));
|
||||
@ -417,7 +417,7 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTNo
|
||||
if (!size) {
|
||||
return nullptr;
|
||||
}
|
||||
String name(type->name());
|
||||
String name(type->fName);
|
||||
int64_t count;
|
||||
if (size->kind() == Expression::Kind::kIntLiteral) {
|
||||
count = size->as<IntLiteral>().value();
|
||||
@ -441,7 +441,7 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTNo
|
||||
}
|
||||
auto var = std::make_unique<Variable>(varDecl.fOffset, modifiers, varData.fName, type,
|
||||
fIsBuiltinCode, storage);
|
||||
if (var->name() == Compiler::RTADJUST_NAME) {
|
||||
if (var->fName == Compiler::RTADJUST_NAME) {
|
||||
SkASSERT(!fRTAdjust);
|
||||
SkASSERT(var->type() == *fContext.fFloat4_Type);
|
||||
fRTAdjust = var.get();
|
||||
@ -459,8 +459,8 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTNo
|
||||
var->fWriteCount = 1;
|
||||
var->fInitialValue = value.get();
|
||||
}
|
||||
const Symbol* symbol = (*fSymbolTable)[var->name()];
|
||||
if (symbol && storage == Variable::kGlobal_Storage && var->name() == "sk_FragColor") {
|
||||
const Symbol* symbol = (*fSymbolTable)[var->fName];
|
||||
if (symbol && storage == Variable::kGlobal_Storage && var->fName == "sk_FragColor") {
|
||||
// Already defined, ignore.
|
||||
} else if (symbol && storage == Variable::kGlobal_Storage &&
|
||||
symbol->kind() == Symbol::Kind::kVariable &&
|
||||
@ -470,7 +470,7 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTNo
|
||||
} else {
|
||||
variables.emplace_back(std::make_unique<VarDeclaration>(var.get(), std::move(sizes),
|
||||
std::move(value)));
|
||||
StringFragment name = var->name();
|
||||
StringFragment name = var->fName;
|
||||
fSymbolTable->add(name, std::move(var));
|
||||
}
|
||||
}
|
||||
@ -706,7 +706,7 @@ std::unique_ptr<Statement> IRGenerator::convertReturn(const ASTNode& r) {
|
||||
// early returns from a vertex main function will bypass the sk_Position normalization, so
|
||||
// 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.
|
||||
SkASSERT(Program::kVertex_Kind != fKind || !fRTAdjust || "main" != fCurrentFunction->name());
|
||||
SkASSERT(Program::kVertex_Kind != fKind || !fRTAdjust || "main" != fCurrentFunction->fName);
|
||||
if (r.begin() != r.end()) {
|
||||
std::unique_ptr<Expression> result = this->convertExpression(*r.begin());
|
||||
if (!result) {
|
||||
@ -1011,7 +1011,7 @@ void IRGenerator::convertFunction(const ASTNode& f) {
|
||||
return;
|
||||
}
|
||||
for (const FunctionDeclaration* other : functions) {
|
||||
SkASSERT(other->name() == funcData.fName);
|
||||
SkASSERT(other->fName == funcData.fName);
|
||||
if (parameters.size() == other->fParameters.size()) {
|
||||
bool match = true;
|
||||
for (size_t i = 0; i < parameters.size(); i++) {
|
||||
@ -1076,7 +1076,7 @@ void IRGenerator::convertFunction(const ASTNode& f) {
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < parameters.size(); i++) {
|
||||
fSymbolTable->addWithoutOwnership(parameters[i]->name(), decl->fParameters[i]);
|
||||
fSymbolTable->addWithoutOwnership(parameters[i]->fName, decl->fParameters[i]);
|
||||
}
|
||||
bool needInvocationIDWorkaround = fInvocations != -1 && funcData.fName == "main" &&
|
||||
fSettings->fCaps &&
|
||||
@ -1136,7 +1136,7 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTNode
|
||||
SkASSERT(vd.fVar->type() == *fContext.fFloat4_Type);
|
||||
fRTAdjustFieldIndex = fields.size();
|
||||
}
|
||||
fields.push_back(Type::Field(vd.fVar->fModifiers, vd.fVar->name(),
|
||||
fields.push_back(Type::Field(vd.fVar->fModifiers, vd.fVar->fName,
|
||||
&vd.fVar->type()));
|
||||
if (vd.fValue) {
|
||||
fErrors.error(decl->fOffset,
|
||||
@ -1159,7 +1159,7 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTNode
|
||||
if (!converted) {
|
||||
return nullptr;
|
||||
}
|
||||
String name = type->name();
|
||||
String name = type->fName;
|
||||
int64_t count;
|
||||
if (converted->kind() == Expression::Kind::kIntLiteral) {
|
||||
count = converted->as<IntLiteral>().value();
|
||||
@ -1176,7 +1176,7 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTNode
|
||||
std::make_unique<Type>(name, Type::TypeKind::kArray, *type, (int)count));
|
||||
sizes.push_back(std::move(converted));
|
||||
} else {
|
||||
String name = String(type->name()) + "[]";
|
||||
String name = String(type->fName) + "[]";
|
||||
type = symbols->takeOwnershipOfSymbol(std::make_unique<Type>(
|
||||
name, Type::TypeKind::kArray, *type, Type::kUnsizedArray));
|
||||
sizes.push_back(nullptr);
|
||||
@ -1196,7 +1196,7 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTNode
|
||||
old->addWithoutOwnership(id.fInstanceName, var);
|
||||
} else {
|
||||
for (size_t i = 0; i < fields.size(); i++) {
|
||||
old->add(fields[i].fName, std::make_unique<Field>(intf.fOffset, var, (int)i));
|
||||
old->add(fields[i].fName, std::make_unique<Field>(intf.fOffset, *var, (int)i));
|
||||
}
|
||||
}
|
||||
return std::make_unique<InterfaceBlock>(intf.fOffset,
|
||||
@ -1280,8 +1280,7 @@ const Type* IRGenerator::convertType(const ASTNode& type, bool allowVoid) {
|
||||
"an array");
|
||||
}
|
||||
result = fSymbolTable->takeOwnershipOfSymbol(std::make_unique<Type>(
|
||||
String(result->name()) + "?", Type::TypeKind::kNullable,
|
||||
result->as<Type>()));
|
||||
String(result->fName) + "?", Type::TypeKind::kNullable, result->as<Type>()));
|
||||
} else {
|
||||
fErrors.error(type.fOffset, "type '" + td.fName + "' may not be nullable");
|
||||
}
|
||||
@ -1297,7 +1296,7 @@ const Type* IRGenerator::convertType(const ASTNode& type, bool allowVoid) {
|
||||
}
|
||||
}
|
||||
for (const auto& size : type) {
|
||||
String name(result->name());
|
||||
String name(result->fName);
|
||||
name += "[";
|
||||
if (size) {
|
||||
name += to_string(size.getInt());
|
||||
@ -1419,11 +1418,11 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTNode& identi
|
||||
}
|
||||
case Symbol::Kind::kField: {
|
||||
const Field* field = &result->as<Field>();
|
||||
VariableReference* base = new VariableReference(identifier.fOffset, &field->owner(),
|
||||
VariableReference* base = new VariableReference(identifier.fOffset, &field->fOwner,
|
||||
VariableReference::kRead_RefKind);
|
||||
return std::unique_ptr<Expression>(new FieldAccess(
|
||||
std::unique_ptr<Expression>(base),
|
||||
field->fieldIndex(),
|
||||
field->fFieldIndex,
|
||||
FieldAccess::kAnonymousInterfaceBlock_OwnerKind));
|
||||
}
|
||||
case Symbol::Kind::kType: {
|
||||
@ -1480,10 +1479,10 @@ std::unique_ptr<Expression> IRGenerator::coerce(std::unique_ptr<Expression> expr
|
||||
"int"));
|
||||
} else {
|
||||
ctor = this->convertIdentifier(ASTNode(&fFile->fNodes, -1, ASTNode::Kind::kIdentifier,
|
||||
type.name()));
|
||||
type.fName));
|
||||
}
|
||||
if (!ctor) {
|
||||
printf("error, null identifier: %s\n", String(type.name()).c_str());
|
||||
printf("error, null identifier: %s\n", String(type.fName).c_str());
|
||||
}
|
||||
SkASSERT(ctor);
|
||||
return this->call(-1, std::move(ctor), std::move(args));
|
||||
@ -2047,8 +2046,8 @@ void IRGenerator::copyIntrinsicIfNeeded(const FunctionDeclaration& function) {
|
||||
if (a->fOffset != b->fOffset) {
|
||||
return a->fOffset < b->fOffset;
|
||||
}
|
||||
if (a->name() != b->name()) {
|
||||
return a->name() < b->name();
|
||||
if (a->fName != b->fName) {
|
||||
return a->fName < b->fName;
|
||||
}
|
||||
return a->description() < b->description();
|
||||
});
|
||||
@ -2071,7 +2070,7 @@ std::unique_ptr<Expression> IRGenerator::call(int offset,
|
||||
}
|
||||
}
|
||||
if (function.fParameters.size() != arguments.size()) {
|
||||
String msg = "call to '" + function.name() + "' expected " +
|
||||
String msg = "call to '" + function.fName + "' expected " +
|
||||
to_string((uint64_t) function.fParameters.size()) +
|
||||
" argument";
|
||||
if (function.fParameters.size() != 1) {
|
||||
@ -2082,14 +2081,14 @@ std::unique_ptr<Expression> IRGenerator::call(int offset,
|
||||
return nullptr;
|
||||
}
|
||||
if (fKind == Program::kPipelineStage_Kind && !function.fDefinition && !function.fBuiltin) {
|
||||
String msg = "call to undefined function '" + function.name() + "'";
|
||||
String msg = "call to undefined function '" + function.fName + "'";
|
||||
fErrors.error(offset, msg);
|
||||
return nullptr;
|
||||
}
|
||||
std::vector<const Type*> types;
|
||||
const Type* returnType;
|
||||
if (!function.determineFinalTypes(arguments, &types, &returnType)) {
|
||||
String msg = "no match for " + function.name() + "(";
|
||||
String msg = "no match for " + function.fName + "(";
|
||||
String separator;
|
||||
for (size_t i = 0; i < arguments.size(); i++) {
|
||||
msg += separator;
|
||||
@ -2201,7 +2200,7 @@ std::unique_ptr<Expression> IRGenerator::call(int offset,
|
||||
if (best) {
|
||||
return this->call(offset, *best, std::move(arguments));
|
||||
}
|
||||
String msg = "no match for " + ref.fFunctions[0]->name() + "(";
|
||||
String msg = "no match for " + ref.fFunctions[0]->fName + "(";
|
||||
String separator;
|
||||
for (size_t i = 0; i < arguments.size(); i++) {
|
||||
msg += separator;
|
||||
@ -2698,20 +2697,18 @@ std::unique_ptr<Expression> IRGenerator::convertTypeField(int offset, const Type
|
||||
offset, v.fInitialValue->as<IntLiteral>().value(), &type);
|
||||
} else {
|
||||
fErrors.error(offset,
|
||||
"type '" + type.name() + "' does not have a member named '" + field +
|
||||
"'");
|
||||
"type '" + type.fName + "' does not have a member named '" + field + "'");
|
||||
}
|
||||
fSymbolTable = old;
|
||||
return result;
|
||||
} else {
|
||||
// No Enum element? Check the intrinsics, clone it into the program, try again.
|
||||
if (auto found = fIntrinsics->findAndInclude(type.name())) {
|
||||
if (auto found = fIntrinsics->findAndInclude(type.fName)) {
|
||||
fProgramElements->push_back(found->clone());
|
||||
return this->convertTypeField(offset, type, field);
|
||||
}
|
||||
fErrors.error(offset,
|
||||
"type '" + type.displayName() + "' does not have a member named '" + field +
|
||||
"'");
|
||||
"type '" + type.fName + "' does not have a member named '" + field + "'");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -2845,7 +2842,7 @@ void IRGenerator::cloneBuiltinVariables() {
|
||||
// If this is the *first* time we've seen this builtin, findAndInclude will return
|
||||
// the corresponding ProgramElement.
|
||||
if (const ProgramElement* sharedDecls =
|
||||
fGenerator->fIntrinsics->findAndInclude(sharedVar->name())) {
|
||||
fGenerator->fIntrinsics->findAndInclude(sharedVar->fName)) {
|
||||
// Clone the VarDeclarations ProgramElement that declares this variable
|
||||
std::unique_ptr<ProgramElement> clonedDecls = sharedDecls->clone();
|
||||
SkASSERT(clonedDecls->is<VarDeclarations>());
|
||||
@ -2858,7 +2855,7 @@ void IRGenerator::cloneBuiltinVariables() {
|
||||
// so we're pointing at a Program-owned expression.
|
||||
const Variable* clonedVar = fGenerator->fSymbolTable->takeOwnershipOfSymbol(
|
||||
std::make_unique<Variable>(sharedVar->fOffset, sharedVar->fModifiers,
|
||||
sharedVar->name(), &sharedVar->type(),
|
||||
sharedVar->fName, &sharedVar->type(),
|
||||
/*builtin=*/false, sharedVar->fStorage,
|
||||
varDecl.fValue.get()));
|
||||
|
||||
|
@ -542,7 +542,7 @@ std::unique_ptr<Statement> Inliner::inlineStatement(int offset,
|
||||
// regard, but see `InlinerAvoidsVariableNameOverlap` for a counterexample where unique
|
||||
// names are important.
|
||||
auto name = std::make_unique<String>(
|
||||
this->uniqueNameForInlineVar(String(old->name()), symbolTableForStatement));
|
||||
this->uniqueNameForInlineVar(String(old->fName), symbolTableForStatement));
|
||||
const String* namePtr = symbolTableForStatement->takeOwnershipOfString(std::move(name));
|
||||
const Type* typePtr = copy_if_needed(&old->type(), *symbolTableForStatement);
|
||||
const Variable* clone = symbolTableForStatement->takeOwnershipOfSymbol(
|
||||
@ -664,7 +664,7 @@ Inliner::InlinedCall Inliner::inlineCall(FunctionCall* call,
|
||||
std::unique_ptr<Expression> resultExpr;
|
||||
if (function.fDeclaration.fReturnType != *fContext->fVoid_Type) {
|
||||
std::unique_ptr<Expression> noInitialValue;
|
||||
resultExpr = makeInlineVar(String(function.fDeclaration.name()),
|
||||
resultExpr = makeInlineVar(String(function.fDeclaration.fName),
|
||||
&function.fDeclaration.fReturnType,
|
||||
Modifiers{}, &noInitialValue);
|
||||
}
|
||||
@ -691,7 +691,7 @@ Inliner::InlinedCall Inliner::inlineCall(FunctionCall* call,
|
||||
argsToCopyBack.push_back(i);
|
||||
}
|
||||
|
||||
varMap[param] = makeInlineVar(String(param->name()), &arguments[i]->type(),
|
||||
varMap[param] = makeInlineVar(String(param->fName), &arguments[i]->type(),
|
||||
param->fModifiers, &arguments[i]);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
return this->roundUpIfNeeded(result);
|
||||
}
|
||||
default:
|
||||
ABORT("cannot determine size of type %s", String(type.name()).c_str());
|
||||
ABORT("cannot determine size of type %s", type.name().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public:
|
||||
return (total + alignment - 1) & ~(alignment - 1);
|
||||
}
|
||||
default:
|
||||
ABORT("cannot determine size of type %s", String(type.name()).c_str());
|
||||
ABORT("cannot determine size of type %s", type.name().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ void MetalCodeGenerator::writeExpression(const Expression& expr, Precedence pare
|
||||
}
|
||||
|
||||
void MetalCodeGenerator::writeIntrinsicCall(const FunctionCall& c) {
|
||||
auto i = fIntrinsicMap.find(c.fFunction.name());
|
||||
auto i = fIntrinsicMap.find(c.fFunction.fName);
|
||||
SkASSERT(i != fIntrinsicMap.end());
|
||||
Intrinsic intrinsic = i->second;
|
||||
int32_t intrinsicId = intrinsic.second;
|
||||
@ -212,26 +212,25 @@ void MetalCodeGenerator::writeIntrinsicCall(const FunctionCall& c) {
|
||||
}
|
||||
|
||||
void MetalCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
const auto& entry = fIntrinsicMap.find(c.fFunction.name());
|
||||
const auto& entry = fIntrinsicMap.find(c.fFunction.fName);
|
||||
if (entry != fIntrinsicMap.end()) {
|
||||
this->writeIntrinsicCall(c);
|
||||
return;
|
||||
}
|
||||
const StringFragment& name = c.fFunction.name();
|
||||
if (c.fFunction.fBuiltin && name == "atan" && 2 == c.fArguments.size()) {
|
||||
if (c.fFunction.fBuiltin && "atan" == c.fFunction.fName && 2 == c.fArguments.size()) {
|
||||
this->write("atan2");
|
||||
} else if (c.fFunction.fBuiltin && name == "inversesqrt") {
|
||||
} else if (c.fFunction.fBuiltin && "inversesqrt" == c.fFunction.fName) {
|
||||
this->write("rsqrt");
|
||||
} else if (c.fFunction.fBuiltin && name == "inverse") {
|
||||
} else if (c.fFunction.fBuiltin && "inverse" == c.fFunction.fName) {
|
||||
SkASSERT(c.fArguments.size() == 1);
|
||||
this->writeInverseHack(*c.fArguments[0]);
|
||||
} else if (c.fFunction.fBuiltin && name == "dFdx") {
|
||||
} else if (c.fFunction.fBuiltin && "dFdx" == c.fFunction.fName) {
|
||||
this->write("dfdx");
|
||||
} else if (c.fFunction.fBuiltin && name == "dFdy") {
|
||||
} else if (c.fFunction.fBuiltin && "dFdy" == c.fFunction.fName) {
|
||||
// Flipping Y also negates the Y derivatives.
|
||||
this->write((fProgram.fSettings.fFlipY) ? "-dfdy" : "dfdy");
|
||||
} else {
|
||||
this->writeName(name);
|
||||
this->writeName(c.fFunction.fName);
|
||||
}
|
||||
this->write("(");
|
||||
const char* separator = "";
|
||||
@ -708,7 +707,7 @@ void MetalCodeGenerator::writeVariableReference(const VariableReference& ref) {
|
||||
this->write("_globals->");
|
||||
}
|
||||
}
|
||||
this->writeName(ref.fVariable->name());
|
||||
this->writeName(ref.fVariable->fName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -799,8 +798,8 @@ void MetalCodeGenerator::writeMatrixTimesEqualHelper(const Type& left, const Typ
|
||||
fExtraFunctions.printf("%s operator*=(thread %s& left, thread const %s& right) {\n"
|
||||
" left = left * right;\n"
|
||||
" return left;\n"
|
||||
"}", String(result.name()).c_str(), String(left.name()).c_str(),
|
||||
String(right.name()).c_str());
|
||||
"}", result.name().c_str(), left.name().c_str(),
|
||||
right.name().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -930,7 +929,7 @@ void MetalCodeGenerator::writeSetting(const Setting& s) {
|
||||
void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
fRTHeightName = fProgram.fInputs.fRTHeight ? "_globals->_anonInterface0->u_skRTHeight" : "";
|
||||
const char* separator = "";
|
||||
if ("main" == f.fDeclaration.name()) {
|
||||
if ("main" == f.fDeclaration.fName) {
|
||||
switch (fProgram.fKind) {
|
||||
case Program::kFragment_Kind:
|
||||
this->write("fragment Outputs fragmentMain");
|
||||
@ -967,12 +966,12 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
return;
|
||||
}
|
||||
this->write(", texture2d<float> ");
|
||||
this->writeName(var.fVar->name());
|
||||
this->writeName(var.fVar->fName);
|
||||
this->write("[[texture(");
|
||||
this->write(to_string(var.fVar->fModifiers.fLayout.fBinding));
|
||||
this->write(")]]");
|
||||
this->write(", sampler ");
|
||||
this->writeName(var.fVar->name());
|
||||
this->writeName(var.fVar->fName);
|
||||
this->write(SAMPLER_SUFFIX);
|
||||
this->write("[[sampler(");
|
||||
this->write(to_string(var.fVar->fModifiers.fLayout.fBinding));
|
||||
@ -1007,7 +1006,7 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
} else {
|
||||
this->writeType(f.fDeclaration.fReturnType);
|
||||
this->write(" ");
|
||||
this->writeName(f.fDeclaration.name());
|
||||
this->writeName(f.fDeclaration.fName);
|
||||
this->write("(");
|
||||
Requirements requirements = this->requirements(f.fDeclaration);
|
||||
if (requirements & kInputs_Requirement) {
|
||||
@ -1050,7 +1049,7 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
this->write("*");
|
||||
}
|
||||
this->write(" ");
|
||||
this->writeName(param->name());
|
||||
this->writeName(param->fName);
|
||||
for (int s : sizes) {
|
||||
if (s == Type::kUnsizedArray) {
|
||||
this->write("[]");
|
||||
@ -1063,7 +1062,7 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
|
||||
SkASSERT(!fProgram.fSettings.fFragColorIsInOut);
|
||||
|
||||
if (f.fDeclaration.name() == "main") {
|
||||
if ("main" == f.fDeclaration.fName) {
|
||||
this->writeGlobalInit();
|
||||
this->writeLine(" Outputs _outputStruct;");
|
||||
this->writeLine(" thread Outputs* _out = &_outputStruct;");
|
||||
@ -1080,7 +1079,7 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
this->writeLine();
|
||||
}
|
||||
}
|
||||
if (f.fDeclaration.name() == "main") {
|
||||
if ("main" == f.fDeclaration.fName) {
|
||||
switch (fProgram.fKind) {
|
||||
case Program::kFragment_Kind:
|
||||
this->writeLine("return *_out;");
|
||||
@ -1232,7 +1231,7 @@ void MetalCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, bool
|
||||
this->write(" ");
|
||||
wroteType = true;
|
||||
}
|
||||
this->writeName(var.fVar->name());
|
||||
this->writeName(var.fVar->fName);
|
||||
for (const auto& size : var.fSizes) {
|
||||
this->write("[");
|
||||
if (size) {
|
||||
@ -1429,7 +1428,7 @@ void MetalCodeGenerator::writeUniformStruct() {
|
||||
this->write(" ");
|
||||
for (const auto& stmt : decls.fVars) {
|
||||
const VarDeclaration& var = stmt->as<VarDeclaration>();
|
||||
this->writeName(var.fVar->name());
|
||||
this->writeName(var.fVar->fName);
|
||||
}
|
||||
this->write(";\n");
|
||||
}
|
||||
@ -1456,7 +1455,7 @@ void MetalCodeGenerator::writeInputStruct() {
|
||||
this->write(" ");
|
||||
for (const auto& stmt : decls.fVars) {
|
||||
const VarDeclaration& var = stmt->as<VarDeclaration>();
|
||||
this->writeName(var.fVar->name());
|
||||
this->writeName(var.fVar->fName);
|
||||
if (-1 != var.fVar->fModifiers.fLayout.fLocation) {
|
||||
if (fProgram.fKind == Program::kVertex_Kind) {
|
||||
this->write(" [[attribute(" +
|
||||
@ -1495,7 +1494,7 @@ void MetalCodeGenerator::writeOutputStruct() {
|
||||
this->write(" ");
|
||||
for (const auto& stmt : decls.fVars) {
|
||||
const VarDeclaration& var = stmt->as<VarDeclaration>();
|
||||
this->writeName(var.fVar->name());
|
||||
this->writeName(var.fVar->fName);
|
||||
if (fProgram.fKind == Program::kVertex_Kind) {
|
||||
this->write(" [[user(locn" +
|
||||
to_string(var.fVar->fModifiers.fLayout.fLocation) + ")]]");
|
||||
@ -1555,8 +1554,8 @@ void MetalCodeGenerator::visitGlobalStruct(GlobalStructVisitor* visitor) {
|
||||
|
||||
if (var.fVar->type().typeKind() == Type::TypeKind::kSampler) {
|
||||
// Samplers are represented as a "texture/sampler" duo in the global struct.
|
||||
visitor->VisitTexture(first.type(), var.fVar->name());
|
||||
visitor->VisitSampler(first.type(), String(var.fVar->name()) + SAMPLER_SUFFIX);
|
||||
visitor->VisitTexture(first.type(), var.fVar->fName);
|
||||
visitor->VisitSampler(first.type(), String(var.fVar->fName) + SAMPLER_SUFFIX);
|
||||
} else {
|
||||
// Visit a regular variable.
|
||||
visitor->VisitVariable(*var.fVar, var.fValue.get());
|
||||
@ -1596,7 +1595,7 @@ void MetalCodeGenerator::writeGlobalStruct() {
|
||||
fCodeGen->write(" ");
|
||||
fCodeGen->writeType(var.type());
|
||||
fCodeGen->write(" ");
|
||||
fCodeGen->writeName(var.name());
|
||||
fCodeGen->writeName(var.fName);
|
||||
fCodeGen->write(";\n");
|
||||
}
|
||||
void AddElement() {
|
||||
|
@ -33,7 +33,7 @@ String PipelineStageCodeGenerator::getTypeName(const Type& type) {
|
||||
}
|
||||
|
||||
void PipelineStageCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
if (c.fFunction.fBuiltin && c.fFunction.name() == "sample" &&
|
||||
if (c.fFunction.fBuiltin && c.fFunction.fName == "sample" &&
|
||||
c.fArguments[0]->type().typeKind() != Type::TypeKind::kSampler) {
|
||||
SkASSERT(c.fArguments.size() <= 2);
|
||||
SkDEBUGCODE(const Type& arg0Type = c.fArguments[0]->type());
|
||||
@ -152,7 +152,7 @@ void PipelineStageCodeGenerator::writeVariableReference(const VariableReference&
|
||||
this->write("_vtx_attr_");
|
||||
this->write(to_string(varIndexByFlag(Modifiers::kVarying_Flag)));
|
||||
} else {
|
||||
this->write(ref.fVariable->name());
|
||||
this->write(ref.fVariable->fName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ void PipelineStageCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
OutputStream* oldOut = fOut;
|
||||
StringStream buffer;
|
||||
fOut = &buffer;
|
||||
if (f.fDeclaration.name() == "main") {
|
||||
if (f.fDeclaration.fName == "main") {
|
||||
for (const std::unique_ptr<Statement>& stmt : f.fBody->as<Block>().children()) {
|
||||
this->writeStatement(*stmt);
|
||||
this->writeLine();
|
||||
@ -192,14 +192,14 @@ void PipelineStageCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
fErrors.error(f.fOffset, "unsupported return type");
|
||||
return;
|
||||
}
|
||||
result.fName = decl.name();
|
||||
result.fName = decl.fName;
|
||||
for (const Variable* v : decl.fParameters) {
|
||||
GrSLType paramSLType;
|
||||
if (!type_to_grsltype(fContext, v->type(), ¶mSLType)) {
|
||||
fErrors.error(v->fOffset, "unsupported parameter type");
|
||||
return;
|
||||
}
|
||||
result.fParameters.emplace_back(v->name(), paramSLType);
|
||||
result.fParameters.emplace_back(v->fName, paramSLType);
|
||||
}
|
||||
for (const std::unique_ptr<Statement>& stmt : f.fBody->as<Block>().children()) {
|
||||
this->writeStatement(*stmt);
|
||||
|
@ -174,7 +174,7 @@ const Symbol* Rehydrator::symbol() {
|
||||
const Variable* owner = this->symbolRef<Variable>(Symbol::Kind::kVariable);
|
||||
uint8_t index = this->readU8();
|
||||
const Field* result = fSymbolTable->takeOwnershipOfSymbol(
|
||||
std::make_unique<Field>(/*offset=*/-1, owner, index));
|
||||
std::make_unique<Field>(/*offset=*/-1, *owner, index));
|
||||
return result;
|
||||
}
|
||||
case kNullableType_Command: {
|
||||
|
@ -381,7 +381,7 @@ SpvId SPIRVCodeGenerator::nextId() {
|
||||
|
||||
void SPIRVCodeGenerator::writeStruct(const Type& type, const MemoryLayout& memoryLayout,
|
||||
SpvId resultId) {
|
||||
this->writeInstruction(SpvOpName, resultId, String(type.name()).c_str(), fNameBuffer);
|
||||
this->writeInstruction(SpvOpName, resultId, type.name().c_str(), fNameBuffer);
|
||||
// go ahead and write all of the field types, so we don't inadvertently write them while we're
|
||||
// in the middle of writing the struct instruction
|
||||
std::vector<SpvId> types;
|
||||
@ -691,7 +691,7 @@ SpvId SPIRVCodeGenerator::writeExpression(const Expression& expr, OutputStream&
|
||||
}
|
||||
|
||||
SpvId SPIRVCodeGenerator::writeIntrinsicCall(const FunctionCall& c, OutputStream& out) {
|
||||
auto intrinsic = fIntrinsicMap.find(c.fFunction.name());
|
||||
auto intrinsic = fIntrinsicMap.find(c.fFunction.fName);
|
||||
SkASSERT(intrinsic != fIntrinsicMap.end());
|
||||
int32_t intrinsicId;
|
||||
if (c.fArguments.size() > 0) {
|
||||
@ -2095,7 +2095,7 @@ std::unique_ptr<Expression> create_literal_1(const Context& context, const Type&
|
||||
else if (type.isFloat()) {
|
||||
return std::unique_ptr<Expression>(new FloatLiteral(-1, 1.0, &type));
|
||||
} else {
|
||||
ABORT("math is unsupported on type '%s'", String(type.name()).c_str());
|
||||
ABORT("math is unsupported on type '%s'", type.name().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2575,7 +2575,7 @@ SpvId SPIRVCodeGenerator::writeFunctionStart(const FunctionDeclaration& f, Outpu
|
||||
SpvId result = fFunctionMap[&f];
|
||||
this->writeInstruction(SpvOpFunction, this->getType(f.fReturnType), result,
|
||||
SpvFunctionControlMaskNone, this->getFunctionType(f), out);
|
||||
this->writeInstruction(SpvOpName, result, f.name(), fNameBuffer);
|
||||
this->writeInstruction(SpvOpName, result, f.fName, fNameBuffer);
|
||||
for (size_t i = 0; i < f.fParameters.size(); i++) {
|
||||
SpvId id = this->nextId();
|
||||
fVariableMap[f.fParameters[i]] = id;
|
||||
@ -2593,7 +2593,7 @@ SpvId SPIRVCodeGenerator::writeFunction(const FunctionDefinition& f, OutputStrea
|
||||
StringStream bodyBuffer;
|
||||
this->writeBlock((Block&) *f.fBody, bodyBuffer);
|
||||
write_stringstream(fVariableBuffer, out);
|
||||
if (f.fDeclaration.name() == "main") {
|
||||
if (f.fDeclaration.fName == "main") {
|
||||
write_stringstream(fGlobalInitializersBuffer, out);
|
||||
}
|
||||
write_stringstream(bodyBuffer, out);
|
||||
@ -2821,7 +2821,7 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
|
||||
typeId = this->getPointerType(type, storageClass);
|
||||
}
|
||||
this->writeInstruction(SpvOpVariable, typeId, id, storageClass, fConstantBuffer);
|
||||
this->writeInstruction(SpvOpName, id, var->name(), fNameBuffer);
|
||||
this->writeInstruction(SpvOpName, id, var->fName, fNameBuffer);
|
||||
this->writePrecisionModifier(type, id);
|
||||
if (varDecl.fValue) {
|
||||
SkASSERT(!fCurrentBlock);
|
||||
@ -2857,7 +2857,7 @@ void SPIRVCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, Outpu
|
||||
fVariableMap[var] = id;
|
||||
SpvId type = this->getPointerType(var->type(), SpvStorageClassFunction);
|
||||
this->writeInstruction(SpvOpVariable, type, id, SpvStorageClassFunction, fVariableBuffer);
|
||||
this->writeInstruction(SpvOpName, id, var->name(), fNameBuffer);
|
||||
this->writeInstruction(SpvOpName, id, var->fName, fNameBuffer);
|
||||
if (varDecl.fValue) {
|
||||
SpvId value = this->writeExpression(*varDecl.fValue, out);
|
||||
this->writeInstruction(SpvOpStore, id, value, out);
|
||||
@ -3222,7 +3222,7 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream&
|
||||
}
|
||||
const FunctionDeclaration* main = nullptr;
|
||||
for (auto entry : fFunctionMap) {
|
||||
if (entry.first->name() == "main") {
|
||||
if (entry.first->fName == "main") {
|
||||
main = entry.first;
|
||||
}
|
||||
}
|
||||
@ -3241,7 +3241,7 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream&
|
||||
this->writeCapabilities(out);
|
||||
this->writeInstruction(SpvOpExtInstImport, fGLSLExtendedInstructions, "GLSL.std.450", out);
|
||||
this->writeInstruction(SpvOpMemoryModel, SpvAddressingModelLogical, SpvMemoryModelGLSL450, out);
|
||||
this->writeOpCode(SpvOpEntryPoint, (SpvId) (3 + (main->name().fLength + 4) / 4) +
|
||||
this->writeOpCode(SpvOpEntryPoint, (SpvId) (3 + (main->fName.fLength + 4) / 4) +
|
||||
(int32_t) interfaceVars.size(), out);
|
||||
switch (program.fKind) {
|
||||
case Program::kVertex_Kind:
|
||||
@ -3258,7 +3258,7 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream&
|
||||
}
|
||||
SpvId entryPoint = fFunctionMap[main];
|
||||
this->writeWord(entryPoint, out);
|
||||
this->writeString(main->name().fChars, main->name().fLength, out);
|
||||
this->writeString(main->fName.fChars, main->fName.fLength, out);
|
||||
for (int var : interfaceVars) {
|
||||
this->writeWord(var, out);
|
||||
}
|
||||
|
@ -181,18 +181,6 @@ bool StringFragment::operator<(StringFragment other) const {
|
||||
return fLength < other.fLength;
|
||||
}
|
||||
|
||||
String StringFragment::operator+(const char* other) const {
|
||||
return String(*this) + other;
|
||||
}
|
||||
|
||||
String StringFragment::operator+(const StringFragment& other) const {
|
||||
return String(*this) + other;
|
||||
}
|
||||
|
||||
String StringFragment::operator+(const String& other) const {
|
||||
return String(*this) + other;
|
||||
}
|
||||
|
||||
bool operator==(const char* s1, StringFragment s2) {
|
||||
return s2 == s1;
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
class String;
|
||||
|
||||
// Represents a (not necessarily null-terminated) slice of a string.
|
||||
struct StringFragment {
|
||||
StringFragment()
|
||||
@ -44,9 +42,6 @@ struct StringFragment {
|
||||
bool operator==(StringFragment s) const;
|
||||
bool operator!=(StringFragment s) const;
|
||||
bool operator<(StringFragment s) const;
|
||||
String operator+(const char* s) const;
|
||||
String operator+(const StringFragment& s) const;
|
||||
String operator+(const String& s) const;
|
||||
|
||||
#ifndef SKSL_STANDALONE
|
||||
operator SkString() const { return SkString(fChars, fLength); }
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
class Symbol;
|
||||
struct Symbol;
|
||||
|
||||
class Enum : public ProgramElement {
|
||||
public:
|
||||
@ -53,10 +53,10 @@ public:
|
||||
sortedSymbols.push_back(pair.second);
|
||||
}
|
||||
std::sort(sortedSymbols.begin(), sortedSymbols.end(),
|
||||
[](const Symbol* a, const Symbol* b) { return a->name() < b->name(); });
|
||||
[](const Symbol* a, const Symbol* b) { return a->fName < b->fName; });
|
||||
for (const auto& s : sortedSymbols) {
|
||||
const Expression& initialValue = *s->as<Variable>().fInitialValue;
|
||||
result += separator + " " + s->name() + " = " +
|
||||
result += separator + " " + s->fName + " = " +
|
||||
to_string(initialValue.as<IntLiteral>().value());
|
||||
separator = ",\n";
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ struct ExternalFunctionCall : public Expression {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
String result = String(this->function()->name()) + "(";
|
||||
String result = String(this->function()->fName) + "(";
|
||||
String separator;
|
||||
for (const std::unique_ptr<Expression>& arg : this->arguments()) {
|
||||
result += separator;
|
||||
|
@ -28,7 +28,7 @@ struct ExternalValueReference : public Expression {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
return String(fValue->name());
|
||||
return String(fValue->fName);
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> clone() const override {
|
||||
|
@ -21,33 +21,21 @@ namespace SkSL {
|
||||
* whenever a bare reference to an identifier should refer to a struct field; in GLSL, this is the
|
||||
* result of declaring anonymous interface blocks.
|
||||
*/
|
||||
class Field : public Symbol {
|
||||
public:
|
||||
struct Field : public Symbol {
|
||||
static constexpr Kind kSymbolKind = Kind::kField;
|
||||
|
||||
Field(int offset, const Variable* owner, int fieldIndex)
|
||||
: INHERITED(offset, FieldData{owner->type().fields()[fieldIndex].fName,
|
||||
owner->type().fields()[fieldIndex].fType,
|
||||
owner,
|
||||
fieldIndex}) {}
|
||||
|
||||
StringFragment name() const override {
|
||||
return this->fieldData().fName;
|
||||
}
|
||||
|
||||
int fieldIndex() const {
|
||||
return this->fieldData().fFieldIndex;
|
||||
}
|
||||
|
||||
const Variable& owner() const {
|
||||
return *this->fieldData().fOwner;
|
||||
}
|
||||
Field(int offset, const Variable& owner, int fieldIndex)
|
||||
: INHERITED(offset, kSymbolKind, owner.type().fields()[fieldIndex].fName)
|
||||
, fOwner(owner)
|
||||
, fFieldIndex(fieldIndex) {}
|
||||
|
||||
String description() const override {
|
||||
return this->owner().description() + "." + this->name();
|
||||
return fOwner.description() + "." + fOwner.type().fields()[fFieldIndex].fName;
|
||||
}
|
||||
|
||||
private:
|
||||
const Variable& fOwner;
|
||||
const int fFieldIndex;
|
||||
|
||||
using INHERITED = Symbol;
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,7 @@ struct FunctionCall : public Expression {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
String result = String(fFunction.name()) + "(";
|
||||
String result = String(fFunction.fName) + "(";
|
||||
String separator;
|
||||
for (size_t i = 0; i < fArguments.size(); i++) {
|
||||
result += separator;
|
||||
|
@ -38,7 +38,7 @@ struct FunctionDeclaration : public Symbol {
|
||||
, fReturnType(returnType) {}
|
||||
|
||||
String description() const override {
|
||||
String result = fReturnType.displayName() + " " + this->name() + "(";
|
||||
String result = fReturnType.displayName() + " " + fName + "(";
|
||||
String separator;
|
||||
for (auto p : fParameters) {
|
||||
result += separator;
|
||||
@ -50,7 +50,7 @@ struct FunctionDeclaration : public Symbol {
|
||||
}
|
||||
|
||||
bool matches(const FunctionDeclaration& f) const {
|
||||
if (this->name() != f.name()) {
|
||||
if (fName != f.fName) {
|
||||
return false;
|
||||
}
|
||||
if (fParameters.size() != f.fParameters.size()) {
|
||||
|
@ -33,11 +33,6 @@ IRNode::IRNode(int offset, int kind, const ExternalValueData& data)
|
||||
, fKind(kind)
|
||||
, fData(data) {}
|
||||
|
||||
IRNode::IRNode(int offset, int kind, const FieldData& data)
|
||||
: fOffset(offset)
|
||||
, fKind(kind)
|
||||
, fData(data) {}
|
||||
|
||||
IRNode::IRNode(int offset, int kind, const IntLiteralData& data)
|
||||
: fOffset(offset)
|
||||
, fKind(kind)
|
||||
@ -53,11 +48,6 @@ IRNode::IRNode(int offset, int kind, const String& data)
|
||||
, fKind(kind)
|
||||
, fData(data) {}
|
||||
|
||||
IRNode::IRNode(int offset, int kind, const SymbolData& data)
|
||||
: fOffset(offset)
|
||||
, fKind(kind)
|
||||
, fData(data) {}
|
||||
|
||||
IRNode::IRNode(int offset, int kind, const Type* data)
|
||||
: fOffset(offset)
|
||||
, fKind(kind)
|
||||
|
@ -22,7 +22,6 @@ class ExternalValue;
|
||||
struct Statement;
|
||||
class SymbolTable;
|
||||
class Type;
|
||||
struct Variable;
|
||||
|
||||
/**
|
||||
* Represents a node in the intermediate representation (IR) tree. The IR is a fully-resolved
|
||||
@ -58,12 +57,8 @@ public:
|
||||
return *this->externalValueData().fType;
|
||||
case NodeData::Kind::kIntLiteral:
|
||||
return *this->intLiteralData().fType;
|
||||
case NodeData::Kind::kField:
|
||||
return *this->fieldData().fType;
|
||||
case NodeData::Kind::kFloatLiteral:
|
||||
return *this->floatLiteralData().fType;
|
||||
case NodeData::Kind::kSymbol:
|
||||
return *this->symbolData().fType;
|
||||
case NodeData::Kind::kType:
|
||||
return *this->typeData();
|
||||
case NodeData::Kind::kTypeToken:
|
||||
@ -98,13 +93,6 @@ protected:
|
||||
const ExternalValue* fValue;
|
||||
};
|
||||
|
||||
struct FieldData {
|
||||
StringFragment fName;
|
||||
const Type* fType;
|
||||
const Variable* fOwner;
|
||||
int fFieldIndex;
|
||||
};
|
||||
|
||||
struct FloatLiteralData {
|
||||
const Type* fType;
|
||||
float fValue;
|
||||
@ -115,11 +103,6 @@ protected:
|
||||
int64_t fValue;
|
||||
};
|
||||
|
||||
struct SymbolData {
|
||||
StringFragment fName;
|
||||
const Type* fType;
|
||||
};
|
||||
|
||||
struct TypeTokenData {
|
||||
const Type* fType;
|
||||
Token::Kind fToken;
|
||||
@ -131,11 +114,9 @@ protected:
|
||||
kBoolLiteral,
|
||||
kEnum,
|
||||
kExternalValue,
|
||||
kField,
|
||||
kFloatLiteral,
|
||||
kIntLiteral,
|
||||
kString,
|
||||
kSymbol,
|
||||
kType,
|
||||
kTypeToken,
|
||||
} fKind = Kind::kType;
|
||||
@ -146,11 +127,9 @@ protected:
|
||||
BoolLiteralData fBoolLiteral;
|
||||
EnumData fEnum;
|
||||
ExternalValueData fExternalValue;
|
||||
FieldData fField;
|
||||
FloatLiteralData fFloatLiteral;
|
||||
IntLiteralData fIntLiteral;
|
||||
String fString;
|
||||
SymbolData fSymbol;
|
||||
const Type* fType;
|
||||
TypeTokenData fTypeToken;
|
||||
|
||||
@ -179,11 +158,6 @@ protected:
|
||||
*(new(&fContents) ExternalValueData) = data;
|
||||
}
|
||||
|
||||
NodeData(const FieldData& data)
|
||||
: fKind(Kind::kField) {
|
||||
*(new(&fContents) FieldData) = data;
|
||||
}
|
||||
|
||||
NodeData(const FloatLiteralData& data)
|
||||
: fKind(Kind::kFloatLiteral) {
|
||||
*(new(&fContents) FloatLiteralData) = data;
|
||||
@ -199,11 +173,6 @@ protected:
|
||||
*(new(&fContents) String) = data;
|
||||
}
|
||||
|
||||
NodeData(const SymbolData& data)
|
||||
: fKind(Kind::kSymbol) {
|
||||
*(new(&fContents) SymbolData) = data;
|
||||
}
|
||||
|
||||
NodeData(const Type* data)
|
||||
: fKind(Kind::kType) {
|
||||
*(new(&fContents) const Type*) = data;
|
||||
@ -234,9 +203,6 @@ protected:
|
||||
case Kind::kExternalValue:
|
||||
*(new(&fContents) ExternalValueData) = other.fContents.fExternalValue;
|
||||
break;
|
||||
case Kind::kField:
|
||||
*(new(&fContents) FieldData) = other.fContents.fField;
|
||||
break;
|
||||
case Kind::kFloatLiteral:
|
||||
*(new(&fContents) FloatLiteralData) = other.fContents.fFloatLiteral;
|
||||
break;
|
||||
@ -246,9 +212,6 @@ protected:
|
||||
case Kind::kString:
|
||||
*(new(&fContents) String) = other.fContents.fString;
|
||||
break;
|
||||
case Kind::kSymbol:
|
||||
*(new(&fContents) SymbolData) = other.fContents.fSymbol;
|
||||
break;
|
||||
case Kind::kType:
|
||||
*(new(&fContents) const Type*) = other.fContents.fType;
|
||||
break;
|
||||
@ -278,9 +241,6 @@ protected:
|
||||
case Kind::kExternalValue:
|
||||
fContents.fExternalValue.~ExternalValueData();
|
||||
break;
|
||||
case Kind::kField:
|
||||
fContents.fField.~FieldData();
|
||||
break;
|
||||
case Kind::kFloatLiteral:
|
||||
fContents.fFloatLiteral.~FloatLiteralData();
|
||||
break;
|
||||
@ -290,9 +250,6 @@ protected:
|
||||
case Kind::kString:
|
||||
fContents.fString.~String();
|
||||
break;
|
||||
case Kind::kSymbol:
|
||||
fContents.fSymbol.~SymbolData();
|
||||
break;
|
||||
case Kind::kType:
|
||||
break;
|
||||
case Kind::kTypeToken:
|
||||
@ -311,16 +268,12 @@ protected:
|
||||
|
||||
IRNode(int offset, int kind, const ExternalValueData& data);
|
||||
|
||||
IRNode(int offset, int kind, const FieldData& data);
|
||||
|
||||
IRNode(int offset, int kind, const IntLiteralData& data);
|
||||
|
||||
IRNode(int offset, int kind, const FloatLiteralData& data);
|
||||
|
||||
IRNode(int offset, int kind, const String& data);
|
||||
|
||||
IRNode(int offset, int kind, const SymbolData& data);
|
||||
|
||||
IRNode(int offset, int kind, const Type* data = nullptr);
|
||||
|
||||
IRNode(int offset, int kind, const TypeTokenData& data);
|
||||
@ -391,11 +344,6 @@ protected:
|
||||
return fData.fContents.fExternalValue;
|
||||
}
|
||||
|
||||
const FieldData& fieldData() const {
|
||||
SkASSERT(fData.fKind == NodeData::Kind::kField);
|
||||
return fData.fContents.fField;
|
||||
}
|
||||
|
||||
const FloatLiteralData& floatLiteralData() const {
|
||||
SkASSERT(fData.fKind == NodeData::Kind::kFloatLiteral);
|
||||
return fData.fContents.fFloatLiteral;
|
||||
@ -411,16 +359,6 @@ protected:
|
||||
return fData.fContents.fString;
|
||||
}
|
||||
|
||||
SymbolData& symbolData() {
|
||||
SkASSERT(fData.fKind == NodeData::Kind::kSymbol);
|
||||
return fData.fContents.fSymbol;
|
||||
}
|
||||
|
||||
const SymbolData& symbolData() const {
|
||||
SkASSERT(fData.fKind == NodeData::Kind::kSymbol);
|
||||
return fData.fContents.fSymbol;
|
||||
}
|
||||
|
||||
const Type* typeData() const {
|
||||
SkASSERT(fData.fKind == NodeData::Kind::kType);
|
||||
return fData.fContents.fType;
|
||||
|
@ -29,7 +29,7 @@ struct InlineMarker : public Statement {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
return String("/* inlined: ") + fFuncDecl->name() + String(" */");
|
||||
return String("/* inlined: ") + fFuncDecl->fName + String(" */");
|
||||
}
|
||||
|
||||
std::unique_ptr<Statement> clone() const override {
|
||||
|
@ -16,8 +16,7 @@ namespace SkSL {
|
||||
/**
|
||||
* Represents a symboltable entry.
|
||||
*/
|
||||
class Symbol : public IRNode {
|
||||
public:
|
||||
struct Symbol : public IRNode {
|
||||
enum class Kind {
|
||||
kExternal = (int) ProgramElement::Kind::kLast + 1,
|
||||
kField,
|
||||
@ -31,13 +30,11 @@ public:
|
||||
};
|
||||
|
||||
Symbol(int offset, Kind kind, StringFragment name, const Type* type = nullptr)
|
||||
: INHERITED(offset, (int) kind, SymbolData{name, type}) {
|
||||
: INHERITED(offset, (int) kind, type)
|
||||
, fName(name) {
|
||||
SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast);
|
||||
}
|
||||
|
||||
Symbol(int offset, const FieldData& data)
|
||||
: INHERITED(offset, (int) Kind::kField, data) {}
|
||||
|
||||
Symbol(const Symbol&) = default;
|
||||
Symbol& operator=(const Symbol&) = default;
|
||||
|
||||
@ -47,10 +44,6 @@ public:
|
||||
return (Kind) fKind;
|
||||
}
|
||||
|
||||
virtual StringFragment name() const {
|
||||
return this->symbolData().fName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use is<T> to check the type of a symbol.
|
||||
* e.g. replace `sym.kind() == Symbol::Kind::kVariable` with `sym.is<Variable>()`.
|
||||
@ -75,7 +68,8 @@ public:
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
StringFragment fName;
|
||||
|
||||
using INHERITED = IRNode;
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@ CoercionCost Type::coercionCost(const Type& other) const {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (this->name() == "null" && other.typeKind() == TypeKind::kNullable) {
|
||||
if (this->fName == "null" && other.typeKind() == TypeKind::kNullable) {
|
||||
return CoercionCost::Free();
|
||||
}
|
||||
if (this->typeKind() == TypeKind::kVector && other.typeKind() == TypeKind::kVector) {
|
||||
|
@ -97,69 +97,91 @@ public:
|
||||
// Create an "other" (special) type with the given name. These types cannot be directly
|
||||
// referenced from user code.
|
||||
Type(const char* name)
|
||||
: INHERITED(-1, kSymbolKind, name)
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(TypeKind::kOther)
|
||||
, fNumberKind(NumberKind::kNonnumeric) {}
|
||||
, fNumberKind(NumberKind::kNonnumeric) {
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create an "other" (special) type that supports field access.
|
||||
Type(const char* name, std::vector<Field> fields)
|
||||
: INHERITED(-1, kSymbolKind, name)
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(TypeKind::kOther)
|
||||
, fNumberKind(NumberKind::kNonnumeric)
|
||||
, fFields(std::move(fields)) {}
|
||||
, fFields(std::move(fields)) {
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a simple type.
|
||||
Type(String name, TypeKind kind)
|
||||
: INHERITED(-1, kSymbolKind, "")
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(std::move(name))
|
||||
, fTypeKind(kind)
|
||||
, fNumberKind(NumberKind::kNonnumeric) {
|
||||
this->symbolData().fName = StringFragment(fNameString.c_str(), fNameString.length());
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a generic type which maps to the listed types.
|
||||
Type(const char* name, std::vector<const Type*> types)
|
||||
: INHERITED(-1, kSymbolKind, name)
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(TypeKind::kGeneric)
|
||||
, fNumberKind(NumberKind::kNonnumeric)
|
||||
, fCoercibleTypes(std::move(types)) {}
|
||||
, fCoercibleTypes(std::move(types)) {
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a struct type with the given fields.
|
||||
Type(int offset, String name, std::vector<Field> fields)
|
||||
: INHERITED(offset, kSymbolKind, "")
|
||||
: INHERITED(offset, kSymbolKind, StringFragment())
|
||||
, fNameString(std::move(name))
|
||||
, fTypeKind(TypeKind::kStruct)
|
||||
, fNumberKind(NumberKind::kNonnumeric)
|
||||
, fFields(std::move(fields)) {
|
||||
this->symbolData().fName = StringFragment(fNameString.c_str(), fNameString.length());
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a scalar type.
|
||||
Type(const char* name, NumberKind numberKind, int priority, bool highPrecision = false)
|
||||
: INHERITED(-1, kSymbolKind, name)
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(TypeKind::kScalar)
|
||||
, fNumberKind(numberKind)
|
||||
, fPriority(priority)
|
||||
, fColumns(1)
|
||||
, fRows(1)
|
||||
, fHighPrecision(highPrecision) {}
|
||||
, fHighPrecision(highPrecision) {
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a scalar type which can be coerced to the listed types.
|
||||
Type(const char* name,
|
||||
NumberKind numberKind,
|
||||
int priority,
|
||||
std::vector<const Type*> coercibleTypes)
|
||||
: INHERITED(-1, kSymbolKind, name)
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(TypeKind::kScalar)
|
||||
, fNumberKind(numberKind)
|
||||
, fPriority(priority)
|
||||
, fCoercibleTypes(std::move(coercibleTypes))
|
||||
, fColumns(1)
|
||||
, fRows(1) {}
|
||||
, fRows(1) {
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a nullable type.
|
||||
Type(String name, TypeKind kind, const Type& componentType)
|
||||
: INHERITED(-1, kSymbolKind, "")
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(std::move(name))
|
||||
, fTypeKind(kind)
|
||||
, fNumberKind(NumberKind::kNonnumeric)
|
||||
@ -167,7 +189,8 @@ public:
|
||||
, fColumns(1)
|
||||
, fRows(1)
|
||||
, fDimensions(SpvDim1D) {
|
||||
this->symbolData().fName = StringFragment(fNameString.c_str(), fNameString.length());
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a vector type.
|
||||
@ -178,7 +201,7 @@ public:
|
||||
|
||||
// Create a vector or array type.
|
||||
Type(String name, TypeKind kind, const Type& componentType, int columns)
|
||||
: INHERITED(-1, kSymbolKind, "")
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(std::move(name))
|
||||
, fTypeKind(kind)
|
||||
, fNumberKind(NumberKind::kNonnumeric)
|
||||
@ -187,34 +210,45 @@ public:
|
||||
, fRows(1)
|
||||
, fDimensions(SpvDim1D) {
|
||||
SkASSERT(fColumns > 0 || (fTypeKind == TypeKind::kArray && fColumns == kUnsizedArray));
|
||||
this->symbolData().fName = StringFragment(fNameString.c_str(), fNameString.length());
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a matrix type.
|
||||
Type(const char* name, const Type& componentType, int columns, int rows)
|
||||
: INHERITED(-1, kSymbolKind, name)
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(TypeKind::kMatrix)
|
||||
, fNumberKind(NumberKind::kNonnumeric)
|
||||
, fComponentType(&componentType)
|
||||
, fColumns(columns)
|
||||
, fRows(rows)
|
||||
, fDimensions(SpvDim1D) {}
|
||||
, fDimensions(SpvDim1D) {
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a texture type.
|
||||
Type(const char* name, SpvDim_ dimensions, bool isDepth, bool isArrayed, bool isMultisampled,
|
||||
bool isSampled)
|
||||
: INHERITED(-1, kSymbolKind, name)
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(TypeKind::kTexture)
|
||||
, fNumberKind(NumberKind::kNonnumeric)
|
||||
, fDimensions(dimensions)
|
||||
, fIsDepth(isDepth)
|
||||
, fIsArrayed(isArrayed)
|
||||
, fIsMultisampled(isMultisampled)
|
||||
, fIsSampled(isSampled) {}
|
||||
, fIsSampled(isSampled)
|
||||
{
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a sampler type.
|
||||
Type(const char* name, const Type& textureType)
|
||||
: INHERITED(-1, kSymbolKind, name)
|
||||
: INHERITED(-1, kSymbolKind, StringFragment())
|
||||
, fNameString(name)
|
||||
, fTypeKind(TypeKind::kSampler)
|
||||
, fNumberKind(NumberKind::kNonnumeric)
|
||||
, fDimensions(textureType.dimensions())
|
||||
@ -222,17 +256,24 @@ public:
|
||||
, fIsArrayed(textureType.isArrayed())
|
||||
, fIsMultisampled(textureType.isMultisampled())
|
||||
, fIsSampled(textureType.isSampled())
|
||||
, fTextureType(&textureType) {}
|
||||
, fTextureType(&textureType)
|
||||
{
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
const String& name() const {
|
||||
return fNameString;
|
||||
}
|
||||
|
||||
String displayName() const {
|
||||
StringFragment name = this->name();
|
||||
if (name == "$floatLiteral") {
|
||||
if (fNameString == "$floatLiteral") {
|
||||
return "float";
|
||||
}
|
||||
if (name == "$intLiteral") {
|
||||
if (fNameString == "$intLiteral") {
|
||||
return "int";
|
||||
}
|
||||
return name;
|
||||
return fNameString;
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
@ -240,11 +281,11 @@ public:
|
||||
}
|
||||
|
||||
bool operator==(const Type& other) const {
|
||||
return this->name() == other.name();
|
||||
return fName == other.fName;
|
||||
}
|
||||
|
||||
bool operator!=(const Type& other) const {
|
||||
return this->name() != other.name();
|
||||
return fName != other.fName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ struct TypeReference : public Expression {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
return String(fValue.name());
|
||||
return String(fValue.fName);
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> clone() const override {
|
||||
|
@ -19,7 +19,7 @@ struct UnresolvedFunction : public Symbol {
|
||||
static constexpr Kind kSymbolKind = Kind::kUnresolvedFunction;
|
||||
|
||||
UnresolvedFunction(std::vector<const FunctionDeclaration*> funcs)
|
||||
: INHERITED(-1, kSymbolKind, funcs[0]->name())
|
||||
: INHERITED(-1, kSymbolKind, funcs[0]->fName)
|
||||
, fFunctions(std::move(funcs)) {
|
||||
#ifdef DEBUG
|
||||
for (auto func : funcs) {
|
||||
@ -29,7 +29,7 @@ struct UnresolvedFunction : public Symbol {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
return this->name();
|
||||
return fName;
|
||||
}
|
||||
|
||||
const std::vector<const FunctionDeclaration*> fFunctions;
|
||||
|
@ -45,7 +45,7 @@ struct VarDeclaration : public Statement {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
String result = fVar->fModifiers.description() + fVar->type().name() + " " + fVar->name();
|
||||
String result = fVar->fModifiers.description() + fVar->type().name() + " " + fVar->fName;
|
||||
for (const auto& size : fSizes) {
|
||||
if (size) {
|
||||
result += "[" + size->description() + "]";
|
||||
@ -113,7 +113,7 @@ struct VarDeclarations : public ProgramElement {
|
||||
VarDeclaration& var = (VarDeclaration&) *rawVar;
|
||||
result += separator;
|
||||
separator = ", ";
|
||||
result += var.fVar->name();
|
||||
result += var.fVar->fName;
|
||||
if (var.fValue) {
|
||||
result += " = " + var.fValue->description();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ struct Variable : public Symbol {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
return fModifiers.description() + this->type().name() + " " + this->name();
|
||||
return fModifiers.description() + this->type().fName + " " + fName;
|
||||
}
|
||||
|
||||
bool dead() const {
|
||||
|
@ -51,7 +51,7 @@ struct VariableReference : public Expression {
|
||||
bool hasProperty(Property property) const override {
|
||||
switch (property) {
|
||||
case Property::kSideEffects: return false;
|
||||
case Property::kContainsRTAdjust: return fVariable->name() == "sk_RTAdjust";
|
||||
case Property::kContainsRTAdjust: return fVariable->fName == "sk_RTAdjust";
|
||||
default:
|
||||
SkASSERT(false);
|
||||
return false;
|
||||
@ -67,7 +67,7 @@ struct VariableReference : public Expression {
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
return fVariable->name();
|
||||
return fVariable->fName;
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator,
|
||||
|
Loading…
Reference in New Issue
Block a user