text:
package Interpreter;

import StatementClasses.*;
import StatementExecuteClasses.Executor;

import java.util.ArrayList;
import java.util.Stack;

public class Context {
    private static Context Instance = new Context();
    public static Context getInstance() {return Instance;}
    private Context() {
        statue = new Stack();
        varinit =false;
        argms = null;
        Expression1 = 0;
        Expression2 = 0;
        Expression3 = 0;
    }

    private Stack<Integer> statue;

    private String identifier;
    private boolean varinit;
    private int Expression1;
    private int Expression2;
    private int Expression3;
    private ArrayList<Integer> argms;
    static Executor Exe = new Executor();
    //private SingleExpression S1;
    /*
        0------------idle
        1------------Block Start
        2------------Var Def Statement
        3------------Return Statement
        4------------If Statement, haven't meet Expression
        5------------If Statement, haven't meet Else
        6------------If Statement, have met Else
        7------------Expression statement
        8------------Argument Statement
        9------------For Statement, haven't meet First Expression
        10-----------For Statement, haven't meet Second Expression
        11-----------For Statement, haven't meet Third Expression
        12-----------For Statement, Reading for statement
        13-----------While Statement, waiting for condition Expression
        14-----------While Statement, Reading for statement
        15-----------Function Declaration, havn't meet Function Body
        16-----------Function Declaration, meeting function body
        17-----------New Statement
        18-----------For Statement, Can read input.
        19-----------While Statement, Can read input.
     */

    public int initial() {
        statue = new Stack<Integer>();
        statue.push(0);
        identifier = "";
        varinit = false;
        //S1 = NULL;
        //Exe = new Executor();
        return 0;

    }

    public int blockstart() {
        if (statue.peek() == 2) {
            return -1;
        } else {
            if (statue.peek() != 5 && statue.peek() != 6 && statue.peek() != 18 && statue.peek() != 16 && statue.peek() != 19) {
                NewSegStatement E = new NewSegStatement();
                try {
                    Exe.ExecuteStatement(E);
                } catch (Exception Err) {
                    Err.printStackTrace();
                }
            }
            statue.push(1);
            return 0;
        }
    }

    public int blockend(){
        if (statue.peek() == 2) {
            return -1;
        } else {
            OverSegStatement E = new OverSegStatement();
            try {
                Exe.ExecuteStatement(E);
            } catch (Exception Err) {
                Err.printStackTrace();
            }
            statue.pop();
            return 0;
        }
    }

    public int VardefStart() {
        statue.push(2);
        return 0;
    }

    public int setIdentifier(String s) {
        identifier = s;
        return 0;
    }

    public int initforVar() {
        varinit = true;
        return 0;
    }

    public int NoinitforVar() {
        varinit =false;
        return 0;
    }

    public int EndVarDef() {
        statue.pop();
        System.out.println("Var Define:"+identifier);
        VarDeclStatement varDeclStatement=new VarDeclStatement(identifier);
        try {
            Exe.ExecuteStatement(varDeclStatement);
        } catch (Exception E) {

        }

        if (varinit == true) {
           /* ExpressionStatement E = new ExpressionStatement(Expression1);
            try {
                Exe
            }*/
            varinit = false;
        }
        return 0;
    }

    public int SignalBreak() {
        BreakStatement s = new BreakStatement();
        try {
            Exe.ExecuteStatement(s);
        } catch (Exception Err) {

        }
        System.out.println("BreakAssignment");
        return 0;
    }

    public int SignalContinue() {
       /* ContinueStatement s = new ContinueStatement();
        try {
            Exe.ExecuteStatement(s);
        } catch (Exception Err) {

        }*/
        System.out.println("Continue!");
        return 0;
    }

    public int SignalReturn() {
        statue.push(3);
        Expression1 = -1;
        System.out.println("Return!");
        return 0;
    }

    public int EndofReturn() {
        ReturnStatement S = new ReturnStatement(Expression1);
        try {
            Exe.ExecuteStatement(S);
        } catch (Exception Err) {

        }
        statue.pop();
        return 0;
    }

    public int Ifstart() {
        statue.push(4);
        return 0;
    }

    public int IfcondSet() {
        if (statue.peek() != 4) {
            System.err.println("Wrong If statement!");
            return -1;
        } else {
            statue.pop();
            statue.push(5);
            IfStatement E = new IfStatement(Expression1);
            try {
                Exe.ExecuteStatement(E);
            } catch (Exception Err) {
                Err.printStackTrace();
            }
            /*
                Create a if statement
                Condition = Expression1
             */
            return 0;
        }
    }

    public int ElseSet() {
        if (statue.peek() != 5) {
            System.err.println("Wrong If statement!");
            return -1;
        } else {
            statue.pop();
            statue.push(6);
            ElseStatement E = new ElseStatement();
            try {
                Exe.ExecuteStatement(E);
            } catch (Exception Err) {
                Err.printStackTrace();
            }
            /*
                Create a else statement;
             */
            return 0;
        }
    }

    public int EndofIf() {
        if (statue.peek() != 6 && statue.peek() != 5) {
            System.err.println("Wrong If statement!");
            return -1;
        } else {
            statue.pop();
            return 0;
        }
    }

    public int pushExpression(int index) {
        switch (statue.peek()) {
            case 7: statue.add(7); return 0;
            case 3: case 4: {
                Expression1 = index;
                break;
            }
            case 2: {
                if (varinit) {
                    Expression1 = index;
                    break;
                }
            }
            case 8:{
                //argms.add(index);
                break;
            }
            case 9:{
                statue.pop();
                statue.push(10);
                Expression1 = index;
                break;
            }
            case 10:{
                statue.pop();
                statue.push(11);
                Expression2 = index;
                break;
            }
            case 11:{
                statue.pop();
                statue.push(12);
                Expression3 = index;
                break;
            }
            case 13:{
                statue.pop();
                statue.push(14);
                Expression1 = index;
            }
            default:

        }
        statue.add(7);
        return 0;
    }
    public int EndExpression(int index) {
        statue.pop();
        int s = statue.peek();
        if (s == 1 || s == 6 || s == 5 || s == 18 || s == 19 || s == 0 || s == 16
            /*&& something else */){
            try {
                ExpressionStatement E = new ExpressionStatement(index);
                Exe.ExecuteStatement(E);
            } catch (Exception E) {
                E.printStackTrace();
            }
        }
        return 0;
    }

    public int VisitArgument(int index) {
        statue.push(8);
        System.out.println("Function Call!");
        argms = new ArrayList<Integer>();
        return 0;
    }

    public ArrayList<Integer> AskForArgument() {
        return argms;
    }

    public int ArgumentFinish(int index) {
        statue.pop();

        return 0;
    }

    public int ForStatementBegin() {
        statue.push(9);
        return 0;
    }

    public int ForStatementEnd() {
        if (statue.peek() != 12) {
            System.err.println("Wrong For Statement!");
            return -1;
        } else {
            statue.pop();
            statue.push(18);
            ForStatement s = new ForStatement(Expression1,Expression2,Expression3);
            try {
                Exe.ExecuteStatement(s);
            } catch (Exception Err) {

            }
        }
        return 0;
    }

    public int ForStatementBodyEnd() {
        if (statue.peek() != 18) {
            System.err.println("Wrong For Statement!");
            return -1;
        } else {
            /*
                Signal That For statement End
             */
        }
        statue.pop();
        return 0;
    }

    public int WhileStatementBegin() {
        statue.push(13);
        return 0;
    }

    public int WhileStatementEnd() {
        if (statue.peek() != 14) {
            System.err.println("Wrong While Statement!");
            return -1;
        } else {
            statue.pop();
            statue.push(19);
            WhileStatement s = new WhileStatement(Expression1);
            try {
                Exe.ExecuteStatement(s);
            } catch (Exception Err) {

            }
        }
        return 0;
    }

    public int WhileStatementBodyEnd() {
        if (statue.peek() != 19) {
            System.err.println("Wrong While Statement!");
            return -1;
        } else {
            /*
                Signal That For statement End
             */
        }
        statue.pop();
        return 0;
    }

    public int FunctionDeclaration() {
        statue.push(15);
        return 0;
    }

    public ArrayList<Integer> SetFunctionPara() {
        argms = new ArrayList<Integer>();
        return argms;
    }

    public int FunctionBodyBegin() {
        if (statue.peek() == 15) {
            FuncDefStatement F = new FuncDefStatement(identifier,argms);
            try {
                Exe.ExecuteStatement(F);
            } catch (Exception Err) {

            }
            statue.pop();
            statue.push(16);
            return 0;
        } else {
            System.err.println("Wrong Function Expression");
            return -1;
        }
    }

    public int FunctionBodyEnd() {
        OverSegStatement E = new OverSegStatement();
        try {
            Exe.ExecuteStatement(E);
        } catch (Exception Err) {
            Err.printStackTrace();
        }
        statue.pop();
        return 0;
    }

    public int NewExpressionBegin(int index) {
        statue.push(17);
        return 0;
    }

    public int NewExpressionEnd(int index) {
        statue.pop();
        ExpressionStatement S = new ExpressionStatement(index);
        try {
            Exe.ExecuteStatement(S);
        } catch (Exception Err) {

        }
        return 0;
    }
}


text:
<?php

/**
 * Visit itemized list / bullet lists
 *
 * Visit itemized lists (bullet list) and maintain the correct indentation for
 * list items.
 *
 * @package Document
 * @version 1.3.1
 */
class ezcDocumentDocbookToRstVariableListHandler extends ezcDocumentDocbookToRstBaseHandler
{
    /**
     * Handle a node.
     *
     * Handle / transform a given node, and return the result of the
     * conversion.
     *
     * @param ezcDocumentElementVisitorConverter $converter
     * @param DOMElement $node
     * @param mixed $root
     * @return mixed
     */
    public function handle( ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root )
    {
        foreach ( $node->childNodes as $child )
        {
            if ( ( $child->nodeType === XML_ELEMENT_NODE ) &&
                 ( $child->tagName === 'varlistentry' ) )
            {
                $term = $child->getElementsByTagName( 'term' )->item( 0 );
                $root .= ezcDocumentDocbookToRstConverter::wordWrap( trim( $converter->visitChildren( $term, '' ) ) ) . "\n";
                ezcDocumentDocbookToRstConverter::$indentation += 4;
                foreach ( $child->childNodes as $subChild )
                {
                    if ( ( $subChild->nodeType === XML_ELEMENT_NODE ) &&
                         ( $subChild->tagName === 'listitem' ) )
                    {
                        $root = $converter->visitChildren( $subChild, $root );
                    }
                }
                ezcDocumentDocbookToRstConverter::$indentation -= 4;
            }
        }

        return $root;
    }
}

?>

redpajama_set_name: RedPajamaGithub


text:
using AllReady.Areas.Admin.Models;
using AllReady.Models;
using MediatR;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace AllReady.Areas.Admin.Features.Events
{
    public class EventSummaryQueryHandlerAsync : IAsyncRequestHandler<EventSummaryQuery, EventSummaryModel>
    {
        private readonly AllReadyContext _context;

        public EventSummaryQueryHandlerAsync(AllReadyContext context)
        {
            _context = context;
        }

        public async Task<EventSummaryModel> Handle(EventSummaryQuery message)
        {
            EventSummaryModel result = null;

            var campaignEvent = await GetEvent(message);

            if (campaignEvent != null)
            {
                result = new EventSummaryModel
                {
                    Id = campaignEvent.Id,
                    EventType = campaignEvent.EventType,
                    CampaignName = campaignEvent.Campaign.Name,
                    CampaignId = campaignEvent.Campaign.Id,
                    OrganizationId = campaignEvent.Campaign.ManagingOrganizationId,
                    OrganizationName = campaignEvent.Campaign.ManagingOrganization.Name,
                    Name = campaignEvent.Name,
                    Description = campaignEvent.Description,
                    TimeZoneId = campaignEvent.Campaign.TimeZoneId,
                    StartDateTime = campaignEvent.StartDateTime,
                    EndDateTime = campaignEvent.EndDateTime,
                    NumberOfVolunteersRequired = campaignEvent.NumberOfVolunteersRequired,
                    IsLimitVolunteers = campaignEvent.IsLimitVolunteers,
                    IsAllowWaitList = campaignEvent.IsAllowWaitList,
                    ImageUrl = campaignEvent.ImageUrl,
                };
            }

            return result;
        }

        private async Task<Event> GetEvent(EventSummaryQuery message)
        {
            return await _context.Events
                .AsNoTracking()
                .Include(a => a.Campaign).ThenInclude(c => c.ManagingOrganization)
                .SingleOrDefaultAsync(a => a.Id == message.EventId)
                .ConfigureAwait(false);
        }
    }
}


text:
/*
 * @test
 * @bug 4502729 7054918
 * @summary BasicPermissionCollection serial version UID incorrect
 */

import java.security.*;
import java.io.*;

public class SerialVersion {

    public static void main(String[] args) throws Exception {
        String dir = System.getProperty("test.src");
        File  sFile =  new File (dir,"SerialVersion.1.2.1");
        // read in a 1.2.1 BasicPermissionCollection
        try (FileInputStream fis = new FileInputStream(sFile);
                ObjectInputStream ois = new ObjectInputStream(fis)) {
            PermissionCollection pc = (PermissionCollection)ois.readObject();
            System.out.println("1.2.1 collection = " + pc);
        }

        // read in a 1.3.1 BasicPermissionCollection
        sFile =  new File (dir,"SerialVersion.1.3.1");

        try (FileInputStream fis = new FileInputStream(sFile);
                ObjectInputStream ois = new ObjectInputStream(fis)) {
            PermissionCollection pc = (PermissionCollection)ois.readObject();
            System.out.println("1.3.1 collection = " + pc);
        }

        // read in a 1.4 BasicPermissionCollection
        sFile =  new File (dir,"SerialVersion.1.4");
        try (FileInputStream fis = new FileInputStream(sFile);
                ObjectInputStream ois = new ObjectInputStream(fis)) {
            PermissionCollection pc = (PermissionCollection)ois.readObject();
            System.out.println("1.4 collection = " + pc);
        }

        // write out current BasicPermissionCollection
        MyPermission mp = new MyPermission("SerialVersionTest");
        PermissionCollection bpc = mp.newPermissionCollection();
        sFile =  new File (dir,"SerialVersion.current");
        try (FileOutputStream fos = new FileOutputStream("SerialVersion.current");
                ObjectOutputStream oos = new ObjectOutputStream(fos)) {
            oos.writeObject(bpc);
        }

        // read in current BasicPermissionCollection
        try (FileInputStream fis = new FileInputStream("SerialVersion.current");
                ObjectInputStream ois = new ObjectInputStream(fis)) {
            PermissionCollection pc = (PermissionCollection)ois.readObject();
            System.out.println("current collection = " + pc);
        }
    }
}

class MyPermission extends BasicPermission {
    public MyPermission(String name) {
        super(name);
    }
}


text:
static const uint16_t CARTRIDGE_TYPE_ADDRESS = 0x0147;
static const uint16_t ROM_SIZE_CODE_ADDRESS = 0x0148;
static const uint16_t EXTRAM_SIZE_CODE_ADDRESS = 0x0149;

void cart_reset_mbc(struct controller *controller);
void cart_default_cleanup();

static uint8_t mbc_read_ff( struct controller *controller, uint16_t address )
{
  return 0xff;
}

static void mbc_write_dummy( struct controller *controller, uint16_t address, uint8_t data )
{
}

static void mbc_write_ram_enable( struct controller *controller, uint16_t address, uint8_t data )
{
  data &= 0xF;
  if (data == 0) {
    controller->cart.extram_enabled = false;
  } else if (data == 0x0A) {
    controller->cart.extram_enabled = true;
  }
}

static uint8_t mbc_read_bank_0( struct controller *controller, uint16_t address )
{
  return controller->cart.cartrom_bank_zero[address];
}

static uint8_t mbc_read_bank_n( struct controller *controller, uint16_t address )
{
  return controller->cart.cartrom_bank_n[address&0x3fff];
}

// read A000-BFFF (extram)
static uint8_t mbc_read_extram( struct controller *controller, uint16_t address ) {
  if (controller->cart.extram_enabled) {
    return controller->cart.extram_bank[address&0x1fff];
  } else {
    return 0xFF;
  }
}

static void mbc_write_extram( struct controller *controller, uint16_t address, uint8_t data ) {
  if (controller->cart.extram_enabled) {
    controller->cart.extram_bank[address&0x1fff] = data;
  }
}

// write 2000-3FFF
static void mbc_mbc1_write_rom_bank_select( struct controller *controller, uint16_t address, uint8_t data ) {
  struct gb_cart *cart = &controller->cart;

  // Only first 5 bits of this register count.
  data &= 0x1F;

  // And then we shift the 2 bits from the high register on top of it.
  uint8_t bank = (cart->reg_rom_bank_high << 5) | data;
  // lower bank register cannot contain 0, so it automatically becomes 1.
  if (bank == 0x00 || bank == 0x20 || bank == 0x40 || bank == 0x60) {
      bank++;
  }

  // If the selected bank is higher than the number of banks, it loops around.
  if (bank >= cart->cartrom_num_banks) {
      bank = bank % cart->cartrom_num_banks;
  }

  cart->reg_rom_bank_low = bank & 0x1F;
  cart->cart_bank_num = bank;

  cart->cartrom_bank_n = cart->cartrom + bank * 0x4000;
}

// write 4000-5FFF
static void mbc_mbc1_write_rom_ram_bank_select( struct controller *controller, uint16_t address, uint8_t data ) {
  // this is where MBC1 gets stupidly complicated.
  // we only care abotu the first two bits.
  data &= 3;

  struct gb_cart *cart = &controller->cart;
  if (cart->mbc1_mode == 0 || cart->cartrom_num_banks > 0x1F) {
    // According to the mooneye-gb tests writing here updates rom_bank_n for larger ROMS, even in RAM mode.
    // This is contrary to more easy to find info and common sense.
    if (cart->cartrom_num_banks > 0x1F) {
      // reg_rom_bank_low is 5 bits.
      uint8_t bank = (data << 5) | cart->reg_rom_bank_low;
      // lower bank register cannot contain 0, so it automatically becomes 1.
      if (bank == 0x00 || bank == 0x20 || bank == 0x40 || bank == 0x60) {
        bank++;
      }

      // If the selected bank is higher than the number of banks, it loops around.
      if (bank >= cart->cartrom_num_banks) {
        bank = bank % cart->cartrom_num_banks;
      }

      cart->reg_rom_bank_high = bank >> 5;
      cart->cartrom_bank_n = cart->cartrom + bank * 0x4000;
    }

    // in ROM mode, 0x0000 should always point to bank 0
    cart->cartrom_bank_zero = cart->cartrom;

    if (cart->mbc1_mode == 0) {
      // If we're not in mode 1, 'RAM' mode, we're done for now.
      return;
    }
  }

  if (cart->mbc1_mode == 1) {
    // Again according to mooneye-gb tests, bank_zero actually changes when you write in mode 1.
    // This is how you can access banks 20, 40 & 60
    if (cart->cartrom_num_banks > 0x20) {
      uint8_t bank = data << 5;
      if (bank >= cart->cartrom_num_banks) {
        bank = bank % cart->cartrom_num_banks;
      }

      cart->cartrom_bank_zero = cart->cartrom + bank * 0x4000;
    }

    // There are no banks to switch.
    if (cart->extram_num_banks <= 1) {
      return;
    }

    cart->extram_bank_num = data;
    cart->extram_bank = cart->extram + data * 0x2000;
  }
}

// 6000 - 7FFF
static void mbc_mbc1_write_bank_mode_select(struct controller *controller, uint16_t address, uint8_t data ) {
  struct gb_cart *cart = &controller->cart;
  cart->mbc1_mode = data & 0x1;
  if (cart->mbc1_mode == 0) {
    // Can only access ram bank 0 in mode 0.
    cart->extram_bank_num = 0;
    cart->extram_bank = cart->extram;
  } else {
    // can only access first 32 rom banks in mode 1, high reg set to 0.
    cart->reg_rom_bank_high = 0;
    cart->cartrom_bank_n = cart->cartrom + cart->reg_rom_bank_low * 0x4000;
  }
}

static void mbc_mbc1_install(struct controller *controller) {
  int i;
  controller->cart.mbc1_mode = 0;

  // cart bank zero
  for( i=0x00; i<=0x3F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_0;
  }
  // cart bank n
  for( i=0x40; i<=0x7F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_n;
  }

  // write 0000-1FFF: ram enable
  for( i=0x00; i<=0x1F; ++i ) {
    controller->gb_writemem[i] = mbc_write_ram_enable;
  }
  // write 2000-3FFF: rom bank select
  for( i=0x20; i<=0x3F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc1_write_rom_bank_select;
  }
  // write 4000-5FFF: ram bank select
  for( i=0x40; i<=0x5F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc1_write_rom_ram_bank_select;
  }

  // write 6000-7FFF: bank mode select
  for( i=0x60; i<=0x7F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc1_write_bank_mode_select;
  }

  // read A000-BFFF: read extram
  // calculate the last address where extram is installed
  int extram_end = 0xA0 + (controller->cart.extram_size>8192?8192:controller->cart.extram_size)/256;
  for( i=0xA0; i<extram_end; ++i ) {
    controller->gb_readmem[i] = mbc_read_extram;
  }
  for( i=extram_end; i<=0xBF; ++i ) {
    controller->gb_readmem[i] = mbc_read_ff;
  }

  // write A000-BFFF: write extram
  for( i=0xA0; i<extram_end; ++i ) {
    controller->gb_writemem[i] = mbc_write_extram;
  }
  for( i=extram_end; i<=0xBF; ++i ) {
    controller->gb_writemem[i] = mbc_write_dummy;
  }
}

static void mbc_mbc2_write_rom_bank_select(struct controller *controller, uint16_t address, uint8_t data) {
  struct gb_cart *cart = &controller->cart;

  // Only lower four bits matter.
  uint8_t bank = data & 0xF;

  // If the selected bank is higher than the number of banks, it loops around.
  if (bank >= cart->cartrom_num_banks) {
    bank = bank % cart->cartrom_num_banks;
  }

  if (bank == 0) {
    bank++;
  }

  cart->reg_rom_bank_low = bank;
  cart->cart_bank_num = bank;

  cart->cartrom_bank_n = cart->cartrom + bank * 0x4000;
}

static uint8_t mbc_mbc2_read_extram(struct controller *controller, uint16_t address) {
  if (controller->cart.extram_enabled) {
    // MBC2s only have 512 addresses for extram
    address &= 0x1FF;
    // And only four bits per address.
    return (controller->cart.extram_bank[address&0x1fff] & 0xF);
  } else {
    return 0xFF;
  }
}

static void mbc_mbc2_write_extram(struct controller *controller, uint16_t address, uint8_t data) {
  if (controller->cart.extram_enabled) {
    // MBC2s only have 512 addresses for extram
    address &= 0x1FF;
    // And only four bits per address.
    controller->cart.extram_bank[address&0x1fff] = (data & 0xF);
  }
}

static void mbc_mbc2_install(struct controller *controller) {
  int i;

  // cart bank zero
  for( i=0x00; i<=0x3F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_0;
  }
  // cart bank n
  for( i=0x40; i<=0x7F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_n;
  }

  for (i=0x00; i<=0x3F; ++i) {
    // If bit 8 of the address is 1
    if (i & 1) {
      controller->gb_writemem[i] = mbc_mbc2_write_rom_bank_select;
    } else  {
      controller->gb_writemem[i] = mbc_write_ram_enable;
    }
  }

  // mbc2 have unique behaviour when accessing external ram.
  for( i=0xA0; i<0xBF; ++i ) {
    controller->gb_readmem[i] = mbc_mbc2_read_extram;
  }
  for( i=0xA0; i<=0xBF; ++i ) {
    controller->gb_writemem[i] = mbc_mbc2_write_extram;
  }
}

// write 2000-3FFF
void mbc_mbc3_write_rom_bank_select( struct controller *controller, uint16_t address, uint8_t data ) {

  struct gb_cart *cart = &controller->cart;

  size_t offset;
  data &= 0x7F;
  cart->cart_bank_num = data;
  if( data == 0 )
    offset = (size_t)16384;
  else
    offset = (size_t)data*16384 % cart->cartromsize;

//   printf( "switch cart bank num: %02X\n", cart->cart_bank_num );
//   assert("MBC3 rom bank select: offset computation", offset <= (cart->cartromsize - 16384));
  cart->cartrom_bank_n = cart->cartrom + offset;
}

// read A000-BFFF rtc
uint8_t mbc_mbc3_read_rtc( struct controller *controller, uint16_t address ) {
  return 0x00;  // TODO
}

// write A000-BFFF rtc
void mbc_mbc3_write_rtc( struct controller *controller, uint16_t address, uint8_t data ) {
  // TODO
}

// write 4000-5FFF
void mbc_mbc3_write_ram_bank_select( struct controller *controller, uint16_t address, uint8_t data ) {
  struct gb_cart *cart = &controller->cart;
  int i;
  switch( data )
  {
    case 0x00:
    case 0x01:
    case 0x02:
    case 0x03:
      //       printf("Switching to RAM bank %02X \n", data );
      cart->extram_bank_num = data;
      cart->extram_bank = cart->extram + data*8192;
      // read A000-BFFF: read extram
      // calculate the last address where extram is installed
      int extram_end = 0xA0 + (cart->extram_size>8192?8192:cart->extram_size)/256;
      for( i=0xA0; i<extram_end; ++i ) {
        controller->gb_readmem[i] = mbc_read_extram;
      }
      for( i=extram_end; i<=0xBF; ++i ) {
        controller->gb_readmem[i] = mbc_read_ff;
      }

      // write A000-BFFF: write extram
      for( i=0xA0; i<extram_end; ++i ) {
        controller->gb_writemem[i] = mbc_write_extram;
      }
      for( i=extram_end; i<=0xBF; ++i ) {
        controller->gb_writemem[i] = mbc_write_dummy;
      }
      break;
    case 0x08:        // seconds
    case 0x09:        // minutes
    case 0x0A:        // hours
    case 0x0B:        // day bits 0-7
    case 0x0C:        // day bit 8, carry bit, halt flag
    //       printf("Switching to RTC bank %02X \n", data );
      cart->extram_bank_num = data;
      // read A000-BFFF: read rtc
      for( i=0xA0; i<=0xBF; ++i ) {
        controller->gb_readmem[i] = mbc_mbc3_read_rtc;
      }
      // write A000-BFFF: write rtc
      for( i=0xA0; i<=0xBF; ++i ) {
        controller->gb_writemem[i] = mbc_mbc3_write_rtc;
      }
      break;
    default:
      printf("Switching to invalid extram bank %02X \n", data );
      break;
  }
}

// write 6000-7FFF
void mbc_mbc3_write_clock_data_latch( struct controller *controller, uint16_t address, uint8_t data ) {
  // TODO
}

void mbc_mbc3_install(struct controller *controller)
{
  int i;
  // cart bank zero
  for( i=0x00; i<=0x3F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_0;
  }
  // cart bank n
  for( i=0x40; i<=0x7F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_n;
  }

  // write 0000-1FFF: ram enable
  for( i=0x00; i<=0x1F; ++i ) {
    controller->gb_writemem[i] = mbc_write_ram_enable;
  }
  // write 2000-3FFF: rom bank select
  for( i=0x20; i<=0x3F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc3_write_rom_bank_select;
  }
  // write 4000-5FFF: ram bank select
  for( i=0x40; i<=0x5F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc3_write_ram_bank_select;
  }
  // write 6000-7FFF: clock data latch
  for( i=0x60; i<=0x7F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc3_write_clock_data_latch;
  }

  // read A000-BFFF: read extram
  // calculate the last address where extram is installed
  int extram_end = 0xA0 + (controller->cart.extram_size>8192?8192:controller->cart.extram_size)/256;
  for( i=0xA0; i<extram_end; ++i ) {
    controller->gb_readmem[i] = mbc_read_extram;
  }
  for( i=extram_end; i<=0xBF; ++i ) {
    controller->gb_readmem[i] = mbc_read_ff;
  }

  // write A000-BFFF: write extram
  for( i=0xA0; i<extram_end; ++i ) {
    controller->gb_writemem[i] = mbc_write_extram;
  }
  for( i=extram_end; i<=0xBF; ++i ) {
    controller->gb_writemem[i] = mbc_write_dummy;
  }

}

static void mbc_rom_only_install(struct controller *controller) {
  int i;
  // cart bank zero
  for( i=0x00; i<=0x3F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_0;
  }
  // cart bank n
  for( i=0x40; i<=0x7F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_n;
  }

  // write 0000-1FFF: ram enable
  for( i=0x00; i<=0x7F; ++i ) {
    controller->gb_writemem[i] = mbc_write_dummy;
  }

  // read A000-BFFF: read extram
  for( i=0xA0; i<0xBF; ++i ) {
    controller->gb_readmem[i] = mbc_read_ff;
  }

  // write A000-BFFF: write extram
  for( i=0xA0; i<0xBF; ++i ) {
    controller->gb_writemem[i] = mbc_write_dummy;
  }
}

static void mbc_mbc5_write_ram_enable(struct controller *controller, uint16_t address, uint8_t data) {
  // Don't & the input in mbc5, all bits matter.
  if (data == 0x0A) {
    controller->cart.extram_enabled = true;
  } else {
    controller->cart.extram_enabled = false;
  }
}

// 0x2000 -0x2FFF
static void mbc_mbc5_write_rom_bank_select_lower(struct controller *controller, uint16_t address, uint8_t data) {
  struct gb_cart *cart = &controller->cart;

  // And then we shift the 2 bits from the high register on top of it.
  uint16_t bank = (cart->reg_rom_bank_high << 8) | data;

  // If the selected bank is higher than the number of banks, it loops around.
  if (bank >= cart->cartrom_num_banks) {
      bank = bank % cart->cartrom_num_banks;
  }

  cart->reg_rom_bank_low = data;
  cart->cart_bank_num = bank;

  cart->cartrom_bank_n = cart->cartrom + bank * 0x4000;
}

// 0x3000 - 0x3FFF
static void mbc_mbc5_write_rom_bank_select_upper(struct controller *controller, uint16_t address, uint8_t data) {
  struct gb_cart *cart = &controller->cart;

  // only lower bit matters.
  data &= 1;

  // And then we shift the 2 bits from the high register on top of it.
  uint16_t bank = data << 8 | cart->reg_rom_bank_low;

  // If the selected bank is higher than the number of banks, it loops around.
  if (bank >= cart->cartrom_num_banks) {
      bank = bank % cart->cartrom_num_banks;
  }

  cart->reg_rom_bank_high = data;
  cart->cart_bank_num = bank;

  cart->cartrom_bank_n = cart->cartrom + bank * 0x4000;
}

static void mbc_mbc5_write_ram_bank_select(struct controller *controller, uint16_t address, uint8_t data) {
    // Only lowest 4 bits matter.
    data &= 0xF;
    controller->cart.extram_bank_num = data;
    controller->cart.extram_bank = controller->cart.extram + data * 0x2000;
}

static void mbc_mbc5_install(struct controller *controller) {
  int i;

  // cart bank zero
  for( i=0x00; i<=0x3F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_0;
  }
  // cart bank n
  for( i=0x40; i<=0x7F; ++i ) {
    controller->gb_readmem[i] = mbc_read_bank_n;
  }

  // write 0000-1FFF: ram enable
  for( i=0x00; i<=0x1F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc5_write_ram_enable;
  }
  // write 2000-3FFF: rom bank select
  for( i=0x20; i<=0x2F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc5_write_rom_bank_select_lower;
  }
  // write 4000-5FFF: ram bank select
  for( i=0x30; i<=0x3F; ++i ) {
    controller->gb_writemem[i] = mbc_mbc5_write_rom_bank_select_upper;
  }

  // write 6000-7FFF: bank mode select
  for( i=0x40; i<=0x5f; ++i ) {
    controller->gb_writemem[i] = mbc_mbc5_write_ram_bank_select;
  }

  // read A000-BFFF: read extram
  // calculate the last address where extram is installed
  int extram_end = 0xA0 + (controller->cart.extram_size>8192?8192:controller->cart.extram_size)/256;
  for( i=0xA0; i<extram_end; ++i ) {
    controller->gb_readmem[i] = mbc_read_extram;
  }
  for( i=extram_end; i<=0xBF; ++i ) {
    controller->gb_readmem[i] = mbc_read_ff;
  }

  // write A000-BFFF: write extram
  for( i=0xA0; i<extram_end; ++i ) {
    controller->gb_writemem[i] = mbc_write_extram;
  }
  for( i=extram_end; i<=0xBF; ++i ) {
    controller->gb_writemem[i] = mbc_write_dummy;
  }
}

static void mbc_unsupported_install(struct controller *controller) {
  printf("Transfer Pak ROM type not fully supported. Defaulting to MBC3 behaviour\n");
  mbc_mbc3_install(controller);
}

uint8_t gb_read(struct controller *controller, uint16_t address) {
  uint8_t (*myfunc)(struct controller *,uint16_t) = controller->gb_readmem[address>>8];
  uint8_t data;
  if(myfunc != NULL)
    data = myfunc(controller, address);
  else
    data = 0xFF;
//   printf("gb_read: %04X:%02X\n", address, data);
  return data;
}

void gb_write(struct controller *controller, uint16_t address, uint8_t data) {
  void (*myfunc)(struct controller *,uint16_t,uint8_t) = controller->gb_writemem[address>>8];
  if(myfunc != NULL)
    myfunc(controller, address, data);
//   printf("gb_write: %04X:%02X\n", address, data);
}

void gb_init(struct controller *controller) {
  for(int i=0;i<0x100;i++) {
    controller->gb_readmem [i] = NULL;
    controller->gb_writemem[i] = NULL;
  }

  struct gb_cart *cart = &controller->cart;

  // set up pak rom
  cart->cartromsize = controller->tpak_rom.size;
  cart->cartrom = (uint8_t *)(controller->tpak_rom.ptr);
  cart->cartrom_bank_zero = cart->cartrom;
  cart->cartrom_bank_n = cart->cartrom + 0x4000;

  // set up pak ram
  if( controller->tpak_save.ptr != NULL ) {
    cart->extram = (uint8_t *)(controller->tpak_save.ptr);
    cart->extram_size = controller->tpak_save.size;
  } else {
    cart->extram = calloc( 1, 65536 );  // TODO: deallocate this eventually?
    cart->extram_size = 65536;
  }
  cart->extram_bank = cart->extram;

  uint8_t rom_size_code = cart->cartrom_bank_zero[ROM_SIZE_CODE_ADDRESS];
  if (rom_size_code <= 8) {
    // powers of 2
    cart->cartrom_num_banks = 1 << (rom_size_code + 1);
  } else {
    switch(rom_size_code) {
      case 0x52:
        cart->cartrom_num_banks = 72;
        break;
      case 0x53:
        cart->cartrom_num_banks = 80;
        break;
      case 0x54:
        cart->cartrom_num_banks = 96;
        break;
    }
  }

  switch(cart->cartrom_bank_zero[EXTRAM_SIZE_CODE_ADDRESS]) {
    case 0:
      cart->extram_num_banks = 0;
      break;
    case 1:
      cart->extram_num_banks = 1;
      break;
    case 2:
      cart->extram_num_banks = 1;
      break;
    case 3:
      cart->extram_num_banks = 4;
      break;
    case 4:
      cart->extram_num_banks = 16;
      break;
    case 5:
      cart->extram_num_banks = 8;
      break;
  }

  switch(cart->cartrom_bank_zero[CARTRIDGE_TYPE_ADDRESS]) {
    case 0:
      mbc_rom_only_install(controller);
      break;
    case 1:
    case 2:
    case 3:
      mbc_mbc1_install(controller);
      break;
    case 5:
    case 6:
      mbc_mbc2_install(controller);
      break;
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
      mbc_mbc3_install(controller);
      break;
    case 25:
    case 26:
    case 27:
    case 28:
    case 29:
    case 30:
      mbc_mbc5_install(controller);
      break;
    default:
      mbc_unsupported_install(controller);
      break;
  }
}


text:
namespace autofill_assistant {

WebsiteLoginManager::Login::Login(const GURL& _origin,
                                  const std::string& _username)
    : origin(_origin), username(_username) {}

WebsiteLoginManager::Login::Login(const Login& other) = default;
WebsiteLoginManager::Login::~Login() = default;

}  // namespace autofill_assistant


text:
Send an example span to a [Zipkin](https://zipkin.io/) service.
These instructions expect you have [docker-compose](https://docs.docker.com/compose/) installed.

Bring up the `zipkin-collector` service and example `zipkin-client` service to send an example trace:

```sh
docker-compose up --detach zipkin-collector zipkin-client
```

The `zipkin-client` service sends just one trace and exits. Retrieve the `traceId` generated by the `zipkin-client` service; should be the last line in the logs:

```sh
docker-compose logs --tail=1 zipkin-client
```

With the `traceId` you can view the trace from the `zipkin-collector` service UI hosted on port `9411`, e.g. with `traceId` of `f5695ba3b2ed00ea583fa4fa0badbeef`: [http://localhost:9411/zipkin/traces/f5695ba3b2ed00ea583fa4fa0badbeef](http://localhost:9411/zipkin/traces/f5695ba3b2ed00ea583fa4fa0badbeef)

Shut down the services when you are finished with the example:

```sh
docker-compose down
```


text:
class OSMComponentBase:
    def __init__(self):
        self.instance = None

    def start(self):
        self.instance.start()


text:
<?php

namespace App\Models;

class Tags extends DatabaseModel
{
	protected static $tableName = "tags";
	protected static $columns = ['id','tag'];
	protected static $validationRules = [ "tag" => "inputValidate, minlength:1"
];

}


text:
package org.cactoos.scalar;

import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

/**
 * Test case for {@link SumOfDoubleScalar}.
 *
 * @author Nikita Salomatin (nsalomatin@hotmail.com)
 * @version $Id$
 * @since 0.30
 * @checkstyle JavadocMethodCheck (500 lines)
 * @checkstyle MagicNumberCheck (500 lines)
 */
public final class SumOfDoubleScalarTest {

    @Test
    public void withListOfScalarsInt() {
        MatcherAssert.assertThat(
            new SumOfDoubleScalar(() -> 1.1, () -> 2.1, () -> 3.1)
                .value(),
            new IsEqual<>(6.3)
        );
    }

    @Test
    public void withEmptyList() {
        MatcherAssert.assertThat(
            new SumOfDoubleScalar().value(),
            new IsEqual<>(0.0)
        );
    }

    @Test
    public void withListOfOneElement() {
        MatcherAssert.assertThat(
            new SumOfDoubleScalar(() -> 5.1).value(),
            new IsEqual<>(5.1)
        );
    }
}


text:
module Seek
  module GroupedPagination
    def self.included(base)
      base.extend ClassMethods
    end
    module ClassMethods
      # this is the array of possible pages, defaults to A-Z. Can be set with the options[:pages] in grouped_pagination definition in model
      attr_reader :pages

      # this is limit to the list when showing 'latest', 7. Can be set with the options[:latest_limit] in grouped_pagination definition in model
      attr_reader :latest_limit

      # this is the default page to use if :page is not provided when paginating.
      attr_reader :default_page

      def grouped_pagination(options = {})
        @pages = options[:pages] || ('A'..'Z').to_a + ['?']
        @field = options[:field] || 'first_letter'
        @latest_limit = options[:latest_limit] || Seek::Config.limit_latest
        @default_page = options[:default_page] || Seek::Config.default_page(name.underscore.pluralize) || 'all'

        before_save :update_first_letter

        include Seek::GroupedPagination::InstanceMethods
        extend Seek::GroupedPagination::SingletonMethods
      end

      def paginate_after_fetch(collection, *args)
        options = args.pop unless args.nil?
        options ||= {}
        reorder = options[:reorder].nil? ? true : options[:reorder]

        # only reorder if there are items and they respond to updated_at
        reorder = reorder && collection.first && collection.first.respond_to?(:updated_at)

        @latest_limit = options[:latest_limit] || @latest_limit
        @default_page = options[:default_page] || @default_page

        default_page = @default_page
        default_page = @pages.first if default_page == 'first'

        page = options[:page] || default_page

        records = []
        if page == 'all'
          records = collection
        elsif page == 'latest'
          if reorder
            records = collection.sort { |x, y| y.updated_at <=> x.updated_at }[0...@latest_limit]
          else
            records = collection[0...@latest_limit]
          end
        elsif @pages.include?(page)
          records = collection.select { |i| i.first_letter == page }
        end

        page_totals = {}
        @pages.each do |p|
          page_totals[p] = collection.count { |i| i.first_letter == p }
        end

        result = Collection.new(records, page, @pages, page_totals)

        # jump to the first page with content if no page is specified and their is no content in the first page.
        if result.empty? && options[:page].nil?
          first_page_with_content = result.pages.find { |p| result.page_totals[p] > 0 }
          unless first_page_with_content.nil?
            options[:page] = first_page_with_content
            result = paginate_after_fetch(collection, options)
          end
        end

        result
      end
    end

    module SingletonMethods

      def paginate(*args)
        options = args.pop unless args.nil?
        options ||= {}

        default_page = options[:default_page] || @default_page
        default_page = @pages.first if default_page == 'first'

        page = options[:page] || default_page

        records = []
        if page == 'all'
          records = default_order
        elsif page == 'latest'
          records = unscoped.order('updated_at DESC').limit(@latest_limit)
        elsif @pages.include?(page)
          query_options = { conditions: options[:conditions] }
          query_options.merge!(options.except(:conditions, :page, :default_page))
          records = unscoped.where("#{@field}" => page).where(query_options[:conditions]).order(query_options[:order])
        end

        page_totals = {}
        @pages.each do |p|
          query_options = [conditions: options[:conditions]]
          query_options[0].merge!(options.except(:conditions, :page, :default_page))
          page_totals[p] = where("#{@field}" => p).where(query_options[0][:conditions]).count
        end

        result = Collection.new(records, page, @pages, page_totals)

        # jump to the first page with content if no page is specified and their is no content in the first page.
        if result.empty? && options[:page].nil?
          first_page_with_content = result.pages.find { |p| result.page_totals[p] > 0 }
          unless first_page_with_content.nil?
            options[:page] = first_page_with_content
            result = paginate(options)
          end
        end

        result
      end

    end

    module InstanceMethods
      # Helper to strip the first letter from the text, converting non standard A-Z characters to their equivalent, e.g Ø -> O
      # uses some code based upon: http://github.com/grosser/sort_alphabetical/blob/9a8665d17394506c29cce51d8e22af69e2931523/lib/sort_alphabetical.rb with special handling for Ø
      def strip_first_letter(text)
        # handle the characters that can't be handled through normalization
        %w(ØO).each do |s|
          text.gsub!(/[#{s[0..-2]}]/, s[-1..-1])
        end

        codepoints = text.mb_chars.normalize(:d).split(//u)
        ascii = codepoints.map(&:to_s).reject { |e| e.length > 1 }.join

        ascii.first.capitalize
      end

      def update_first_letter
        self.first_letter = strip_first_letter(title.strip.gsub(/[\[\]]/, ''))
        self.first_letter = '?' unless self.class.pages.include?(first_letter)
      end
    end

    class Collection < Array
      attr_reader :page, :page_totals, :pages

      def initialize(records, page, pages, page_totals)
        super(records)
        @page = page
        @page_totals = page_totals
        @pages = pages
      end
    end
  end
end

ActiveRecord::Base.class_eval do
  include Seek::GroupedPagination
end


text:
class S2Region;
class S2RegionCoverer;

namespace arangodb {
namespace geo {

/// interval to scan over for near / within /intersect queries.
/// Bounds are INCLUSIVE! It may hold true that min === max,
/// in that case a lookup is completely valid. Do not use these
/// bounds for any kind of arithmetics
struct Interval {
  Interval(S2CellId mn, S2CellId mx) noexcept : range_min(mn), range_max(mx) {}
  S2CellId range_min; /// @brief inclusive minimum cell id
  S2CellId range_max; /// @brief inclusive maximum cell id
  static bool compare(const Interval& a, const Interval& b) {
    return a.range_min < b.range_min;
  }
};

class Ellipsoid;

/// Utilitiy methods to construct S2Region objects from various definitions,
/// construct coverings for regions with S2RegionCoverer and generate
/// search intervals for use in an iterator
namespace utils {

/// Generate a cover cell from an array [lat, lng] or [lng, lat]
Result indexCellsLatLng(velocypack::Slice const& data, bool isGeoJson,
                        std::vector<S2CellId>& cells, S2Point& centroid);

/// generate intervalls of list of intervals to scan
void scanIntervals(QueryParams const& params, S2RegionCoverer* coverer,
                   S2Region const& region, std::vector<geo::Interval>& sortedIntervals);

/// will return all the intervals including the cells containing them
/// in the less detailed levels. Should allow us to scan all intervals
/// which may contain intersecting geometries
void scanIntervals(QueryParams const& params, std::vector<S2CellId> const& cover,
                   std::vector<geo::Interval>& sortedIntervals);

/// Returns the ellipsoidal distance between p1 and p2 on e (in meters).
/// (solves the inverse geodesic problem)
double geodesicDistance(S2LatLng const& p1, S2LatLng const& p2, geo::Ellipsoid const& e);

/// Returns a point at distance `dist` (in meters) of `p` in direction `azimuth`
/// (in degrees between -180 and 180)
/// (solves the direct geodesic problem)
S2LatLng geodesicPointAtDist(S2LatLng const& p, double dist, double azimuth,
                             geo::Ellipsoid const& e);
}  // namespace utils
}  // namespace geo
}  // namespace arangodb


text:
"""
Copyright (c) 2016 Genome Research Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

import unittest

from mupit.util import is_url

class TestIsUrl(unittest.TestCase):

    def test_is_url(self):
        """ test correct output of json formatted file of probands by gene
        """

        self.assertTrue(is_url('http://example.com'))
        self.assertTrue(is_url('ftp://example.com'))
        self.assertTrue(is_url('https://example.com'))
        self.assertFalse(is_url('/nfs/example'))


text:
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://zjzit.cn>
// +----------------------------------------------------------------------

namespace sunny\exception;

use sunny\Exception;

/**
 * Database相关异常处理类
 */
class DbException extends Exception
{
    /**
     * DbException constructor.
     * @access public
     * @param  string    $message
     * @param  array     $config
     * @param  string    $sql
     * @param  int       $code
     */
    public function __construct($message, array $config, $sql, $code = 10500)
    {
        $this->message = $message;
        $this->code    = $code;

        $this->setData('Database Status', [
            'Error Code'    => $code,
            'Error Message' => $message,
            'Error SQL'     => $sql,
        ]);

        unset($config['username'], $config['password']);
        $this->setData('Database Config', $config);
    }

}


text:
namespace Nz
{
	VideoMode VideoModeImpl::GetDesktopMode()
	{
		SDL_DisplayMode mode;
		if (SDL_GetDesktopDisplayMode(0, &mode) != 0) // handle multi screen ?
		{
			NazaraError(SDL_GetError());

			return VideoMode(800, 600, static_cast<UInt8>(32)); // useless ?
		}

		return VideoMode(mode.w, mode.h, SDL_BITSPERPIXEL(mode.format));
	}

	void VideoModeImpl::GetFullscreenModes(std::vector<VideoMode>& modes)
	{
		SDL_DisplayMode mode;

		int numModes = SDL_GetNumDisplayModes(0);
		if (numModes < 0)
		{
			NazaraError(SDL_GetError());

			return;
		}

		for (int i = 0; i < numModes; i++)
		{
			if (SDL_GetDisplayMode(0, i, &mode) != 0) // handle multi screen ?

				NazaraError(SDL_GetError());

			VideoMode vMode(mode.w, mode.h, SDL_BITSPERPIXEL(mode.format));

			if (std::find(modes.begin(), modes.end(), vMode) == modes.end())
				modes.push_back(vMode);
		}
	}
}


text:
// Copyright (C) 2010 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.server.events;

import com.google.gerrit.common.data.ApprovalType;
import com.google.gerrit.common.data.ApprovalTypes;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.ChangeMessage;
import com.google.gerrit.reviewdb.client.PatchLineComment;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.client.RevId;
import com.google.gerrit.reviewdb.client.TrackingId;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.patch.PatchList;
import com.google.gerrit.server.patch.PatchListCache;
import com.google.gerrit.server.patch.PatchListEntry;
import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;

import org.eclipse.jgit.lib.ObjectId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;

import javax.annotation.Nullable;

@Singleton
public class EventFactory {
  private static final Logger log = LoggerFactory.getLogger(EventFactory.class);
  private final AccountCache accountCache;
  private final Provider<String> urlProvider;
  private final ApprovalTypes approvalTypes;
  private final PatchListCache patchListCache;
  private final SchemaFactory<ReviewDb> schema;

  @Inject
  EventFactory(AccountCache accountCache,
      @CanonicalWebUrl @Nullable Provider<String> urlProvider,
      ApprovalTypes approvalTypes,
      PatchListCache patchListCache, SchemaFactory<ReviewDb> schema) {
    this.accountCache = accountCache;
    this.urlProvider = urlProvider;
    this.approvalTypes = approvalTypes;
    this.patchListCache = patchListCache;
    this.schema = schema;
  }

  /**
   * Create a ChangeAttribute for the given change suitable for serialization to
   * JSON.
   *
   * @param change
   * @return object suitable for serialization to JSON
   */
  public ChangeAttribute asChangeAttribute(final Change change) {
    ChangeAttribute a = new ChangeAttribute();
    a.project = change.getProject().get();
    a.branch = change.getDest().getShortName();
    a.topic = change.getTopic();
    a.id = change.getKey().get();
    a.number = change.getId().toString();
    a.subject = change.getSubject();
    a.url = getChangeUrl(change);
    a.owner = asAccountAttribute(change.getOwner());
    return a;
  }

  /**
   * Create a RefUpdateAttribute for the given old ObjectId, new ObjectId, and
   * branch that is suitable for serialization to JSON.
   *
   * @param refUpdate
   * @param refName
   * @return object suitable for serialization to JSON
   */
  public RefUpdateAttribute asRefUpdateAttribute(final ObjectId oldId, final ObjectId newId, final Branch.NameKey refName) {
    RefUpdateAttribute ru = new RefUpdateAttribute();
    ru.newRev = newId != null ? newId.getName() : ObjectId.zeroId().getName();
    ru.oldRev = oldId != null ? oldId.getName() : ObjectId.zeroId().getName();
    ru.project = refName.getParentKey().get();
    ru.refName = refName.getShortName();
    return ru;
  }

  /**
   * Extend the existing ChangeAttribute with additional fields.
   *
   * @param a
   * @param change
   */
  public void extend(ChangeAttribute a, Change change) {
    a.createdOn = change.getCreatedOn().getTime() / 1000L;
    a.lastUpdated = change.getLastUpdatedOn().getTime() / 1000L;
    a.sortKey = change.getSortKey();
    a.open = change.getStatus().isOpen();
    a.status = change.getStatus();
  }

  public void addDependencies(ChangeAttribute ca, Change change) {
    ca.dependsOn = new ArrayList<DependencyAttribute>();
    ca.neededBy = new ArrayList<DependencyAttribute>();
    try {
      final ReviewDb db = schema.open();
      try {
        final PatchSet.Id psId = change.currentPatchSetId();
        for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf(psId)) {
          for (PatchSet p :
              db.patchSets().byRevision(a.getAncestorRevision())) {
            Change c = db.changes().get(p.getId().getParentKey());
            ca.dependsOn.add(newDependsOn(c, p));
          }
        }

        final RevId revId = db.patchSets().get(psId).getRevision();
        for (PatchSetAncestor a : db.patchSetAncestors().descendantsOf(revId)) {
          final PatchSet p = db.patchSets().get(a.getPatchSet());
          final Change c = db.changes().get(p.getId().getParentKey());
          ca.neededBy.add(newNeededBy(c, p));
        }
      } finally {
        db.close();
      }
    } catch (OrmException e) {
      // Squash DB exceptions and leave dependency lists partially filled.
    }
    // Remove empty lists so a confusing label won't be displayed in the output.
    if (ca.dependsOn.isEmpty()) {
      ca.dependsOn = null;
    }
    if (ca.neededBy.isEmpty()) {
      ca.neededBy = null;
    }
  }

  private DependencyAttribute newDependsOn(Change c, PatchSet ps) {
    DependencyAttribute d = newDependencyAttribute(c, ps);
    d.isCurrentPatchSet = c.currPatchSetId().equals(ps.getId());
    return d;
  }

  private DependencyAttribute newNeededBy(Change c, PatchSet ps) {
    return newDependencyAttribute(c, ps);
  }

  private DependencyAttribute newDependencyAttribute(Change c, PatchSet ps) {
    DependencyAttribute d = new DependencyAttribute();
    d.number = c.getId().toString();
    d.id = c.getKey().toString();
    d.revision = ps.getRevision().get();
    d.ref = ps.getRefName();
    return d;
  }

  public void addTrackingIds(ChangeAttribute a, Collection<TrackingId> ids) {
    if (!ids.isEmpty()) {
      a.trackingIds = new ArrayList<TrackingIdAttribute>(ids.size());
      for (TrackingId t : ids) {
        a.trackingIds.add(asTrackingIdAttribute(t));
      }
    }
  }

  public void addCommitMessage(ChangeAttribute a, String commitMessage) {
    a.commitMessage = commitMessage;
  }

  public void addPatchSets(ChangeAttribute a, Collection<PatchSet> ps) {
    addPatchSets(a, ps, null, false, null);
  }

  public void addPatchSets(ChangeAttribute ca, Collection<PatchSet> ps,
      Map<PatchSet.Id,Collection<PatchSetApproval>> approvals) {
    addPatchSets(ca, ps, approvals, false, null);
  }

  public void addPatchSets(ChangeAttribute ca, Collection<PatchSet> ps,
      Map<PatchSet.Id,Collection<PatchSetApproval>> approvals,
      boolean includeFiles, Change change) {

    if (!ps.isEmpty()) {
      ca.patchSets = new ArrayList<PatchSetAttribute>(ps.size());
      for (PatchSet p : ps) {
        PatchSetAttribute psa = asPatchSetAttribute(p);
        if (approvals != null) {
          addApprovals(psa, p.getId(), approvals);
        }
        ca.patchSets.add(psa);
        if (includeFiles && change != null) {
          addPatchSetFileNames(psa, change, p);
        }
      }
    }
  }

  public void addPatchSetComments(PatchSetAttribute patchSetAttribute,
      Collection<PatchLineComment> patchLineComments) {
    for (PatchLineComment comment : patchLineComments) {
      if (comment.getKey().getParentKey().getParentKey().get()
          == Integer.parseInt(patchSetAttribute.number)) {
        if (patchSetAttribute.comments == null) {
          patchSetAttribute.comments =
            new ArrayList<PatchSetCommentAttribute>();
        }
        patchSetAttribute.comments.add(asPatchSetLineAttribute(comment));
      }
    }
  }

  public void addPatchSetFileNames(PatchSetAttribute patchSetAttribute,
      Change change, PatchSet patchSet) {
    try {
      PatchList patchList = patchListCache.get(change, patchSet);
      for (PatchListEntry patch : patchList.getPatches()) {
        if (patchSetAttribute.files == null) {
          patchSetAttribute.files = new ArrayList<PatchAttribute>();
        }

        PatchAttribute p = new PatchAttribute();
        p.file = patch.getNewName();
        p.type = patch.getChangeType();
        patchSetAttribute.files.add(p);
      }
    } catch (PatchListNotAvailableException e) {
    }
  }

  public void addComments(ChangeAttribute ca,
      Collection<ChangeMessage> messages) {
    if (!messages.isEmpty()) {
      ca.comments = new ArrayList<MessageAttribute>();
      for (ChangeMessage message : messages) {
        ca.comments.add(asMessageAttribute(message));
      }
    }
  }

  public TrackingIdAttribute asTrackingIdAttribute(TrackingId id) {
    TrackingIdAttribute a = new TrackingIdAttribute();
    a.system = id.getSystem();
    a.id = id.getTrackingId();
    return a;
  }

  /**
   * Create a PatchSetAttribute for the given patchset suitable for
   * serialization to JSON.
   *
   * @param patchSet
   * @return object suitable for serialization to JSON
   */
  public PatchSetAttribute asPatchSetAttribute(final PatchSet patchSet) {
    PatchSetAttribute p = new PatchSetAttribute();
    p.revision = patchSet.getRevision().get();
    p.number = Integer.toString(patchSet.getPatchSetId());
    p.ref = patchSet.getRefName();
    p.uploader = asAccountAttribute(patchSet.getUploader());
    p.createdOn = patchSet.getCreatedOn().getTime() / 1000L;
    try {
      final ReviewDb db = schema.open();
      try {
        p.parents = new ArrayList<String>();
        for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf(
            patchSet.getId())) {
          p.parents.add(a.getAncestorRevision().get());
        }
      } finally {
        db.close();
      }
    } catch (OrmException e) {
      log.error("Cannot load patch set data for " + patchSet.getId(), e);
    }
    return p;
  }

  public void addApprovals(PatchSetAttribute p, PatchSet.Id id,
      Map<PatchSet.Id,Collection<PatchSetApproval>> all) {
    Collection<PatchSetApproval> list = all.get(id);
    if (list != null) {
      addApprovals(p, list);
    }
  }

  public void addApprovals(PatchSetAttribute p,
      Collection<PatchSetApproval> list) {
    if (!list.isEmpty()) {
      p.approvals = new ArrayList<ApprovalAttribute>(list.size());
      for (PatchSetApproval a : list) {
        if (a.getValue() != 0) {
          p.approvals.add(asApprovalAttribute(a));
        }
      }
      if (p.approvals.isEmpty()) {
        p.approvals = null;
      }
    }
  }

  /**
   * Create an AuthorAttribute for the given account suitable for serialization
   * to JSON.
   *
   * @param id
   * @return object suitable for serialization to JSON
   */
  public AccountAttribute asAccountAttribute(Account.Id id) {
    return asAccountAttribute(accountCache.get(id).getAccount());
  }

  /**
   * Create an AuthorAttribute for the given account suitable for serialization
   * to JSON.
   *
   * @param account
   * @return object suitable for serialization to JSON
   */
  public AccountAttribute asAccountAttribute(final Account account) {
    AccountAttribute who = new AccountAttribute();
    who.name = account.getFullName();
    who.email = account.getPreferredEmail();
    who.username = account.getUserName();
    return who;
  }

  /**
   * Create an ApprovalAttribute for the given approval suitable for
   * serialization to JSON.
   *
   * @param approval
   * @return object suitable for serialization to JSON
   */
  public ApprovalAttribute asApprovalAttribute(PatchSetApproval approval) {
    ApprovalAttribute a = new ApprovalAttribute();
    a.type = approval.getCategoryId().get();
    a.value = Short.toString(approval.getValue());
    a.by = asAccountAttribute(approval.getAccountId());
    a.grantedOn = approval.getGranted().getTime() / 1000L;

    ApprovalType at = approvalTypes.byId(approval.getCategoryId());
    if (at != null) {
      a.description = at.getCategory().getName();
    }
    return a;
  }

  public MessageAttribute asMessageAttribute(ChangeMessage message) {
    MessageAttribute a = new MessageAttribute();
    a.timestamp = message.getWrittenOn().getTime() / 1000L;
    a.reviewer = asAccountAttribute(message.getAuthor());
    a.message = message.getMessage();
    return a;
  }

  public PatchSetCommentAttribute asPatchSetLineAttribute(PatchLineComment c) {
    PatchSetCommentAttribute a = new PatchSetCommentAttribute();
    a.reviewer = asAccountAttribute(c.getAuthor());
    a.file = c.getKey().getParentKey().get();
    a.line = c.getLine();
    a.message = c.getMessage();
    return a;
  }

  /** Get a link to the change; null if the server doesn't know its own address. */
  private String getChangeUrl(final Change change) {
    if (change != null && urlProvider.get() != null) {
      final StringBuilder r = new StringBuilder();
      r.append(urlProvider.get());
      r.append(change.getChangeId());
      return r.toString();
    }
    return null;
  }
}


text:
/*
 *  Copyright (c) 2013, Michael Bedward. All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without modification,
 *  are permitted provided that the following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this
 *    list of conditions and the following disclaimer in the documentation and/or
 *    other materials provided with the distribution.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 *  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package it.geosolutions.jaiext.jiffle.parser;

import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.ASSIGN;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.AssignExprContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.AssignmentContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.BodyContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.ExprStmtContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.ExpressionContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.ExpressionListContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.InitBlockContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.ScriptContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.StatementContext;
import static it.geosolutions.jaiext.jiffle.parser.JiffleParser.VarDeclarationContext;

import org.antlr.v4.runtime.tree.ParseTree;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import it.geosolutions.jaiext.jiffle.parser.node.Band;
import it.geosolutions.jaiext.jiffle.parser.node.BinaryExpression;
import it.geosolutions.jaiext.jiffle.parser.node.Break;
import it.geosolutions.jaiext.jiffle.parser.node.BreakIf;
import it.geosolutions.jaiext.jiffle.parser.node.DefaultScalarValue;
import it.geosolutions.jaiext.jiffle.parser.node.Expression;
import it.geosolutions.jaiext.jiffle.parser.node.GlobalVars;
import it.geosolutions.jaiext.jiffle.parser.node.IfElse;
import it.geosolutions.jaiext.jiffle.parser.node.ListAppend;
import it.geosolutions.jaiext.jiffle.parser.node.ListLiteral;
import it.geosolutions.jaiext.jiffle.parser.node.LoopInLiteralList;
import it.geosolutions.jaiext.jiffle.parser.node.LoopInRange;
import it.geosolutions.jaiext.jiffle.parser.node.LoopInVariable;
import it.geosolutions.jaiext.jiffle.parser.node.NodeException;
import it.geosolutions.jaiext.jiffle.parser.node.ScalarLiteral;
import it.geosolutions.jaiext.jiffle.parser.node.Script;
import it.geosolutions.jaiext.jiffle.parser.node.SetDestValue;
import it.geosolutions.jaiext.jiffle.parser.node.SimpleStatement;
import it.geosolutions.jaiext.jiffle.parser.node.Statement;
import it.geosolutions.jaiext.jiffle.parser.node.StatementList;
import it.geosolutions.jaiext.jiffle.parser.node.Until;
import it.geosolutions.jaiext.jiffle.parser.node.Variable;
import it.geosolutions.jaiext.jiffle.parser.node.While;
import it.geosolutions.jaiext.jiffle.runtime.JiffleRuntime;

/**
 * Generates a Java model representing the script, from which sources can be generated
 *
 * @author michael
 */
public class RuntimeModelWorker extends AbstractModelWorker {

    /** A key for the declared variables set */
    private static class VariableKey {
        SymbolScope scope;
        String name;

        public VariableKey(SymbolScope scope, String name) {
            this.scope = scope;
            this.name = name;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            VariableKey that = (VariableKey) o;
            return Objects.equals(scope, that.scope) && Objects.equals(name, that.name);
        }

        @Override
        public int hashCode() {

            return Objects.hash(scope, name);
        }
    }

    private final TreeNodeProperties<JiffleType> types;
    private final TreeNodeProperties<SymbolScope> scopes;
    private final Map<String, String> options;
    private final Set<VariableKey> declaredVariables = new HashSet<>();
    private final Map<String, Integer> destImageBands = new HashMap<>();

    // Set to a non-null reference if an init block is found
    private InitBlockContext initBlockContext = null;
    private Script script;

    /**
     * Labels the parse tree with Node objects representing elements of the runtime code. Expects
     * that the tree has been previously annotated by an ExpressionWorker.
     */
    public RuntimeModelWorker(
            ParseTree tree,
            Map<String, String> options,
            TreeNodeProperties<JiffleType> types,
            TreeNodeProperties<SymbolScope> scopes) {

        super(tree);
        this.types = types;
        this.scopes = scopes;
        this.options = options;

        walkTree();
    }

    @Override
    public void exitScript(ScriptContext ctx) {
        StatementList stmts = getAsType(ctx.body(), StatementList.class);

        GlobalVars globals =
                initBlockContext == null
                        ? new GlobalVars()
                        : getAsType(initBlockContext, GlobalVars.class);
        GlobalScope globalScope = (GlobalScope) scopes.get(ctx);
        Set<String> sourceImages = globalScope.getByType(Symbol.Type.SOURCE_IMAGE);
        Set<String> destImages = globalScope.getByType(Symbol.Type.DEST_IMAGE);

        this.script = new Script(options, sourceImages, destImages, globals, stmts,
                readsOptimizer);
        set(ctx, this.script);
    }

    @Override
    public void exitBody(BodyContext ctx) {
        List<Statement> statements = new ArrayList<>();

        for (StatementContext sctx : ctx.statement()) {
            statements.add(getAsType(sctx, Statement.class));
        }

        set(ctx, new StatementList(statements));
    }

    @Override
    public void exitInitBlock(InitBlockContext ctx) {
        List<BinaryExpression> inits = new ArrayList<>();

        List<VarDeclarationContext> decls = ctx.varDeclaration();
        if (decls != null) {
            try {
                for (VarDeclarationContext dc : decls) {
                    String name = dc.ID().getText();
                    ExpressionContext exprCtx = dc.expression();

                    final Expression value;
                    if (exprCtx == null) {
                        value = new DefaultScalarValue();
                    } else {
                        value = getAsType(exprCtx, Expression.class);
                    }

                    inits.add(
                            new BinaryExpression(ASSIGN, new Variable(name, JiffleType.D), value));
                }

            } catch (NodeException ex) {
                messages.error(ctx.getStart(), ex.getError());
            }
        }

        set(ctx, new GlobalVars(inits));
        initBlockContext = ctx;
    }

    @Override
    public void exitExprStmt(ExprStmtContext ctx) {
        set(ctx, new SimpleStatement(getAsType(ctx.expression(), Expression.class)));
    }

    @Override
    public void exitExpressionList(ExpressionListContext ctx) {}

    @Override
    public void exitAssignExpr(AssignExprContext ctx) {
        set(ctx, get(ctx.assignment()));
    }

    @Override
    public void exitAssignment(AssignmentContext ctx) {
        String varName = ctx.assignmentTarget().ID().getText();
        Band band = null;
        if (ctx.assignmentTarget().bandSpecifier() != null) {
            band = getAsType(ctx.assignmentTarget().bandSpecifier(), Band.class);
        }
        SymbolScope scope = getScope(ctx);
        Symbol symbol = scope.get(varName);
        SymbolScope declaringScope = scope.getDeclaringScope(varName);
        boolean declare = checkAndSetDeclared(declaringScope, varName);

        int opType = ctx.op.getType();

        Expression expr = getAsType(ctx.expression(), Expression.class);

        try {
            switch (symbol.getType()) {
                case DEST_IMAGE:
                    updateDestinationImageBands(varName, band);
                    set(ctx, new SetDestValue(varName, band, expr));
                    break;

                case LIST:
                    set(
                            ctx,
                            new BinaryExpression(
                                    opType, new Variable(varName, JiffleType.LIST), expr, declare));
                    break;

                case SCALAR:
                    set(
                            ctx,
                            new BinaryExpression(
                                    opType, new Variable(varName, JiffleType.D), expr, declare));
                    break;

                default:
                    // Invalid RHS var type. This should have been caught
                    // in an earlier stage.
                    throw new InternalCompilerException("Invalid assignment to " + varName);
            }
        } catch (NodeException ex) {
            messages.error(ctx.getStart(), ex.getError());
        }
    }

    private void updateDestinationImageBands(String varName, Band band) {
        Integer bandNumber;
        if (band == null) {
            // band count is 1
            bandNumber = 1;
        } else {
            Expression index = band.getIndex();
            if (index instanceof ScalarLiteral) {
                // from index to band count
                bandNumber = Integer.valueOf(((ScalarLiteral) index).getValue()) + 1;
            } else {
                bandNumber = JiffleRuntime.DYNAMIC_BANDS;
            }
        }
        Integer current = destImageBands.get(varName);
        if (current == JiffleRuntime.DYNAMIC_BANDS
                || bandNumber == JiffleRuntime.DYNAMIC_BANDS) {
            destImageBands.put(varName, JiffleRuntime.DYNAMIC_BANDS);
        } else if (current == null || bandNumber > current) {
            destImageBands.put(varName, bandNumber);
        }
    }

    /**
     * Checks if a variable has already been declared in this scope, and if not, marks it as such
     *
     * @param scope
     * @param symbol
     * @return True if the variable still needed to be declared in this scope
     */
    private boolean checkAndSetDeclared(SymbolScope scope, String varName) {
        if (scope instanceof GlobalScope) {
            return false;
        }
        return declaredVariables.add(new VariableKey(scope, varName));
    }

    /*
     * Looks up the inner-most scope for a rule node.
     */
    protected SymbolScope getScope(ParseTree ctx) {
        if (ctx != null) {
            SymbolScope s = scopes.get(ctx);
            return s != null ? s : getScope(ctx.getParent());

        } else {
            throw new IllegalStateException("Compiler error: failed to find symbol scope");
        }
    }

    @Override
    public void exitUntilStmt(JiffleParser.UntilStmtContext ctx) {
        Expression condition = getAsType(ctx.parenExpression().expression(), Expression.class);
        Statement statement = getAsType(ctx.statement(), Statement.class);
        set(ctx, new Until(condition, statement));
    }

    @Override
    public void exitBreakifStmt(JiffleParser.BreakifStmtContext ctx) {
        Expression condition = getAsType(ctx.expression(), Expression.class);
        set(ctx, new BreakIf(condition));
    }

    @Override
    public void exitBlock(JiffleParser.BlockContext ctx) {
        List<StatementContext> contexts = ctx.statement();
        List<Statement> statements = new ArrayList<>();
        for (StatementContext context : contexts) {
            Statement st = getAsType(context, Statement.class);
            statements.add(st);
        }

        set(ctx, new StatementList(statements));
    }

    @Override
    public void exitBlockStmt(JiffleParser.BlockStmtContext ctx) {
        set(ctx, get(ctx.block()));
    }

    public Script getScriptNode() {
        return this.script;
    }

    @Override
    public void exitIfStmt(JiffleParser.IfStmtContext ctx) {
        Expression condition = getAsType(ctx.parenExpression().expression(), Expression.class);
        List<StatementContext> statements = ctx.statement();
        Statement ifBlock = getAsType(statements.get(0), Statement.class);
        Statement elseBlock = null;
        if (statements.size() > 1) {
            elseBlock = getAsType(statements.get(1), Statement.class);
        }
        set(ctx, new IfElse(condition, ifBlock, elseBlock));
    }

    @Override
    public void exitListAppendStmt(JiffleParser.ListAppendStmtContext ctx) {
        String varName = ctx.ID().getText();
        Expression expression = getAsType(ctx.expression(), Expression.class);
        set(ctx, new ListAppend(new Variable(varName, JiffleType.LIST), expression));
    }

    @Override
    public void exitForeachStmt(JiffleParser.ForeachStmtContext ctx) {
        String varName = ctx.ID().getText();
        JiffleParser.RangeContext range = ctx.loopSet().range();
        Variable loopVariable = new Variable(varName, JiffleType.D);
        Statement statement = getAsType(ctx.statement(), Statement.class);
        if (ctx.loopSet().ID() != null) {
            Variable listVariable = new Variable(ctx.loopSet().ID().getText(), JiffleType.LIST);
            set(ctx, new LoopInVariable(loopVariable, listVariable, statement));
        } else if (range != null) {
            Expression low = getAsType(range.expression(0), Expression.class);
            Expression high = getAsType(range.expression(1), Expression.class);
            set(ctx, new LoopInRange(loopVariable, low, high, statement));
        } else {
            ListLiteral listLiteral = getAsType(ctx.loopSet().listLiteral(), ListLiteral.class);
            set(ctx, new LoopInLiteralList(loopVariable, listLiteral, statement));
        }
    }

    @Override
    public void exitBreakStmt(JiffleParser.BreakStmtContext ctx) {
        set(ctx, new Break());
    }

    @Override
    public void exitWhileStmt(JiffleParser.WhileStmtContext ctx) {
        Expression condition = getAsType(ctx.parenExpression().expression(), Expression.class);
        Statement statement = getAsType(ctx.statement(), Statement.class);
        set(ctx, new While(condition, statement));
    }

    /**
     * Retuns number of bands used by the destination image assignments, or {@link
     * JiffleRuntime#DYNAMIC_BANDS} if the assignment is using expressions, and could not be
     * statically determined.
     *
     * @return
     */
    public Map<String, Integer> getDestinationBands() {
        return destImageBands;
    }
}


text:
package com.alachisoft.tayzgrid.caching;

import com.alachisoft.tayzgrid.common.net.Address;
import java.util.Calendar;

public class ShutDownServerInfo
 {
		private String _uniqueId;
		private Address _blockserverAddress = null;
		private Address _renderedAddress;
		private long _blockinterval;
		private java.util.Date _startShutDown = new java.util.Date();
                long startTime;
		public ShutDownServerInfo()
		{
			_startShutDown = new java.util.Date();
                        startTime = (Calendar.getInstance().getTime().getTime() - 621355968000000000l) / 10000l;
		}

		public final long getBlockInterval()
		{
			long timeout = (int)(_blockinterval * 1000) - (int)((Calendar.getInstance().getTime().getTime() - 621355968000000000l) / 10000l - startTime);
			return (timeout / 1000);
		}
		public final void setBlockInterval(long value)
		{
			_blockinterval = value;
		}

		public final String getUniqueBlockingId()
		{
			return _uniqueId;
		}
		public final void setUniqueBlockingId(String value)
		{
			_uniqueId = value;
		}

		public final Address getBlockServerAddress()
		{
			return _blockserverAddress;
		}
		public final void setBlockServerAddress(Address value)
		{
			_blockserverAddress = value;
		}

		public final Address getRenderedAddress()
		{
			return _renderedAddress;
		}
		public final void setRenderedAddress(Address value)
		{
			_renderedAddress = value;
		}
 }