TODO: move this to IonConstants or IonUTF8
1337
static final public int makeUTF8IntFromScalar(int c) throws IOException
    {
        // TO DO: check this encoding, it is from:
        //      http://en.wikipedia.org/wiki/UTF-8
        // we probably should use some sort of Java supported
        // library for this.  this class might be of interest:
        //     CharsetDecoder(Charset cs, float averageCharsPerByte, float maxCharsPerByte)
        // in: java.nio.charset.CharsetDecoder

        int value = 0;

        // first the quick, easy and common case - ascii
        if (c < 0x80) {
            value = (0xff & c );
        }
        else if (c < 0x800) {
            // 2 bytes characters from 0x000080 to 0x0007FF
            value  = ( 0xff & (0xC0 | (c >> 6)        ) );
            value |= ( 0xff & (0x80 | (c       & 0x3F)) ) <<  8;
        }
        else if (c < 0x10000) {
            // 3 byte characters from 0x800 to 0xFFFF
            // but only 0x800...0xD7FF and 0xE000...0xFFFF are valid
            if (c > 0xD7FF && c < 0xE000) {
                throwUTF8Exception();
            }
            value  = ( 0xff & (0xE0 |  (c >> 12)       ) );
            value |= ( 0xff & (0x80 | ((c >>  6) & 0x3F)) ) <<  8;
            value |= ( 0xff & (0x80 |  (c        & 0x3F)) ) << 16;

        }
        else if (c <= 0x10FFFF) {
            // 4 byte characters 0x010000 to 0x10FFFF
            // these are are valid
            value  = ( 0xff & (0xF0 |  (c >> 18)) );
            value |= ( 0xff & (0x80 | ((c >> 12) & 0x3F)) ) <<  8;
            value |= ( 0xff & (0x80 | ((c >>  6) & 0x3F)) ) << 16;
            value |= ( 0xff & (0x80 |  (c        & 0x3F)) ) << 24;
        }
        else {
            throwUTF8Exception();
        }
        return value;
    }
164438
private _Private_IonTextWriterBuilder fillDefaults()
    {
        // Ensure that we don't modify the user's builder.
        IonTextWriterBuilder b = copy();

        if (b.getCatalog() == null)
        {
            b.setCatalog(new SimpleCatalog());
        }

        if (b.getCharset() == null)
        {
            b.setCharset(UTF8);
        }

        return (_Private_IonTextWriterBuilder) b.immutable();
    }
899367
public void addLoadConstant(int k) {
        switch (k) {
            case 0:
                add(ByteCode.ICONST_0);
                break;
            case 1:
                add(ByteCode.ICONST_1);
                break;
            case 2:
                add(ByteCode.ICONST_2);
                break;
            case 3:
                add(ByteCode.ICONST_3);
                break;
            case 4:
                add(ByteCode.ICONST_4);
                break;
            case 5:
                add(ByteCode.ICONST_5);
                break;
            default:
                add(ByteCode.LDC, itsConstantPool.addConstant(k));
                break;
        }
    }
684131
def _copy(self):
        
        args, kwargs = self._to_constructor_args(self)
        value = self.__class__(*args, **kwargs)
        value.ion_event = None
        value.ion_type = self.ion_type
        value.ion_annotations = self.ion_annotations
        return value
1062961
function _fnGetTrNodes ( oSettings )
		{
			var aNodes = [];
			var aoData = oSettings.aoData;
			for ( var i=0, iLen=aoData.length ; i<iLen ; i++ )
			{
				if ( aoData[i].nTr !== null )
				{
					aNodes.push( aoData[i].nTr );
				}
			}
			return aNodes;
		}
1128904
function (src) {
    if (isConstant(src)) {
      return this.buffer(toConstant(src) + '')
    }
    var body = this.parseExpr(src);
    var ast = this.ast_buffer(body);
    return ast;
  }
514632
function outputNeededConstants( code ) {
    try {
        let out = arrayToCodeWithNewLine( code.generateRequires(), "    " );
        out += arrayToCodeWithNewLine( code.generateNeededBehindFunctions(), "    " );
        out += arrayToCodeWithNewLine( code.generateFunctions(), "    " );
        out += arrayToCodeWithNewLine( code.generateGlobalVariables(), "    " );
        return out;
    } catch ( ex ) {
        bubble( ex, "outputNeededConstants" );
        return null;
    }
}
952767
function (src) {
    if (isConstant(src)) {
      return this.buffer(toConstant(src) + '')
    }
    if (this.lastBufferedIdx == this.buf.length && this.bufferedConcatenationCount < 100) {
      this.bufferedConcatenationCount++;
      if (this.lastBufferedType === 'text') this.lastBuffered += '"';
      this.lastBufferedType = 'code';
      this.lastBuffered += ' + (' + src + ')';
      this.buf[this.lastBufferedIdx - 1] = 'pug_html = pug_html + (' + this.bufferStartChar + this.lastBuffered + ');';
    } else {
      this.bufferedConcatenationCount = 0;
      this.buf.push('pug_html = pug_html + (' + src + ');');
      this.lastBufferedType = 'code';
      this.bufferStartChar = '';
      this.lastBuffered = '(' + src + ')';
      this.lastBufferedIdx = this.buf.length;
    }
  }
42774
def write_atoms(fn, this, cycfn=None, conv=1.0, symbols=True):
    
    f = paropen(fn, "w")

    f.write("<--- Number of atoms\n")
    f.write("%i\n" % len(this))
    f.write("<--- Number of occupied orbitals\n")
    f.write("%f\n" % 0.0)
    f.write("<--- Atom positions\n")

    groups = None
    if this.has("groups"):
        groups = this.get_array("groups")

    gamma = None
    if this.has("gamma"):
        gamma = this.get_array("gamma")

    T = None
    if this.has("T"):
        T = this.get_array("T")

    for idx, i in enumerate(this):
        group_str = "1"
        if groups is not None:
            group_str = "%i" % groups[idx]
        gamma_str = "0.0"
        if gamma is not None:
            gamma_str = "%20.10e" % gamma[idx]
        T_str = "0.0"
        if T is not None:
            T_str = "%20.10e" % T[idx]

        sym = i.symbol

        r = i.position

        if symbols:
            f.write("%s   %f   %20.10e  %20.10e  %20.10e   %s %s %s\n" % (sym, ase.data.atomic_masses[ase.data.chemical_symbols.index(sym)], r[0]*conv, r[1]*conv, r[2]*conv, group_str, gamma_str, T_str))
        else:
            f.write("%i   %f   %20.10e  %20.10e  %20.10e   %s %s %s\n" % (ase.data.chemical_symbols.index(sym), ase.data.atomic_masses[ase.data.chemical_symbols.index(sym)], r[0]*conv, r[1]*conv, r[2]*conv, group_str, gamma_str, T_str))


    f.write("<--- Velocities\n")
    for i in this:
        m = i.mass
        if m is None:
            m = ase.data.atomic_masses[ase.data.chemical_symbols.index(i.symbol)]
        if i.momentum is not None:
            v = i.momentum/m
        else:
            v = [ 0.0, 0.0, 0.0 ]
        f.write("%20.10e %20.10e %20.10e\n" % ( v[0], v[1], v[2] ))

    f.write("<--- Forces\n")
    for i in this:
        f.write("0 0 0\n")

    f.write("<--- cell\n")
    cell = this.get_cell()
    f.write("%f %f %f\n" % tuple(cell[0, :]))
    f.write("%f %f %f\n" % tuple(cell[1, :]))
    f.write("%f %f %f\n" % tuple(cell[2, :]))

    for name, aux in this.arrays.items():
        if not name in atoms_default_fields:
            f.write("<--- %s\n" % name)
            if aux.dtype == int:
                if len(aux.shape) == 1:
                    for i in this:
                        f.write(" %i\n" % aux[i.index])
                else:
                    for i in this:
                        f.write(( aux.shape[1]*" %i" + "\n" ) % tuple(aux[i.index].tolist()))
            else:
                if len(aux.shape) == 1:
                    for i in this:
                        f.write(" %e\n" % aux[i.index])
                else:
                    for i in this:
                        f.write(( aux.shape[1]*" %e" + "\n" ) % tuple(aux[i.index].tolist()))

    f.close()

    if cycfn:
        write_cyc(cycfn, this, conv=conv)
910730
def _ions(self, f):
        
        outside_pos = f.tell()
        doff = find_offset(f, 4 * b'\xff' + 'HapsSearch'.encode('ascii'))
        # actual end of prev section is 34 bytes before, but assume 1 rec
        f.seek(doff - 62)
        # seek backwards to find the FFFFFFFF header
        while True:
            f.seek(f.tell() - 8)
            if f.read(4) == 4 * b'\xff':
                break
        f.seek(f.tell() + 64)
        nsegments = struct.unpack('<I', f.read(4))[0]
        for _ in range(nsegments):
            # first 32 bytes are segment name, rest are something else?
            f.seek(f.tell() + 96)
            nions = struct.unpack('<I', f.read(4))[0]
            ions = []
            for _ in range(nions):
                # TODO: check that itype is actually a SIM/full scan switch
                i1, i2, _, _, _, _, itype, _ = struct.unpack('<' + 8 * 'I',
                                                             f.read(32))
                if itype == 0:  # SIM
                    ions.append(i1 / 100.)
                else:  # full scan
                    # TODO: this might be a little hacky?
                    #  ideally we would need to know n for this, e.g.:
                    # ions += np.linspace(i1 / 100, i2 / 100, n).tolist()
                    ions += np.arange(i1 / 100., i2 / 100. + 1, 1).tolist()
            # save the file position and load the position
            # that we were at before we started this code
            inside_pos = f.tell()
            f.seek(outside_pos)
            yield ions
            outside_pos = f.tell()
            f.seek(inside_pos)
        f.seek(outside_pos)
170168
public final static void writeExtendedMediumInt(IoBuffer out, int value) {
        value = ((value & 0xff000000) >> 24) | (value << 8);
        out.putInt(value);
    }
145295
def _ensureAtomicity(fn):
    """"""
    @ensureScoopStartedProperly
    def wrapper(*args, **kwargs):
        """setConst(**kwargs)
        Set a constant that will be shared to every workers.
        This call blocks until the constant has propagated to at least one
        worker.

        :param \*\*kwargs: One or more combination(s) key=value. Key being the
            variable name and value the object to share.

        :returns: None.

        Usage: setConst(name=value)
        """
        # Note that the docstring is the one of setConst.
        # This is because of the documentation framework (sphinx) limitations.

        from . import _control

        # Enforce retrieval of currently awaiting constants
        _control.execQueue.socket.pumpInfoSocket()

        for key, value in kwargs.items():
            # Object name existence check
            if key in itertools.chain(*(elem.keys() for elem in elements.values())):
                raise TypeError("This constant already exists: {0}.".format(key))

        # Retry element propagation until it is returned
        while all(key in elements.get(scoop.worker, []) for key in kwargs.keys()) is not True:
            scoop.logger.debug("Sending global variables {0}...".format(
                list(kwargs.keys())
            ))
            # Call the function
            fn(*args, **kwargs)

            # Enforce retrieval of currently awaiting constants
            _control.execQueue.socket.pumpInfoSocket()

            # TODO: Make previous blocking instead of sleep
            time.sleep(0.1)

        # Atomicity check
        elementNames = list(itertools.chain(*(elem.keys() for elem in elements.values())))
        if len(elementNames) != len(set(elementNames)):
            raise TypeError("This constant already exists: {0}.".format(key))

    return wrapper
1274372
private _Private_IonBinaryWriterBuilder fillDefaults()
    {
        // Ensure that we don't modify the user's builder.
        _Private_IonBinaryWriterBuilder b = copy();

        if (b.getSymtabValueFactory() == null)
        {
            IonSystem system = IonSystemBuilder.standard().build();
            b.setSymtabValueFactory(system);
        }

        return b.immutable();
    }
52372
@Override
	public EnumeratedConstant findConstantInScope(String currentScope, String constant)
    {
        int i = constant.indexOf('.');
        if (i == -1)
        {
            return null;
        }
        String className = constant.substring(0,i);
        String fieldName = constant.substring(i+1);
        List<String> constants = m_constants.get(className);
        if (constants == null)
        {
            return null;
        }
        if (constants.contains(fieldName))
        {
            return new EnumeratedConstant(m_xsdpackageName,className,fieldName);
        }
        return null;
    }
203672
@Override
    @Nullable
    public Constant getConstant(int column) throws OntopResultConversionException {
        final MainTypeLangValues cell = row.get(column - 1);
        if (cell.getMainValue() == null) {
            return null;
        } else {
            return constantRetriever.getConstantFromJDBC(cell);
        }
    }
549508
public final void enumConstant() throws RecognitionException {
		int enumConstant_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 14) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:330:5: ( ( annotations )? Identifier ( arguments )? ( classBody )? )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:330:7: ( annotations )? Identifier ( arguments )? ( classBody )?
			{
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:330:7: ( annotations )?
			int alt23=2;
			int LA23_0 = input.LA(1);
			if ( (LA23_0==58) ) {
				alt23=1;
			}
			switch (alt23) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:330:7: annotations
					{
					pushFollow(FOLLOW_annotations_in_enumConstant491);
					annotations();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			match(input,Identifier,FOLLOW_Identifier_in_enumConstant494); if (state.failed) return;
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:330:31: ( arguments )?
			int alt24=2;
			int LA24_0 = input.LA(1);
			if ( (LA24_0==36) ) {
				alt24=1;
			}
			switch (alt24) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:330:32: arguments
					{
					pushFollow(FOLLOW_arguments_in_enumConstant497);
					arguments();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:330:44: ( classBody )?
			int alt25=2;
			int LA25_0 = input.LA(1);
			if ( (LA25_0==121) ) {
				alt25=1;
			}
			switch (alt25) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:330:45: classBody
					{
					pushFollow(FOLLOW_classBody_in_enumConstant502);
					classBody();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 14, enumConstant_StartIndex); }

		}
	}
562726
function(key) {
  this.buffer = new Uint8Array(16);
  this.r = new Uint16Array(10);
  this.h = new Uint16Array(10);
  this.pad = new Uint16Array(8);
  this.leftover = 0;
  this.fin = 0;

  var t0, t1, t2, t3, t4, t5, t6, t7;

  t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0                     ) & 0x1fff;
  t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 <<  3)) & 0x1fff;
  t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 <<  6)) & 0x1f03;
  t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>>  7) | (t3 <<  9)) & 0x1fff;
  t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>>  4) | (t4 << 12)) & 0x00ff;
  this.r[5] = ((t4 >>>  1)) & 0x1ffe;
  t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 <<  2)) & 0x1fff;
  t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 <<  5)) & 0x1f81;
  t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>>  8) | (t7 <<  8)) & 0x1fff;
  this.r[9] = ((t7 >>>  5)) & 0x007f;

  this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
}