summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-04-29 17:03:46 -0400
committerTim Foley <tfoleyNV@users.noreply.github.com>2019-04-29 14:03:46 -0700
commit4880789e3003441732cca4471091563f36531635 (patch)
tree8e0d3ed58a561373b35729d24787afe6b39732e3 /source/slang/emit.cpp
parentded340beb4b5197b559626acc39920abb2d39e77 (diff)
String/List closer to conventions, and use Index type (#959)
* List made members m_ Tweaked types to closer match conventions. * Use asserts for checking conditions on List. Other small improvements. * List<T>.Count() -> getSize() * List<T> Add -> add First -> getFirst Last -> getLast RemoveLast -> removeLast ReleaseBuffer -> detachBuffer GetArrayView -> getArrayView * List<T>:: AddRange -> addRange Capacity -> getCapacity Insert -> insert InsertRange -> insertRange AddRange -> addRange RemoveRange -> removeRange RemoveAt -> removeAt Remove -> remove Reverse -> reverse FastRemove -> fastRemove FastRemoveAt -> fastRemoveAt Clear -> clear * List<T> FreeBuffer -> _deallocateBuffer Free -> clearAndDeallocate SwapWith -> swapWith * List<T> SetSize -> setSize Reserve -> reserve GrowToSize growToSize * UnsafeShrinkToSize -> unsafeShrinkToSize Compress -> compress FindLast -> findLastIndex FindLast -> findLastIndex Simplify Contains * List<T> Removed m_allocator (wasn't used) Swap -> swapElements Sort -> sort Contains -> contains ForEach -> forEach QuickSort -> quickSort InsertionSort -> insertionSort BinarySearch -> binarySearch Max -> calcMax Min -> calcMin * Initializer::Initialize -> initialize List<T>:: Allocate -> _allocate Init -> _init IndexOf -> indexOf * * Put #include <assert.h> in common.h, and remove unneeded inclusions * Small refactor of ArrayView - remove stride as not used * getSize -> getCount setSize -> setCount unsafeShrinkToSize->unsafeShrinkToCount growToSize -> growToCount m_size -> m_count * Some tidy up around Allocator. * Use Index type on List. * Refactor of IntSet. First tentative look at using Index. * Made Index an Int Did preliminary fixes. Made String use Index. * Partial refactor of String. * String::Buffer -> getBuffer ToWString -> toWString * Small improvements to String. String:: Buffer() -> getBuffer() Equals() -> equals * Try to use Index where appropriate. * Fix warnings on windows x86 builds.
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 8bb2a244b..24d1ce56c 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -1490,7 +1490,7 @@ struct EmitVisitor
// If no target name was specified, then the modifier implicitly
// applies to all targets.
- if(targetName.Length() == 0)
+ if(targetName.getLength() == 0)
return true;
return isTargetIntrinsicModifierApplicable(targetName);
@@ -2105,7 +2105,7 @@ struct EmitVisitor
char const* dummyChar = "U";
// Special case a name that is the empty string, just in case.
- if(name.Length() == 0)
+ if(name.getLength() == 0)
return dummyChar;
// Otherwise, we are going to walk over the name byte by byte
@@ -2117,7 +2117,7 @@ struct EmitVisitor
// GLSL reserverse all names that start with `gl_`,
// so if we are in danger of collision, then make
// our name start with a dummy character instead.
- if(name.StartsWith("gl_"))
+ if(name.startsWith("gl_"))
{
sb.append(dummyChar);
}
@@ -2126,7 +2126,7 @@ struct EmitVisitor
// We will also detect user-defined names that
// might overlap with our convention for mangled names,
// to avoid an possible collision.
- if(name.StartsWith("_S"))
+ if(name.startsWith("_S"))
{
sb.Append(dummyChar);
}
@@ -2259,7 +2259,7 @@ struct EmitVisitor
sb.append(nameHint);
// Avoid introducing a double underscore
- if(!nameHint.EndsWith("_"))
+ if(!nameHint.endsWith("_"))
{
sb.append("_");
}
@@ -3037,7 +3037,7 @@ struct EmitVisitor
auto outerPrec = inOuterPrec;
IRUse* args = inst->getOperands();
- UInt argCount = inst->getOperandCount();
+ Index argCount = inst->getOperandCount();
// First operand was the function to be called
args++;
@@ -3053,7 +3053,7 @@ struct EmitVisitor
emit(name);
Emit("(");
- for (UInt aa = 0; aa < argCount; ++aa)
+ for (Index aa = 0; aa < argCount; ++aa)
{
if (aa != 0) Emit(", ");
emitIROperand(ctx, args[aa].get(), mode, kEOp_General);
@@ -3100,7 +3100,7 @@ struct EmitVisitor
case '5': case '6': case '7': case '8': case '9':
{
// Simple case: emit one of the direct arguments to the call
- UInt argIndex = d - '0';
+ Index argIndex = d - '0';
SLANG_RELEASE_ASSERT((0 <= argIndex) && (argIndex < argCount));
Emit("(");
emitIROperand(ctx, args[argIndex].get(), mode, kEOp_General);
@@ -3223,7 +3223,7 @@ struct EmitVisitor
// we can use it in the constructed expression.
SLANG_RELEASE_ASSERT(*cursor >= '0' && *cursor <= '9');
- UInt argIndex = (*cursor++) - '0';
+ Index argIndex = (*cursor++) - '0';
SLANG_RELEASE_ASSERT(argCount > argIndex);
auto vectorArg = args[argIndex].get();
@@ -3246,7 +3246,7 @@ struct EmitVisitor
// (this is the inverse of `$z`).
//
SLANG_RELEASE_ASSERT(*cursor >= '0' && *cursor <= '9');
- UInt argIndex = (*cursor++) - '0';
+ Index argIndex = (*cursor++) - '0';
SLANG_RELEASE_ASSERT(argCount > argIndex);
auto arg = args[argIndex].get();
@@ -3303,7 +3303,7 @@ struct EmitVisitor
// with the front-end picking the right overload
// based on the "address space" of the argument.
- UInt argIndex = 0;
+ Index argIndex = 0;
SLANG_RELEASE_ASSERT(argCount > argIndex);
auto arg = args[argIndex].get();
@@ -3328,7 +3328,7 @@ struct EmitVisitor
// to the `imageAtomic*` function.
//
- UInt argIndex = 0;
+ Index argIndex = 0;
SLANG_RELEASE_ASSERT(argCount > argIndex);
auto arg = args[argIndex].get();
@@ -3411,7 +3411,7 @@ struct EmitVisitor
// used as the argument ray payload at a
// trace call site.
- UInt argIndex = 0;
+ Index argIndex = 0;
SLANG_RELEASE_ASSERT(argCount > argIndex);
auto arg = args[argIndex].get();
auto argLoad = as<IRLoad>(arg);
@@ -3428,7 +3428,7 @@ struct EmitVisitor
// used as the argument callable payload at a
// call site.
- UInt argIndex = 0;
+ Index argIndex = 0;
SLANG_RELEASE_ASSERT(argCount > argIndex);
auto arg = args[argIndex].get();
auto argLoad = as<IRLoad>(arg);
@@ -4105,8 +4105,8 @@ struct EmitVisitor
auto ii = (IRSwizzle*)inst;
emitIROperand(ctx, ii->getBase(), mode, leftSide(outerPrec, prec));
emit(".");
- UInt elementCount = ii->getElementCount();
- for (UInt ee = 0; ee < elementCount; ++ee)
+ const Index elementCount = Index(ii->getElementCount());
+ for (Index ee = 0; ee < elementCount; ++ee)
{
IRInst* irElementIndex = ii->getElementIndex(ee);
SLANG_RELEASE_ASSERT(irElementIndex->op == kIROp_IntLit);
@@ -4816,8 +4816,8 @@ struct EmitVisitor
{
assert(attrib);
- attrib->args.Count();
- if (attrib->args.Count() != 1)
+ attrib->args.getCount();
+ if (attrib->args.getCount() != 1)
{
SLANG_DIAGNOSE_UNEXPECTED(getSink(), entryPoint->loc, "Attribute expects single parameter");
return;
@@ -4843,8 +4843,8 @@ struct EmitVisitor
{
assert(attrib);
- attrib->args.Count();
- if (attrib->args.Count() != 1)
+ attrib->args.getCount();
+ if (attrib->args.getCount() != 1)
{
SLANG_DIAGNOSE_UNEXPECTED(getSink(), entryPoint->loc, "Attribute expects single parameter");
return;
@@ -6814,7 +6814,7 @@ struct EmitVisitor
}
ctx->mapInstToLevel[inst] = requiredLevel;
- ctx->actions->Add(action);
+ ctx->actions->add(action);
}
void computeIREmitActions(