parseUniform function

void parseUniform(
  1. dynamic activeInfo,
  2. dynamic addr,
  3. WebGLUniform container
)

Implementation

void parseUniform(activeInfo, addr, WebGLUniform container) {
  var path = activeInfo.name;
  var pathLength = path.length;

  // print("WebGLUniformsHelper.parseUniform path: ${path} addr: ${addr} ");

  // reset RegExp object, because of the early exit of a previous run
  // RePathPart.lastIndex = 0;

  var matches = rePathPart.allMatches(path);

  for (var match in matches) {
    dynamic id = match.group(1);
    var idIsIndex = match.group(2) == ']';
    var subscript = match.group(3);

    if (idIsIndex) id = int.parse(id); // convert to integer

    var matchEnd = match.end;

    if (subscript == null || subscript == '[' && matchEnd + 2 == pathLength) {
      // bare name or "pure" bottom-level array "[0]" suffix

      addUniform(
          container, subscript == null ? SingleUniform(id, activeInfo, addr) : PureArrayUniform(id, activeInfo, addr));

      break;
    } else {
      // step into inner node / create it in case it doesn't exist

      var map = container.map;
      var next = map[id];

      if (next == null) {
        next = StructuredUniform(id);
        addUniform(container, next);
      }

      container = next;
    }
  }
}