Modify shading code so that we can write code once
    and make it run "everywhere".
975400
def convert_shaders(convert, shaders):
    

    # New version of the shaders
    out = []

    if convert == 'es2':

        for isfragment, shader in enumerate(shaders):
            has_version = False
            has_prec_float = False
            has_prec_int = False
            lines = []
            # Iterate over lines
            for line in shader.lstrip().splitlines():
                if line.startswith('#version'):
                    has_version = True
                    continue
                if line.startswith('precision '):
                    has_prec_float = has_prec_float or 'float' in line
                    has_prec_int = has_prec_int or 'int' in line
                lines.append(line.rstrip())
            # Write
            # BUG: fails on WebGL (Chrome)
            # if True:
            #     lines.insert(has_version, '#line 0')
            if not has_prec_float:
                lines.insert(has_version, 'precision highp float;')
            if not has_prec_int:
                lines.insert(has_version, 'precision highp int;')
            # BUG: fails on WebGL (Chrome)
            # if not has_version:
            #     lines.insert(has_version, '#version 100')
            out.append('\n'.join(lines))

    elif convert == 'desktop':

        for isfragment, shader in enumerate(shaders):
            has_version = False
            lines = []
            # Iterate over lines
            for line in shader.lstrip().splitlines():
                has_version = has_version or line.startswith('#version')
                if line.startswith('precision '):
                    line = ''
                for prec in (' highp ', ' mediump ', ' lowp '):
                    line = line.replace(prec, ' ')
                lines.append(line.rstrip())
            # Write
            if not has_version:
                lines.insert(0, '#version 120\n')
            out.append('\n'.join(lines))

    else:
        raise ValueError('Cannot convert shaders to %r.' % convert)

    return tuple(out)
572410
private void updateShadow() {
		float radius = shadowEnabled ? shadowRadius : 0;
		//paint.setShadowLayer(radius, shadowDx, shadowDy, shadowColor);
		paintBorder.setShadowLayer(radius, shadowDx, shadowDy, shadowColor);
		paintSelectorBorder.setShadowLayer(radius, shadowDx, shadowDy, shadowColor);
	}
1226967
def run_once(func):
    '''  '''
    def wrapper(*args, **kwargs):
        if not wrapper.has_run:
            wrapper.has_run = True
            return func(*args, **kwargs)
    wrapper.has_run = False
    return wrapper
110627
function onceify(f) {
  var ran, ret;
  return function() {
    return ran ? ret : (ran=true, ret=f.apply(this,arguments));
  };
}
1174913
function reapplyDisplayStyles() {
    reapplyDisplayStyle(".show-Idl",        e_showIdl.checked)
    reapplyDisplayStyle(".show-JavaScript", e_showJavaScript.checked)
    reapplyDisplayStyle(".show-Java",       e_showJava.checked)
}
1093945
function(code, url, done) {
  var vm = require('vm')
  var sandbox = {}
  var expose = [
    'application',
    'setTimeout',
    'setInterval',
    'clearTimeout',
    'clearInterval'
  ]

  for (var i = 0; i < expose.length; i++) {
    sandbox[expose[i]] = global[expose[i]]
  }

  code = '"use strict";\n' + code
  try {
    vm.runInNewContext(code, vm.createContext(sandbox), url)
    done()
  } catch (e) {
    done(e)
  }
}
505046
def _new_program(self, p):
        
        for k, v in self._set_items.items():
            getattr(p, self._shader)[k] = v
842535
function compileProgram(gl, vertex, fragment) {
       var vertShader = compileShader(gl, gl.VERTEX_SHADER, vertex);
       var fragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragment);
       var program = gl.createProgram();
       gl.attachShader(program, vertShader);
       gl.attachShader(program, fragShader);
       gl.linkProgram(program);

       if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
         throw new Error("Error initializing Shader " + this + "\n" + "gl.VALIDATE_STATUS: " + gl.getProgramParameter(program, gl.VALIDATE_STATUS) + "\n" + "gl.getError()" + gl.getError() + "\n" + "gl.getProgramInfoLog()" + gl.getProgramInfoLog(program));
       }

       gl.useProgram(program); // clean-up

       gl.deleteShader(vertShader);
       gl.deleteShader(fragShader);
       return program;
     }
87896
public function weave(): void
    {
        if (!count($this->modules)) {
            return;
        }
        $compiler = $this->getCompiler();
        $container = $this->containerAdaptor($this->app);
        foreach ($this->aspectConfiguration() as $class => $pointcuts) {
            $bind = (new AspectBind($this->filesystem, strval($this->configure['cache_dir']), $this->cacheable))
                ->bind($class, $pointcuts);
            $container->intercept($class, $bind, $compiler->compile($class, $bind));
        }
    }
7223
function transformShader(shaderContent, variableDict, config) {
  let match = null;
  let unrolledContents = null;
  let shaderString = shaderContent;

  // First do all the variable replacements
  Object.keys(variableDict).forEach((vname) => {
    const value = variableDict[vname];
    const r = new RegExp(`\\$\\{${vname}\\}`, 'g');
    shaderString = shaderString.replace(r, value);
  });

  // Now check if any loops need to be inlined
  if (config.inlineLoops) {
    const loopRegex = /\/\/@INLINE_LOOP([\s\S]+?)(?=\/\/@INLINE_LOOP)\/\/@INLINE_LOOP/;

    match = shaderString.match(loopRegex);
    while (match) {
      const capture = match[1];
      /* eslint-disable no-useless-escape */
      const infoRegex = /^\s*\(([^\),]+)\s*,\s*([^\),]+)\s*,\s*([^\)]+)\)/;
      const infoRegexMatch = capture.match(infoRegex);
      const loopVariableName = infoRegexMatch[1];
      const loopMin = infoRegexMatch[2];
      const loopCount = infoRegexMatch[3];
      const forLoop = capture.replace(infoRegex, '');
      const loopContentsRegex = /^\s*[^\{]+\{([\s\S]+?)\s*\}\s*$/;
      /* eslint-enable no-useless-escape */
      const forLoopMatch = forLoop.match(loopContentsRegex);
      const loopBody = forLoopMatch[1];
      const loopBodyReplacer = new RegExp(loopVariableName, 'g');

      unrolledContents = '';
      for (let i = loopMin; i < loopCount; ++i) {
        unrolledContents += loopBody.replace(loopBodyReplacer, i);
        unrolledContents += '\n';
      }

      shaderString = shaderString.replace(loopRegex, unrolledContents);
      match = shaderString.match(loopRegex);
    }
  }

  if (config.debug) {
    console.log('Transformed shader string:');
    console.log(shaderString);
  }

  return shaderString;
}
101927
def rewrite_css(css_module_code)
      # Parse incoming CSS into an AST
      css_root = Sass::SCSS::CssParser.new(css_module_code, "(CSSModules)", 1).parse

      Sass::Tree::Visitors::SetOptions.visit(css_root, {})
      ModuleVisitor.visit(css_root)

      css_root.render
    end
1102892
function compileShader( gl, shader, code ){
  gl.shaderSource( shader, code );
  gl.compileShader( shader );

  if (Program.debug && !gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
    warn( gl.getShaderInfoLog(shader) );
    warn( formatCode( code ) );
    return false;
  }

  return true;
}
419765
function updateSourceCode(code, changes) {
  // Summary:
  //  This must be called before code is changed some places else rather than ast

  changes.sort((c1, c2) => c2.start - c1.start);
  // Remove same or overlapped changes
  const newChanges = _.reduce(
    changes,
    (cleanChanges, curr) => {
      const last = _.last(cleanChanges);

      if (!cleanChanges.length || last.start > curr.end) {
        cleanChanges.push(curr);
      } else if (last.start === last.end && last.end === curr.start && curr.start === curr.end) {
        // insert code at the same position, merge them
        last.replacement += curr.replacement;
      }
      return cleanChanges;
    },
    [],
  );

  const chars = code.split('');
  newChanges.forEach(c => {
    // Special case: after the change, two empty lines occurs, should delete one line
    if (
      c.replacement === '' &&
      (c.start === 0 || chars[c.start - 1] === '\n') &&
      chars[c.end] === '\n'
    ) {
      c.end += 1;
    }
    chars.splice(c.start, c.end - c.start, c.replacement);
  });
  return chars.join('');
}
158283
def _run_module_code(code, init_globals=None,
                    mod_name=None, mod_fname=None,
                    mod_loader=None, pkg_name=None):
    """"""
    with _ModifiedArgv0(mod_fname):
        with _TempModule(mod_name) as temp_module:
            mod_globals = temp_module.module.__dict__
            _run_code(code, mod_globals, init_globals,
                      mod_name, mod_fname, mod_loader, pkg_name)
    # Copy the globals of the temporary module, as they
    # may be cleared when the temporary module goes away
    return mod_globals.copy()
866174
function (code, location) {

			if (arguments.length === 1) {
				location = code;
				code = 302;
			}

			render(code, EMPTY_STRING, location);
		}
1346056
public function onBeforeInit() {
        $only_dev = LessCompilerConfig::config()->only_dev;
        
        // Only check and compile either on dev, or on all environments (if set)
        if (!$only_dev || $only_dev && Director::isDev()) {

            // Allow extensions for before less is compiled
            $this->owner->extend("onBeforeLessCompiler");

            $files = LessCompilerConfig::config()->file_mappings;
            $root_path = LessCompilerConfig::config()->root_path;
            $temp_folder = TEMP_FOLDER;
            
            if (is_array($files)) {
                $theme_dir = Controller::join_links(
                    "themes",
                    SSViewer::current_theme()
                );
                $base_theme = Controller::join_links(
                    $theme_dir,
                    SSViewer::current_theme()
                );
                
                $options = array('cache_dir' => $temp_folder);
                
                if (LessCompilerConfig::config()->compress) {
                    $options['compress'] = true;
                }
                
                // First loop through all files and deal with inputs
                foreach ($files as $input => $output) {
                    if ($input && $output) {
                        
                        // Does output and input contain a path
                        if (strpos($input, '/') === false) {
                            $input = Controller::join_links(
                                $theme_dir,
                                "less",
                                $input
                            );
                        }
                        
                        if (strpos($output, '/') === false) {
                            $output = Controller::join_links(
                                $theme_dir,
                                "css",
                                $output
                            );
                        }
                        
                        // Now append the full system path to the input
                        // and output file.
                        $input = Controller::join_links(BASE_PATH, $input);
                        $output = Controller::join_links(BASE_PATH, $output);
                        
                        // Finally try to compile our less files
                        try {
                            $css_file_name = Less_Cache::Get(
                                array( $input => $root_path),
                                $options
                            );
                            $css = file_get_contents(Controller::join_links($temp_folder,$css_file_name));
                            
                            $output_file = fopen($output, "w");
                            fwrite($output_file, $css);
                            fclose($output_file);
                        } catch (exception $e) {
                            error_log($e->getMessage());
                        }
                    }
                }
            }

            // Allow extensions for after less has compiled
            $this->owner->extend("onAfterLessCompiler");
        }
    }
177482
function RenderProgramWrapper(layer, shader) {
    this.shader = shader;
    this.layer = layer;
    this.context = layer.context;
    this.draw = function() {};

    this.array_size = 16;
    this.max_size = 1024;
    this._indexArray = new Uint16Array(6 * this.array_size);
    this._indexBuffer = layer.context.createBuffer();
}