content stringlengths 4 1.04M | lang stringclasses 358
values | score int64 0 5 | repo_name stringlengths 5 114 | repo_path stringlengths 4 229 | repo_licenses listlengths 1 8 |
|---|---|---|---|---|---|
/*
Copyright © 2011 MLstate
This file is part of Opa.
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.
*/
/**
* A widget displaying popups
*
* @author Hugo Heuzard, Guillem Rieu, 2011
* @author Adam Koprowski, 2011 (fade-in/out animations, better customization, ...)
* @category WIDGET
* @destination PUBLIC
* @stability EXPERIMENTAL
* @version 0.1
*/
import stdlib.widgets.core
import stdlib.widgets.button
type WNotification.config_box = {
style_top: WStyler.styler
style_content:WStyler.styler
style_buttons:WStyler.styler
style_main:WStyler.styler
sizex: int
sizey: int
}
type WNotification.config = {
style_box : WNotification.config_box
style_back : WStyler.styler
}
type WNotification.box_id = (string, string)
type WNotification.button = {
label : string
action : WNotification.box_id -> void
}
type WNotification.box = {
/**
* Whether the notification dialog blocks actions on the page or not:
* - if 'modal', a user action is required on the dialog box itself.
* - if 'loose', the dialog disappears when clicking outside.
* - if 'free', actions on the page are still possible.
*/
mode: { modal } / { loose } / { free }
/** Fade in/out speed when showing/hiding the box (no fade effect for {none}) */
fade: {none} / {slow} / {default} / {fast}
/** Delay in ms to keep the notification open */
delay: option(int)
/** Title of dialog box **/
title : xhtml
/** Content of dialog box **/
content : xhtml
/** Buttons of dialog box **/
buttons : { standard : list(WNotification.button) } / { customized : WNotification.box_id -> xhtml } / { no_buttons }
}
WNotification =
get_notification_id(id) = id ^ "_notification"
get_notification_box_id(id) = id ^ "_notificationbox"
get_notification_modal_id(id) = id ^ "_notificationmodal"
get_notification_background_id(id) = id ^ "_background"
animate(immediate, fade, speed) : dom -> void =
do_fade(speed) = id ->
effect = Dom.Effect.with_duration(speed, fade())
Dom.transition(id, effect) |> ignore
match speed with
| {none} -> immediate
| {slow} -> do_fade({slow})
| {default} -> do_fade({default})
| {fast} -> do_fade({fast})
add_notification(fade, cid, id, modal, new_html) =
_ = Log.debug("add notif",new_html)
show = animate(Dom.show, Dom.Effect.fade_in, fade)
if modal
then
do Dom.transform([#{get_notification_modal_id(cid)} +<- new_html])
do show(#{get_notification_box_id(id)})
do show(#{get_notification_background_id(cid)})
do show(#{get_notification_modal_id(cid)})
void
else
do Dom.transform([#{get_notification_id(cid)} +<- new_html])
do show(#{get_notification_box_id(id)})
do show(#{get_notification_id(cid)})
void
rem_notification(fade, cid, id, modal) =
_ = Log.debug("rem notif",id)
hide = animate(Dom.hide, Dom.Effect.fade_out, fade)
do hide(#{get_notification_box_id(id)})
do Dom.remove(#{get_notification_box_id(id)})
if modal
then do
if Dom.is_empty(Dom.select_children(#{get_notification_modal_id(cid)}))
then (do hide(#{get_notification_modal_id(cid)})
do hide(#{get_notification_background_id(cid)})
Dom.unbind_event(#{get_notification_background_id(cid)},{click}))
void
else
do
if Dom.is_empty(Dom.select_children(#{get_notification_id(cid)}))
then hide(#{get_notification_id(cid)})
void
notification_html(id: string, new_id:string, modal:bool, notification: WNotification.box, conf): xhtml =
ids = (id, new_id)
rem = ( -> rem_notification(notification.fade, id, new_id, modal))
// TODO: add drag'n'drop when available
prefix = "{id}_notification_{new_id}"
// action_close = [("Close", rem)]
(kind_html, content_html, actions) = (notification.title, notification.content, notification.buttons)
// | {error} -> (<>Error</>, notification.value, action_close)
// | {warning} -> (<>Warning</>, notification.value, action_close)
// | {info} -> (<>Info</>, notification.value, action_close)
// | {~custom} -> custom(notification.value))
make_button(~{label action}) : xhtml =
uniq_id = Dom.fresh_id()
WSimpleButton.html(uniq_id, (_ -> action(ids)), label)
|> WCore.make_inline_default(uniq_id, _)
index = match notification.mode with
| {modal} -> 1001
| {loose} -> _ = Dom.bind(#{get_notification_background_id(id)},{click},(_ -> rem())) 1001
| {free} -> 999
top =
// <span style="text-align: right; position: relative; float: right;">
// <a onclick={rem}>X</a>
// </span>
// <span style="clear:both"></span>
<div id="{prefix}_notification_bar">
<span>{kind_html}</span>
</div> |> WStyler.add(conf.style_top,_)
content =
<div>
<div id="{prefix}_notification_content">
{content_html}
</div>
</div> |> WStyler.add(conf.style_content,_)
buttons =
match actions with
| {standard=buttons} ->
<div id="{prefix}_notification_actions">
{List.map((action -> make_button(action)), buttons)}
</div> |> WStyler.add(conf.style_buttons,_)
| {customized=f} -> f(ids)
| {no_buttons} -> <></>;
<div id="{get_notification_box_id(new_id)}"
style="z-index:{index};display:none;
height: {conf.sizey}px;
width: {conf.sizex}px; position: fixed; top: 50%; left: 50%;
margin-left: -{conf.sizex/2}px;
margin-top: -{conf.sizey/2}px;
padding-bottom: 20px;">
{top}
{content}
{buttons}
</div>
|> WStyler.add(conf.style_main,_)
{{
default_config_box : WNotification.config_box = {
sizex = 300
sizey = 160
style_top = WStyler.make_style( css {
width: 100%;
height: 30px;
border-bottom: 1px solid black;
})
style_content = WStyler.make_style( css {
height: 100px;
overflow: auto;
})
style_buttons = WStyler.make_style( css {
height: 30px;
text-align: right;
width: 100%;
border-top: 1px solid black;
})
style_main = WStyler.make_style( css {
background: gray;
border: 1px solid black;
})
}
default_config : WNotification.config = {
style_box = default_config_box
style_back = WStyler.make_style(
(css {
display:none;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1000;
background: black;
opacity: .6
}))
}
/* Add this xhtml to your page before using notify function */
html(config : WNotification.config, id : string) : xhtml =
back = <div id="{get_notification_background_id(id)}" style=""></div> |> WStyler.add(config.style_back,_)
<>
{back}
<div id="{get_notification_id(id)}" style="display:none"/>
<div id="{get_notification_modal_id(id)}" style="display:none"/>
</>
/* default warning notification box with custom content */
default_warning(xhtml : xhtml) : WNotification.box =
fade = {default}
{
title = <>Warning</>
content = xhtml
buttons = {standard = [{label="Ok" action=destroy(fade, _)}]}
mode = {loose}
delay = none
~fade
}
/* default error notification box with custom content */
default_error(xhtml : xhtml) : WNotification.box =
fade = {default}
{
title = <>Error</>
content = xhtml
buttons = {standard = [{label="Ok" action=destroy(fade, _)}]}
mode = {modal}
delay = none
~fade
}
/* default info notificaiton box with custom content */
default_info(xhtml : xhtml) : WNotification.box =
fade = {default}
{
title = <>Info</>
content = xhtml
buttons = {standard = [{label="Ok" action=destroy(fade, _)}]}
mode = {free}
delay = none
~fade
}
default_confirm(xhtml : xhtml, result : (bool -> void)) : WNotification.box =
fade = {default}
yes_no(label, v) = {~label action=(box_id -> do result(v) destroy(fade, box_id))}
yes = yes_no("Yes", true)
no = yes_no("No", false)
{
title = <>Confirm</>
content = xhtml
buttons = {standard = [yes, no]}
mode = {modal}
delay = none
~fade
}
// default_prompt(xhtml : xhtml, result : (string -> void)) : WNotification.box =
// yes = ("Yes",(_ -> result(true)))
// no = ("No", (_ -> result(false)))
// {
// kind = content : xhtml -> (<>Confirm</>, content, [yes,no]) }
// mode = {modal}
// delay = none
// value = xhtml
// }
/* display a notification box
* notify(config,id,newid,notification)
* where :
* - 'id' is the id used in the 'html' function
* - 'newid' is a new id to identify the popup
*/
notify(config : WNotification.config,(id : string, id_box : string) : WNotification.box_id, notification: WNotification.box) : void =
modal = match notification.mode with
| {modal} -> {true}
| {loose} -> {true}
| {free} -> {false}
html = notification_html(id, id_box, modal, notification, config.style_box)
do add_notification(notification.fade, id, id_box, modal, html)
match notification.delay with
| {none} -> void
| {~some} -> sleep(some, (-> rem_notification(notification.fade, id, id_box, modal) ))
/* remove a notification box
* destroy(id,newid)
* where :
* - 'id' is the id used in the 'html' function
* - 'newid' is a id identifying the popup
*/
destroy(fade, (id : string, new_id : string) : WNotification.box_id) : void =
do rem_notification(fade, id, new_id, true)
do rem_notification(fade, id, new_id, false)
void
box_id(id : string) : WNotification.box_id = (id, Dom.fresh_id())
}}
| Opa | 5 | Machiaweliczny/oppailang | lib/stdlib/widgets/notification/notification.opa | [
"MIT"
] |
(set-logic QF_AUFBV)
(declare-fun zf () (_ BitVec 1))
(declare-fun cf () (_ BitVec 1))
(assert (= (bvor zf cf) (_ bv1 1)))
(check-sat)
(get-model)
| SMT | 3 | o2e/Triton | src/samples/smt/jbe.smt2 | [
"Apache-2.0"
] |
var $myStruct < struct{
@number i32,
@p <* i8> }>
func $main ()i32{
#Character
var %sChar i8
var %usChar i8
#signed and unsigned short integer
var %shortInt i16
var %shortInt2 i16
var %sShortInt i16
var %sShortInt2 i16
var %usShortInt i16
var %usShortInt2 i16
#signed and unsigned integer
var %int1 i32
var %sInt i32
var %usInt i32
var %usInt2 i32
#signed and unsigned long integer
var %long1 i64
var %long2 i64
var %sLong1 i64
var %sLong2 i64
var %usLong i64
var %usLong2 i64
var %lLong1 i64
var %iLong2 i64
var %sLlong1 i64
var %sLlonog2 i64
var %usLlong i64
var %usLlong2 i64
#float
var %Float f32
#double
var %Double f64
#long double
var %lDouble f64
#Address
var %array <[10] i8>
iassign<* i8>(
array 1 a64<*[10] i8>(addrof a64 %array, constval i64 1),
constval i32 120)}
# EXEC: %irbuild Main.mpl
# EXEC: %irbuild Main.irb.mpl
# EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl
| Maple | 3 | harmonyos-mirror/OpenArkCompiler-test | test/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/Main.mpl | [
"MulanPSL-1.0"
] |
package com.blankj.mock.subutil;
import android.content.Context;
import com.blankj.subutil.export.api.SubUtilApi;
import com.blankj.utilcode.util.ApiUtils;
import com.blankj.utilcode.util.ToastUtils;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2019/07/10
* desc :
* </pre>
*/
@ApiUtils.Api(isMock = true)
public class SubUtilApiMock extends SubUtilApi {
@Override
public void startSubUtilActivity(Context context) {
ToastUtils.showShort("startSubUtilActivity");
}
}
| Java | 4 | YashBangera7/AndroidUtilCode | feature/mock/src/main/java/com/blankj/mock/subutil/SubUtilApiMock.java | [
"Apache-2.0"
] |
{:enums
{:episode
{:description "The episodes of the original Star Wars trilogy."
:values [{:enum-value :NEWHOPE :description "The first one you saw."}
{:enum-value :EMPIRE :description "The good one."}
{:enum-value :JEDI :description "The one with the killer teddy bears."}]}}}
| edn | 3 | hagenek/lacinia | docs/_examples/enum-definition-description.edn | [
"Apache-2.0"
] |
dfstab_file=Plats för NFS-exporterade filer,0
share_all_command=Kommando för att påbörja fildelning,0
unshare_all_command=Kommando för att avsluta fildelning,0
| SystemVerilog | 0 | GalaxyGFX/webmin | dfsadmin/config.info.sv | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] |
// script-squarewave.click
// A Script element is used to control a RatedSource element's rate
// according to a square wave: 1/2 second at 1000 packets per second
// alternates with 1/2 second off. Watch the result by running
// click -p9999 script-squarewave.click && clicky -p9999
// See also the other script-*wave.click scripts.
s :: RatedSource(RATE 1000)
-> c :: Counter
-> d :: Discard;
Script(TYPE ACTIVE,
init x 0,
wait 0.5s,
set x $(sub 1000 $x),
write s.rate $x,
loop);
ClickyInfo(STYLE #c { decorations: activity } activity { decay: 0 });
| Click | 4 | MacWR/Click-changed-for-ParaGraph | conf/script-squarewave.click | [
"Apache-2.0"
] |
module Utils.DateTimePicker.Types exposing
( DateTimePicker
, InputHourOrMinute(..)
, Msg(..)
, StartOrEnd(..)
, initDateTimePicker
, initFromStartAndEndTime
)
import Time exposing (Posix)
import Utils.DateTimePicker.Utils exposing (floorMinute)
type alias DateTimePicker =
{ month : Maybe Posix
, mouseOverDay : Maybe Posix
, startDate : Maybe Posix
, endDate : Maybe Posix
, startTime : Maybe Posix
, endTime : Maybe Posix
}
type Msg
= NextMonth
| PrevMonth
| MouseOverDay Posix
| OnClickDay
| ClearMouseOverDay
| SetInputTime StartOrEnd InputHourOrMinute Int
| IncrementTime StartOrEnd InputHourOrMinute Int
type StartOrEnd
= Start
| End
type InputHourOrMinute
= InputHour
| InputMinute
initDateTimePicker : DateTimePicker
initDateTimePicker =
{ month = Nothing
, mouseOverDay = Nothing
, startDate = Nothing
, endDate = Nothing
, startTime = Nothing
, endTime = Nothing
}
initFromStartAndEndTime : Maybe Posix -> Maybe Posix -> DateTimePicker
initFromStartAndEndTime start end =
let
startTime =
Maybe.map (\s -> floorMinute s) start
endTime =
Maybe.map (\e -> floorMinute e) end
in
{ month = start
, mouseOverDay = Nothing
, startDate = start
, endDate = end
, startTime = startTime
, endTime = endTime
}
| Elm | 5 | creganFL/alertmanager | ui/app/src/Utils/DateTimePicker/Types.elm | [
"ECL-2.0",
"Apache-2.0"
] |
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.{{dominio_site}};
set $base /var/www/{{dominio_site}}/;
root $base/public_html;
# SSL
ssl_certificate /etc/letsencrypt/live/www.{{dominio_site}}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.{{dominio_site}}/privkey.pem;
# security
include /etc/nginx/security.conf;
# index.php
index index.php;
# index.php fallback
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# additional config
include /etc/nginx/general.conf;
include /etc/nginx/magento.conf;
# handle .php
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
include /etc/nginx/php_fastcgi.conf;
}
}
# non-www, subdomains redirect
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name .{{dominio_site}};
# SSL
ssl_certificate /etc/letsencrypt/live/www.{{dominio_site}}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.{{dominio_site}}/privkey.pem;
return 301 https://www.{{dominio_site}}$request_uri;
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name .{{dominio_site}};
return 301 https://www.{{dominio_site}}$request_uri;
}
| ApacheConf | 4 | alejunio/magento-ansible | ansible/nginx/templates/mag.vhost | [
"MIT"
] |
const { locales, sourceLocale } = require('./lingui.config.js')
module.exports = {
i18n: {
locales,
defaultLocale: sourceLocale,
},
webpack: (config) => {
config.module.rules.push({
test: /\.po/,
use: ['@lingui/loader'],
})
return config
},
}
| JavaScript | 4 | blomqma/next.js | examples/with-lingui/next.config.js | [
"MIT"
] |
set RootPath to (path to me)
set JuliaPath to POSIX path of ((RootPath as text) & "Contents:Resources:julia:bin:julia")
set JuliaFile to POSIX file JuliaPath
tell application id "com.apple.finder" to open JuliaFile
| AppleScript | 3 | JuliaLabs/julia | contrib/mac/app/startup.applescript | [
"MIT"
] |
## GET /
+ Response 200 (application/json)
+ Attributes
+ (array)
+ foo
+ bar
| API Blueprint | 2 | realcredit1/drafter | test/fixtures/render/issue-547.apib | [
"BSL-1.0",
"MIT"
] |
#if defined(SOKOL_GLCORE33) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
void v_sapp_gl_read_rgba_pixels(int x, int y, int width, int height, unsigned char* pixels) {
glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}
#else
void v_sapp_gl_read_rgba_pixels(int x, int y, int width, int height, unsigned char* pixels) {
// TODO
}
#endif
| C | 4 | zakuro9715/v | thirdparty/sokol/sokol_v.post.h | [
"MIT"
] |
#*****************************************************************************
# *
# Make file for VMS *
# Author : J.Jansen (joukj@hrem.nano.tudelft.nl) *
# Date : 6 October 2009 *
# *
#*****************************************************************************
.first
define wx [--.include.wx]
.ifdef __WXMOTIF__
CXX_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short)\
/assume=(nostdnew,noglobal_array_new)/incl=([],[-])
.else
.ifdef __WXGTK__
CXX_DEFINE = /define=(__WXGTK__=1)/float=ieee/name=(as_is,short)/ieee=denorm\
/assume=(nostdnew,noglobal_array_new)/incl=([],[-])
.else
.ifdef __WXGTK2__
CXX_DEFINE = /define=(__WXGTK__=1,VMS_GTK2=1)/float=ieee/name=(as_is,short)/ieee=denorm\
/assume=(nostdnew,noglobal_array_new)/incl=([],[-])
.else
.ifdef __WXX11__
CXX_DEFINE = /define=(__WXX11__=1,__WXUNIVERSAL__==1)/float=ieee\
/name=(as_is,short)/assume=(nostdnew,noglobal_array_new)/incl=([],[-])
.else
CXX_DEFINE =
.endif
.endif
.endif
.endif
.suffixes : .cpp
.cpp.obj :
cxx $(CXXFLAGS)$(CXX_DEFINE) $(MMS$TARGET_NAME).cpp
all :
.ifdef __WXMOTIF__
$(MMS)$(MMSQUALIFIERS) arttest.exe
.else
.ifdef __WXGTK__
$(MMS)$(MMSQUALIFIERS) arttest_gtk.exe
.else
.ifdef __WXGTK2__
$(MMS)$(MMSQUALIFIERS) arttest_gtk2.exe
.else
.ifdef __WXX11__
$(MMS)$(MMSQUALIFIERS) arttest_x11.exe
.endif
.endif
.endif
.endif
OBJS=arttest.obj,artbrows.obj
.ifdef __WXMOTIF__
arttest.exe : $(OBJS)
cxxlink $(OBJS),[--.lib]vms/opt
.else
.ifdef __WXGTK__
arttest_gtk.exe : $(OBJS)
cxxlink/exec=arttest_gtk.exe $(OBJS),[--.lib]vms_gtk/opt
.else
.ifdef __WXGTK2__
arttest_gtk2.exe : $(OBJS)
cxxlink/exec=arttest_gtk2.exe $(OBJS),[--.lib]vms_gtk2/opt
.else
.ifdef __WXX11__
arttest_x11.exe : $(OBJS)
cxxlink/exec=arttest_x11.exe $(OBJS),[--.lib]vms_x11_univ/opt
.endif
.endif
.endif
.endif
arttest.obj : arttest.cpp
artbrows.obj : artbrows.cpp
| Module Management System | 3 | madanagopaltcomcast/pxCore | examples/pxScene2d/external/WinSparkle/3rdparty/wxWidgets/samples/artprov/descrip.mms | [
"Apache-2.0"
] |
untyped
global function VR_Init
global function VR_GroundTroopsDeathCallback
struct {
string vr_settings = ""
} file
function VR_Init( string settings = "", bool enableDropships = false )
{
if ( reloadingScripts )
return
if ( !enableDropships )
FlagSet( "DisableDropships" )
file.vr_settings = settings
//AddDeathCallback( "npc_soldier", VR_GroundTroopsDeathCallback )
//AddDeathCallback( "npc_spectre", VR_GroundTroopsDeathCallback )
//AddDeathCallback( "npc_marvin", VR_GroundTroopsDeathCallback )
//AddDeathCallback( "player", VR_GroundTroopsDeathCallback )
AddCallback_EntitiesDidLoad( EntitiesDidLoad )
}
void function EntitiesDidLoad()
{
if ( file.vr_settings.find( "no_evac" ) != null )
svGlobal.evacEnabled = false
if ( file.vr_settings.find( "no_npc" ) != null )
{
disable_npcs()
}
if ( file.vr_settings.find( "no_titan" ) != null )
{
Riff_ForceTitanAvailability( eTitanAvailability.Never )
FlagSet( "PilotBot" )
}
}
void function VR_GroundTroopsDeathCallback( entity guy, var damageInfo )
{
EmitSoundAtPosition( TEAM_UNASSIGNED, guy.GetOrigin(), "Object_Dissolve" )
if ( ShouldDoDissolveDeath( guy, damageInfo ) )
guy.Dissolve( ENTITY_DISSOLVE_CHAR, Vector( 0, 0, 0 ), 0 )
}
function ShouldDoDissolveDeath( guy, damageInfo )
{
if ( !guy.IsPlayer() )
return true
// can't dissolve players when they're not playing the game, otherwise when the game starts again they're invisible
local gs = GetGameState()
if ( gs != eGameState.Playing && gs != eGameState.SuddenDeath && gs != eGameState.Epilogue )
{
printt( "Skipping player dissolve death because game is not active ( player:", guy, ")" )
return false
}
return true
} | Squirrel | 5 | GeckoEidechse/NorthstarMods | Northstar.CustomServers/mod/scripts/vscripts/mp/_vr.nut | [
"MIT"
] |
module: b
url: https://code.google.com/codejam/contest/1460488/dashboard#s=p1
define function line() => (line :: <string>) read-line(*standard-input*) end;
define function number() => (number :: <integer>) string-to-integer(line()) end;
define function do-case(i) => ()
let fields = map(string-to-integer, split(line(), " "));
let n = fields[0];
let s = fields[1];
let p = fields[2];
let t = copy-sequence(fields, start: 3);
let total = p * 3;
let set-a = choose(method(x) (total - 4 >= 0) & (x >= total - 4) end, t);
let set-b = choose(method(x) x >= total - 2 end, t);
let surprising = size(set-a) - size(set-b);
let j = max(surprising, 0);
let k = min(j, s);
format-out("Case #%d: %d\n", i, size(set-b) + k)
end function do-case;
do(curry(do-case), range(from: 1, to: number()));
| Dylan | 4 | Ashindustry007/competitive-programming | codejam/2012-qualification/b.dylan | [
"WTFPL"
] |
# -*- perl -*-
use strict;
use warnings;
use tests::tests;
check_expected ([<<'EOF']);
(wait-killed) begin
(child-bad) begin
child-bad: exit(-1)
(wait-killed) wait(exec()) = -1
(wait-killed) end
wait-killed: exit(0)
EOF
pass;
| ChucK | 3 | Jeffxzj/PintOS-Project1 | tests/userprog/wait-killed.ck | [
"MIT"
] |
import Data.Vect
import Data.Vect.Elem
oneInVector : Elem 1 [1,2,3]
oneInVector = Here
maryInVector : Elem "Mary" ["Peter", "Paul", "Mary"]
maryInVector = There (There Here)
fourNotInVector : Elem 4 [1,2,3] -> Void
fourNotInVector (There (There (There Here))) impossible
fourNotInVector (There (There (There (There _)))) impossible
peteNotInVector : Elem "Pete" ["John", "Paul", "George", "Ringo"] -> Void
peteNotInVector (There (There (There (There Here)))) impossible
peteNotInVector (There (There (There (There (There _))))) impossible
| Idris | 4 | Qqwy/Idris2-Erlang | idris2/tests/typedd-book/chapter09/Elem.idr | [
"BSD-3-Clause"
] |
{
"Version" : 0.2,
"ModuleName" : "EDASQLite",
"ModuleVersion" : "0.44",
"Options" : {
"Warnings" : "All",
"Optimization" : "None",
"PreprocessorDefinitions" : [
"SQLITE_ENABLE_RTREE=1",
"SQLITE_DEFAULT_LOCKING_MODE=1",
"SQLITE_OMIT_AUTHORIZATION"
],
"TargetType" : "SharedLibrary",
"TargetFileName" : "EDASQLite",
"Libraries" : [
"ecere",
"ffi"
]
},
"Platforms" : [
{
"Name" : "linux",
"Options" : {
"Libraries" : [
"pthread",
"dl",
"sqlite3"
]
}
},
{
"Name" : "apple",
"Options" : {
"Libraries" : [
"pthread",
"dl"
]
}
},
{
"Name" : "win32",
"Options" : {
"IncludeDirs" : [
"../../../deps/libffi-3.0.11/i686-pc-mingw32/include"
],
"Libraries" : [
"gnurx-0"
],
"LibraryDirs" : [
"../../../deps/libffi-3.0.11/obj/release.$(PLATFORM)$(COMPILER_SUFFIX)"
]
}
}
],
"Configurations" : [
{
"Name" : "Debug",
"Options" : {
"Debug" : true,
"PreprocessorDefinitions" : [
"_DEBUG"
],
"FastMath" : false
}
},
{
"Name" : "Release",
"Options" : {
"Warnings" : "All",
"Debug" : false,
"NoLineNumbers" : true,
"Optimization" : "Speed",
"PreprocessorDefinitions" : [
"SQLITE_ENABLE_RTREE=1"
],
"LibraryDirs" : [
"../../../obj/$(PLATFORM)/bin",
"../../../obj/$(PLATFORM)/lib"
],
"FastMath" : true,
"PostbuildCommands" : [
"$(call cp,$(TARGET),../../../$(SODESTDIR))"
],
"InstallCommands" : [
"$(call cp,$(TARGET),\"$(DESTLIBDIR)/ec/\")",
"$(if $(WINDOWS_HOST),,ln -sf $(LP)$(MODULE)$(SOV) $(DESTLIBDIR)/ec/$(LP)$(MODULE)$(SO).0)",
"$(if $(WINDOWS_HOST),,ln -sf $(LP)$(MODULE)$(SOV) $(DESTLIBDIR)/ec/$(LP)$(MODULE)$(SO))"
]
}
},
{
"Name" : "MemoryGuard",
"Options" : {
"Debug" : true,
"MemoryGuard" : true,
"PreprocessorDefinitions" : [
"_DEBUG"
],
"FastMath" : false
}
},
{
"Name" : "Static",
"Options" : {
"NoLineNumbers" : true,
"Optimization" : "Speed",
"PreprocessorDefinitions" : [
"ECERE_STATIC"
],
"TargetType" : "StaticLibrary",
"TargetFileName" : "EDASQLiteStatic",
"CompilerOptions" : [
"-mmmx",
"-msse",
"-msse2",
"-msse3",
"-msse4"
],
"FastMath" : true
}
},
{
"Name" : "Android",
"Platforms" : [
{
"Name" : "linux",
"Options" : {
"NoLineNumbers" : true,
"Optimization" : "Speed",
"Libraries" : [
"pthread",
"dl"
]
}
}
]
},
{
"Name" : "Lumin",
"Options" : {
"NoLineNumbers" : true,
"Optimization" : "Speed",
"PreprocessorDefinitions" : [
"ECERE_STATIC"
],
"TargetType" : "StaticLibrary",
"TargetFileName" : "EDASQLiteLuminStatic",
"CompilerOptions" : [
"-mmmx",
"-msse3",
"-msse4"
],
"FastMath" : true
}
}
],
"Files" : [
{
"FileName" : "sqlite3.c",
"Options" : {
"FastMath" : false
},
"Platforms" : [
{
"Name" : "linux",
"Options" : {
"ExcludeFromBuild" : true
}
}
],
"Configurations" : [
{
"Name" : "Android",
"Platforms" : [
{
"Name" : "linux",
"Options" : {
"ExcludeFromBuild" : false
}
}
]
},
{
"Name" : "Lumin",
"Platforms" : [
{
"Name" : "linux",
"Options" : {
"ExcludeFromBuild" : false
}
}
]
}
]
},
{
"FileName" : "sqlite3.h",
"Platforms" : [
{
"Name" : "linux",
"Options" : {
"ExcludeFromBuild" : true
}
}
]
},
{
"FileName" : "EDASQLite.ec",
"Configurations" : [
{
"Name" : "Android",
"Platforms" : [
{
"Name" : "linux",
"Options" : {
"FastMath" : true
}
}
]
}
]
},
{
"FileName" : "sqliteDB.ec",
"Configurations" : [
{
"Name" : "Android",
"Platforms" : [
{
"Name" : "linux",
"Options" : {
"FastMath" : true
}
}
]
}
]
}
],
"ResourcesPath" : "",
"Resources" : [
{
"Folder" : "locale",
"Files" : [
"es.mo",
"he.mo",
"pt_BR.mo",
"ru.mo",
"zh_CN.mo"
]
}
]
}
| Ecere Projects | 3 | redj/ecere-sdk | eda/drivers/sqlite/EDASQLite.epj | [
"BSD-3-Clause"
] |
module.exports (terms) = terms.term {
constructor () =
self.is continue = true
generate statement (scope) =
self.code 'continue;'
rewrite result term into (return term) = self
}
| PogoScript | 0 | Sotrek/Alexa | Alexa_Cookbook/Workshop/StatePop/4_IOT/tests/node_modules/aws-sdk/node_modules/cucumber/node_modules/pogo/lib/terms/continueStatement.pogo | [
"MIT"
] |
(
SynthDef("help-OffsetOut",
{ arg out=0, freq=440, dur=0.05;
var env;
env = EnvGen.kr(Env.perc(0.01, dur, 0.2), doneAction: Done.freeSelf);
OffsetOut.ar(out, SinOsc.ar(freq, 0, env))
}).send(s);
SynthDef("help-Out",
{ arg out=0, freq=440, dur=0.05;
var env;
env = EnvGen.kr(Env.perc(0.01, dur, 0.2), doneAction: Done.freeSelf);
//compare to Out:
Out.ar(out, SinOsc.ar(freq, 0, env))
}).send(s);
)
Synth('help-OffsetOut');
// these are in sync
(
Routine({
loop {
s.sendBundle(0.2, ["/s_new", "help-OffsetOut", -1]);
0.01.wait;
}
}).play;
)
// these are less reliably in sync and are placed at multiples of blocksize.
(
Routine({
loop {
s.sendBundle(0.2, ["/s_new", "help-Out", -1]);
0.01.wait;
}
}).play;
)
(
plot({
var z;
z = Dust.ar(1000);
[z, z - Delay1.ar(z)] // [ original, subtract delayed from original ]
}))
(
plot({
var z;
z = Dust.ar(1000);
[z, z - Delay2.ar(z)] // [ original, subtract delayed from original ]
}))
// These examples compare the variants, so that you can hear the difference in interpolation
// Comb used as a resonator. The resonant fundamental is equal to
// reciprocal of the delay time.
{ CombN.ar(WhiteNoise.ar(0.01), 0.01, XLine.kr(0.0001, 0.01, 20), 0.2) }.play;
{ CombL.ar(WhiteNoise.ar(0.01), 0.01, XLine.kr(0.0001, 0.01, 20), 0.2) }.play;
{ CombC.ar(WhiteNoise.ar(0.01), 0.01, XLine.kr(0.0001, 0.01, 20), 0.2) }.play;
// with negative feedback:
{ CombN.ar(WhiteNoise.ar(0.01), 0.01, XLine.kr(0.0001, 0.01, 20), -0.2) }.play;
{ CombL.ar(WhiteNoise.ar(0.01), 0.01, XLine.kr(0.0001, 0.01, 20), -0.2) }.play;
{ CombC.ar(WhiteNoise.ar(0.01), 0.01, XLine.kr(0.0001, 0.01, 20), -0.2) }.play;
// used as an echo.
{ CombN.ar(Decay.ar(Dust.ar(1,0.5), 0.2, WhiteNoise.ar), 0.2, 0.2, 3) }.play;
// large delay lines
(
s.options.memSize= 8192*2;
s.reboot;
)
({
var in, del1, del2, del3, del4;
in = SoundIn.ar(0);
del1 = CombC.ar(in, 8, LFNoise2.kr(0.01).range(1, 8), 1);
del2 = CombC.ar(del1, 8, LFNoise2.kr(0.01).range(1, 8), 1);
del3 = CombC.ar(del2, 8, LFNoise2.kr(0.01).range(1, 8), 1);
del4 = CombC.ar(del3, 8, LFNoise2.kr(0.01).range(1, 8), 1);
(del1 + del2 + del3 + del4)!2;
}.play;
);
// Since the allpass delay has no audible effect as a resonator on
// steady-state sound ...
{ AllpassC.ar(WhiteNoise.ar(0.1), 0.01, XLine.kr(0.0001, 0.01, 20), 0.2) }.play;
// ...these examples add the input to the effected sound and compare variants so that you can hear
// the effect of the phase comb:
(
{
z = WhiteNoise.ar(0.2);
z + AllpassN.ar(z, 0.01, XLine.kr(0.0001, 0.01, 20), 0.2)
}.play)
(
{
z = WhiteNoise.ar(0.2);
z + AllpassL.ar(z, 0.01, XLine.kr(0.0001, 0.01, 20), 0.2)
}.play)
(
{
z = WhiteNoise.ar(0.2);
z + AllpassC.ar(z, 0.01, XLine.kr(0.0001, 0.01, 20), 0.2)
}.play)
// used as an echo - doesn't really sound different than Comb,
// but it outputs the input signal immediately (inverted) and the echoes
// are lower in amplitude.
{ AllpassC.ar(Decay.ar(Dust.ar(1,0.5), 0.2, WhiteNoise.ar), 0.2, 0.2, 3) }.play;
(
s = Server.local;
s.waitForBoot({
b = Buffer.alloc(s, 44100 * 2, 2);
SynthDef("help-PingPong", { |out = 0, bufnum = 0, feedback = 0.5, delayTime = 0.2|
var left, right;
left = Decay2.ar(Impulse.ar(0.7, 0.25), 0.01, 0.25,
SinOsc.ar(SinOsc.kr(3.7,0,200,500)));
right = Decay2.ar(Impulse.ar(0.5, 0.25), 0.01, 0.25,
Resonz.ar(PinkNoise.ar(4), SinOsc.kr(2.7,0,1000,2500), 0.2));
Out.ar(out ,
PingPong.ar(bufnum, [left,right], delayTime, feedback, 1)
)
}).play(s, [\out, 0, \bufnum, b.bufnum, \feedback, 0.5, \delayTime,0.1]);
})
)
b.free;
(
s = Server.local;
s.waitForBoot({
b = Buffer.alloc(s, 44100 * 2, 2);
SynthDef("help-PingPong", { |out = 0, bufnum = 0|
var left, right;
left = Decay2.ar(Impulse.ar(0.7, 0.25), 0.01, 0.25,
SinOsc.ar(SinOsc.kr(3.7,0,200,500)));
right = Decay2.ar(Impulse.ar(0.5, 0.25), 0.01, 0.25,
Resonz.ar(PinkNoise.ar(4), SinOsc.kr(2.7,0,1000,2500),
0.2));
Out.ar(out,
PingPong.ar(bufnum, [left, right] * EnvGen.kr(Env([1, 1, 0], [2, 0.1])),
0.1, 0.8, 1)
)
}).play(s, [\out, 0, \bufnum, b.bufnum]);
});
)
b.free;
(
// Dust randomly triggers Decay to create an exponential
// decay envelope for the WhiteNoise input source
{
z = Decay.ar(Dust.ar(1,0.5), 0.3, WhiteNoise.ar);
DelayN.ar(z, 0.2, 0.2, 1, z); // input is mixed with delay via the add input
}.play
)
(
// recursive application of delay.
{
z = Decay2.ar(Dust.ar(1, 0.5), 0.01, 0.1, Saw.ar(100 + [0, 1]));
5.do { |i| z = DelayN.ar(RLPF.ar(z, Rand(100, 3000), 0.03), 1, 1 / (2**i), 1, z * 0.5) };
z
}.play
) | SuperCollider | 4 | drichardson/examples | SuperCollider/Delays.scd | [
"Unlicense"
] |
set terminal epslatex standalone color
#set output "histexp_1.tex"
#set output "histexp_2.tex"
set output "histexp_3.tex"
set size square
#set title "True count of 10,000"
#set title "True count of 500,000"
set title "True count of 1,000,000"
set xlabel ''
#set xrange [-255:9745]
#set xtics ("6000" -255, "10,000" 3745, "16,000" 9745)
#set xrange [352000:644000]
#set xrange[-1458:538542]
#set xtics ("320,000" -1458, "500,000" 178542, "860,000" 538542)
#set xrange [808000:1240000]
set xrange[-19374:1100626]
set xtics ("600,0000" -19374, "1,000,000" 380626, "1,720,000" 1100626)
#set ylabel 'Approximate count $\left( \times 10^{5} \right)$'
#set ytics ("0" 0, "2" 200000, "4" 400000, "6" 600000, "8" 800000, "10" 1000000)
#plot "histogram_1exp.dat" w l lw 10 title ""
#plot "histogram_2exp.dat" w l lw 10 title ""
plot "histogram_3exp.dat" w l lw 10 title ""
| Gnuplot | 4 | alzawad26/algorithm-archive | contents/approximate_counting/res/hist_2_plot.gp | [
"MIT"
] |
"""
[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute]
public final transient class Slice_property_intModule(object):
private static def Main(argv as (string)) as void:
l = ['foo']
l.set_Item(0, 'bar')
Boo.Lang.Builtins.print(l.get_Item(0))
private def constructor():
super()
"""
l = ["foo"]
l[0] = "bar"
print(l.get_Item(0))
| Boo | 2 | popcatalin81/boo | tests/testcases/semantics/slice_property_int.boo | [
"BSD-3-Clause"
] |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.spark.sql.execution.datasources.orc
import java.util.Random
import org.apache.orc.impl.HadoopShimsFactory
import org.apache.spark.sql.Row
import org.apache.spark.sql.test.SharedSparkSession
class OrcEncryptionSuite extends OrcTest with SharedSparkSession {
import testImplicits._
val originalData = Seq(("123456789", "dongjoon@apache.org", "Dongjoon Hyun"))
val rowDataWithoutKey =
Row(null, "841626795E7D351555B835A002E3BF10669DE9B81C95A3D59E10865AC37EA7C3", "Dongjoon Hyun")
test("Write and read an encrypted file") {
val conf = spark.sessionState.newHadoopConf()
val provider = HadoopShimsFactory.get.getHadoopKeyProvider(conf, new Random)
assume(!provider.getKeyNames.isEmpty,
s"$provider doesn't has the test keys. ORC shim is created with old Hadoop libraries")
val df = originalData.toDF("ssn", "email", "name")
withTempPath { dir =>
val path = dir.getAbsolutePath
withSQLConf(
"hadoop.security.key.provider.path" -> "test:///",
"orc.key.provider" -> "hadoop",
"orc.encrypt" -> "pii:ssn,email",
"orc.mask" -> "nullify:ssn;sha256:email") {
df.write.mode("overwrite").orc(path)
checkAnswer(spark.read.orc(path), df)
}
withSQLConf(
"orc.key.provider" -> "memory",
"orc.encrypt" -> "pii:ssn,email",
"orc.mask" -> "nullify:ssn;sha256:email") {
checkAnswer(spark.read.orc(path), rowDataWithoutKey)
}
}
}
test("Write and read an encrypted table") {
val conf = spark.sessionState.newHadoopConf()
val provider = HadoopShimsFactory.get.getHadoopKeyProvider(conf, new Random)
assume(!provider.getKeyNames.isEmpty,
s"$provider doesn't has the test keys. ORC shim is created with old Hadoop libraries")
val df = originalData.toDF("ssn", "email", "name")
withTempDir { dir =>
val path = dir.getAbsolutePath
withTable("encrypted") {
sql(
s"""
|CREATE TABLE encrypted (
| ssn STRING,
| email STRING,
| name STRING
|)
|USING ORC
|LOCATION "$path"
|OPTIONS (
| hadoop.security.key.provider.path "test:///",
| orc.key.provider "hadoop",
| orc.encrypt "pii:ssn,email",
| orc.mask "nullify:ssn;sha256:email"
|)
|""".stripMargin)
sql("INSERT INTO encrypted VALUES('123456789', 'dongjoon@apache.org', 'Dongjoon Hyun')")
checkAnswer(sql("SELECT * FROM encrypted"), df)
}
withTable("normal") {
sql(
s"""
|CREATE TABLE normal (
| ssn STRING,
| email STRING,
| name STRING
|)
|USING ORC
|LOCATION "$path"
|OPTIONS (
| orc.key.provider "memory",
| orc.encrypt "pii:ssn,email",
| orc.mask "nullify:ssn;sha256:email"
|)
|""".stripMargin)
checkAnswer(sql("SELECT * FROM normal"), rowDataWithoutKey)
}
}
}
test("SPARK-35325: Write and read encrypted nested columns") {
val conf = spark.sessionState.newHadoopConf()
val provider = HadoopShimsFactory.get.getHadoopKeyProvider(conf, new Random)
assume(!provider.getKeyNames.isEmpty,
s"$provider doesn't has the test keys. ORC shim is created with old Hadoop libraries")
val originalNestedData = Row(1, Row("123456789", "dongjoon@apache.org", "Dongjoon"))
val rowNestedDataWithoutKey =
Row(1, Row(null, "841626795E7D351555B835A002E3BF10669DE9B81C95A3D59E10865AC37EA7C3",
"Dongjoon"))
withTempDir { dir =>
val path = dir.getAbsolutePath
withTable("encrypted") {
sql(
s"""
|CREATE TABLE encrypted (
| id INT,
| contact struct<ssn:STRING, email:STRING, name:STRING>
|)
|USING ORC
|LOCATION "$path"
|OPTIONS (
| hadoop.security.key.provider.path "test:///",
| orc.key.provider "hadoop",
| orc.encrypt "pii:contact.ssn,contact.email",
| orc.mask "nullify:contact.ssn;sha256:contact.email"
|)
|""".stripMargin)
sql("INSERT INTO encrypted VALUES(1, ('123456789', 'dongjoon@apache.org', 'Dongjoon'))")
checkAnswer(sql("SELECT * FROM encrypted"), originalNestedData)
}
withTable("normal") {
sql(
s"""
|CREATE TABLE normal (
| id INT,
| contact struct<ssn:STRING, email:STRING, name:STRING>
|)
|USING ORC
|LOCATION "$path"
|OPTIONS (
| orc.key.provider "memory"
|)
|""".stripMargin)
checkAnswer(sql("SELECT * FROM normal"), rowNestedDataWithoutKey)
}
}
}
test("SPARK-35992: Write and read fully-encrypted columns with default masking") {
val conf = spark.sessionState.newHadoopConf()
val provider = HadoopShimsFactory.get.getHadoopKeyProvider(conf, new Random)
assume(!provider.getKeyNames.isEmpty,
s"$provider doesn't has the test keys. ORC shim is created with old Hadoop libraries")
val df = originalData.toDF("ssn", "email", "name")
withTempPath { dir =>
val path = dir.getAbsolutePath
withSQLConf(
"hadoop.security.key.provider.path" -> "test:///",
"orc.key.provider" -> "hadoop",
"orc.encrypt" -> "pii:ssn,email,name") {
df.write.mode("overwrite").orc(path)
checkAnswer(spark.read.orc(path), df)
}
withSQLConf(
"orc.key.provider" -> "memory",
"orc.encrypt" -> "pii:ssn,email,name") {
checkAnswer(spark.read.orc(path), Row(null, null, null))
}
}
val originalNestedData = Row(1, Row("123456789", "dongjoon@apache.org", "Dongjoon"))
withTempDir { dir =>
val path = dir.getAbsolutePath
withTable("encrypted") {
sql(
s"""
|CREATE TABLE encrypted (
| id INT,
| contact struct<ssn:STRING, email:STRING, name:STRING>
|)
|USING ORC
|LOCATION "$path"
|OPTIONS (
| hadoop.security.key.provider.path "test:///",
| orc.key.provider "hadoop",
| orc.encrypt "pii:id,contact"
|)
|""".stripMargin)
sql("INSERT INTO encrypted VALUES(1, ('123456789', 'dongjoon@apache.org', 'Dongjoon'))")
checkAnswer(sql("SELECT * FROM encrypted"), originalNestedData)
}
withTable("normal") {
sql(
s"""
|CREATE TABLE normal (
| id INT,
| contact struct<ssn:STRING, email:STRING, name:STRING>
|)
|USING ORC
|LOCATION "$path"
|OPTIONS (
| orc.key.provider "memory"
|)
|""".stripMargin)
checkAnswer(sql("SELECT * FROM normal"), Row(null, null))
checkAnswer(sql("SELECT id, contact.* FROM normal"), Row(null, null, null, null))
}
}
}
}
| Scala | 4 | akhalymon-cv/spark | sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/orc/OrcEncryptionSuite.scala | [
"Apache-2.0"
] |
GET /test HTTP/1.1\r\n
Accept:\r\n
*/*\r\n
\r\n
| HTTP | 1 | ashishmjn/gunicorn | tests/requests/invalid/013.http | [
"MIT"
] |
//
// This file is part of the Simutrans project under the Artistic License.
// (see LICENSE.txt)
//
//
// Test set_/can_set_slope
//
function test_slope_to_dir()
{
local slope_to_dir = {}
slope_to_dir[slope.north] <- dir.south
slope_to_dir[slope.east ] <- dir.west
slope_to_dir[slope.south] <- dir.north
slope_to_dir[slope.west ] <- dir.east
slope_to_dir[2*slope.north] <- dir.south
slope_to_dir[2*slope.east ] <- dir.west
slope_to_dir[2*slope.south] <- dir.north
slope_to_dir[2*slope.west ] <- dir.east
for (local sl = 0; sl < 81; ++sl) {
if (sl in slope_to_dir) {
ASSERT_EQUAL(slope.to_dir(sl), slope_to_dir[sl])
}
else {
ASSERT_EQUAL(slope.to_dir(sl), dir.none)
}
}
}
function test_slope_can_set()
{
local pl = player_x(0)
local pos = coord3d(2, 3, 0)
for (local sl = 0; sl < slope.raised; ++sl) {
for (local target_sl = 0; target_sl < slope.raised; ++target_sl) {
command_x.set_slope(pl, pos, sl)
ASSERT_EQUAL(tile_x(2, 3, 0).get_slope(), sl)
RESET_ALL_PLAYER_FUNDS()
local expected = ""
ASSERT_EQUAL(command_x.can_set_slope(pl, pos, sl), expected)
local sq = square_x(2, 3)
ASSERT_TRUE(sq != null && sq.is_valid())
ASSERT_EQUAL(sq.get_climate(), cl_mediterran)
local tile = sq.get_tile_at_height(0)
ASSERT_TRUE(tile != null && tile.is_valid())
ASSERT_EQUAL(tile.get_slope(), sl)
ASSERT_EQUAL(pl.get_current_cash(), 200000) // get_current_cash is in credits (returns float)
ASSERT_EQUAL(pl.get_current_net_wealth(), 200000*100) // get_current_net_wealth is in 1/100 credits
}
}
// reset to normal slope
command_x.set_slope(pl, pos + coord3d(0, 0, 1), slope.all_down_slope)
command_x.set_slope(pl, pos, slope.all_down_slope)
RESET_ALL_PLAYER_FUNDS()
ASSERT_EQUAL(command_x.can_set_slope(pl, pos + coord3d(0, 0, 1), slope.all_up_slope), "")
ASSERT_EQUAL(command_x.can_set_slope(pl, pos - coord3d(0, 0, 1), slope.all_down_slope), "")
ASSERT_EQUAL(pl.get_current_cash(), 200000) // get_current_cash is in credits (returns float)
ASSERT_EQUAL(pl.get_current_net_wealth(), 200000*100) // get_current_net_wealth is in 1/100 credits
RESET_ALL_PLAYER_FUNDS()
}
function test_slope_set_and_restore()
{
local pl = player_x(0)
local setslope = command_x(tool_setslope)
local restoreslope = command_x(tool_restoreslope)
{
// FIXME Crash when the "" are omitted (default_param is null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, 0), "" + slope.north), null)
ASSERT_EQUAL(tile_x(2, 3, 0).get_slope(), slope.north)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, 0), "" + slope.south), null)
ASSERT_EQUAL(tile_x(2, 3, 0).get_slope(), slope.south)
ASSERT_EQUAL(restoreslope.work(pl, coord3d(2, 3, 0)), null)
ASSERT_EQUAL(tile_x(2, 3, 0).get_slope(), slope.flat)
}
{
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, 0), "" + slope.all_up_slope), null)
ASSERT_TRUE(tile_x(2, 3, 0).is_valid())
ASSERT_TRUE(tile_x(2, 3, 1).is_valid())
ASSERT_EQUAL(tile_x(2, 3, 1).get_slope(), slope.flat)
// fails as expected because ground is 1 unit higher
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, 0), "" + slope.all_up_slope), "")
// TODO check tile height
ASSERT_EQUAL(restoreslope.work(pl, coord3d(2, 3, 0)), "")
ASSERT_TRUE(tile_x(2, 3, 0).is_valid())
ASSERT_EQUAL(tile_x(2, 3, 0).get_slope(), slope.flat)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, 1), "" + slope.all_down_slope), null)
ASSERT_EQUAL(tile_x(2, 3, 1).get_slope(), slope.flat)
}
RESET_ALL_PLAYER_FUNDS()
}
function test_slope_set_near_map_border()
{
local pl = player_x(0)
local setslope = command_x(tool_setslope)
// map edge
{
for (local sl = 0; sl < slope.raised; ++sl) {
ASSERT_EQUAL(setslope.work(pl, coord3d(0, 3, 0), "" + sl), "Zu nah am Kartenrand")
}
}
// map corner
{
for (local sl = 0; sl < slope.raised; ++sl) {
ASSERT_EQUAL(setslope.work(pl, coord3d(0, 0, 0), "" + sl), "Zu nah am Kartenrand")
}
}
RESET_ALL_PLAYER_FUNDS()
}
function test_slope_max_height_diff()
{
local pl = player_x(0)
local setslope = command_x(tool_setslope)
// build upwards, height difference = 4
{
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 0), "" + slope.all_up_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 1), "" + slope.all_up_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 2), "" + slope.all_up_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 3), "" + slope.all_up_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 4), "" + slope.all_up_slope), "Maximum tile height difference reached.")
}
// diagonally, the height difference is unlimited (technically limited to 2*max_diff)
{
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, 0), "" + slope.all_down_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, -1), "" + slope.all_down_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, -2), "" + slope.all_down_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, -3), "" + slope.all_down_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, -4), "" + slope.all_down_slope), "Maximum tile height difference reached.")
}
// and clean up
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 4), "" + slope.all_down_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 3), "" + slope.all_down_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 2), "" + slope.all_down_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(3, 2, 1), "" + slope.all_down_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, -4), "" + slope.all_up_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, -3), "" + slope.all_up_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, -2), "" + slope.all_up_slope), null)
ASSERT_EQUAL(setslope.work(pl, coord3d(2, 3, -1), "" + slope.all_up_slope), null)
RESET_ALL_PLAYER_FUNDS()
}
function test_slope_get_price()
{
local pl = player_x(0)
for (local sl = 0; sl < slope.raised; ++sl) {
ASSERT_EQUAL(command_x.slope_get_price(slope.flat), 2000 * 100)
}
local restore_slope = 84
ASSERT_EQUAL(command_x.slope_get_price(restore_slope), 1500 * 100)
ASSERT_EQUAL(pl.get_current_cash(), 200000) // get_current_cash is in credits (returns float)
ASSERT_EQUAL(pl.get_current_net_wealth(), 200000*100) // get_current_net_wealth is in 1/100 credits
RESET_ALL_PLAYER_FUNDS()
}
| Squirrel | 4 | Andarix/simutrans_nightly | tests/tests/test_slope.nut | [
"Artistic-1.0"
] |
create table explicit_tidb_rowid (pk varchar(6) primary key); | SQL | 3 | imtbkcat/tidb-lightning | tests/tidb_rowid/data/rowid.explicit_tidb_rowid-schema.sql | [
"Apache-2.0"
] |
import React from 'react'
import Image, { ImageProps } from 'next/image'
export default () => {
const props: ImageProps = {
src: '/noop.jpg',
width: 100,
height: 100,
}
const filledProps: ImageProps = {
src: '/noop.jpg',
layout: 'fill',
}
return (
<>
<Image {...props} />
<Image {...filledProps} />
</>
)
}
| TypeScript | 3 | blomqma/next.js | test/integration/typescript/components/image.tsx | [
"MIT"
] |
#include "common.hlsl"
struct VS_OUTPUT {
float4 pos : POSITION;
float2 texCoord : TEXCOORD0;
#ifdef UPSCALE
float4 diffuse : COLOR0;
#endif
};
#ifdef VERTEX
VS_OUTPUT main(VS_INPUT In) {
VS_OUTPUT Out;
Out.pos = mul(uViewProj, float4(In.aCoord.xy, 0.0, 1.0));
Out.texCoord = In.aTexCoord.xy * INV_SHORT_HALF;
#ifdef UPSCALE
Out.diffuse = In.aLight;
#endif
#ifdef _GAPI_D3D9
#if defined(DOWNSAMPLE)
Out.texCoord += float2(2.0, -2.0) * uParam.x; // ???
#elif defined(BLUR) || defined(GRAYSCALE)
Out.texCoord += float2(0.5, 0.5) * uParam.w;
#elif defined(UPSCALE)
Out.texCoord += float2(0.5, 0.5) / uParam.xy;
#endif
#endif
return Out;
}
#else // PIXEL
float4 downsample(float2 uv) { // uParam (texelSize, unused, unused, unused)
float4 color = 0.0;
for (float y = -1.5; y < 2.0; y++) {
for (float x = -1.5; x < 2.0; x++) {
float4 p;
p.xyz = SAMPLE_2D_LINEAR(sDiffuse, uv + float2(x, y) * uParam.x).xyz;
p.w = dot(p.xyz, float3(0.299, 0.587, 0.114));
p.xyz *= p.w;
color += p;
}
}
return float4(color.xyz / color.w, 1.0);
}
float4 grayscale(float2 uv) { // uParam (tint.rgb, texelSize)
float4 color = SAMPLE_2D_POINT(sDiffuse, uv);
float3 gray = dot(color, float4(0.299, 0.587, 0.114, 0.0));
return float4(gray * uParam.xyz, color.w);
}
float4 blur(float2 uv) { // uParam (dirX, dirY, unused, texelSize)
const float3 offset = float3( 0.0, 1.3846153846, 3.2307692308);
const float3 weight = float3(0.2270270270, 0.3162162162, 0.0702702703);
float2 dir = uParam.xy;
float4 color = SAMPLE_2D_LINEAR(sDiffuse, uv) * weight[0];
color += SAMPLE_2D_LINEAR(sDiffuse, uv + dir * offset[1]) * weight[1];
color += SAMPLE_2D_LINEAR(sDiffuse, uv - dir * offset[1]) * weight[1];
color += SAMPLE_2D_LINEAR(sDiffuse, uv + dir * offset[2]) * weight[2];
color += SAMPLE_2D_LINEAR(sDiffuse, uv - dir * offset[2]) * weight[2];
return color;
}
float4 upscale(float2 uv) { // uParam (textureWidth, textureHeight, unused, unused)
uv = uv * uParam.xy + 0.5;
float2 iuv = floor(uv);
float2 fuv = frac(uv);
uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv);
uv = (uv - 0.5) / uParam.xy;
return SAMPLE_2D_LINEAR(sDiffuse, uv);
}
float4 anaglyph(float2 uv) {
float3 eyeL = SAMPLE_2D_POINT(sDiffuse, float2(uv.x, 1.0 - uv.y)).rgb;
float3 eyeR = SAMPLE_2D_POINT(sNormal, float2(uv.x, 1.0 - uv.y)).rgb;
return float4(eyeL.r, eyeR.g, eyeR.b, 1.0);
}
float4 main(VS_OUTPUT In) : COLOR0 {
#ifdef DOWNSAMPLE
return downsample(In.texCoord.xy);
#elif GRAYSCALE
return grayscale(In.texCoord.xy);
#elif BLUR
return blur(In.texCoord.xy);
#elif UPSCALE
return upscale(In.texCoord.xy) * In.diffuse;
#elif ANAGLYPH
return anaglyph(In.texCoord.xy);
#else
#error unsupported filter type
#endif
}
#endif | HLSL | 5 | guitarpukpui/OpenLara | src/shaders/filter.hlsl | [
"BSD-2-Clause"
] |
#!/bin/tcsh
echo "Hello World"
| Tcsh | 1 | conorpreid/hello-world | t/TCSH.tcsh | [
"MIT"
] |
// @@ANTLR Tool Options@@: -trace
tree grammar t051treeRewriteASTacWalker;
options {
language=JavaScript;
output=AST;
ASTLabelType=CommonTree;
tokenVocab=t051treeRewriteASTac;
}
s : ^(ID c=.) -> $c
;
| G-code | 4 | DanielMabadeje/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | java/java2py/antlr-3.1.3/runtime/JavaScript/tests/functional/t051treeRewriteASTacWalker.g | [
"Apache-2.0"
] |
"""The mqtt_json component."""
| Python | 0 | domwillcode/home-assistant | homeassistant/components/mqtt_json/__init__.py | [
"Apache-2.0"
] |
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalcon.io>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/
namespace Phalcon\Mvc\Model\Binder;
/**
* Phalcon\Mvc\Model\Binder\BindableInterface
*
* Interface for bindable classes
*/
interface BindableInterface
{
/**
* Return the model name or models names and parameters keys associated with
* this class
*/
public function getModelName() -> string | array;
}
| Zephir | 4 | tidytrax/cphalcon | phalcon/Mvc/Model/Binder/BindableInterface.zep | [
"BSD-3-Clause"
] |
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Exec=touch xdg-test-desktop-icon-install.tmp
Name=Desktop_Icon
StartupNotify=false
| desktop | 1 | freedesktop-unofficial-mirror/xdg__xdg-utils | tests/xdg-desktop-icon/data/desktop_icon_install.desktop | [
"MIT"
] |
# this script uses foreground ansi index colors to print
# a table of 16 rows by 16 colums where each item is a
# different color
def show_index_colors [] {
let prefix = "38;5;"
echo 1..256 | each { |idx|
let cr = ($"($idx) % 16" | math eval)
let color = ($"(ansi -e $prefix)($idx)m")
let padded_number = ($"($idx)" | str lpad -l 3 -c '0')
if $cr == 0 {
$"($color)($padded_number) (char newline)"
} {
$"($color)($padded_number) "
}
} | str collect
}
show_index_colors
# one-liner version that just prints
# it all on one line which wraps in
# your terminal
#echo 1..256 | each { |idx| echo [(ansi -e '38;5;') (build-string $idx) 'm' (build-string $idx) ' ']} | str collect | Nu | 4 | x3rAx/nu_scripts | coloring/nu_index_fg2.nu | [
"MIT"
] |
/*
Copyright © 2011 MLstate
This file is part of Opa.
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.
*/
/**
* {1 About this module}
*
* This module defines some high level functions to manipulate a couchdb database.
* It's build on top of [CouchDb].
*
* {1 Where should I start?}
*
* You should obviously start by setting up a couchdb server somewhere (cf.
* http://couchdb.apache.org/ ) and having a look at the couchdb official
* documentation.
*
* {1 What if I need more?}
*
* The [CouchDb] module provides numerous "low-level" functions to interract
* with CouchDb, you will probably find what you need there.
*
*/
import stdlib.core.{web.client, web.core, rpc.core}
import stdlib.apis.couchdb
/**
* {1 The types}
*/
type Opacouch.success('a) =
{FormatedRecord : (int, option('a))}
/ CouchDb.success
type Opacouch.result('a) = outcome(Opacouch.success('a), CouchDb.failure)
/**
* {1 The API}
*/
Opacouch = {{
@private embed_rev(document, rev) =
match document
| {Record = fields} ->
match List.assoc("_rev", fields)
| {some = ~{String}} ->
if String == rev
then {success = document}
else {failure = {Other = "The _rev field of the document doesn't match the last revision in the db"}}
| _ -> {success = {Record = [("_rev", {String = rev} : RPC.Json.json) | fields]}}
end
| _ -> {failure = {InvalidJsonDoc}}
update_doc(auth, the_db, docid, document) =
doc = OpaSerialize.Json.serialize(document)
rev = Option.get(get_revision(auth, the_db, docid))
match embed_rev(doc, rev)
| ~{failure} -> ~{failure}
| ~{success} -> CouchDb.Document.put(auth, the_db, docid, success)
create_doc(auth, the_db, docid, document) =
doc = OpaSerialize.Json.serialize(document)
CouchDb.Document.put(auth, the_db, docid, doc)
insert_doc(auth, the_db, docid, document) =
doc = OpaSerialize.Json.serialize(document)
rev = Option.default(dummy_revision, get_revision(auth, the_db, docid))
match embed_rev(doc, rev)
| ~{failure} -> ~{failure}
| ~{success} -> CouchDb.Document.put(auth, the_db, docid, success)
dummy_revision = "0-0" : CouchDb.revision
retrieve_doc(auth, the_db, docid) : Opacouch.result('a) =
match CouchDb.Document.get(auth, the_db, docid)
| {success = {FormatedJson = (code, {some = json_doc})}} ->
// we unserialize only when the HTTP code is 2XX (i.e. the request
// succeeded) since we don't know what structure will have the error
// message.
//
// TODO: check if it's always {error : string , reason : string}
// if it is, we COULD return :
// option('a / {error : string , reason : string })
if (code >= 200 && code < 300) then
{success = { FormatedRecord = (code, OpaSerialize.Json.unserialize_unsorted(json_doc)) }}
else {success = {FormatedJson = (code, {some = json_doc})}}
| ~{failure} -> ~{failure}
| _ -> do @assert(false) {failure = {Other = "This should never happen."}}
/**
* Get the revision of a document.
* @return [none] if the document doesn't exist.
*/
get_revision(auth, the_db, docid) : option(CouchDb.revision) =
match CouchDb.Document.head(auth, the_db, docid)
| {success = {RawResponse = {code=200 ~header_get ... }}} ->
match header_get("ETag")
| {none} -> {none} // This should never happen.
| {some = rev} ->
some = String.drop_right(1, String.drop_left(1, rev))
~{some}
end
| _ -> {none}
}}
| Opa | 5 | Machiaweliczny/oppailang | lib/stdlib/apis/couchdb/tools/tools.opa | [
"MIT"
] |
enum Foo {
enum Bar { Baz }, //~ ERROR `enum` definition cannot be nested inside `enum`
struct Quux { field: u8 }, //~ ERROR `struct` definition cannot be nested inside `enum`
union Wibble { field: u8 }, //~ ERROR `union` definition cannot be nested inside `enum`
Bat,
}
fn main() { }
| Rust | 2 | Eric-Arellano/rust | src/test/ui/enum/nested-enum.rs | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
%h3 503 Service Unavailable
%hr
%p
Sorry.
| Scaml | 0 | tototoshi/skinny-framework | example/src/main/webapp/WEB-INF/views/error/503.html.scaml | [
"MIT"
] |
globals [ noise-level
current-turtle
vocabulary
alphabet
]
turtles-own [
prize-count
temp-word
current-word
currently-playing
]
to setup
clear-all
ifelse Garrulous?
[resize-world -100 100 -50 50]
[resize-world -100 100 -100 100]
set current-turtle []
set alphabet ["a" "b" "C" "c" "d" "e" "f" "g" "o" "1" "2" "3" "4" "5"]
set vocabulary [["a" "a" "a"] ["b" "b" "b"] ["C" "c" "c"] ["1" "1" "1"] ["2" "2" "2"] ["d" "3" "d"] ["f" "o" "o"] ["g" "e" "e"] ["g" "4" "5"] ["l" "o" "l"] ]
set-default-shape turtles "person"
ask patches with [ pxcor < -11 and pxcor > 11 ] [ set pcolor white]
create-turtles Number_Players [
set size 3 ;; be easier to see
set color 2
; __set-line-thickness 2 ;; this command was commented out because it intereferes with the web version.
set currently-playing 0
set prize-count 0
set current-word [""]]
establish-layout
set noise-level random 100
reset-ticks
if Garrulous? [print "Initial set up is now complete."]
end
to establish-layout
ifelse layout-style = "random" [ask turtles [move-to one-of patches]]
[layout-circle turtles 50]
if Garrulous? [print (word "Layout set to " layout-style ".")]
end
to go
set noise-level noise-level + random 10 - random 10
if noise-level < 0 [set noise-level 0]
ifelse length current-turtle = 0
[start-new-game]
[ifelse length current-turtle = game-length
[wait .5
end-game]
[play-game]]
tick
end
to start-new-game
ask turtles [set currently-playing 0]
if choose-starter = "randomly" [ask-random]
if choose-starter = "most prizes" [ask-most]
if choose-starter = "least prizes" [ask-least]
end
to ask-random
ask one-of turtles with [currently-playing = 0 ]
[ if Garrulous? [print "Random player asked to play..."]
participate]
end
to ask-most
ifelse mean [prize-count] of turtles != 0 and any? turtles with [currently-playing = 0 and prize-count > mean [prize-count] of turtles]
[ask one-of turtles with [currently-playing = 0 and prize-count > mean [prize-count] of turtles] [participate]]
[ask-random]
end
to ask-least
ifelse mean [prize-count] of turtles != 0 and any? turtles with [currently-playing = 0 and prize-count < mean [prize-count] of turtles]
[ask one-of turtles with [currently-playing = 0 and prize-count < mean [prize-count] of turtles] [participate]]
[ask-random]
end
to ask-nearest
let closest-to-me min-one-of turtles [distance myself]
ifelse [currently-playing] of closest-to-me = 0 [ask closest-to-me [participate]]
[ask one-of turtles with [currently-playing = 0 ][participate]]
end
to ask-nearish
ifelse any? turtles in-radius 5 with [currently-playing = 0]
[ask one-of turtles in-radius 5 with [currently-playing = 0][participate]]
[ask one-of turtles in-radius 55 with [currently-playing = 0][participate]]
end
to participate
set currently-playing 1
set size 5
ifelse length current-turtle = 0
[set xcor -10
set ycor 0 ]
[set xcor ([xcor] of turtle first current-turtle + 10)
set ycor ([ycor] of turtle first current-turtle + 1)]
ifelse length current-turtle = 0
[set temp-word one-of vocabulary
set current-word temp-word
if Garrulous? [wait .5 print (word "Player " length current-turtle " has decided to whisper the word " current-word ".")]]
[set temp-word ([current-word] of turtle first current-turtle)
if Garrulous? [wait .5 print (word "Player " length current-turtle " is listening...")]
apply-distortion]
set current-turtle fput [who] of self current-turtle
set label current-word
end
to play-game
if choose-next = "randomly" [ask-random]
if choose-next = "most prizes" [ask-most]
if choose-next = "least prizes" [ask-least]
if choose-next = "nearest" [ask turtle first current-turtle [ask-nearest]]
if choose-next = "nearish" [ask turtle first current-turtle [ask-nearish]]
end
to apply-distortion
ifelse apply-noise-distortion?
[ifelse noise-level < Acceptable-noise-level
[set current-word temp-word if Garrulous? [print (word "Player " length current-turtle " can hear easily at " noise-level " decibels." )]]
[set current-word temp-word
ifelse random 3 >= 2
[set temp-word replace-item 0 temp-word one-of alphabet
if Garrulous? [print (word "Ah, it is quite noisy at " noise-level " decibels. Player " length current-turtle " has misheard the first phoneme. ")]]
[if Garrulous? [print (word "Player " length current-turtle " is listening closely, even at " noise-level " decibels and has heard the first phoneme correctly.")]]
ifelse random 3 >= 2
[set temp-word replace-item 1 temp-word one-of alphabet
if Garrulous? [print (word "Ah, it is quite noisy at " noise-level " decibels. Player " length current-turtle " has misheard the second phoneme. ")]]
[if Garrulous? [print (word "Player " length current-turtle " is listening closely, even at " noise-level " decibels and has heard the second phoneme correctly.")]]
ifelse random 3 >= 2
[set temp-word replace-item 2 temp-word one-of alphabet
if Garrulous? [print (word "Ah, it is quite noisy at " noise-level " decibels. Player " length current-turtle " has misheard the third phoneme. ")]]
[if Garrulous? [print (word "Player " length current-turtle " is listening closely, even at " noise-level " decibels and has heard the third phoneme correctly.")]]
set current-word temp-word
if Garrulous? [print (word "Player " length current-turtle " has heard" current-word ".")]]]
[set current-word temp-word
if Garrulous? [print (word "Player " length current-turtle " has heard" current-word ".")]]
end
to end-game
if Garrulous? [print (word "The players this round were "current-turtle ".")]
let start-turtle-word [current-word] of turtle last current-turtle
let end-turtle-word [current-word] of turtle first current-turtle
ifelse start-turtle-word = end-turtle-word [
if Garrulous? [print (word "Everyone gets a big prize! Player 0 whispered " start-turtle-word " and Player " length current-turtle " heard " end-turtle-word ".")]
ask turtles with [currently-playing = 1] [ set prize-count prize-count + 5]]
[ if Garrulous? [print (word "It was just too noisy. Player 0 whispered " start-turtle-word " but Player " length current-turtle " heard " end-turtle-word ". Still, small prizes will be awarded if any of the phonemes match.")]
ask turtles with [size = 5][
if item 0 start-turtle-word = item 0 end-turtle-word [set prize-count prize-count + 1]
if item 1 start-turtle-word = item 1 end-turtle-word [ set prize-count prize-count + 1]
if item 2 start-turtle-word = item 2 end-turtle-word [ set prize-count prize-count + 1]]]
ask turtles with [size = 5][
set color 0 + prize-count
if remainder color 10 = 0 [set color color + 2]
set size 3
set currently-playing 0
set label ""]
set current-turtle []
establish-layout
end
@#$#@#$#@
GRAPHICS-WINDOW
275
15
1067
418
-1
-1
3.90244
1
14
1
1
1
0
1
1
1
-100
100
-50
50
1
1
1
ticks
30.0
BUTTON
30
10
98
43
setup
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
181
10
249
43
go
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
0
BUTTON
99
10
180
43
go once
go
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
0
SLIDER
1225
15
1395
48
Number_Players
Number_Players
10
300
95.0
1
1
NIL
HORIZONTAL
PLOT
10
203
260
368
Prize distribution
Players
Prize count
0.0
10.0
0.0
150.0
true
false
"set-plot-x-range 0 count turtles\nset-plot-y-range 0 count turtles\nset-histogram-num-bars Number_Players\n\n" ""
PENS
"Distribution" 1.0 1 -10899396 true "" "histogram [color] of turtles"
MONITOR
135
65
260
110
Total prize count
sum [prize-count] of turtles
3
1
11
MONITOR
5
65
130
110
Current noise level
noise-level
3
1
11
CHOOSER
1080
70
1218
115
choose-starter
choose-starter
"randomly" "most prizes" "least prizes"
0
CHOOSER
1080
125
1218
170
choose-next
choose-next
"randomly" "nearest" "most prizes" "least prizes" "nearish"
0
CHOOSER
1080
15
1218
60
layout-style
layout-style
"layout-circle" "random"
0
SWITCH
1225
105
1395
138
apply-noise-distortion?
apply-noise-distortion?
0
1
-1000
SWITCH
1080
240
1192
273
Garrulous?
Garrulous?
0
1
-1000
SLIDER
1225
60
1397
93
game-length
game-length
2
10
4.0
1
1
NIL
HORIZONTAL
INPUTBOX
1230
155
1382
215
Acceptable-noise-level
70.0
1
0
Number
@#$#@#$#@
## WHAT IS IT?
This is a model of a game of Telephone (also known as Chinese Whispers in the UK), with agents representing people that can be asked, to play. The first player selects a word from their internal vocabulary and "whispers" it to the next player, who may mishear it depending on the current noise level, who whispers that word to the next player, and so on.
When the game ends, the word chosen by the first player is compared to the word heard by the last player. If they match exactly, all players earn large prize. If the words do not match exactly, a small prize is awarded to all players for each part of the words that do match. Players change color to reflect their current prize-count. A histogram shows the distribution of colors over all the players.
The user can decide on factors like
* how many players there are,
* whether they are laid out in a circle or just randomly,
* how many players participate in a game,
* whether to apply noise-distortion or not,
* at what decibel level noise distortion starts interfering with the game,
* how the first player to participate is chosen,
* how further players are chosen, and
* whether or not the games run quickly and silently or slowly and with commentary to explain what is happening.
These factors influence how likely players are to win a game and thus how the color of players will be distributed over time.
## HOW IT WORKS
The world has dimensions and also a noise level that moves up and down randomly at each time step, but cannot fall below 0. When the model is initiated, a number of characters are laid out across the dimensions according to a modeller input, which appears in the interface as "layout-style" and gives the options of random or circle. When created, all agents have a vocabulary (set in the code) of several 2 character "words" and an alphabet consisting of all the characters that appear in any position of any of the words in their vocabulary.
The first player is chosen according to a modeller input, which appears on the interface as "choose-starter" which gives the options of randomly, most prizes and least prizes (self-explanatory). That agent randomly selects one of the words in their vocabulary.
The next player is chosen according to a modeller input, which appears on the interface as "choose-next" which gives the options of randomly, most prizes, least prizes, nearest and near-ish (self-explanatory?). The first player "whispers" their chosen word to the next player, who will hear it correctly if the noise-level is below the "Appropriate-noise-level" as set by the modeller. If the noise level is above "Appropriate-noise-level" then a small test is performed for each part of the word, with a chance that the listener may mishear some but not all of the sounds. The listener then becomes the whisperer and the process is repeated until the number of players reaches the "game-length" as set by the modeller. At that point, the game ends, the word chosen by the first player and the word heard by the last player are compared and prizes are awarded.
Each player in the game earns a 5 point prize if the two words match exactly. Thus, [a a a] and [a a a] earn 5 points for all players.
Each player in the game earns a 1 point prize for each phoneme that matches when the two words do not match exactly. Thus, a maximum of 2 points can be awarded for partially matched words, so [a a a] and [a a b] would earn 2 points but [a a a] and [a b b] would earn 1 point.
Players do not earn any points for words that have no matching phoneme-positions in common. Thus, [a a a] and [b b b] would earn 0 points, as would [a b a] and [b a b].
After the game ends and any prizes are awarded, all agents lay themselves out again according to the modeller designated layout-style and adjust their color to reflect their current prize-count. 0 prizes = dark grey (color value 2) but players that have won a prize for exactly matching the first and final words would become light grey (color value 7). If they won again, they would be dark red (color value 12), etc. Any player whose prize count ends in 0 (such as 10, 20, 150, etc.) would become invisible against a black background, so their prize count is increased by 2.
A histogram shows the distribution of colors over all the players as a proxy for showing the distribution of prize counts.
## HOW TO USE IT
Adjusting the layout-style has no effect on the model functioning. This is purely an option to demonstrate the visual capabilities of NetLogo.
Similarly, adjusting Garrulous? To Yes or No has no real effect on the model functioning, although it does make the model run much slower and with much more writing appearing in the Command Centre bar at the bottom of the screen. This is useful for those unfamiliar with the model to gain an understanding of the steps taken by the model. It is also useful for bug-testing during model development.
Adjusting the other sliders and switches DOES affect the model functioning. Choices about how
* to select the first player or the subsequent players can skew the prize distribution.
* long a game lasts can affect the chance that players will get a perfect match between first and final words.
* to apply noise-distortion, and what level of noise is appropriate, influence the likelihood of earning (big) prizes.
* many agents are available to play can effect how long it takes for feedback loops and large scale dynamics to display.
These are not always straightforward and can interact. For example, setting a long game means more players can win prizes but makes it much harder to win prizes if noise distortion is applied when Appropriate-noise-level is set low.
## THINGS TO NOTICE
What shape is the histogram? Does this change over time? Does it depend on the way the sliders and swiches are set?
## THINGS TO TRY
Try varying all of the switches and sliders in various combinations (excluding layout-style and Garrolous?, which only affect the modeller's experience of the model while it is running).
## EXTENDING THE MODEL
Add more words to the vocabulary.
Extend the code to make the words longer.
Adjust the prizes awarded for getting perfect and/or partial matches.
Adjust the likelihood that players can correctly hear/mishear a word when the noise-level is above the Appropriate-noise-level.
## NETLOGO FEATURES
## CREDITS AND REFERENCES
## HOW TO CITE
If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.
For the model itself:
* Kasmire, J. (2020). Telephone Game. UK Data Services and University of Manchester, UK.
Please cite the NetLogo software as:
* Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
## COPYRIGHT AND LICENSE
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.
This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.
@#$#@#$#@
default
true
0
Polygon -7500403 true true 150 5 40 250 150 205 260 250
airplane
true
0
Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15
arrow
true
0
Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150
box
false
0
Polygon -7500403 true true 150 285 285 225 285 75 150 135
Polygon -7500403 true true 150 135 15 75 150 15 285 75
Polygon -7500403 true true 15 75 15 225 150 285 150 135
Line -16777216 false 150 285 150 135
Line -16777216 false 150 135 15 75
Line -16777216 false 150 135 285 75
bug
true
0
Circle -7500403 true true 96 182 108
Circle -7500403 true true 110 127 80
Circle -7500403 true true 110 75 80
Line -7500403 true 150 100 80 30
Line -7500403 true 150 100 220 30
butterfly
true
0
Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
Circle -16777216 true false 135 90 30
Line -16777216 false 150 105 195 60
Line -16777216 false 150 105 105 60
car
false
0
Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180
Circle -16777216 true false 180 180 90
Circle -16777216 true false 30 180 90
Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
Circle -7500403 true true 47 195 58
Circle -7500403 true true 195 195 58
circle
false
0
Circle -7500403 true true 0 0 300
circle 2
false
0
Circle -7500403 true true 0 0 300
Circle -16777216 true false 30 30 240
cow
false
0
Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167
Polygon -7500403 true true 73 210 86 251 62 249 48 208
Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123
cylinder
false
0
Circle -7500403 true true 0 0 300
dot
false
0
Circle -7500403 true true 90 90 120
face happy
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240
face neutral
false
0
Circle -7500403 true true 8 7 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Rectangle -16777216 true false 60 195 240 225
face sad
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183
fish
false
0
Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166
Circle -16777216 true false 215 106 30
flag
false
0
Rectangle -7500403 true true 60 15 75 300
Polygon -7500403 true true 90 150 270 90 90 30
Line -7500403 true 75 135 90 135
Line -7500403 true 75 45 90 45
flower
false
0
Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
Circle -7500403 true true 85 132 38
Circle -7500403 true true 130 147 38
Circle -7500403 true true 192 85 38
Circle -7500403 true true 85 40 38
Circle -7500403 true true 177 40 38
Circle -7500403 true true 177 132 38
Circle -7500403 true true 70 85 38
Circle -7500403 true true 130 25 38
Circle -7500403 true true 96 51 108
Circle -16777216 true false 113 68 74
Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240
house
false
0
Rectangle -7500403 true true 45 120 255 285
Rectangle -16777216 true false 120 210 180 285
Polygon -7500403 true true 15 120 150 15 285 120
Line -16777216 false 30 120 270 120
leaf
false
0
Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195
Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195
line
true
0
Line -7500403 true 150 0 150 300
line half
true
0
Line -7500403 true 150 0 150 150
pentagon
false
0
Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120
person
false
0
Circle -7500403 true true 110 5 80
Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90
Rectangle -7500403 true true 127 79 172 94
Polygon -7500403 true true 195 90 240 150 225 180 165 105
Polygon -7500403 true true 105 90 60 150 75 180 135 105
plant
false
0
Rectangle -7500403 true true 135 90 165 300
Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90
square
false
0
Rectangle -7500403 true true 30 30 270 270
square 2
false
0
Rectangle -7500403 true true 30 30 270 270
Rectangle -16777216 true false 60 60 240 240
star
false
0
Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108
target
false
0
Circle -7500403 true true 0 0 300
Circle -16777216 true false 30 30 240
Circle -7500403 true true 60 60 180
Circle -16777216 true false 90 90 120
Circle -7500403 true true 120 120 60
tree
false
0
Circle -7500403 true true 118 3 94
Rectangle -6459832 true false 120 195 180 300
Circle -7500403 true true 65 21 108
Circle -7500403 true true 116 41 127
Circle -7500403 true true 45 90 120
Circle -7500403 true true 104 74 152
triangle
false
0
Polygon -7500403 true true 150 30 15 255 285 255
triangle 2
false
0
Polygon -7500403 true true 150 30 15 255 285 255
Polygon -16777216 true false 151 99 225 223 75 224
truck
false
0
Rectangle -7500403 true true 4 45 195 187
Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
Rectangle -1 true false 195 60 195 105
Polygon -16777216 true false 238 112 252 141 219 141 218 112
Circle -16777216 true false 234 174 42
Rectangle -7500403 true true 181 185 214 194
Circle -16777216 true false 144 174 42
Circle -16777216 true false 24 174 42
Circle -7500403 false true 24 174 42
Circle -7500403 false true 144 174 42
Circle -7500403 false true 234 174 42
turtle
true
0
Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99
wheel
false
0
Circle -7500403 true true 3 3 294
Circle -16777216 true false 30 30 240
Line -7500403 true 150 285 150 15
Line -7500403 true 15 150 285 150
Circle -7500403 true true 120 120 60
Line -7500403 true 216 40 79 269
Line -7500403 true 40 84 269 221
Line -7500403 true 40 216 269 79
Line -7500403 true 84 40 221 269
x
false
0
Polygon -7500403 true true 270 75 225 30 30 225 75 270
Polygon -7500403 true true 30 75 75 30 270 225 225 270
@#$#@#$#@
NetLogo 6.1.1
@#$#@#$#@
setup
repeat 20 [ go ]
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
default
0.0
-0.2 0 0.0 1.0
0.0 1 1.0 0.0
0.2 0 0.0 1.0
link direction
true
0
Line -7500403 true 150 150 90 180
Line -7500403 true 150 150 210 180
@#$#@#$#@
1
@#$#@#$#@
| NetLogo | 5 | hubahuuduwu/abm-workshop | 2020_Training_series_materials/Telephone_Model/Telephone.nlogo | [
"MIT"
] |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Solution Notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem: Given a knapsack with a total weight capacity and a list of items with weight w(i) and value v(i), determine the max total value you can carry.\n",
"\n",
"* [Constraints](#Constraints)\n",
"* [Test Cases](#Test-Cases)\n",
"* [Algorithm](#Algorithm)\n",
"* [Code](#Code)\n",
"* [Unit Test](#Unit-Test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Constraints\n",
"\n",
"* Can we replace the items once they are placed in the knapsack?\n",
" * Yes, this is the unbounded knapsack problem\n",
"* Can we split an item?\n",
" * No\n",
"* Can we get an input item with weight of 0 or value of 0?\n",
" * No\n",
"* Do we need to return the items that make up the max total value?\n",
" * No, just the total value\n",
"* Can we assume the inputs are valid?\n",
" * No\n",
"* Are the inputs in sorted order by val/weight?\n",
" * Yes\n",
"* Can we assume this fits memory?\n",
" * Yes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test Cases\n",
"\n",
"* items or total weight is None -> Exception\n",
"* items or total weight is 0 -> 0\n",
"* General case\n",
"\n",
"<pre>\n",
"total_weight = 8\n",
"items\n",
" v | w\n",
" 0 | 0\n",
"a 1 | 1\n",
"b 3 | 2\n",
"c 7 | 4\n",
"\n",
"max value = 14 \n",
"</pre>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Algorithm\n",
"\n",
"We'll use bottom up dynamic programming to build a table. \n",
"\n",
"Taking what we learned with the 0/1 knapsack problem, we could solve the problem like the following:\n",
"\n",
"<pre>\n",
"\n",
"v = value\n",
"w = weight\n",
"\n",
" j \n",
" -------------------------------------------------\n",
" | v | w || 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |\n",
" -------------------------------------------------\n",
" | 0 | 0 || 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |\n",
" a | 1 | 1 || 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |\n",
"i b | 3 | 2 || 0 | 1 | 3 | 4 | 6 | 7 | 9 | 10 | 12 |\n",
" c | 7 | 4 || 0 | 1 | 3 | 4 | 7 | 8 | 10 | 11 | 14 |\n",
" -------------------------------------------------\n",
"\n",
"i = row\n",
"j = col\n",
"\n",
"</pre>\n",
"\n",
"However, unlike the 0/1 knapsack variant, we don't actually need to keep space of O(n * w), where n is the number of items and w is the total weight. We just need a single array that we update after we process each item:\n",
"\n",
"<pre>\n",
"\n",
" -------------------------------------------------\n",
" | v | w || 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |\n",
" -------------------------------------------------\n",
"\n",
" -------------------------------------------------\n",
" a | 1 | 1 || 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |\n",
" -------------------------------------------------\n",
"\n",
" -------------------------------------------------\n",
" b | 3 | 2 || 0 | 1 | 3 | 4 | 6 | 7 | 9 | 10 | 12 |\n",
" -------------------------------------------------\n",
"\n",
" -------------------------------------------------\n",
" c | 7 | 4 || 0 | 1 | 3 | 4 | 7 | 8 | 10 | 11 | 14 |\n",
" -------------------------------------------------\n",
"\n",
"if j >= items[i].weight:\n",
" T[j] = max(items[i].value + T[j - items[i].weight],\n",
" T[j])\n",
"\n",
"</pre>\n",
"\n",
"Complexity:\n",
"* Time: O(n * w), where n is the number of items and w is the total weight\n",
"* Space: O(w), where w is the total weight"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Code"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Item Class"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"class Item(object):\n",
"\n",
" def __init__(self, label, value, weight):\n",
" self.label = label\n",
" self.value = value\n",
" self.weight = weight\n",
"\n",
" def __repr__(self):\n",
" return self.label + ' v:' + str(self.value) + ' w:' + str(self.weight)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Knapsack Bottom Up"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"class Knapsack(object):\n",
"\n",
" def fill_knapsack(self, items, total_weight):\n",
" if items is None or total_weight is None:\n",
" raise TypeError('items or total_weight cannot be None')\n",
" if not items or total_weight == 0:\n",
" return 0\n",
" num_rows = len(items)\n",
" num_cols = total_weight + 1\n",
" T = [0] * (num_cols)\n",
" for i in range(num_rows):\n",
" for j in range(num_cols):\n",
" if j >= items[i].weight:\n",
" T[j] = max(items[i].value + T[j - items[i].weight],\n",
" T[j])\n",
" return T[-1]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Unit Test"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting test_knapsack_unbounded.py\n"
]
}
],
"source": [
"%%writefile test_knapsack_unbounded.py\n",
"import unittest\n",
"\n",
"\n",
"class TestKnapsack(unittest.TestCase):\n",
"\n",
" def test_knapsack(self):\n",
" knapsack = Knapsack()\n",
" self.assertRaises(TypeError, knapsack.fill_knapsack, None, None)\n",
" self.assertEqual(knapsack.fill_knapsack(0, 0), 0)\n",
" items = []\n",
" items.append(Item(label='a', value=1, weight=1))\n",
" items.append(Item(label='b', value=3, weight=2))\n",
" items.append(Item(label='c', value=7, weight=4))\n",
" total_weight = 8\n",
" expected_value = 14\n",
" results = knapsack.fill_knapsack(items, total_weight)\n",
" total_weight = 7\n",
" expected_value = 11\n",
" results = knapsack.fill_knapsack(items, total_weight)\n",
" self.assertEqual(results, expected_value)\n",
" print('Success: test_knapsack')\n",
"\n",
"def main():\n",
" test = TestKnapsack()\n",
" test.test_knapsack()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Success: test_knapsack\n"
]
}
],
"source": [
"%run -i test_knapsack_unbounded.py"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
| Jupyter Notebook | 5 | rubenparedes0796/interactive-coding-challenges | recursion_dynamic/knapsack_unbounded/knapsack_unbounded_solution.ipynb | [
"Apache-2.0"
] |
// Code generated by avx512test. DO NOT EDIT.
#include "../../../../../../runtime/textflag.h"
TEXT asmtest_avx512cd(SB), NOSPLIT, $0
VPBROADCASTMB2Q K1, X25 // 6262fe082ac9
VPBROADCASTMB2Q K5, X25 // 6262fe082acd
VPBROADCASTMB2Q K1, X11 // 6272fe082ad9
VPBROADCASTMB2Q K5, X11 // 6272fe082add
VPBROADCASTMB2Q K1, X17 // 62e2fe082ac9
VPBROADCASTMB2Q K5, X17 // 62e2fe082acd
VPBROADCASTMB2Q K3, Y0 // 62f2fe282ac3
VPBROADCASTMB2Q K1, Y0 // 62f2fe282ac1
VPBROADCASTMB2Q K3, Y19 // 62e2fe282adb
VPBROADCASTMB2Q K1, Y19 // 62e2fe282ad9
VPBROADCASTMB2Q K3, Y31 // 6262fe282afb
VPBROADCASTMB2Q K1, Y31 // 6262fe282af9
VPBROADCASTMB2Q K5, Z21 // 62e2fe482aed
VPBROADCASTMB2Q K4, Z21 // 62e2fe482aec
VPBROADCASTMB2Q K5, Z8 // 6272fe482ac5
VPBROADCASTMB2Q K4, Z8 // 6272fe482ac4
VPBROADCASTMW2D K7, X18 // 62e27e083ad7
VPBROADCASTMW2D K6, X18 // 62e27e083ad6
VPBROADCASTMW2D K7, X11 // 62727e083adf
VPBROADCASTMW2D K6, X11 // 62727e083ade
VPBROADCASTMW2D K7, X9 // 62727e083acf
VPBROADCASTMW2D K6, X9 // 62727e083ace
VPBROADCASTMW2D K4, Y22 // 62e27e283af4
VPBROADCASTMW2D K6, Y22 // 62e27e283af6
VPBROADCASTMW2D K4, Y9 // 62727e283acc
VPBROADCASTMW2D K6, Y9 // 62727e283ace
VPBROADCASTMW2D K4, Y23 // 62e27e283afc
VPBROADCASTMW2D K6, Y23 // 62e27e283afe
VPBROADCASTMW2D K0, Z16 // 62e27e483ac0
VPBROADCASTMW2D K7, Z16 // 62e27e483ac7
VPBROADCASTMW2D K0, Z9 // 62727e483ac8
VPBROADCASTMW2D K7, Z9 // 62727e483acf
VPCONFLICTD X6, K6, X6 // 62f27d0ec4f6
VPCONFLICTD X1, K6, X6 // 62f27d0ec4f1
VPCONFLICTD X8, K6, X6 // 62d27d0ec4f0
VPCONFLICTD 15(R8), K6, X6 // 62d27d0ec4b00f000000
VPCONFLICTD (BP), K6, X6 // 62f27d0ec47500
VPCONFLICTD X6, K6, X17 // 62e27d0ec4ce
VPCONFLICTD X1, K6, X17 // 62e27d0ec4c9
VPCONFLICTD X8, K6, X17 // 62c27d0ec4c8
VPCONFLICTD 15(R8), K6, X17 // 62c27d0ec4880f000000
VPCONFLICTD (BP), K6, X17 // 62e27d0ec44d00
VPCONFLICTD X6, K6, X28 // 62627d0ec4e6
VPCONFLICTD X1, K6, X28 // 62627d0ec4e1
VPCONFLICTD X8, K6, X28 // 62427d0ec4e0
VPCONFLICTD 15(R8), K6, X28 // 62427d0ec4a00f000000
VPCONFLICTD (BP), K6, X28 // 62627d0ec46500
VPCONFLICTD Y14, K3, Y2 // 62d27d2bc4d6
VPCONFLICTD Y8, K3, Y2 // 62d27d2bc4d0
VPCONFLICTD Y20, K3, Y2 // 62b27d2bc4d4
VPCONFLICTD -7(CX), K3, Y2 // 62f27d2bc491f9ffffff
VPCONFLICTD 15(DX)(BX*4), K3, Y2 // 62f27d2bc4949a0f000000
VPCONFLICTD Y14, K3, Y7 // 62d27d2bc4fe
VPCONFLICTD Y8, K3, Y7 // 62d27d2bc4f8
VPCONFLICTD Y20, K3, Y7 // 62b27d2bc4fc
VPCONFLICTD -7(CX), K3, Y7 // 62f27d2bc4b9f9ffffff
VPCONFLICTD 15(DX)(BX*4), K3, Y7 // 62f27d2bc4bc9a0f000000
VPCONFLICTD Y14, K3, Y21 // 62c27d2bc4ee
VPCONFLICTD Y8, K3, Y21 // 62c27d2bc4e8
VPCONFLICTD Y20, K3, Y21 // 62a27d2bc4ec
VPCONFLICTD -7(CX), K3, Y21 // 62e27d2bc4a9f9ffffff
VPCONFLICTD 15(DX)(BX*4), K3, Y21 // 62e27d2bc4ac9a0f000000
VPCONFLICTD Z11, K7, Z21 // 62c27d4fc4eb
VPCONFLICTD Z25, K7, Z21 // 62827d4fc4e9
VPCONFLICTD -15(R14)(R15*1), K7, Z21 // 62827d4fc4ac3ef1ffffff
VPCONFLICTD -15(BX), K7, Z21 // 62e27d4fc4abf1ffffff
VPCONFLICTD Z11, K7, Z13 // 62527d4fc4eb
VPCONFLICTD Z25, K7, Z13 // 62127d4fc4e9
VPCONFLICTD -15(R14)(R15*1), K7, Z13 // 62127d4fc4ac3ef1ffffff
VPCONFLICTD -15(BX), K7, Z13 // 62727d4fc4abf1ffffff
VPCONFLICTQ X11, K4, X8 // 6252fd0cc4c3
VPCONFLICTQ X16, K4, X8 // 6232fd0cc4c0
VPCONFLICTQ X6, K4, X8 // 6272fd0cc4c6
VPCONFLICTQ 15(R8)(R14*8), K4, X8 // 6212fd0cc484f00f000000
VPCONFLICTQ -15(R14)(R15*2), K4, X8 // 6212fd0cc4847ef1ffffff
VPCONFLICTQ X11, K4, X6 // 62d2fd0cc4f3
VPCONFLICTQ X16, K4, X6 // 62b2fd0cc4f0
VPCONFLICTQ X6, K4, X6 // 62f2fd0cc4f6
VPCONFLICTQ 15(R8)(R14*8), K4, X6 // 6292fd0cc4b4f00f000000
VPCONFLICTQ -15(R14)(R15*2), K4, X6 // 6292fd0cc4b47ef1ffffff
VPCONFLICTQ X11, K4, X0 // 62d2fd0cc4c3
VPCONFLICTQ X16, K4, X0 // 62b2fd0cc4c0
VPCONFLICTQ X6, K4, X0 // 62f2fd0cc4c6
VPCONFLICTQ 15(R8)(R14*8), K4, X0 // 6292fd0cc484f00f000000
VPCONFLICTQ -15(R14)(R15*2), K4, X0 // 6292fd0cc4847ef1ffffff
VPCONFLICTQ Y5, K4, Y11 // 6272fd2cc4dd
VPCONFLICTQ Y18, K4, Y11 // 6232fd2cc4da
VPCONFLICTQ Y20, K4, Y11 // 6232fd2cc4dc
VPCONFLICTQ 99(R15)(R15*8), K4, Y11 // 6212fd2cc49cff63000000
VPCONFLICTQ 7(AX)(CX*8), K4, Y11 // 6272fd2cc49cc807000000
VPCONFLICTQ Y5, K4, Y24 // 6262fd2cc4c5
VPCONFLICTQ Y18, K4, Y24 // 6222fd2cc4c2
VPCONFLICTQ Y20, K4, Y24 // 6222fd2cc4c4
VPCONFLICTQ 99(R15)(R15*8), K4, Y24 // 6202fd2cc484ff63000000
VPCONFLICTQ 7(AX)(CX*8), K4, Y24 // 6262fd2cc484c807000000
VPCONFLICTQ Y5, K4, Y1 // 62f2fd2cc4cd
VPCONFLICTQ Y18, K4, Y1 // 62b2fd2cc4ca
VPCONFLICTQ Y20, K4, Y1 // 62b2fd2cc4cc
VPCONFLICTQ 99(R15)(R15*8), K4, Y1 // 6292fd2cc48cff63000000
VPCONFLICTQ 7(AX)(CX*8), K4, Y1 // 62f2fd2cc48cc807000000
VPCONFLICTQ Z27, K7, Z3 // 6292fd4fc4db
VPCONFLICTQ Z15, K7, Z3 // 62d2fd4fc4df
VPCONFLICTQ 7(AX)(CX*4), K7, Z3 // 62f2fd4fc49c8807000000
VPCONFLICTQ 7(AX)(CX*1), K7, Z3 // 62f2fd4fc49c0807000000
VPCONFLICTQ Z27, K7, Z12 // 6212fd4fc4e3
VPCONFLICTQ Z15, K7, Z12 // 6252fd4fc4e7
VPCONFLICTQ 7(AX)(CX*4), K7, Z12 // 6272fd4fc4a48807000000
VPCONFLICTQ 7(AX)(CX*1), K7, Z12 // 6272fd4fc4a40807000000
VPLZCNTD X3, K3, X17 // 62e27d0b44cb
VPLZCNTD X26, K3, X17 // 62827d0b44ca
VPLZCNTD X23, K3, X17 // 62a27d0b44cf
VPLZCNTD 15(DX)(BX*1), K3, X17 // 62e27d0b448c1a0f000000
VPLZCNTD -7(CX)(DX*2), K3, X17 // 62e27d0b448c51f9ffffff
VPLZCNTD X3, K3, X15 // 62727d0b44fb
VPLZCNTD X26, K3, X15 // 62127d0b44fa
VPLZCNTD X23, K3, X15 // 62327d0b44ff
VPLZCNTD 15(DX)(BX*1), K3, X15 // 62727d0b44bc1a0f000000
VPLZCNTD -7(CX)(DX*2), K3, X15 // 62727d0b44bc51f9ffffff
VPLZCNTD X3, K3, X8 // 62727d0b44c3
VPLZCNTD X26, K3, X8 // 62127d0b44c2
VPLZCNTD X23, K3, X8 // 62327d0b44c7
VPLZCNTD 15(DX)(BX*1), K3, X8 // 62727d0b44841a0f000000
VPLZCNTD -7(CX)(DX*2), K3, X8 // 62727d0b448451f9ffffff
VPLZCNTD Y5, K3, Y20 // 62e27d2b44e5
VPLZCNTD Y28, K3, Y20 // 62827d2b44e4
VPLZCNTD Y7, K3, Y20 // 62e27d2b44e7
VPLZCNTD (BX), K3, Y20 // 62e27d2b4423
VPLZCNTD -17(BP)(SI*1), K3, Y20 // 62e27d2b44a435efffffff
VPLZCNTD Y5, K3, Y12 // 62727d2b44e5
VPLZCNTD Y28, K3, Y12 // 62127d2b44e4
VPLZCNTD Y7, K3, Y12 // 62727d2b44e7
VPLZCNTD (BX), K3, Y12 // 62727d2b4423
VPLZCNTD -17(BP)(SI*1), K3, Y12 // 62727d2b44a435efffffff
VPLZCNTD Y5, K3, Y3 // 62f27d2b44dd
VPLZCNTD Y28, K3, Y3 // 62927d2b44dc
VPLZCNTD Y7, K3, Y3 // 62f27d2b44df
VPLZCNTD (BX), K3, Y3 // 62f27d2b441b
VPLZCNTD -17(BP)(SI*1), K3, Y3 // 62f27d2b449c35efffffff
VPLZCNTD Z21, K3, Z3 // 62b27d4b44dd
VPLZCNTD Z13, K3, Z3 // 62d27d4b44dd
VPLZCNTD 17(SP)(BP*8), K3, Z3 // 62f27d4b449cec11000000
VPLZCNTD 17(SP)(BP*4), K3, Z3 // 62f27d4b449cac11000000
VPLZCNTD Z21, K3, Z0 // 62b27d4b44c5
VPLZCNTD Z13, K3, Z0 // 62d27d4b44c5
VPLZCNTD 17(SP)(BP*8), K3, Z0 // 62f27d4b4484ec11000000
VPLZCNTD 17(SP)(BP*4), K3, Z0 // 62f27d4b4484ac11000000
VPLZCNTQ X9, K2, X13 // 6252fd0a44e9
VPLZCNTQ X15, K2, X13 // 6252fd0a44ef
VPLZCNTQ X26, K2, X13 // 6212fd0a44ea
VPLZCNTQ -17(BP), K2, X13 // 6272fd0a44adefffffff
VPLZCNTQ -15(R14)(R15*8), K2, X13 // 6212fd0a44acfef1ffffff
VPLZCNTQ X9, K2, X28 // 6242fd0a44e1
VPLZCNTQ X15, K2, X28 // 6242fd0a44e7
VPLZCNTQ X26, K2, X28 // 6202fd0a44e2
VPLZCNTQ -17(BP), K2, X28 // 6262fd0a44a5efffffff
VPLZCNTQ -15(R14)(R15*8), K2, X28 // 6202fd0a44a4fef1ffffff
VPLZCNTQ X9, K2, X24 // 6242fd0a44c1
VPLZCNTQ X15, K2, X24 // 6242fd0a44c7
VPLZCNTQ X26, K2, X24 // 6202fd0a44c2
VPLZCNTQ -17(BP), K2, X24 // 6262fd0a4485efffffff
VPLZCNTQ -15(R14)(R15*8), K2, X24 // 6202fd0a4484fef1ffffff
VPLZCNTQ Y12, K1, Y0 // 62d2fd2944c4
VPLZCNTQ Y1, K1, Y0 // 62f2fd2944c1
VPLZCNTQ Y14, K1, Y0 // 62d2fd2944c6
VPLZCNTQ 15(R8)(R14*4), K1, Y0 // 6292fd294484b00f000000
VPLZCNTQ -7(CX)(DX*4), K1, Y0 // 62f2fd29448491f9ffffff
VPLZCNTQ Y12, K1, Y22 // 62c2fd2944f4
VPLZCNTQ Y1, K1, Y22 // 62e2fd2944f1
VPLZCNTQ Y14, K1, Y22 // 62c2fd2944f6
VPLZCNTQ 15(R8)(R14*4), K1, Y22 // 6282fd2944b4b00f000000
VPLZCNTQ -7(CX)(DX*4), K1, Y22 // 62e2fd2944b491f9ffffff
VPLZCNTQ Y12, K1, Y13 // 6252fd2944ec
VPLZCNTQ Y1, K1, Y13 // 6272fd2944e9
VPLZCNTQ Y14, K1, Y13 // 6252fd2944ee
VPLZCNTQ 15(R8)(R14*4), K1, Y13 // 6212fd2944acb00f000000
VPLZCNTQ -7(CX)(DX*4), K1, Y13 // 6272fd2944ac91f9ffffff
VPLZCNTQ Z3, K2, Z11 // 6272fd4a44db
VPLZCNTQ Z12, K2, Z11 // 6252fd4a44dc
VPLZCNTQ 7(SI)(DI*4), K2, Z11 // 6272fd4a449cbe07000000
VPLZCNTQ -7(DI)(R8*2), K2, Z11 // 6232fd4a449c47f9ffffff
VPLZCNTQ Z3, K2, Z25 // 6262fd4a44cb
VPLZCNTQ Z12, K2, Z25 // 6242fd4a44cc
VPLZCNTQ 7(SI)(DI*4), K2, Z25 // 6262fd4a448cbe07000000
VPLZCNTQ -7(DI)(R8*2), K2, Z25 // 6222fd4a448c47f9ffffff
RET
| GAS | 1 | Havoc-OS/androidprebuilts_go_linux-x86 | src/cmd/asm/internal/asm/testdata/avx512enc/avx512cd.s | [
"BSD-3-Clause"
] |
---
layout: post
title: LiquidHaskell is a GHC Plugin
date: 2020-08-20
comments: true
author: Ranjit Jhala
published: true
tags: basic
demo: refinements101.hs
---
<div class="hidden">
\begin{code}
module Plugin where
incr :: Int -> Int
incr x = x + 1
\end{code}
</div>
I enjoy working with LH. However, I'd be the very first to confess
that it has been incredibly tedious to get to work on *existing* code
bases, for various reasons.
1. LH ran *one file at a time*; it was a hassle to **systematically analyze**
all the modules in a single package.
2. LH had *no notion of packages*; it was impossible to **import specifications**
across packages.
3. LH had *no integration* with the standard compilation cycle; it was difficult
to get robust, **development-time feedback** using `ghci` based tools.
I'm delighted to announce the release of [LH version 0.8.10.2](http://ucsd-progsys.github.io/liquidhaskell/).
Thanks to the ingenuity and tireless efforts of our friends [Alfredo Di Napoli](http://www.alfredodinapoli.com/)
and [Andres Loh](https://www.andres-loeh.de/) at [Well-Typed](http://www.well-typed.com/) this new version
solves all three of the above problems in a single stroke, making it vastly simpler
(dare I say, quite straightforward!) to run LH on your Haskell code.
<!-- more -->
Alfredo and Andres' key insight was that all the above problems could be solved if
LH could be re-engineered as a [GHC Compiler Plugin](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/extending_ghc.html#compiler-plugins)
using hooks that GHC exposes to integrate external checkers during compilation.
I strongly encourage you to check out Alfredo's talk at the [Haskell Implementor's Workshop](https://icfp20.sigplan.org/details/hiw-2020-papers/1/Liquid-Haskell-as-a-GHC-Plugin)
if you want to learn more about the rather non-trivial mechanics of how this plugin was engineered.
However, in this post, lets look at *how* and *why* to use the plugin,
in particular, how the plugin lets us
1. Use GHC's dependency resolution to analyze entire packages with minimal recompilation;
2. Ship refined type specifications for old or new packages, and have them be verified at client code;
3. Use tools like `ghci` based IDE tooling (e.g. `ghcid` or `ghcide` to get interactive feedback),
all of which ultimately, I hope, make Liquid Haskell easier to use.
1. Analyzing Packages
---------------------
First, lets see a small "demo" of how to *use* the plugin to compile
a small [`lh-plugin-demo`](https://github.com/ucsd-progsys/lh-plugin-demo)
package with two modules
```haskell
module Demo.Lib where
{-@ type Pos = {v:Int | 0 < v} @-}
{-@ incr :: Pos -> Pos @-}
incr :: Int -> Int
incr x = x - 1
```
which defines a function `incr` that consumes and returns positive integers, and
```haskell
module Demo.Client where
import Demo.Lib
bump :: Int -> Int
bump n = incr n
```
which imports `Demo.Lib` and uses `incr`.
### Updating `.cabal` to compile with the LH plugin
To "check" this code with LH we need only tell GHC to use it as a plugin, in two steps.
1. First, adding a dependency to LH in the `.cabal` file (or `package.yaml`)
```
build-depends:
liquid-base,
liquidhaskell >= 0.8.10
```
2. Second, tell GHC to use the plugin
```
ghc-options: -fplugin=LiquidHaskell
```
That's it. Now, everytime you (re-)build the code, GHC will _automatically_
run LH on the changed modules! If you use `stack` you may have to specify
a few more dependencies, as shown in the `stack.yaml`; there are none needed
if you use `cabal-v2`. If you clone the repo and run, e.g. `cabal v2-build`
or `stack build` you'll get the following result, after the relevant dependencies
are downloaded and built of course...
```
rjhala@khao-soi ~/r/lh-demo (main)> stack build
lh-plugin-demo> configure (lib)
Configuring lh-plugin-demo-0.1.0.0...
lh-plugin-demo> build (lib)
Preprocessing library for lh-plugin-demo-0.1.0.0..
Building library for lh-plugin-demo-0.1.0.0..
[1 of 2] Compiling Demo.Lib
**** LIQUID: UNSAFE ************************************************************
/Users/rjhala/research/lh-demo/src/Demo/Lib.hs:7:1: error:
Liquid Type Mismatch
.
The inferred type
VV : {v : GHC.Types.Int | v == x - 1}
.
is not a subtype of the required type
VV : {VV : GHC.Types.Int | 0 < VV}
.
in the context
x : {v : GHC.Types.Int | 0 < v}
|
7 | incr x = x - 1
| ^^^^^^^^^^^^^^
```
oops, of course that `(-)` should be a `(+)` if we want the output to also be *positive* so
lets edit the code to
```haskell
incr x = x + 1
```
and now we get
```
rjhala@khao-soi ~/r/lh-plugin-demo (main)> stack build
lh-plugin-demo> configure (lib)
Configuring lh-plugin-demo-0.1.0.0...
lh-plugin-demo> build (lib)
Preprocessing library for lh-plugin-demo-0.1.0.0..
Building library for lh-plugin-demo-0.1.0.0..
[1 of 2] Compiling Demo.Lib
**** LIQUID: SAFE (2 constraints checked) *****************************
[2 of 2] Compiling Demo.Client
**** LIQUID: UNSAFE ***************************************************
/Users/rjhala/lh-plugin-demo/src/Demo/Client.hs:6:15: error:
Liquid Type Mismatch
.
The inferred type
VV : {v : GHC.Types.Int | v == n}
.
is not a subtype of the required type
VV : {VV : GHC.Types.Int | 0 < VV}
.
in the context
n : GHC.Types.Int
|
6 | bump n = incr n
| ^
```
That is, during the build, LH complains that `incr` is being called with a value `n`
that is not strictly positive as required by `incr`. To fix the code, we can edit it
in various ways, e.g. to only call `incr` if `n > 0`
```haskell
bump n
| n > 0 = incr n
| otherwise = 0
```
and now the code builds successfully
```
rjhala@khao-soi ~/r/lh-plugin-demo (main)> stack build
lh-plugin-demo> configure (lib)
Configuring lh-plugin-demo-0.1.0.0...
lh-plugin-demo> build (lib)
Preprocessing library for lh-plugin-demo-0.1.0.0..
Building library for lh-plugin-demo-0.1.0.0..
[2 of 2] Compiling Demo.Client
**** LIQUID: SAFE (2 constraints checked) ****************************
lh-plugin-demo> copy/register
Installing library in ...
Registering library for lh-plugin-demo-0.1.0.0..
```
### Benefits
There are a couple of benefits to note immediately
+ A plain `stack build` or `cabal v2-build` takes care of all the installing _and_ checking!
+ No need to separately _install_ LH; its part of the regular build.
+ GHC's recompilation machinery ensures that only the relevant
modules are checked, e.g. the second time round, LH did not need
to analyze `Lib.hs` only `Client.hs`
2. Shipping Specifications with Packages
----------------------------------------
While the above is nice, in principle it could have been done
with some clever `makefile` trickery (perhaps?). What I'm much
more excited about is that now, for the first time, you can
*ship refinement type specifications within plain Haskell packages*.
For example, consider a different [lh-plugin-demo-client](https://github.com/ucsd-progsys/lh-plugin-demo-client)
package that uses `incr` from `lh-plugin-demo`:
```haskell
bump :: Int -> Int
bump n
| n > 0 = incr n
| otherwise = incr (0 - n)
```
Again, the `lh-plugin-demo-client.cabal` file need only specify the various
dependencies:
```
build-depends:
liquid-base,
liquidhaskell,
lh-plugin-demo
````
and that GHC should use the plugin
```
ghc-options: -fplugin=LiquidHaskell
```
and lo! a plain `stack build` or `cabal v2-build` takes care of all the rest.
```
rjhala@khao-soi ~/r/lh-plugin-demo-client (main)> stack build
lh-plugin-demo-client> configure (lib)
Configuring lh-plugin-demo-client-0.1.0.0...
lh-plugin-demo-client> build (lib)
Preprocessing library for lh-plugin-demo-client-0.1.0.0..
Building library for lh-plugin-demo-client-0.1.0.0..
[1 of 1] Compiling Demo.ExternalClient
**** LIQUID: UNSAFE ****************************************************
/Users/rjhala/lh-plugin-demo-client/src/Demo/ExternalClient.hs:8:22: error:
Liquid Type Mismatch
.
The inferred type
VV : {v : GHC.Types.Int | v == 0 - n}
.
is not a subtype of the required type
VV : {VV : GHC.Types.Int | VV > 0}
.
in the context
n : GHC.Types.Int
|
8 | | otherwise = incr (0 - n)
| ^^^^^^^
```
(Whoops another off by one error, lets fix it!)
```haskell
bump :: Int -> Int
bump n
| n > 0 = incr n
| otherwise = incr (1 - n)
```
and now all is well
```
rjhala@khao-soi ~/r/lh-plugin-demo-client (main)> stack build --fast
lh-plugin-demo-client> configure (lib)
Configuring lh-plugin-demo-client-0.1.0.0...
lh-plugin-demo-client> build (lib)
Preprocessing library for lh-plugin-demo-client-0.1.0.0..
Building library for lh-plugin-demo-client-0.1.0.0..
[1 of 1] Compiling Demo.ExternalClient
**** LIQUID: SAFE (3 constraints checked) *****************************
lh-plugin-demo-client> copy/register
Installing library in ...
Registering library for lh-plugin-demo-client-0.1.0.0..
```
### Prelude Specifications
Did you notice the strange `liquid-base` dependency in the cabal files?
Previously, LH came installed with a "built-in" set of specifications for
various `prelude` modules. This was _hacked_ inside LH in a rather unfortunate
manner, which made these specifications very difficult to extend.
Moving forward, all the refinement specifications e.g. for `GHC.List` or `Data.Vector`
or `Data.Set` or `Data.Bytestring` simply live in packages that *mirror* the original
versions, e.g. `liquid-base`, `liquid-vector`, `liquid-containers`, `liquid-bytestring`.
Each `liquid-X` package directly _re-exports_ all the contents of the corresponding `X` package,
but with any additional refinement type specifications.
So if you want to verify that _your_ code has no `vector`-index overflow errors, you simply
build with `liquid-vector` instead of `vector`! Of course, in an ideal, and hopefully
not too distant future, we'd get the refinement types directly inside `vector`, `containers`
or `bytestring`.
### Benefits
So to recap, the plugin offers several nice benefits with respect to *shipping specifications*
* Refined signatures are bundled together with packages,
* Importing packages with refined signatures automatically ensures those signatures are
checked on client code,
* You can (optionally) use refined versions of `prelude` signatures, and hence, even
write refined versions of your favorite *custom preludes*.
3. Editor Tooling
-----------------
I saved _my_ favorite part for the end.
What I have enjoyed the most about the plugin is that now (almost) all the GHC-based
tools that I use in my regular Haskell development workflow, automatically incorporate
LH too! For example, reloading a module in `ghci` automatically re-runs LH on that file.
### `ghcid`
This means, that the mega robust, editor-independent `ghcid` now automatically
produces LH type errors when you save a file. Here's `ghcid` running in a terminal.

### `vscode`
Editor plugins now produce little red squiggles for LH errors too.
Here's `code` with the `Simple GHC (Haskell) Integration` plugin

### `emacs`
Here's `doom-emacs` with the `dante` plugin

### `vim`
And here is `neovim` with `ALE` and the `stack-build` linter

### Benefits
+ Some of this _was_ possible before: we had to write special LH modes for different
editors. However, now we can simply work with the increasingly more robust GHCi and
Language-Server based tools already available for major editors and IDEs.
4. Caveats
----------
Of course, all the above is quite new, and so there are a few things to watch out for.
* First, for certain kinds of code, LH can take much longer than GHC to check a file.
This means, it may actually be too slow to run on every save, and you may want to
tweak your `.cabal` file to *only* run the plugin during particular builds, not on
every file update.
* Second, the `liquid-X` machinery is designed to allow drop in replacements for various
base packages; it appears to work well in our testing, but if you try it, do let us know
if you hit some odd problems that we may not have anticipated.
Summary
-------
Hopefully the above provides an overview of the new plugin mode: how it can be used,
and what things it enables. In particular, by virtue of being a GHC plugin, LH can now
1. Run on entire Haskell packages;
2. Export and import specifications across packages;
3. Provide errors via existing GHC/i based editor tooling.
All of which, I hope, makes it a lot easier to run LH on your code.
Our most profound thanks to the [National Science Foundation](https://nsf.gov/):
this work was made possible by the support provided by grant 1917854:
"FMitF: Track II: Refinement Types in the Haskell Ecosystem".
| Literate Haskell | 4 | curiousleo/liquidhaskell | docs/blog/2020-08-20-lh-as-a-ghc-plugin.lhs | [
"MIT",
"BSD-3-Clause"
] |
digraph graphname {
graph [fontname = "helvetica", fontsize=11];
node [shape="box", fontname = "helvetica", fontsize=11];
subgraph cluster_ax_tree {
label = "Accessibility Tree";
a [label="Document"];
a -> b;
b [label="Heading"];
b -> c;
c [label="StaticText 'Sign In'"];
a -> d;
d [label="TextBox 'Username'"];
a -> e;
e [label="Button 'Submit'"];
}
subgraph cluster_ui_tree {
label = "DOM Tree";
A [label="<body>"];
A -> B;
B [label="<h1>"];
B -> C;
C [label="Sign In"];
A -> D;
D [label="<input type='text'\nplaceholder='Username'>"];
A -> E;
E [label="<input type='submit'>"];
}
}
| Graphviz (DOT) | 4 | zealoussnow/chromium | docs/accessibility/browser/figures/single_process.gv | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] |
ALTER TABLE hdb_catalog.hdb_version
ALTER COLUMN hasura_uuid
SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.event_log
ALTER COLUMN id
SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.event_invocation_logs
ALTER COLUMN id
SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_action_log
ALTER COLUMN id
SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_cron_events
ALTER COLUMN id
SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_cron_event_invocation_logs
ALTER COLUMN id
SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_scheduled_events
ALTER COLUMN id
SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_scheduled_event_invocation_logs
ALTER COLUMN id
SET DEFAULT gen_random_uuid();
DROP FUNCTION hdb_catalog.gen_hasura_uuid();
| SQL | 3 | gh-oss-contributor/graphql-engine-1 | server/src-rsr/migrations/42_to_41.sql | [
"Apache-2.0",
"MIT"
] |
import "./shared";
export default "a";
// content content content content content content content content
// content content content content content content content content
| JavaScript | 0 | 1shenxi/webpack | test/statsCases/named-chunk-groups/a.js | [
"MIT"
] |
CLASS zcl_abapgit_html_form_utils DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
METHODS constructor
IMPORTING
!io_form TYPE REF TO zcl_abapgit_html_form .
CLASS-METHODS create
IMPORTING
!io_form TYPE REF TO zcl_abapgit_html_form
RETURNING
VALUE(ro_form_util) TYPE REF TO zcl_abapgit_html_form_utils .
METHODS normalize
IMPORTING
!io_form_data TYPE REF TO zcl_abapgit_string_map
RETURNING
VALUE(ro_form_data) TYPE REF TO zcl_abapgit_string_map
RAISING
zcx_abapgit_exception .
METHODS validate
IMPORTING
!io_form_data TYPE REF TO zcl_abapgit_string_map
RETURNING
VALUE(ro_validation_log) TYPE REF TO zcl_abapgit_string_map
RAISING
zcx_abapgit_exception .
METHODS is_empty
IMPORTING
!io_form_data TYPE REF TO zcl_abapgit_string_map
RETURNING
VALUE(rv_empty) TYPE abap_bool
RAISING
zcx_abapgit_exception .
METHODS set_data
IMPORTING
!io_form_data TYPE REF TO zcl_abapgit_string_map .
METHODS exit
IMPORTING
!io_form_data TYPE REF TO zcl_abapgit_string_map
RETURNING
VALUE(rv_state) TYPE i
RAISING
zcx_abapgit_exception .
PROTECTED SECTION.
PRIVATE SECTION.
DATA mo_form TYPE REF TO zcl_abapgit_html_form .
DATA mo_form_data TYPE REF TO zcl_abapgit_string_map .
METHODS is_dirty
IMPORTING
!io_form_data TYPE REF TO zcl_abapgit_string_map
RETURNING
VALUE(rv_dirty) TYPE abap_bool .
ENDCLASS.
CLASS zcl_abapgit_html_form_utils IMPLEMENTATION.
METHOD constructor.
mo_form = io_form.
ENDMETHOD.
METHOD create.
CREATE OBJECT ro_form_util
EXPORTING
io_form = io_form.
ENDMETHOD.
METHOD exit.
DATA lv_answer TYPE c LENGTH 1.
IF is_dirty( io_form_data ) = abap_true.
lv_answer = zcl_abapgit_ui_factory=>get_popups( )->popup_to_confirm(
iv_titlebar = 'abapGit - Unsaved Changes'
iv_text_question = 'There are unsaved changes. Do you want to exit the form?'
iv_default_button = '2' ).
IF lv_answer = '1'.
rv_state = zcl_abapgit_gui=>c_event_state-go_back_to_bookmark.
ELSE.
rv_state = zcl_abapgit_gui=>c_event_state-no_more_act.
ENDIF.
ELSE.
rv_state = zcl_abapgit_gui=>c_event_state-go_back_to_bookmark.
ENDIF.
ENDMETHOD.
METHOD is_dirty.
rv_dirty = boolc( io_form_data->mt_entries <> mo_form_data->mt_entries ).
ENDMETHOD.
METHOD is_empty.
DATA:
lt_fields TYPE zif_abapgit_html_form=>ty_fields,
lv_value TYPE string,
lv_rows TYPE i,
lv_row TYPE i.
FIELD-SYMBOLS <ls_field> LIKE LINE OF lt_fields.
rv_empty = abap_true.
lt_fields = mo_form->get_fields( ).
LOOP AT lt_fields ASSIGNING <ls_field> WHERE type <> zif_abapgit_html_form=>c_field_type-field_group.
lv_value = condense(
val = io_form_data->get( <ls_field>-name )
del = ` ` ).
IF <ls_field>-type = zif_abapgit_html_form=>c_field_type-number.
rv_empty = boolc( lv_value IS INITIAL OR lv_value = '0' ).
ELSEIF <ls_field>-type = zif_abapgit_html_form=>c_field_type-table.
lv_rows = io_form_data->get( |{ <ls_field>-name }-{ zif_abapgit_html_form=>c_rows }| ).
DO lv_rows TIMES.
lv_row = sy-index.
DO lines( <ls_field>-subitems ) TIMES.
lv_value = io_form_data->get( |{ <ls_field>-name }-{ lv_row }-{ sy-index }| ).
rv_empty = boolc( lv_value IS INITIAL ).
IF rv_empty <> abap_true.
RETURN.
ENDIF.
ENDDO.
ENDDO.
ELSEIF <ls_field>-type = zif_abapgit_html_form=>c_field_type-textarea.
REPLACE ALL OCCURRENCES OF zif_abapgit_definitions=>c_crlf IN lv_value WITH ''.
REPLACE ALL OCCURRENCES OF zif_abapgit_definitions=>c_newline IN lv_value WITH ''.
rv_empty = boolc( lv_value IS INITIAL ).
ELSE.
rv_empty = boolc( lv_value IS INITIAL ).
ENDIF.
IF rv_empty <> abap_true.
RETURN.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD normalize.
DATA:
lt_fields TYPE zif_abapgit_html_form=>ty_fields,
lv_value TYPE string,
lv_rows TYPE i,
lv_row TYPE i,
lv_len TYPE i.
FIELD-SYMBOLS <ls_field> LIKE LINE OF lt_fields.
CREATE OBJECT ro_form_data.
IF io_form_data->is_empty( ) = abap_true.
RETURN.
ENDIF.
lt_fields = mo_form->get_fields( ).
LOOP AT lt_fields ASSIGNING <ls_field> WHERE type <> zif_abapgit_html_form=>c_field_type-field_group.
CLEAR lv_value.
lv_value = io_form_data->get( <ls_field>-name ).
IF <ls_field>-condense = abap_true.
lv_value = condense( val = lv_value
del = ` ` ).
ENDIF.
IF <ls_field>-type = zif_abapgit_html_form=>c_field_type-checkbox.
ro_form_data->set(
iv_key = <ls_field>-name
iv_val = boolc( lv_value = 'on' ) ) ##TYPE.
ELSEIF <ls_field>-type = zif_abapgit_html_form=>c_field_type-text AND <ls_field>-upper_case = abap_true.
ro_form_data->set(
iv_key = <ls_field>-name
iv_val = to_upper( lv_value ) ).
ELSEIF <ls_field>-type = zif_abapgit_html_form=>c_field_type-number.
" Numeric value is checked in validation
ro_form_data->set(
iv_key = <ls_field>-name
iv_val = condense( val = lv_value del = ` ` ) ).
ELSEIF <ls_field>-type = zif_abapgit_html_form=>c_field_type-table.
lv_rows = io_form_data->get( |{ <ls_field>-name }-{ zif_abapgit_html_form=>c_rows }| ).
DO lv_rows TIMES.
lv_row = sy-index.
DO lines( <ls_field>-subitems ) TIMES.
lv_value = io_form_data->get( |{ <ls_field>-name }-{ lv_row }-{ sy-index }| ).
ro_form_data->set(
iv_key = |{ <ls_field>-name }-{ lv_row }-{ sy-index }|
iv_val = lv_value ).
ENDDO.
ENDDO.
ro_form_data->set(
iv_key = |{ <ls_field>-name }-{ zif_abapgit_html_form=>c_rows }|
iv_val = |{ lv_rows }| ).
ELSEIF <ls_field>-type = zif_abapgit_html_form=>c_field_type-textarea.
REPLACE ALL OCCURRENCES OF zif_abapgit_definitions=>c_crlf IN lv_value
WITH zif_abapgit_definitions=>c_newline.
" Remove last line if empty (ie 2x newline)
lv_len = strlen( lv_value ) - 2.
IF lv_len >= 0 AND lv_value+lv_len(1) = zif_abapgit_definitions=>c_newline.
lv_len = lv_len + 1.
lv_value = lv_value(lv_len).
ENDIF.
ro_form_data->set(
iv_key = <ls_field>-name
iv_val = lv_value ).
ELSE.
ro_form_data->set(
iv_key = <ls_field>-name
iv_val = lv_value ).
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD set_data.
mo_form_data = io_form_data.
ENDMETHOD.
METHOD validate.
DATA:
lt_fields TYPE zif_abapgit_html_form=>ty_fields,
lv_value TYPE string,
lv_number TYPE i.
FIELD-SYMBOLS <ls_field> LIKE LINE OF lt_fields.
CREATE OBJECT ro_validation_log.
lt_fields = mo_form->get_fields( ).
LOOP AT lt_fields ASSIGNING <ls_field>.
lv_value = io_form_data->get( <ls_field>-name ).
IF <ls_field>-condense = abap_true.
lv_value = condense( val = lv_value
del = ` ` ).
ENDIF.
IF <ls_field>-required IS NOT INITIAL AND lv_value IS INITIAL.
ro_validation_log->set(
iv_key = <ls_field>-name
iv_val = |{ <ls_field>-label } cannot be empty| ).
ENDIF.
CASE <ls_field>-type.
WHEN zif_abapgit_html_form=>c_field_type-text.
IF <ls_field>-min <> cl_abap_math=>min_int4 AND strlen( lv_value ) < <ls_field>-min.
ro_validation_log->set(
iv_key = <ls_field>-name
iv_val = |{ <ls_field>-label } must not be shorter than { <ls_field>-min } characters| ).
ENDIF.
IF <ls_field>-max <> cl_abap_math=>max_int4 AND strlen( lv_value ) > <ls_field>-max.
ro_validation_log->set(
iv_key = <ls_field>-name
iv_val = |{ <ls_field>-label } must not be longer than { <ls_field>-max } characters| ).
ENDIF.
WHEN zif_abapgit_html_form=>c_field_type-number.
TRY.
lv_number = lv_value.
CATCH cx_root.
ro_validation_log->set(
iv_key = <ls_field>-name
iv_val = |{ <ls_field>-label } is not numeric| ).
CONTINUE.
ENDTRY.
IF <ls_field>-min <> cl_abap_math=>min_int4 AND lv_number < <ls_field>-min.
ro_validation_log->set(
iv_key = <ls_field>-name
iv_val = |{ <ls_field>-label } must not be lower than { <ls_field>-min }| ).
ENDIF.
IF <ls_field>-max <> cl_abap_math=>max_int4 AND lv_number > <ls_field>-max.
ro_validation_log->set(
iv_key = <ls_field>-name
iv_val = |{ <ls_field>-label } must not be higher than { <ls_field>-max }| ).
ENDIF.
ENDCASE.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
| ABAP | 5 | Manny27nyc/abapGit | src/ui/zcl_abapgit_html_form_utils.clas.abap | [
"MIT"
] |
*** Settings ***
Library Library.py
*** Test Cases ***
Normal and kwargs
[Documentation] FAIL Keyword 'Library.Normal And Kwargs' expected 1 non-named argument, got 0.
Normal and kwargs arg
Normal and kwargs arg a=1 b=2
Normal and kwargs a=1
Varargs and kwargs
Varargs and kwargs
Varargs and kwargs a
Varargs and kwargs a b c
Varargs and kwargs a=1
Varargs and kwargs a=1 b=2 c=3
Varargs and kwargs a b c=3 d=4
Kwargs
Kwargs
Kwargs a=1
Kwargs a=1 b=2 c=3
Kwargs @{EMPTY}
Invalid kwargs
[Documentation] FAIL Keyword 'Library.Varargs And Kwargs' got positional argument after named arguments.
Varargs and kwargs a=1 @{EMPTY} invalid
| RobotFramework | 3 | phil-davis/robotframework | atest/testdata/cli/dryrun/kwargs.robot | [
"ECL-2.0",
"Apache-2.0"
] |
<%--
Copyright 2012 Netflix, Inc.
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.
--%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main"/>
<title>Edit Load Balancer</title>
</head>
<body>
<div class="body">
<h1>Edit Load Balancer</h1>
<g:if test="${flash.message}">
<div class="message">${flash.message}</div>
</g:if>
<g:hasErrors bean="${loadBalancer}">
<div class="errors">
<g:renderErrors bean="${loadBalancer}" as="list"/>
</div>
</g:hasErrors>
<g:form method="post">
<input type="hidden" name="name" value="${loadBalancer.loadBalancerName}"/>
<div class="dialog">
<table>
<tbody>
<tr class="prop">
<td class="name">
<label>Name:</label>
</td>
<td>${loadBalancer.loadBalancerName}</td>
</tr>
<tr class="prop">
<td class="name">
<label for="selectedZones">Availablity Zones:</label>
</td>
<td>
<select multiple="true" size="5" id="selectedZones" name="selectedZones">
<g:each var="z" in="${zoneList}">
<g:if test="${loadBalancer.availabilityZones.contains(z.zoneName)}">
<option selected value="${z.zoneName}">${z.zoneName}</option>
</g:if>
<g:else>
<option value="${z.zoneName}">${z.zoneName}</option>
</g:else>
</g:each>
</select>
</td>
</tr>
<tr class="prop">
<td class="name">
<label>Health Check:</label>
</td>
<td class="numbers">
<label for="target">Target:</label><input class="string" type="text" id="target" name="target" value="${loadBalancer.healthCheck.target}">
<label for="interval">Interval:</label><input type="text" id="interval" name="interval" value="${loadBalancer.healthCheck.interval}">
<label for="timeout">Timeout:</label><input type="text" id="timeout" name="timeout" value="${loadBalancer.healthCheck.timeout}">
<label for="unhealthy">Unhealthy Threshold:</label><input type="text" id="unhealthy" name="unhealthy" value="${loadBalancer.healthCheck.unhealthyThreshold}">
<label for="healthy">Healthy Threshold:</label><input type="text" id="healthy" name="healthy" value="${loadBalancer.healthCheck.healthyThreshold}">
</td>
</tr>
</tbody>
</table>
</div>
<div class="buttons">
<g:buttonSubmit class="save" value="Update Load Balancer" action="update"/>
</div>
</g:form>
</div>
</body>
</html>
| Groovy Server Pages | 3 | michaelneale/asgard | grails-app/views/loadBalancer/edit.gsp | [
"Apache-2.0"
] |
// Licensed to the Apache Software Foundation(ASF) under one
// or more contributor license agreements.See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.The ASF licenses this file
// to you 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 org.apache.thrift;
class TConfiguration
{
public static inline var DEFAULT_MAX_MESSAGE_SIZE = 100 * 1024 * 1024;
public static inline var DEFAULT_MAX_FRAME_SIZE = 16384000; // this value is used consistently across all Thrift libraries
public static inline var DEFAULT_RECURSION_DEPTH = 64;
public var MaxMessageSize(default,null) : Int = DEFAULT_MAX_MESSAGE_SIZE;
public var MaxFrameSize(default,null) : Int = DEFAULT_MAX_FRAME_SIZE;
public var RecursionLimit(default,null) : Int = DEFAULT_RECURSION_DEPTH;
// TODO(JensG): add connection and i/o timeouts
public function new() {
// CTOR
}
}
| Haxe | 4 | Jimexist/thrift | lib/haxe/src/org/apache/thrift/TConfiguration.hx | [
"Apache-2.0"
] |
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Tree} from '@angular-devkit/schematics';
import {existsSync, readFileSync} from 'fs';
import {dirname, relative, resolve} from 'path';
import ts from 'typescript';
import {computeLineStartsMap, getLineAndCharacterFromPosition} from './line_mappings';
import {getAngularDecorators} from './ng_decorators';
import {unwrapExpression} from './typescript/functions';
import {getPropertyNameText} from './typescript/property_name';
export interface ResolvedTemplate {
/** Class declaration that contains this template. */
container: ts.ClassDeclaration;
/** File content of the given template. */
content: string;
/** Start offset of the template content (e.g. in the inline source file) */
start: number;
/** Whether the given template is inline or not. */
inline: boolean;
/** Path to the file that contains this template. */
filePath: string;
/**
* Gets the character and line of a given position index in the template.
* If the template is declared inline within a TypeScript source file, the line and
* character are based on the full source file content.
*/
getCharacterAndLineOfPosition: (pos: number) => {
character: number, line: number
};
}
/**
* Visitor that can be used to determine Angular templates referenced within given
* TypeScript source files (inline templates or external referenced templates)
*/
export class NgComponentTemplateVisitor {
resolvedTemplates: ResolvedTemplate[] = [];
constructor(public typeChecker: ts.TypeChecker, private _basePath: string, private _tree: Tree) {}
visitNode(node: ts.Node) {
if (node.kind === ts.SyntaxKind.ClassDeclaration) {
this.visitClassDeclaration(node as ts.ClassDeclaration);
}
ts.forEachChild(node, n => this.visitNode(n));
}
private visitClassDeclaration(node: ts.ClassDeclaration) {
if (!node.decorators || !node.decorators.length) {
return;
}
const ngDecorators = getAngularDecorators(this.typeChecker, node.decorators);
const componentDecorator = ngDecorators.find(dec => dec.name === 'Component');
// In case no "@Component" decorator could be found on the current class, skip.
if (!componentDecorator) {
return;
}
const decoratorCall = componentDecorator.node.expression;
// In case the component decorator call is not valid, skip this class declaration.
if (decoratorCall.arguments.length !== 1) {
return;
}
const componentMetadata = unwrapExpression(decoratorCall.arguments[0]);
// Ensure that the component metadata is an object literal expression.
if (!ts.isObjectLiteralExpression(componentMetadata)) {
return;
}
const sourceFile = node.getSourceFile();
const sourceFileName = sourceFile.fileName;
// Walk through all component metadata properties and determine the referenced
// HTML templates (either external or inline)
componentMetadata.properties.forEach(property => {
if (!ts.isPropertyAssignment(property)) {
return;
}
const propertyName = getPropertyNameText(property.name);
// In case there is an inline template specified, ensure that the value is statically
// analyzable by checking if the initializer is a string literal-like node.
if (propertyName === 'template' && ts.isStringLiteralLike(property.initializer)) {
// Need to add an offset of one to the start because the template quotes are
// not part of the template content.
// The `getText()` method gives us the original raw text.
// We could have used the `text` property, but if the template is defined as a backtick
// string then the `text` property contains a "cooked" version of the string. Such cooked
// strings will have converted CRLF characters to only LF. This messes up string
// replacements in template migrations.
// The raw text returned by `getText()` includes the enclosing quotes so we change the
// `content` and `start` values accordingly.
const content = property.initializer.getText().slice(1, -1);
const start = property.initializer.getStart() + 1;
this.resolvedTemplates.push({
filePath: sourceFileName,
container: node,
content,
inline: true,
start: start,
getCharacterAndLineOfPosition: pos =>
ts.getLineAndCharacterOfPosition(sourceFile, pos + start)
});
}
if (propertyName === 'templateUrl' && ts.isStringLiteralLike(property.initializer)) {
const templateDiskPath = resolve(dirname(sourceFileName), property.initializer.text);
// TODO(devversion): Remove this when the TypeScript compiler host is fully virtual
// relying on the devkit virtual tree and not dealing with disk paths. This is blocked on
// providing common utilities for schematics/migrations, given this is done in the
// Angular CDK already:
// https://github.com/angular/components/blob/3704400ee67e0190c9783e16367587489c803ebc/src/cdk/schematics/update-tool/utils/virtual-host.ts.
const templateDevkitPath = relative(this._basePath, templateDiskPath);
// In case the template does not exist in the file system, skip this
// external template.
if (!this._tree.exists(templateDevkitPath)) {
return;
}
const fileContent = this._tree.read(templateDevkitPath)!.toString();
const lineStartsMap = computeLineStartsMap(fileContent);
this.resolvedTemplates.push({
filePath: templateDiskPath,
container: node,
content: fileContent,
inline: false,
start: 0,
getCharacterAndLineOfPosition: pos => getLineAndCharacterFromPosition(lineStartsMap, pos),
});
}
});
}
}
| TypeScript | 5 | John-Cassidy/angular | packages/core/schematics/utils/ng_component_template.ts | [
"MIT"
] |
// run-rustfix
#![allow(unused, clippy::suspicious_map, clippy::iter_count)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList};
#[warn(clippy::needless_collect)]
#[allow(unused_variables, clippy::iter_cloned_collect, clippy::iter_next_slice)]
fn main() {
let sample = [1; 5];
let len = sample.iter().collect::<Vec<_>>().len();
if sample.iter().collect::<Vec<_>>().is_empty() {
// Empty
}
sample.iter().cloned().collect::<Vec<_>>().contains(&1);
// #7164 HashMap's and BTreeMap's `len` usage should not be linted
sample.iter().map(|x| (x, x)).collect::<HashMap<_, _>>().len();
sample.iter().map(|x| (x, x)).collect::<BTreeMap<_, _>>().len();
sample.iter().map(|x| (x, x)).collect::<HashMap<_, _>>().is_empty();
sample.iter().map(|x| (x, x)).collect::<BTreeMap<_, _>>().is_empty();
// Notice the `HashSet`--this should not be linted
sample.iter().collect::<HashSet<_>>().len();
// Neither should this
sample.iter().collect::<BTreeSet<_>>().len();
sample.iter().collect::<LinkedList<_>>().len();
sample.iter().collect::<LinkedList<_>>().is_empty();
sample.iter().cloned().collect::<LinkedList<_>>().contains(&1);
sample.iter().collect::<LinkedList<_>>().contains(&&1);
// `BinaryHeap` doesn't have `contains` method
sample.iter().collect::<BinaryHeap<_>>().len();
sample.iter().collect::<BinaryHeap<_>>().is_empty();
}
| Rust | 4 | narpfel/rust-clippy | tests/ui/needless_collect.rs | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
//This file is part of "GZE - GroundZero Engine"
//The permisive licence allow to use GZE for free or commercial project (Apache License, Version 2.0).
//For conditions of distribution and use, see copyright notice in Licence.txt, this license must be included with any distribution of the code.
package {
import GZ.Gfx.Attribute;
import GZ.Gfx.Object;
import GZ.Gfx.Root;
import GZ.Gfx.Clip;
import GZ.Base.Math.Math;
import GZ.File.RcImgSequence;
import GZ.Gfx.Clip.Img;
/**
* @author Maeiky
*/
public extension MovieClip extends Clip {
//public var aTimeline : Array;
public var oImg2 : Img;
public var aTest : Array<Img>;
public var nCurrInTimeline : Float = 0;
//public var aTimeline : Array< QArray<Root> >;
public var aTimeline : Array< Clip >;
public var nLimit : Float;
public var nAnimSpeed : Float = 0.05;
public var aOwnTest : Array<Root>;
//public var qaTest : QArray<Root>;
public function MovieClip( _oParent : Root, _nX: Float, _nY:Float):Void {
Clip(_oParent, _nX , _nY);
//aOwnTest = aChild;
}
public function fUpdateSequence():Void {
nCurrInTimeline += nAnimSpeed;
if(nCurrInTimeline < 0){
nCurrInTimeline += nLimit;
}
if(nCurrInTimeline > nLimit){
nCurrInTimeline -= nLimit;
}
var _nIntIndex : UInt = Math.fAbs(nCurrInTimeline);
if(aTimeline.nSize != 0){
var _oClip : Clip = aTimeline[_nIntIndex % aTimeline.nSize];
aChild.fClear();
aChild.fPush(_oClip);
}
}
override public function fUpdateParentToChild():Void {
fUpdateSequence();
}
public function fAddSequence( _oRc : RcImgSequence, _nX: Float = 0, _nY:Float = 0, _bCenter:Bool = true, _nCenterX:Int = 0, _nCenterY:Int = 0):Void {
for (var i : UInt = 0; i < _oRc.aImg.nSize; i++) {
var _oClip : Clip = new Clip(this, 0 , 0);
aTimeline[i] = _oClip;
aTest[i] = new Img(_oClip, _nX, _nY, _oRc.aImg[i], _bCenter, _nCenterX, _nCenterY);
}
nLimit = aTimeline.nSize;
}
}
} | Redcode | 3 | VLiance/GZE | src/Lib_GZ/Gfx/MovieClip.cw | [
"Apache-2.0"
] |
import io.vertx.ceylon.core {
Vertx
}
import io.vertx.ceylon.platform {
Container,
Verticle
}
import io.vertx.ceylon.core.http {
HttpServerRequest,
HttpClientResponse
}
import org.vertx.java.core.buffer {
Buffer
}
shared class ProxyServer() extends Verticle() {
shared actual void start(Vertx vertx, Container container) {
value client = vertx.createHttpClient {
host = "localhost";
port = 8282;
};
vertx.createHttpServer().requestHandler(void(HttpServerRequest req) {
print("Proxying request:``req.uri``");
value creq = client.request(req.method, req.uri);
creq.response.onComplete(void(HttpClientResponse cresp) {
print("Proxying response:``cresp.statusCode``");
req.response.status(cresp.statusCode);
req.response.headers(cresp.headers);
req.response.chunked = true;
cresp.stream.dataHandler(void(Buffer buffer) {
print("Proxying response body:``buffer``");
req.response.write(buffer);
});
cresp.stream.endHandler(void() { req.response.end(); });
});
creq.headers(req.headers);
creq.chunked = true;
req.stream.dataHandler(void(Buffer buffer) {
print("Proxying request body:``buffer``");
creq.write(buffer);
});
req.stream.endHandler(void() {
print("end of the request");
creq.end();
});
}).listen(8080);
}
}
| Ceylon | 4 | vietj/vertx-examples | src/raw/ceylon/proxyserver/ProxyServer.ceylon | [
"Apache-2.0"
] |
# typed: false
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
describe "brew log" do
it_behaves_like "parseable arguments"
it "shows the Git log for a given Formula", :integration_test do
setup_test_formula "testball"
core_tap = CoreTap.new
core_tap.path.cd do
system "git", "init"
system "git", "add", "--all"
system "git", "commit", "-m", "This is a test commit for Testball"
end
core_tap_url = "file://#{core_tap.path}"
shallow_tap = Tap.fetch("homebrew", "shallow")
system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path
expect { brew "log", "#{shallow_tap}/testball" }
.to output(/This is a test commit for Testball/).to_stdout
.and output(%r{Warning: homebrew/shallow is a shallow clone}).to_stderr
.and be_a_success
expect(shallow_tap.path/".git/shallow").to exist, "A shallow clone should have been created."
end
end
| Ruby | 4 | ylht/brew | Library/Homebrew/test/cmd/log_spec.rb | [
"BSD-2-Clause"
] |
.version 49 0
.source JsrWithoutRet.java
.class super public JsrWithoutRet
.super java/lang/Object
.method public <init> : ()V
.limit stack 1
.limit locals 1
aload_0
invokespecial java/lang/Object <init> ()V
return
.end method
.method static public main : ([Ljava/lang/String;)V
.limit stack 2
.limit locals 1
goto first
second:
pop
getstatic java/lang/System out Ljava/io/PrintStream;
ldc 'Hello world'
invokevirtual java/io/PrintStream println (Ljava/lang/String;)V
goto third
first:
jsr_w second
third:
return
.end method
| Jasmin | 3 | PranavPurwar/procyon | Procyon.CompilerTools/src/test/resources/JsrWithoutRet.j | [
"Apache-2.0"
] |
#ifdef ECERE_STATIC
public import static "ecere"
#else
public import "ecere"
#endif
default:
private:
public class LayoutPage : Stacker
{
direction = vertical;
gap = 4;
opacity = 0.0f;
//clickThrough = true;
tabCycle = true;
}
public class LayoutLine : Stacker
{
direction = horizontal;
gap = 8;
opacity = 0.0f;
tabCycle = true;
size = { h = 26 };
anchor = { left = 0, right = 0 };
}
public class LayoutSeperatorLine : Window
{
background = black;
size = { h = 1 };
anchor = { left = 8, right = 8 };
tabCycle = true;
}
| eC | 3 | N-eil/ecere-sdk | extras/gui/layout.ec | [
"BSD-3-Clause"
] |
; Copyright (C) 2007 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.
.class Blort
.super java/lang/Object
; Methods to "consume" an int.
.method public static consume1(I)V
.limit stack 0
.limit locals 1
nop
return
.end method
.method public static consume2(I)V
.limit stack 0
.limit locals 1
nop
return
.end method
.method public static consume3(I)V
.limit stack 0
.limit locals 1
nop
return
.end method
.method public static consume4(I)V
.limit stack 0
.limit locals 1
nop
return
.end method
.method public static consume5(I)V
.limit stack 0
.limit locals 1
nop
return
.end method
.method public static consume6(I)V
.limit stack 0
.limit locals 1
nop
return
.end method
; Methods to "consume" a long.
.method public static consume1(J)V
.limit stack 0
.limit locals 2
nop
return
.end method
.method public static consume2(J)V
.limit stack 0
.limit locals 2
nop
return
.end method
.method public static consume3(J)V
.limit stack 0
.limit locals 2
nop
return
.end method
.method public static consume4(J)V
.limit stack 0
.limit locals 2
nop
return
.end method
; Test of "pop" opcode. This should end up causing a call to consume1(0).
.method public static test_pop()V
.limit stack 2
.limit locals 0
iconst_0
iconst_1
pop ; A1 -> (empty)
invokestatic Blort/consume1(I)V
return
.end method
; Test of "pop2" opcode, form 1. This should end up causing a call
; to consume1(0).
.method public static test_pop2_form1()V
.limit stack 3
.limit locals 0
iconst_0
iconst_1
iconst_2
pop2 ; A1 B1 -> (empty)
invokestatic Blort/consume1(I)V
return
.end method
; Test of "pop2" opcode, form 2. This should end up causing a call
; to consume1(0).
.method public static test_pop2_form2()V
.limit stack 3
.limit locals 0
iconst_0
lconst_0
pop2 ; A2 -> (empty)
invokestatic Blort/consume1(I)V
return
.end method
; Test of "dup" opcode. This should end up causing these calls in order:
; consume1(0), consume2(0).
.method public static test_dup()V
.limit stack 2
.limit locals 0
iconst_0
dup ; A1 -> A1 A1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(I)V
return
.end method
; Test of "dup_x1" opcode. This should end up causing these calls in order:
; consume1(1), consume2(0), consume3(1).
.method public static test_dup_x1()V
.limit stack 3
.limit locals 0
iconst_0
iconst_1
dup_x1 ; A1 B1 -> B1 A1 B1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(I)V
invokestatic Blort/consume3(I)V
return
.end method
; Test of "dup_x2" opcode, form 1. This should end up causing these calls
; in order: consume1(2), consume2(1), consume3(0), consume4(2).
.method public static test_dup_x2_form1()V
.limit stack 4
.limit locals 0
iconst_0
iconst_1
iconst_2
dup_x2 ; A1 B1 C1 -> C1 A1 B1 C1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(I)V
invokestatic Blort/consume3(I)V
invokestatic Blort/consume4(I)V
return
.end method
; Test of "dup_x2" opcode, form 2. This should end up causing these calls
; in order: consume1(1), consume2(0L), consume3(1).
.method public static test_dup_x2_form2()V
.limit stack 4
.limit locals 0
lconst_0
iconst_1
dup_x2 ; A2 B1 -> B1 A2 B1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(J)V
invokestatic Blort/consume3(I)V
return
.end method
; Test of "dup2" opcode, form 1. This should end up causing these calls
; in order: consume1(1), consume2(0), consume3(1), consume4(0).
.method public static test_dup2_form1()V
.limit stack 4
.limit locals 0
iconst_0
iconst_1
dup2 ; A1 B1 -> A1 B1 A1 B1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(I)V
invokestatic Blort/consume3(I)V
invokestatic Blort/consume4(I)V
return
.end method
; Test of "dup2" opcode, form 2. This should end up causing these calls
; in order: consume1(0L), consume2(0L).
.method public static test_dup2_form2()V
.limit stack 4
.limit locals 0
lconst_0
dup2 ; A2 -> A2 A2
invokestatic Blort/consume1(J)V
invokestatic Blort/consume2(J)V
return
.end method
; Test of "dup2_x1" opcode, form 1. This should end up causing these calls
; in order: consume1(1), consume2(2), consume3(0), consume4(1), consume5(2).
.method public static test_dup2_x1_form1()V
.limit stack 5
.limit locals 0
iconst_0
iconst_1
iconst_2
dup2_x1 ; A1 B1 C1 -> B1 C1 A1 B1 C1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(I)V
invokestatic Blort/consume3(I)V
invokestatic Blort/consume4(I)V
invokestatic Blort/consume5(I)V
return
.end method
; Test of "dup2_x1" opcode, form 2. This should end up causing these calls
; in order: consume1(1L), consume2(2), consume3(1L).
.method public static test_dup2_x1_form2()V
.limit stack 5
.limit locals 0
iconst_0
lconst_1
dup2_x1 ; A1 B2 -> B2 A1 B2
invokestatic Blort/consume1(J)V
invokestatic Blort/consume2(I)V
invokestatic Blort/consume3(J)V
return
.end method
; Test of "dup2_x2" opcode, form 1. This should end up causing these calls
; in order: consume1(3), consume2(2), consume3(1), consume4(0), consume5(3),
; consume6(2).
.method public static test_dup2_x2_form1()V
.limit stack 6
.limit locals 0
iconst_0
iconst_1
iconst_2
iconst_3
dup2_x2 ; A1 B1 C1 D1 -> C1 D1 A1 B1 C1 D1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(I)V
invokestatic Blort/consume3(I)V
invokestatic Blort/consume4(I)V
invokestatic Blort/consume5(I)V
invokestatic Blort/consume6(I)V
return
.end method
; Test of "dup2_x2" opcode, form 2. This should end up causing these calls
; in order: consume1(2L), consume2(1), consume3(0), consume4(2L).
.method public static test_dup2_x2_form2()V
.limit stack 6
.limit locals 0
iconst_0
iconst_1
ldc2_w 2
dup2_x2 ; A1 B1 C2 -> C2 A1 B1 C2
invokestatic Blort/consume1(J)V
invokestatic Blort/consume2(I)V
invokestatic Blort/consume3(I)V
invokestatic Blort/consume4(J)V
return
.end method
; Test of "dup2_x2" opcode, form 3. This should end up causing these calls
; in order: consume1(2), consume2(1), consume3(0L), consume4(2), consume5(1).
.method public static test_dup2_x2_form3()V
.limit stack 6
.limit locals 0
lconst_0
iconst_1
iconst_2
dup2_x2 ; A2 B1 C1 -> B1 C1 A2 B1 C1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(I)V
invokestatic Blort/consume3(J)V
invokestatic Blort/consume4(I)V
invokestatic Blort/consume5(I)V
return
.end method
; Test of "dup2_x2" opcode, form 4. This should end up causing these calls
; in order: consume1(1L), consume2(0L), consume3(1L).
.method public static test_dup2_x2_form4()V
.limit stack 6
.limit locals 0
lconst_0
lconst_1
dup2_x2 ; A2 B2 -> B2 A2 B2
invokestatic Blort/consume1(J)V
invokestatic Blort/consume2(J)V
invokestatic Blort/consume3(J)V
return
.end method
; Test of "swap" opcode. This should end up causing these calls
; in order: consume1(0), consume2(1).
.method public static test_swap()V
.limit stack 2
.limit locals 0
iconst_0
iconst_1
swap ; A1 B1 -> B1 A1
invokestatic Blort/consume1(I)V
invokestatic Blort/consume2(I)V
return
.end method
| Jasmin | 4 | Unknoob/buck | third-party/java/dx/tests/071-dex-java-stack-ops/blort.j | [
"Apache-2.0"
] |
#ifndef CAFFE2_OPERATORS_UNSAFE_COALESCE_OP_H_
#define CAFFE2_OPERATORS_UNSAFE_COALESCE_OP_H_
#include "caffe2/core/context.h"
#include "caffe2/core/export_caffe2_op_to_c10.h"
#include "caffe2/core/operator.h"
namespace caffe2 {
template <class Context>
class UnsafeCoalesceOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
using Operator<Context>::Operator;
bool RunOnDevice() override {
size_t coalesced_size = 0;
for (int i = 0; i < InputSize(); ++i) {
// For now only float type is supported
CAFFE_ENFORCE(
Input(i).dtype().template Match<float>(),
"Must only coalesce float type, error at input: ",
i);
}
for (int i = 0; i < InputSize(); ++i) {
coalesced_size += Input(i).numel();
}
auto* coalesced = Output(OutputSize() - 1, coalesced_size, at::dtype<float>());
auto coalesced_data = coalesced->template mutable_data<float>();
size_t coalesced_offset = 0;
for (auto i = 0; i < InputSize(); ++i) {
const auto num_elems = Input(i).numel();
auto input_sizes = Input(i).sizes().vec();
// Don't do anything if both tensors are already pointing on the same data
auto input_data = Input(i).template data<float>();
if (input_data != coalesced_data + coalesced_offset) {
// Make sure that we don't run operation on the same tensor
CAFFE_ENFORCE_NE(
input_data - Input(i).unsafeGetTensorImpl()->storage_offset(),
coalesced_data -
Output(OutputSize() - 1)
->unsafeGetTensorImpl()
->storage_offset(),
"Tensors used in UnsafeCoalesce operator cannot share storage, unless it's inplace operation");
context_.CopyItemsSameDevice(
Input(i).dtype(),
num_elems,
input_data,
coalesced_data + coalesced_offset);
// Note: this could cause Input(i) to free it's data if
// Output(i) and Input(i) alias each other. This is safe on a
// GPU (as the copy will happen-before the free), but it's
// worth mentioning.
OperatorBase::SetOutputTensor(i, coalesced->Alias());
Output(i)->unsafeGetTensorImpl()->set_storage_offset(coalesced_offset);
Output(i)->Resize(input_sizes);
}
coalesced_offset += num_elems;
}
return true;
}
};
} // namespace caffe2
#endif /* CAFFE2_OPERATORS_UNSAFE_COALESCE_OP_H_ */
| C | 4 | Hacky-DH/pytorch | caffe2/operators/unsafe_coalesce.h | [
"Intel"
] |
Rebol [title: "Test script"]
print ["[bug-load-null.r3] dir:" what-dir]
data: transcode sys/read-decode %tmp.data none
either find data/2 #"^@" [
prin "NULL found! Test FAILED!"
][ prin "Test OK"]
| Rebol | 3 | 0branch/r3 | src/tests/units/files/bug-load-null.r3 | [
"Apache-2.0"
] |
constant A : Type
constant a : A
constant A_has_add : has_add A
#check a + a -- ERROR
attribute [instance] A_has_add
#check a + a
| Lean | 4 | JLimperg/lean | tests/lean/instance_cache_bug1.lean | [
"Apache-2.0"
] |
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
var _jsxRuntime = require("react/jsx-runtime");
var _default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
d: "M12 2 4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5l-8-3zm3.97 12.41c-1.84 2.17-5.21 2.1-6.96-.07-2.19-2.72-.65-6.72 2.69-7.33.34-.06.63.27.51.6-.46 1.23-.39 2.64.32 3.86.71 1.22 1.89 1.99 3.18 2.2.34.05.49.47.26.74z"
}), 'ShieldMoon');
exports.default = _default; | JavaScript | 3 | dany-freeman/material-ui | packages/mui-icons-material/lib/ShieldMoon.js | [
"MIT"
] |
<template name="messagePopupConfig">
<div class="message-popup-results">
{{> messagePopup popupUserConfig}}
{{> messagePopup popupChannelConfig}}
{{> messagePopup popupSlashCommandsConfig}}
{{> messagePopup popupEmojiConfig}}
{{> messagePopup popupReactionEmojiConfig}}
{{#each customMessagePopups}}
{{> messagePopup getCustomConfig}}
{{/each}}
</div>
</template>
| HTML | 4 | subramanir2143/Rocket.Chat | app/ui-message/client/popup/messagePopupConfig.html | [
"MIT"
] |
\sphinxAtStartPar
Equation without a label.
\begin{equation*}
\begin{split}E = mc^2\end{split}
\end{equation*}
\sphinxAtStartPar
Equation with label.
\begin{equation}\label{equation:equations:test}
\begin{split}E = hv\end{split}
\end{equation}
\sphinxAtStartPar
Second equation without label.
\begin{equation*}
\begin{split}c^2 = a^2 + b^2\end{split}
\end{equation*}
\sphinxAtStartPar
Equation with label \eqref{equation:equations:test} is important.
| TeX | 2 | samdoran/sphinx | tests/roots/test-latex-equations/expects/latex-equations.tex | [
"BSD-2-Clause"
] |
0.0 -1.0
8.0e-3 -1.0
1.6e-2 -1.0
2.4e-2 -1.0
3.2e-2 -1.0
4.0000003e-2 -1.0
4.8000004e-2 -1.0
5.6000005e-2 -1.0
6.4e-2 -1.0
7.2000004e-2 -1.0
8.0000006e-2 -1.0
8.800001e-2 -1.0
9.600001e-2 -1.0
0.10400001 -1.0
0.11200001 -1.0
0.12000001 -1.0
0.128 -1.0
0.136 -1.0
0.14400001 -1.0
0.15200001 -1.0
0.16000001 -1.0
0.16800001 -1.0
0.17600001 -1.0
0.18400002 -1.0
0.19200002 -1.0
0.20000002 -1.0
0.20800002 -1.0
0.21600002 -1.0
0.22400002 -1.0
0.23200002 -1.0
0.24000002 -1.0
0.24800003 -1.0
0.256 -1.0
0.264 -1.0
0.27199998 -1.0
0.27999997 -1.0
0.28799996 -1.0
0.29599994 -1.0
0.30399993 -1.0
0.31199992 -1.0
0.3199999 -1.0
0.3279999 -1.0
0.33599988 -1.0
0.34399986 -1.0
0.35199985 -1.0
0.35999984 -1.0
0.36799982 -1.0
0.3759998 -1.0
0.3839998 -1.0
0.39199978 -1.0
0.39999977 -1.0
0.40799975 -1.0
0.41599974 -1.0
0.42399973 -1.0
0.4319997 -1.0
0.4399997 -1.0
0.4479997 -1.0
0.45599967 -1.0
0.46399966 -1.0
0.47199965 -1.0
0.47999963 -1.0
0.48799962 -1.0
0.4959996 -1.0
0.5039996 -1.0
0.5119996 -1.0
0.5199996 -1.0
0.52799964 -1.0
0.53599966 -1.0
0.5439997 -1.0
0.5519997 -1.0
0.5599997 -1.0
0.5679997 -1.0
0.57599974 -1.0
0.58399975 -1.0
0.59199977 -1.0
0.5999998 -1.0
0.6079998 -1.0
0.6159998 -1.0
0.62399983 -1.0
0.63199985 -1.0
0.63999987 -1.0
0.6479999 -1.0
0.6559999 -1.0
0.6639999 -1.0
0.67199993 -1.0
0.67999995 -1.0
0.68799996 -1.0
0.696 -1.0
0.704 -1.0
0.712 -1.0
0.72 -1.0
0.72800004 -1.0
0.73600006 -1.0
0.7440001 -1.0
0.7520001 -1.0
0.7600001 -1.0
0.7680001 -1.0
0.77600014 -1.0
0.78400016 -1.0
0.7920002 -1.0
0.8000002 -1.0
0.8080002 -1.0
0.8160002 -1.0
0.82400024 -1.0
0.83200026 -1.0
0.8400003 -1.0
0.8480003 -1.0
0.8560003 -1.0
0.8640003 -1.0
0.87200034 -1.0
0.88000035 -1.0
0.88800037 -1.0
0.8960004 -1.0
0.9040004 -1.0
0.9120004 -1.0
0.92000043 -1.0
0.92800045 -1.0
0.93600047 -1.0
0.9440005 -1.0
0.9520005 -1.0
0.9600005 -1.0
0.96800053 -1.0
0.97600055 -1.0
0.98400056 -1.0
0.9920006 -1.0
1.0000006 -0.9999851
1.0080006 -0.7999847
1.0160006 -0.5999843
1.0240006 -0.39998388
1.0320007 -0.19998348
1.0400007 1.692772e-5
1.0480007 0.20001733
1.0560007 0.40001774
1.0640007 0.60001814
1.0720007 0.80001855
1.0800008 1.0000191
1.0880008 1.2000194
1.0960008 1.4000196
1.1040008 1.6000202
1.1120008 1.8000207
1.1200008 2.000021
1.1280009 2.2000213
1.1360009 2.4000218
1.1440009 2.6000223
1.1520009 2.8000226
1.1600009 3.000023
1.1680009 3.2000237
1.176001 3.400024
1.184001 3.6000242
1.192001 3.8000245
1.200001 4.0000024
1.208001 4.0199146
1.216001 4.0393105
1.224001 4.058002
1.2320011 4.075812
1.2400011 4.092575
1.2480011 4.1081386
1.2560011 4.122365
1.2640011 4.1351323
1.2720011 4.1463346
1.2800012 4.155884
1.2880012 4.16371
1.2960012 4.1697617
1.3040012 4.174006
1.3120012 4.1764283
1.3200012 4.177034
1.3280013 4.175845
1.3360013 4.1729026
1.3440013 4.168264
1.3520013 4.1620026
1.3600013 4.154207
1.3680013 4.144981
1.3760014 4.13444
1.3840014 4.1227107
1.3920014 4.1099305
1.4000014 4.0962453
1.4080014 4.0818067
1.4160014 4.066773
1.4240015 4.0513043
1.4320015 4.035564
1.4400015 4.0197153
1.4480015 4.003919
1.4560015 3.9883342
1.4640015 3.9731145
1.4720016 3.9584074
1.4800016 3.9443526
1.4880016 3.9310822
1.4960016 3.9187174
1.5040016 3.9073682
1.5120016 3.8971329
1.5200016 3.8880968
1.5280017 3.8803325
1.5360017 3.8738976
1.5440017 3.8688364
1.5520017 3.8651776
1.5600017 3.862936
1.5680017 3.8621116
1.5760018 3.8626904
1.5840018 3.8646445
1.5920018 3.8679318
1.6000018 3.8724985
1.6080018 3.8782783
1.6160018 3.8851929
1.6240019 3.8931556
1.6320019 3.9020686
1.6400019 3.9118276
1.6480019 3.9223208
1.6560019 3.9334302
1.664002 3.9450345
1.672002 3.9570084
1.680002 3.969226
1.688002 3.9815598
1.696002 3.9938836
1.704002 4.0060735
1.712002 4.0180087
1.720002 4.029573
1.7280021 4.0406556
1.7360021 4.0511527
1.7440021 4.060967
1.7520021 4.070011
1.7600021 4.078206
1.7680022 4.085482
1.7760022 4.091781
1.7840022 4.097055
1.7920022 4.101267
1.8000022 4.104391
1.8080022 4.106413
1.8160022 4.1073303
1.8240023 4.1071506
1.8320023 4.105894
1.8400023 4.1035895
1.8480023 4.100278
1.8560023 4.0960073
1.8640023 4.090837
1.8720024 4.0848327
1.8800024 4.0780687
1.8880024 4.0706253
1.8960024 4.0625877
1.9040024 4.054047
1.9120024 4.045097
1.9200025 4.0358343
1.9280025 4.026357
1.9360025 4.016765
1.9440025 4.0071564
1.9520025 3.9976277
1.9600025 3.988274
1.9680026 3.9791875
1.9760026 3.9704547
1.9840026 3.9621587
1.9920026 3.9543757
2.0000026 3.947176
2.0080025 3.9406233
2.0160024 3.934773
2.0240023 3.9296732
2.0320022 3.9253635
2.040002 3.9218745
2.048002 3.9192286
2.056002 3.9174385
2.0640018 3.9165092
2.0720017 3.9164367
2.0800016 3.9172072
2.0880015 3.9188004
2.0960014 3.921187
2.1040013 3.9243298
2.1120012 3.928186
2.120001 3.9327044
2.128001 3.93783
2.1360009 3.9435005
2.1440008 3.9496508
2.1520007 3.956211
2.1600006 3.9631085
2.1680005 3.9702682
2.1760004 3.9776144
2.1840003 3.9850693
2.1920002 3.9925566
2.2 4.0
2.208 4.007325
2.2159998 4.0144606
2.2239997 4.0213366
2.2319996 4.0278883
2.2399995 4.034055
2.2479994 4.0397806
2.2559993 4.0450144
2.2639992 4.049711
2.2719991 4.0538325
2.279999 4.0573454
2.287999 4.060225
2.2959988 4.0624514
2.3039987 4.0640125
2.3119986 4.064904
2.3199985 4.0651274
2.3279984 4.06469
2.3359983 4.0636077
2.3439982 4.0619016
2.351998 4.0595984
2.359998 4.0567307
2.367998 4.053337
2.3759978 4.0494595
2.3839977 4.045145
2.3919976 4.0404434
2.3999975 4.035409
2.4079974 4.030098
2.4159973 4.024567
2.4239972 4.018877
2.431997 4.0130863
2.439997 4.007256
2.4479969 4.0014453
2.4559968 3.9957118
2.4639966 3.9901128
2.4719965 3.984702
2.4799964 3.9795318
2.4879963 3.97465
2.4959962 3.9701009
2.5039961 3.9659252
2.511996 3.9621596
2.519996 3.9588351
2.5279958 3.9559789
2.5359957 3.953611
2.5439956 3.9517488
2.5519955 3.9504023
2.5599954 3.9495773
2.5679953 3.9492736
2.5759952 3.9494863
2.583995 3.9502048
2.591995 3.9514136
2.599995 3.953093
2.6079948 3.9552188
2.6159947 3.9577622
2.6239946 3.9606915
2.6319945 3.9639702
2.6399944 3.9675598
2.6479943 3.9714198
2.6559942 3.9755063
2.663994 3.979775
2.671994 3.98418
2.6799939 3.9886742
2.6879938 3.9932117
2.6959937 3.997745
2.7039936 4.0022297
2.7119935 4.0066204
2.7199934 4.0108747
2.7279932 4.014952
2.7359931 4.0188136
2.743993 4.0224247
2.751993 4.025752
2.7599928 4.028767
2.7679927 4.031444
2.7759926 4.033762
2.7839925 4.0357027
2.7919924 4.0372524
2.7999923 4.038402
2.8079922 4.0391464
2.815992 4.0394845
2.823992 4.0394187
2.831992 4.038957
2.8399918 4.03811
2.8479917 4.036892
2.8559916 4.035321
2.8639915 4.0334196
2.8719914 4.0312114
2.8799913 4.0287237
2.8879912 4.0259857
2.895991 4.0230293
2.903991 4.0198874
2.911991 4.016595
2.9199908 4.013188
2.9279907 4.0097017
2.9359906 4.0061727
2.9439905 4.002638
2.9519904 3.9991326
2.9599903 3.9956918
2.9679902 3.9923487
2.97599 3.9891357
2.98399 3.9860835
2.9919899 3.98322
2.9999897 3.9805713
3.0079896 3.9781604
3.0159895 3.9760075
3.0239894 3.974131
3.0319893 3.9725451
3.0399892 3.971261
3.0479891 3.9702873
3.055989 3.9696283
3.063989 3.969286
3.0719888 3.9692583
3.0799887 3.9695415
3.0879886 3.970127
3.0959885 3.9710045
3.1039884 3.9721603
3.1119883 3.9735785
3.1199882 3.9752407
3.127988 3.9771256
3.135988 3.9792113
3.143988 3.981474
3.1519878 3.9838867
3.1599877 3.9864244
3.1679876 3.989058
3.1759875 3.9917603
3.1839874 3.994503
3.1919873 3.9972572
3.1999872 3.9999957
3.207987 4.002691
3.215987 4.005316
3.2239869 4.0078454
3.2319868 4.010256
3.2399867 4.0125246
3.2479866 4.0146313
3.2559865 4.016557
3.2639863 4.0182853
3.2719862 4.0198016
3.2799861 4.0210943
3.287986 4.022154
3.295986 4.0229735
3.3039858 4.023548
3.3119857 4.0238767
3.3199856 4.023959
3.3279855 4.0237985
3.3359854 4.023401
3.3439853 4.0227737
3.3519852 4.0219264
3.359985 4.020872
3.367985 4.0196238
3.375985 4.0181975
3.3839848 4.0166106
3.3919847 4.014881
3.3999846 4.0130296
3.4079845 4.0110755
3.4159844 4.0090413
3.4239843 4.006948
3.4319842 4.0048175
3.439984 4.0026727
3.447984 4.000535
3.4559839 3.998426
3.4639838 3.996366
3.4719837 3.9943752
3.4799836 3.9924731
3.4879835 3.9906769
3.4959834 3.9890032
3.5039833 3.9874668
3.5119832 3.9860816
3.519983 3.984858
3.527983 3.983807
3.5359828 3.982936
3.5439827 3.9822502
3.5519826 3.9817548
3.5599825 3.981451
3.5679824 3.981339
3.5759823 3.9814167
3.5839822 3.9816809
3.5919821 3.9821253
3.599982 3.9827428
3.607982 3.9835248
3.6159818 3.9844599
3.6239817 3.9855375
3.6319816 3.9867435
3.6399815 3.9880638
3.6479814 3.9894834
3.6559813 3.9909868
3.6639812 3.992557
3.671981 3.9941773
3.679981 3.995831
3.687981 3.9975
3.6959808 3.999168
3.7039807 4.000818
3.7119806 4.002433
3.7199805 4.0039983
3.7279804 4.0054984
3.7359803 4.006919
3.7439802 4.0082474
3.75198 4.009472
3.75998 4.010581
3.7679799 4.011566
3.7759798 4.012419
3.7839797 4.013133
3.7919796 4.013704
3.7999794 4.014127
3.8079793 4.014401
3.8159792 4.0145254
3.8239791 4.0145016
3.831979 4.014332
3.839979 4.0140204
3.8479788 4.0135727
3.8559787 4.0129952
3.8639786 4.0122957
3.8719785 4.0114837
3.8799784 4.010568
3.8879783 4.009561
3.8959782 4.008474
3.903978 4.007318
3.911978 4.006107
3.919978 4.0048537
3.9279778 4.003571
3.9359777 4.002273
3.9439776 4.0009727
3.9519775 3.999683
3.9599774 3.998417
3.9679773 3.9971871
3.9759772 3.996005
3.983977 3.994882
3.991977 3.9938288
3.9999769 3.992854
4.007977 3.9919667
4.015977 3.9911747
4.023977 3.9904842
4.0319767 3.9899006
4.0399766 3.989428
4.0479765 3.98907
4.0559764 3.9888272
4.0639763 3.9887009
4.071976 3.9886909
4.079976 3.9887948
4.087976 3.9890099
4.095976 3.9893327
4.103976 3.9897575
4.1119757 3.9902792
4.1199756 3.9908905
4.1279755 3.9915838
4.1359754 3.992351
4.1439753 3.9931831
4.151975 3.994071
4.159975 3.9950042
4.167975 3.995973
4.175975 3.9969673
4.1839747 3.9979763
4.1919746 3.9989896
4.1999745 3.9999967
4.2079744 3.8670897
4.2159743 3.733758
4.223974 3.6004262
4.231974 3.467095
4.239974 3.3337631
4.247974 3.2004313
4.255974 3.0671
4.2639737 2.9337683
4.2719736 2.8004367
4.2799735 2.6671052
4.2879734 2.5337734
4.2959733 2.400442
4.303973 2.2671103
4.311973 2.1337786
4.319973 2.000447
4.327973 1.8671155
4.335973 1.7337837
4.3439727 1.6004522
4.3519726 1.4671206
4.3599725 1.3337889
4.3679724 1.2004573
4.3759723 1.0671258
4.383972 0.933794
4.391972 0.8004625
4.399972 0.66713095
4.407972 0.5337994
4.4159718 0.40046763
4.4239717 0.2671361
4.4319715 0.13380456
4.4399714 4.7278404e-4
4.4479713 -0.13285875
4.4559712 -0.26619053
4.463971 -0.39952183
4.471971 -0.5328536
4.479971 -0.6661854
4.487971 -0.7995167
4.4959707 -0.93284845
4.5039706 -1.0130347
4.5119705 -1.0388085
4.5199704 -1.0637013
4.5279703 -1.0874522
4.53597 -1.1098169
4.54397 -1.1305714
4.55197 -1.1495129
4.55997 -1.1664628
4.56797 -1.1812674
4.5759697 -1.1937997
4.5839696 -1.2039601
4.5919695 -1.211677
4.5999694 -1.2169073
4.6079693 -1.2196363
4.615969 -1.2198772
4.623969 -1.217671
4.631969 -1.2130848
4.639969 -1.206211
4.647969 -1.1971657
4.6559687 -1.1860877
4.6639686 -1.1731353
4.6719685 -1.1584852
4.6799684 -1.1423297
4.6879683 -1.1248746
4.695968 -1.1063366
4.703968 -1.0869405
4.711968 -1.0669167
4.719968 -1.0464988
4.7279677 -1.0259204
4.7359676 -1.0054132
4.7439675 -0.9852034
4.7519674 -0.9655106
4.7599673 -0.94654465
4.767967 -0.92850345
4.775967 -0.91157144
4.783967 -0.89591736
4.791967 -0.88169277
4.799967 -0.86903095
4.8079667 -0.8580451
4.8159666 -0.84882826
4.8239665 -0.8414518
4.8319664 -0.83596575
4.8399663 -0.83239794
4.847966 -0.83075464
4.855966 -0.8310205
4.863966 -0.83315915
4.871966 -0.83711433
4.879966 -0.84281033
4.8879657 -0.85015345
4.8959656 -0.85903347
4.9039655 -0.8693248
4.9119654 -0.8808886
4.9199653 -0.893574
4.927965 -0.90722066
4.935965 -0.92166007
4.943965 -0.936718
4.951965 -0.95221645
4.9599648 -0.9679753
4.9679646 -0.98381513
4.9759645 -0.9995585
4.9839644 -1.015032
4.9919643 -1.0300686
4.999964 -1.0445088
5.007964 -1.0582025
5.015964 -1.0710107
5.023964 -1.0828063
5.031964 -1.0934762
5.0399637 -1.1029212
5.0479636 -1.111058
5.0559635 -1.1178188
5.0639634 -1.1231527
5.0719633 -1.1270251
5.079963 -1.1294185
5.087963 -1.1303322
5.095963 -1.129782
5.103963 -1.1277993
5.111963 -1.1244311
5.1199627 -1.1197392
5.1279626 -1.1137987
5.1359625 -1.1066976
5.1439624 -1.0985346
5.1519623 -1.0894194
5.159962 -1.0794696
5.167962 -1.0688103
5.175962 -1.0575726
5.183962 -1.0458912
5.191962 -1.0339036
5.1999617 -1.0217485
5.2079616 -1.0095638
5.2159615 -0.99748534
5.2239614 -0.98564565
5.2319613 -0.97417194
5.239961 -0.96318537
5.247961 -0.9527996
5.255961 -0.94311935
5.263961 -0.93424004
5.2719607 -0.92624635
5.2799606 -0.9192115
5.2879605 -0.91319704
5.2959604 -0.908252
5.3039603 -0.9044126
5.31196 -0.9017023
5.31996 -0.90013146
5.32796 -0.8996976
5.33596 -0.90038586
5.34396 -0.90216887
5.3519597 -0.9050078
5.3599596 -0.90885264
5.3679595 -0.9136431
5.3759594 -0.9193096
5.3839593 -0.9257737
5.391959 -0.93294984
5.399959 -0.9407457
5.407959 -0.94906396
5.415959 -0.9578031
5.423959 -0.9668585
5.4319587 -0.9761243
5.4399586 -0.98549366
5.4479585 -0.9948607
5.4559584 -1.0041215
5.4639583 -1.013175
5.471958 -1.021924
5.479958 -1.0302769
5.487958 -1.0381477
5.495958 -1.0454572
5.5039577 -1.0521342
5.5119576 -1.0581155
5.5199575 -1.0633465
5.5279574 -1.0677826
5.5359573 -1.0713881
5.543957 -1.0741376
5.551957 -1.0760152
5.559957 -1.0770156
5.567957 -1.0771428
5.575957 -1.0764107
5.5839567 -1.0748423
5.5919566 -1.0724697
5.5999565 -1.0693333
5.6079564 -1.0654812
5.6159563 -1.0609688
5.623956 -1.0558577
5.631956 -1.0502151
5.639956 -1.0441129
5.647956 -1.0376272
5.655956 -1.0308366
5.6639557 -1.0238217
5.6719556 -1.0166645
5.6799555 -1.0094471
5.6879554 -1.0022506
5.6959553 -0.9951546
5.703955 -0.98823625
5.711955 -0.98156935
5.719955 -0.97522354
5.727955 -0.9692637
5.7359548 -0.9637493
5.7439547 -0.9587339
5.7519546 -0.9542646
5.7599545 -0.9503814
5.7679543 -0.9471172
5.7759542 -0.9444976
5.783954 -0.9425403
5.791954 -0.9412556
5.799954 -0.9406461
5.807954 -0.9407067
5.8159537 -0.94142497
5.8239536 -0.94278157
5.8319535 -0.9447503
5.8399534 -0.9472985
5.8479533 -0.95038784
5.855953 -0.9539745
5.863953 -0.95801
5.871953 -0.9624417
5.879953 -0.96721333
5.887953 -0.9722661
5.8959527 -0.97753865
5.9039526 -0.982969
5.9119525 -0.98849374
5.9199524 -0.99405
5.9279523 -0.99957544
5.935952 -1.005009
5.943952 -1.0102924
5.951952 -1.0153692
5.959952 -1.0201865
5.967952 -1.0246956
5.9759517 -1.0288517
5.9839516 -1.0326146
5.9919515 -1.0359496
5.9999514 -1.0388268
6.0079513 -1.0412226
6.015951 -1.0431185
6.023951 -1.0445021
6.031951 -1.0453672
6.039951 -1.0457132
6.0479507 -1.0455452
6.0559506 -1.0448741
6.0639505 -1.0437161
6.0719504 -1.0420926
6.0799503 -1.0400296
6.08795 -1.037558
6.09595 -1.0347121
6.10395 -1.0315301
6.11195 -1.0280534
6.11995 -1.0243256
6.1279497 -1.0203927
6.1359496 -1.0163016
6.1439495 -1.0121008
6.1519494 -1.007839
6.1599493 -1.0035642
6.167949 -0.9993246
6.175949 -0.9951664
6.183949 -0.9911344
6.191949 -0.9872713
6.199949 -0.98361695
6.2079487 -0.9802085
6.2159486 -0.97707933
6.2239485 -0.97425944
6.2319484 -0.97177476
6.2399483 -0.969647
6.247948 -0.96789366
6.255948 -0.96652764
6.263948 -0.96555734
6.271948 -0.9649867
6.2799478 -0.96481496
6.2879477 -0.9650372
6.2959476 -0.96564406
6.3039474 -0.96662205
6.3119473 -0.9679538
6.3199472 -0.96961844
6.327947 -0.9715916
6.335947 -0.97384596
6.343947 -0.97635156
6.351947 -0.97907627
6.3599467 -0.98198587
6.3679466 -0.98504496
6.3759465 -0.98821676
6.3839464 -0.9914642
6.3919463 -0.9947497
6.399946 -0.9980363
6.407946 -1.0012875
6.415946 -1.0044675
6.423946 -1.0075425
6.431946 -1.01048
6.4399457 -1.0132498
6.4479456 -1.0158241
6.4559455 -1.0181776
6.4639454 -1.0202881
6.4719453 -1.0221364
6.479945 -1.0237064
6.487945 -1.0249858
6.495945 -1.0259651
6.503945 -1.0266389
6.511945 -1.0270048
6.5199447 -1.0270644
6.5279446 -1.0268223
6.5359445 -1.0262864
6.5439444 -1.0254676
6.5519443 -1.0243802
6.559944 -1.023041
6.567944 -1.021469
6.575944 -1.019686
6.583944 -1.0177153
6.5919437 -1.0155822
6.5999436 -1.0133132
6.6079435 -1.0109358
6.6159434 -1.0084784
6.6239433 -1.0059696
6.631943 -1.0034382
6.639943 -1.0009129
6.647943 -0.9984215
6.655943 -0.99599105
6.663943 -0.9936476
6.6719427 -0.99141556
6.6799426 -0.98931783
6.6879425 -0.98737544
6.6959424 -0.98560715
6.7039423 -0.98402965
6.711942 -0.98265713
6.719942 -0.9815013
6.727942 -0.9805711
6.735942 -0.979873
6.743942 -0.97941077
6.7519417 -0.9791853
6.7599416 -0.97919506
6.7679415 -0.97943586
6.7759414 -0.9799009
6.7839413 -0.98058116
6.791941 -0.98146534
6.799941 -0.98253995
6.807941 -0.98378986
6.815941 -0.98519814
6.8239408 -0.98674625
6.8319407 -0.9884146
6.8399405 -0.99018264
6.8479404 -0.99202883
6.8559403 -0.9939314
6.8639402 -0.9958682
6.87194 -0.99781716
6.87994 -0.9997564
6.88794 -1.0016644
6.89594 -1.0035207
6.9039397 -1.0053055
6.9119396 -1.0070002
6.9199395 -1.0085876
6.9279394 -1.0100518
6.9359393 -1.0113788
6.943939 -1.0125563
6.951939 -1.0135736
6.959939 -1.0144224
6.967939 -1.0150962
6.975939 -1.0155905
6.9839387 -1.0159029
6.9919386 -1.0160332
6.9999385 -1.015983
7.0079384 -1.0157561
7.0159383 -1.0153582
7.023938 -1.0147965
7.031938 -1.0140803
7.039938 -1.0132201
7.047938 -1.0122279
7.055938 -1.0111173
7.0639377 -1.0099025
7.0719376 -1.0085988
7.0799375 -1.0072224
7.0879374 -1.0057898
7.0959373 -1.0043178
7.103937 -1.0028235
7.111937 -1.0013238
7.119937 -0.99983567
7.127937 -0.9983753
7.1359367 -0.99695843
7.1439366 -0.9956001
7.1519365 -0.9943144
7.1599364 -0.99311423
7.1679363 -0.99201155
7.175936 -0.99101686
7.183936 -0.99013937
7.191936 -0.9893867
7.199936 -0.9887651
7.207936 -0.98827916
7.2159357 -0.98793197
7.2239356 -0.98772484
7.2319355 -0.9876578
7.2399354 -0.987729
7.2479353 -0.98793536
7.255935 -0.98827213
7.263935 -0.98873335
7.271935 -0.9893117
7.279935 -0.9899987
7.287935 -0.9907849
7.2959347 -0.9916597
7.3039346 -0.99261194
7.3119345 -0.99362963
7.3199344 -0.99470043
7.3279343 -0.99581134
7.335934 -0.99694943
7.343934 -0.9981016
7.351934 -0.99925476
7.359934 -1.000396
7.3679338 -1.001513
7.3759336 -1.0025938
7.3839335 -1.0036267
7.3919334 -1.0046015
7.3999333 -1.005508
7.407933 -1.0063375
7.415933 -1.0070822
7.423933 -1.0077353
7.431933 -1.0082909
7.439933 -1.0087447
7.4479327 -1.0090934
7.4559326 -1.009335
7.4639325 -1.0094688
7.4719324 -1.0094949
7.4799323 -1.0094151
7.487932 -1.009232
7.495932 -1.0089496
7.503932 -1.0
7.511932 -1.0
7.519932 -1.0
7.5279317 -1.0
7.5359316 -1.0
7.5439315 -1.0
7.5519314 -1.0
7.5599313 -1.0
7.567931 -1.0
7.575931 -1.0
7.583931 -1.0
7.591931 -1.0
7.599931 -1.0
7.6079307 -1.0
7.6159306 -1.0
7.6239305 -1.0
7.6319304 -1.0
7.6399302 -1.0
7.64793 -1.0
7.65593 -1.0
7.66393 -1.0
7.67193 -1.0
7.6799297 -1.0
7.6879296 -1.0
7.6959295 -1.0
7.7039294 -1.0
7.7119293 -1.0
7.719929 -1.0
7.727929 -1.0
7.735929 -1.0
7.743929 -1.0
7.751929 -1.0
7.7599287 -1.0
7.7679286 -1.0
7.7759285 -1.0
7.7839284 -1.0
7.7919283 -1.0
7.799928 -1.0
7.807928 -1.0
7.815928 -1.0
7.823928 -1.0
7.831928 -1.0
7.8399277 -1.0
7.8479276 -1.0
7.8559275 -1.0
7.8639274 -1.0
7.8719273 -1.0
7.879927 -1.0
7.887927 -1.0
7.895927 -1.0
7.903927 -1.0
7.9119267 -1.0
7.9199266 -1.0
7.9279265 -1.0
7.9359264 -1.0
7.9439263 -1.0
7.951926 -1.0
7.959926 -1.0
7.967926 -1.0
7.975926 -1.0
7.983926 -1.0
7.9919257 -1.0
7.9999256 -1.0
8.007926 -1.0
8.015926 -1.0
8.023927 -1.0
8.031927 -1.0
8.0399275 -1.0
8.047928 -1.0
8.055928 -1.0
8.063929 -1.0
8.071929 -1.0
8.079929 -1.0
8.08793 -1.0
8.09593 -1.0
8.10393 -1.0
8.111931 -1.0
8.119931 -1.0
8.127932 -1.0
8.135932 -1.0
8.143932 -1.0
8.151933 -1.0
8.159933 -1.0
8.167933 -1.0
8.175934 -1.0
8.183934 -1.0
8.191935 -1.0
8.199935 -1.0
8.207935 -1.0
8.215936 -1.0
8.223936 -1.0
8.231936 -1.0
8.239937 -1.0
8.247937 -1.0
8.255938 -1.0
8.263938 -1.0
8.271938 -1.0
8.279939 -1.0
8.287939 -1.0
8.295939 -1.0
8.30394 -1.0
8.31194 -1.0
8.319941 -1.0
8.327941 -1.0
8.335941 -1.0
8.343942 -1.0
8.351942 -1.0
8.359942 -1.0
8.367943 -1.0
8.375943 -1.0
8.383944 -1.0
8.391944 -1.0
8.399944 -1.0
8.407945 -1.0
8.415945 -1.0
8.423945 -1.0
8.431946 -1.0
8.439946 -1.0
8.447947 -1.0
8.455947 -1.0
8.463947 -1.0
8.471948 -1.0
8.479948 -1.0
8.487948 -1.0
8.495949 -1.0
8.503949 -1.0
8.51195 -1.0
8.51995 -1.0
8.52795 -1.0
8.535951 -1.0
8.543951 -1.0
8.551951 -1.0
8.559952 -1.0
8.567952 -1.0
8.575953 -1.0
8.583953 -1.0
8.591953 -1.0
8.599954 -1.0
8.607954 -1.0
8.615954 -1.0
8.623955 -1.0
8.631955 -1.0
8.6399555 -1.0
8.647956 -1.0
8.655956 -1.0
8.663957 -1.0
8.671957 -1.0
8.679957 -1.0
8.687958 -1.0
8.695958 -1.0
8.7039585 -1.0
8.711959 -1.0
8.719959 -1.0
8.72796 -1.0
8.73596 -1.0
8.74396 -1.0
8.751961 -1.0
8.759961 -1.0
8.7679615 -1.0
8.775962 -1.0
8.783962 -1.0
8.791963 -1.0
8.799963 -1.0
8.807963 -1.0
8.815964 -1.0
8.823964 -1.0
8.8319645 -1.0
8.839965 -1.0
8.847965 -1.0
8.855966 -1.0
8.863966 -1.0
8.871966 -1.0
8.879967 -1.0
8.887967 -1.0
8.8959675 -1.0
8.903968 -1.0
8.911968 -1.0
8.919969 -1.0
8.927969 -1.0
8.935969 -1.0
8.94397 -1.0
8.95197 -1.0
8.95997 -1.0
8.967971 -1.0
8.975971 -1.0
8.983972 -1.0
8.991972 -1.0
8.999972 -1.0
9.007973 -1.0
9.015973 -1.0
9.023973 -1.0
9.031974 -1.0
9.039974 -1.0
9.047975 -1.0
9.055975 -1.0
9.063975 -1.0
9.071976 -1.0
9.079976 -1.0
9.087976 -1.0
9.095977 -1.0
9.103977 -1.0
9.111978 -1.0
9.119978 -1.0
9.127978 -1.0
9.135979 -1.0
9.143979 -1.0
9.151979 -1.0
9.15998 -1.0
9.16798 -1.0
9.175981 -1.0
9.183981 -1.0
9.191981 -1.0
9.199982 -1.0
9.207982 -1.0
9.215982 -1.0
9.223983 -1.0
9.231983 -1.0
9.239984 -1.0
9.247984 -1.0
9.255984 -1.0
9.263985 -1.0
9.271985 -1.0
9.279985 -1.0
9.287986 -1.0
9.295986 -1.0
9.303987 -1.0
9.311987 -1.0
9.319987 -1.0
9.327988 -1.0
9.335988 -1.0
9.343988 -1.0
9.351989 -1.0
9.359989 -1.0
9.36799 -1.0
9.37599 -1.0
9.38399 -1.0
9.391991 -1.0
9.399991 -1.0
9.407991 -1.0
9.415992 -1.0
9.423992 -1.0
9.431993 -1.0
9.439993 -1.0
9.447993 -1.0
9.455994 -1.0
9.463994 -1.0
9.471994 -1.0
9.479995 -1.0
9.487995 -1.0
9.4959955 -1.0
9.503996 -1.0
9.511996 -1.0
9.519997 -1.0
9.527997 -1.0
9.535997 -1.0
9.543998 -1.0
9.551998 -1.0
9.5599985 -1.0
9.567999 -1.0
9.575999 -1.0
9.584 -1.0
9.592 -1.0
9.6 -1.0
9.608001 -1.0
9.616001 -1.0
9.6240015 -1.0
9.632002 -1.0
9.640002 -1.0
9.648003 -1.0
9.656003 -1.0
9.664003 -1.0
9.672004 -1.0
9.680004 -1.0
9.6880045 -1.0
9.696005 -1.0
9.704005 -1.0
9.712006 -1.0
9.720006 -1.0
9.728006 -1.0
9.736007 -1.0
9.744007 -1.0
9.7520075 -1.0
9.760008 -1.0
9.768008 -1.0
9.776009 -1.0
9.784009 -1.0
9.792009 -1.0
9.80001 -1.0
9.80801 -1.0
9.81601 -1.0
9.824011 -1.0
9.832011 -1.0
9.840012 -1.0
9.848012 -1.0
9.856012 -1.0
9.864013 -1.0
9.872013 -1.0
9.880013 -1.0
9.888014 -1.0
9.896014 -1.0
9.904015 -1.0
9.912015 -1.0
9.920015 -1.0
9.928016 -1.0
9.936016 -1.0
9.944016 -1.0
9.952017 -1.0
9.960017 -1.0
9.968018 -1.0
9.976018 -1.0
9.984018 -1.0
9.992019 -1.0
10.000019 -1.0
10.008019 -1.0
10.01602 -1.0
10.02402 -1.0
10.032021 -1.0
10.040021 -1.0
10.048021 -1.0
10.056022 -1.0
10.064022 -1.0
10.072022 -1.0
10.080023 -1.0
10.088023 -1.0
10.096024 -1.0
10.104024 -1.0
10.112024 -1.0
10.120025 -1.0
10.128025 -1.0
10.136025 -1.0
10.144026 -1.0
10.152026 -1.0
10.160027 -1.0
10.168027 -1.0
10.176027 -1.0
10.184028 -1.0
10.192028 -1.0
10.200028 -1.0
10.208029 -1.0
10.216029 -1.0
10.22403 -1.0
10.23203 -1.0
10.24003 -1.0
10.248031 -1.0
10.256031 -1.0
10.264031 -1.0
10.272032 -1.0
10.280032 -1.0
10.288033 -1.0
10.296033 -1.0
10.304033 -1.0
10.312034 -1.0
10.320034 -1.0
10.328034 -1.0
10.336035 -1.0
10.344035 -1.0
10.3520355 -1.0
10.360036 -1.0
10.368036 -1.0
10.376037 -1.0
10.384037 -1.0
10.392037 -1.0
10.400038 -1.0
10.408038 -1.0
10.4160385 -1.0
10.424039 -1.0
10.432039 -1.0
10.44004 -1.0
10.44804 -1.0
10.45604 -1.0
10.464041 -1.0
10.472041 -1.0
10.4800415 -1.0
10.488042 -1.0
10.496042 -1.0
10.504043 -1.0
10.512043 -1.0
10.520043 -1.0
10.528044 -1.0
10.536044 -1.0
10.5440445 -1.0
10.552045 -1.0
10.560045 -1.0
10.568046 -1.0
10.576046 -1.0
10.584046 -1.0
10.592047 -1.0
10.600047 -1.0
10.6080475 -1.0
10.616048 -1.0
10.624048 -1.0
10.632049 -1.0
10.640049 -1.0
10.648049 -1.0
10.65605 -1.0
10.66405 -1.0
10.67205 -1.0
10.680051 -1.0
10.688051 -1.0
10.696052 -1.0
10.704052 -1.0
10.712052 -1.0
10.720053 -1.0
10.728053 -1.0
10.736053 -1.0
10.744054 -1.0
10.752054 -1.0
10.760055 -1.0
10.768055 -1.0
10.776055 -1.0
10.784056 -1.0
10.792056 -1.0
10.800056 -1.0
10.808057 -1.0
10.816057 -1.0
10.824058 -1.0
10.832058 -1.0
10.840058 -1.0
10.848059 -1.0
10.856059 -1.0
10.864059 -1.0
10.87206 -1.0
10.88006 -1.0
10.888061 -1.0
10.896061 -1.0
10.904061 -1.0
10.912062 -1.0
10.920062 -1.0
10.928062 -1.0
10.936063 -1.0
10.944063 -1.0
10.952064 -1.0
10.960064 -1.0
10.968064 -1.0
10.976065 -1.0
10.984065 -1.0
10.992065 -1.0
11.000066 -0.9983549
11.008066 -0.79834557
11.016067 -0.5983362
11.024067 -0.39832687
11.032067 -0.19831753
11.040068 1.6918182e-3
11.048068 0.20170116
11.056068 0.4017105
11.064069 0.60171986
11.072069 0.8017292
11.08007 1.0017385
11.08807 1.2017479
11.09607 1.4017572
11.104071 1.6017666
11.112071 1.8017759
11.120071 2.0017853
11.128072 2.2017946
11.136072 2.401804
11.144073 2.6018133
11.152073 2.8018227
11.160073 3.001832
11.168074 3.2018414
11.176074 3.4018507
11.184074 3.60186
11.192075 3.8018694
11.200075 4.000189
11.208076 4.020098
11.216076 4.039489
11.224076 4.0581737
11.232077 4.0759754
11.240077 4.0927286
11.248077 4.1082807
11.256078 4.1224947
11.264078 4.1352477
11.2720785 4.146435
11.280079 4.155968
11.288079 4.163778
11.29608 4.169812
11.30408 4.1740384
11.31208 4.176443
11.320081 4.177031
11.328081 4.1758246
11.3360815 4.1728644
11.344082 4.1682086
11.352082 4.161931
11.360083 4.1541204
11.368083 4.14488
11.376083 4.1343255
11.384084 4.1225843
11.392084 4.1097937
11.4000845 4.096099
11.408085 4.0816526
11.416085 4.0666127
11.424086 4.05114
11.432086 4.035397
11.440086 4.019547
11.448087 4.0037518
11.456087 3.9881692
11.4640875 3.9729538
11.472088 3.958252
11.480088 3.9442048
11.488089 3.930943
11.496089 3.9185877
11.504089 3.9072495
11.51209 3.8970265
11.52009 3.8880038
11.5280905 3.8802538
11.536091 3.8738337
11.544091 3.8687878
11.552092 3.8651443
11.560092 3.8629189
11.568092 3.8621106
11.576093 3.8627052
11.584093 3.8646746
11.592093 3.8679771
11.600094 3.8725586
11.608094 3.8783517
11.616095 3.8852797
11.624095 3.8932538
11.632095 3.9021783
11.640096 3.9119468
11.648096 3.9224482
11.656096 3.9335647
11.664097 3.9451742
11.672097 3.9571528
11.680098 3.9693727
11.688098 3.981708
11.696098 3.9940314
11.704099 4.0062194
11.712099 4.0181518
11.720099 4.0297112
11.7281 4.0407877
11.7361 4.051277
11.744101 4.0610833
11.752101 4.070118
11.760101 4.078302
11.768102 4.085567
11.776102 4.0918536
11.784102 4.0971146
11.792103 4.101313
11.800103 4.1044235
11.808104 4.1064315
11.816104 4.1073346
11.824104 4.1071415
11.832105 4.105871
11.840105 4.1035533
11.848105 4.100229
11.856106 4.0959463
11.864106 4.090764
11.872107 4.0847497
11.880107 4.0779757
11.888107 4.0705237
11.896108 4.0624785
11.904108 4.053931
11.912108 4.044976
11.920109 4.0357094
11.928109 4.02623
11.93611 4.0166364
11.94411 4.0070276
11.95211 3.9975004
11.960111 3.9881496
11.968111 3.9790664
11.976111 3.9703388
11.984112 3.9620485
11.992112 3.9542727
12.000113 3.9470816
12.008113 3.9405375
12.016113 3.9346972
12.024114 3.9296079
12.032114 3.9253092
12.040114 3.9218316
12.048115 3.919197
12.056115 3.9174194
12.064116 3.9165025
12.072116 3.916442
12.080116 3.9172244
12.088117 3.9188294
12.096117 3.921227
12.104117 3.9243808
12.112118 3.928247
12.120118 3.932775
12.1281185 3.9379091
12.136119 3.9435878
12.144119 3.9497452
12.15212 3.9563112
12.16012 3.9632134
12.16812 3.9703774
12.176121 3.977726
12.184121 3.9851823
12.1921215 3.99267
12.200122 4.0001125
12.208122 4.007436
12.216123 4.0145683
12.224123 4.02144
12.232123 4.027987
12.240124 4.0341477
12.248124 4.0398664
12.2561245 4.045092
12.264125 4.049781
12.272125 4.0538926
12.280126 4.057396
12.288126 4.0602655
12.296126 4.0624814
12.304127 4.064032
12.312127 4.0649133
12.3201275 4.0651255
12.328128 4.0646777
12.336128 4.0635853
12.344129 4.0618687
12.352129 4.059556
12.360129 4.0566792
12.36813 4.053277
12.37613 4.0493917
12.3841305 4.0450697
12.392131 4.0403624
12.400131 4.0353227
12.408132 4.0300064
12.416132 4.0244727
12.424132 4.0187798
12.432133 4.0129876
12.440133 4.007157
12.448133 4.0013466
12.456134 3.9956145
12.464134 3.990018
12.472135 3.984611
12.480135 3.9794445
12.488135 3.974568
12.496136 3.9700246
12.504136 3.9658556
12.512136 3.9620976
12.520137 3.9587808
12.528137 3.9559326
12.536138 3.9535737
12.544138 3.9517202
12.552138 3.9503832
12.560139 3.9495673
12.568139 3.949273
12.576139 3.9494948
12.58414 3.9502225
12.59214 3.9514399
12.600141 3.9531279
12.608141 3.9552617
12.616141 3.9578128
12.624142 3.9607487
12.632142 3.9640336
12.640142 3.967629
12.648143 3.9714937
12.656143 3.975584
12.664144 3.979856
12.672144 3.9842634
12.680144 3.9887595
12.688145 3.993297
12.696145 3.9978309
12.704145 4.002314
12.712146 4.006703
12.720146 4.0109544
12.728147 4.015028
12.736147 4.0188856
12.744147 4.0224915
12.752148 4.0258136
12.760148 4.0288224
12.768148 4.0314927
12.776149 4.0338035
12.784149 4.0357366
12.79215 4.0372787
12.80015 4.0384207
12.80815 4.039157
12.816151 4.039487
12.824151 4.0394135
12.832151 4.038944
12.840152 4.0380893
12.848152 4.036864
12.856153 4.0352864
12.864153 4.033378
12.872153 4.0311637
12.880154 4.0286703
12.888154 4.0259275
12.896154 4.022967
12.904155 4.019821
12.912155 4.016526
12.920156 4.0131164
12.928156 4.009629
12.936156 4.0060997
12.944157 4.002565
12.952157 3.9990602
12.960157 3.9956207
12.968158 3.99228
12.976158 3.98907
12.9841585 3.986021
12.992159 3.983162
13.000159 3.9805174
13.00816 3.9781117
13.01616 3.9759645
13.02416 3.974094
13.032161 3.9725142
13.040161 3.9712367
13.0481615 3.9702697
13.056162 3.9696174
13.064162 3.9692817
13.072163 3.9692612
13.080163 3.969551
13.088163 3.9701433
13.096164 3.971027
13.104164 3.972189
13.1121645 3.9736128
13.120165 3.9752798
13.128165 3.97717
13.136166 3.97926
13.144166 3.981526
13.152166 3.9839425
13.160167 3.9864821
13.168167 3.989118
13.1761675 3.9918218
13.184168 3.994565
13.192168 3.9973197
13.200169 4.000057
13.208169 4.002751
13.216169 4.0053744
13.22417 4.0079017
13.23217 4.0103097
13.2401705 4.012575
13.248171 4.0146775
13.256171 4.016599
13.264172 4.018323
13.272172 4.019834
13.280172 4.0211215
13.288173 4.022176
13.296173 4.0229897
13.304173 4.0235586
13.312174 4.0238814
13.320174 4.023958
13.328175 4.023792
13.336175 4.023389
13.344175 4.022756
13.352176 4.021904
13.360176 4.0208445
13.368176 4.019592
13.376177 4.0181613
13.384177 4.0165706
13.392178 4.0148377
13.400178 4.0129833
13.408178 4.0110273
13.416179 4.008991
13.424179 4.0068965
13.432179 4.0047655
13.44018 4.00262
13.44818 4.000483
13.456181 3.9983745
13.464181 3.996316
13.472181 3.994327
13.480182 3.9924273
13.488182 3.990634
13.496182 3.9889631
13.504183 3.9874306
13.512183 3.9860487
13.520184 3.98483
13.528184 3.9837828
13.536184 3.9829164
13.544185 3.9822354
13.552185 3.9817448
13.560185 3.9814458
13.568186 3.9813385
13.576186 3.981421
13.584187 3.98169
13.592187 3.982139
13.600187 3.982761
13.608188 3.9835467
13.616188 3.984486
13.624188 3.985567
13.632189 3.9867759
13.640189 3.9880996
13.64819 3.9895215
13.65619 3.9910269
13.66419 3.992599
13.672191 3.9942203
13.680191 3.9958744
13.688191 3.9975438
13.696192 3.9992118
13.704192 4.0008607
13.712193 4.0024753
13.720193 4.004039
13.728193 4.005537
13.736194 4.0069556
13.744194 4.0082817
13.752194 4.009503
13.760195 4.010609
13.768195 4.011591
13.776196 4.01244
13.784196 4.0131507
13.792196 4.013717
13.800197 4.0141363
13.808197 4.014406
13.816197 4.014527
13.824198 4.0144987
13.832198 4.014325
13.8401985 4.01401
13.848199 4.0135584
13.856199 4.0129776
13.8642 4.0122747
13.8722 4.0114594
13.8802 4.0105414
13.888201 4.009532
13.896201 4.0084424
13.9042015 4.007285
13.912202 4.0060725
13.920202 4.004818
13.928203 4.003535
13.936203 4.0022364
13.944203 4.000936
13.952204 3.9996467
13.960204 3.9983816
13.9682045 3.9971528
13.976205 3.9959722
13.984205 3.994851
13.992206 3.9937997
14.000206 3.9928274
14.008206 3.991943
14.016207 3.9911537
14.024207 3.990466
14.0322075 3.9898853
14.040208 3.9894161
14.048208 3.9890609
14.056209 3.988822
14.064209 3.988699
14.072209 3.9886923
14.08021 3.9887996
14.08821 3.989018
14.0962105 3.9893436
14.104211 3.9897718
14.112211 3.990296
14.120212 3.9909096
14.128212 3.9916053
14.136212 3.992375
14.144213 3.993209
14.152213 3.9940982
14.160213 3.9950328
14.168214 3.9960027
14.176214 3.9969974
14.184215 3.9980063
14.192215 3.9990196
14.200215 3.996408
14.208216 3.863068
14.216216 3.7297287
14.224216 3.5963893
14.232217 3.4630494
14.240217 3.32971
14.248218 3.1963706
14.256218 3.0630307
14.264218 2.9296913
14.272219 2.796352
14.280219 2.6630123
14.288219 2.5296726
14.29622 2.3963332
14.30422 2.2629936
14.312221 2.129654
14.320221 1.9963145
14.328221 1.8629749
14.336222 1.7296352
14.344222 1.5962958
14.352222 1.4629562
14.360223 1.3296165
14.368223 1.1962771
14.376224 1.0629375
14.384224 0.92959785
14.392224 0.79625845
14.400225 0.6629188
14.408225 0.5295794
14.416225 0.39623976
14.424226 0.2629001
14.432226 0.12956071
14.440227 -3.7789345e-3
14.448227 -0.13711834
14.456227 -0.27045822
14.464228 -0.40379763
14.472228 -0.53713703
14.480228 -0.6704769
14.488229 -0.8038163
14.496229 -0.9371557
14.50423 -1.0138799
14.51223 -1.0396309
14.52023 -1.0644922
14.528231 -1.0882031
14.536231 -1.1105201
14.544231 -1.1312197
14.552232 -1.1501
14.560232 -1.1669829
14.568233 -1.1817157
14.576233 -1.1941723
14.584233 -1.2042537
14.592234 -1.2118895
14.600234 -1.2170376
14.608234 -1.219684
14.616235 -1.219843
14.624235 -1.2175564
14.632236 -1.212892
14.640236 -1.2059433
14.648236 -1.1968274
14.656237 -1.1856833
14.664237 -1.1726702
14.672237 -1.1579654
14.680238 -1.1417618
14.688238 -1.1242657
14.6962385 -1.1056938
14.704239 -1.0862715
14.712239 -1.0662293
14.72024 -1.045801
14.72824 -1.02522
14.73624 -1.004718
14.744241 -0.98452103
14.752241 -0.9648486
14.7602415 -0.9459099
14.768242 -0.92790276
14.776242 -0.9110109
14.784243 -0.89540267
14.792243 -0.88122904
14.800243 -0.86862254
14.808244 -0.85769594
14.816244 -0.8485412
14.8242445 -0.8412293
14.832245 -0.83580923
14.840245 -0.8323083
14.848246 -0.83073187
14.856246 -0.8310639
14.864246 -0.83326745
14.872247 -0.83728534
14.880247 -0.84304124
14.8882475 -0.85044086
14.896248 -0.8593734
14.904248 -0.8697127
14.912249 -0.88131946
14.920249 -0.8940425
14.928249 -0.90772104
14.93625 -0.9221863
14.94425 -0.93726397
14.9522505 -0.9527756
14.960251 -0.9685415
14.968251 -0.98438185
14.976252 -1.0001194
14.984252 -1.015581
14.992252 -1.0305998
15.000253 -1.0450164
15.008253 -1.0586814
15.016253 -1.0714558
15.024254 -1.0832133
15.032254 -1.0938411
15.040255 -1.1032405
15.048255 -1.1113287
15.056255 -1.1180388
15.064256 -1.12332
15.072256 -1.1271389
15.080256 -1.1294781
15.088257 -1.1303378
15.096257 -1.1297342
15.104258 -1.1276994
15.112258 -1.1242812
15.120258 -1.1195414
15.128259 -1.113556
15.136259 -1.1064131
15.144259 -1.0982125
15.15226 -1.0890635
15.16026 -1.0790844
15.168261 -1.0684005
15.176261 -1.0571431
15.184261 -1.0454471
15.192262 -1.03345
15.200262 -1.0212905
15.208262 -1.0091068
15.216263 -0.99703425
15.224263 -0.98520535
15.232264 -0.97374713
15.240264 -0.96278065
15.248264 -0.9524191
15.256265 -0.9427671
15.264265 -0.93391937
15.272265 -0.92596036
15.280266 -0.918963
15.288266 -0.9129882
15.296267 -0.9080845
15.304267 -0.9042878
15.312267 -0.9016209
15.320268 -0.9000938
15.328268 -0.8997035
15.336268 -0.9004345
15.344269 -0.9022592
15.352269 -0.90513813
15.36027 -0.909021
15.36827 -0.91384715
15.37627 -0.9195464
15.384271 -0.9260403
15.392271 -0.93324274
15.400271 -0.9410613
15.408272 -0.94939846
15.416272 -0.9581524
15.424273 -0.96721876
15.432273 -0.9764911
15.440273 -0.9858629
15.448274 -0.9952283
15.456274 -1.0044833
15.464274 -1.0135272
15.472275 -1.0222628
15.480275 -1.0305986
15.488276 -1.0384489
15.496276 -1.0457352
15.504276 -1.052386
15.512277 -1.0583386
15.520277 -1.0635391
15.528277 -1.067943
15.536278 -1.0715148
15.544278 -1.0742297
15.5522785 -1.0760725
15.560279 -1.0770376
15.568279 -1.0771298
15.57628 -1.0763634
15.58428 -1.0747617
15.59228 -1.0723573
15.600281 -1.0691907
15.608281 -1.0653105
15.6162815 -1.0607723
15.624282 -1.0556378
15.632282 -1.0499748
15.640283 -1.0438552
15.648283 -1.037355
15.656283 -1.0305531
15.664284 -1.0235304
15.672284 -1.0163687
15.6802845 -1.0091501
15.688285 -1.0019557
15.696285 -0.9948652
15.704286 -0.9879554
15.712286 -0.98130006
15.720286 -0.9749685
15.728287 -0.9690257
15.736287 -0.96353066
15.7442875 -0.95853686
15.752288 -0.9540909
15.760288 -0.9502326
15.768289 -0.94699466
15.776289 -0.9444023
15.784289 -0.94247293
15.79229 -0.94121647
15.80029 -0.9406352
15.8082905 -0.9407237
15.816291 -0.94146943
15.824291 -0.9428525
15.832292 -0.9448465
15.840292 -0.9474186
15.848292 -0.9505301
15.856293 -0.954137
15.864293 -0.9581907
15.872293 -0.9626382
15.880294 -0.9674233
15.888294 -0.972487
15.896295 -0.97776794
15.904295 -0.98320395
15.912295 -0.9887317
15.920296 -0.9942882
15.928296 -0.99981123
15.936296 -1.00524
15.944297 -1.0105158
15.952297 -1.0155828
15.960298 -1.0203881
15.968298 -1.0248832
15.976298 -1.0290232
15.984299 -1.0327685
15.992299 -1.0360843
16.0003 -1.0389413
16.008299 -1.0413154
16.016298 -1.0431892
16.024298 -1.0445504
16.032297 -1.045393
16.040297 -1.0457165
16.048296 -1.0455265
16.056295 -1.0448341
16.064295 -1.0436556
16.072294 -1.0420127
16.080294 -1.0399318
16.088293 -1.0374434
16.096292 -1.0345825
16.104292 -1.0313873
16.112291 -1.0278991
16.12029 -1.0241619
16.12829 -1.0202215
16.13629 -1.016125
16.144289 -1.0119209
16.152288 -1.0076578
16.160288 -1.0033838
16.168287 -0.99914694
16.176287 -0.9949933
16.184286 -0.9909679
16.192286 -0.987113
16.200285 -0.9834686
16.208284 -0.9800713
16.216284 -0.97695476
16.224283 -0.9741486
16.232283 -0.97167856
16.240282 -0.9695663
16.248281 -0.9678289
16.25628 -0.9664793
16.26428 -0.9655256
16.27228 -0.9649716
16.28028 -0.9648164
16.288279 -0.96505475
16.296278 -0.9656772
16.304277 -0.9666701
16.312277 -0.96801597
16.320276 -0.96969366
16.328276 -0.97167885
16.336275 -0.97394395
16.344275 -0.9764591
16.352274 -0.97919184
16.360273 -0.9821081
16.368273 -0.9851723
16.376272 -0.98834777
16.384272 -0.99159724
16.392271 -0.9948834
16.40027 -0.99816906
16.40827 -1.0014178
16.41627 -1.0045941
16.424269 -1.0076638
16.432268 -1.010595
16.440268 -1.0133573
16.448267 -1.015923
16.456266 -1.0182672
16.464266 -1.0203674
16.472265 -1.0222046
16.480265 -1.0237632
16.488264 -1.0250306
16.496264 -1.0259978
16.504263 -1.0266593
16.512262 -1.0270131
16.520262 -1.0270605
16.528261 -1.0268066
16.53626 -1.0262592
16.54426 -1.0254297
16.55226 -1.0243322
16.560259 -1.0229834
16.568258 -1.0214028
16.576258 -1.0196121
16.584257 -1.0176346
16.592257 -1.0154958
16.600256 -1.0132222
16.608255 -1.0108413
16.616255 -1.0083815
16.624254 -1.0058714
16.632254 -1.00334
16.640253 -1.0008156
16.648252 -0.9983261
16.656252 -0.9958988
16.664251 -0.99355924
16.67225 -0.9913321
16.68025 -0.98924017
16.68825 -0.9873042
16.696249 -0.9855431
16.704248 -0.9839733
16.712248 -0.9826089
16.720247 -0.9814616
16.728247 -0.9805402
16.736246 -0.9798511
16.744246 -0.97939783
16.752245 -0.9791814
16.760244 -0.9792
16.768244 -0.9794494
16.776243 -0.9799227
16.784243 -0.98061085
16.792242 -0.98150235
16.800241 -0.9825838
16.80824 -0.9838399
16.81624 -0.9852537
16.82424 -0.9868066
16.83224 -0.9884789
16.840239 -0.9902501
16.848238 -0.99209875
16.856237 -0.9940029
16.864237 -0.99594045
16.872236 -0.9978893
16.880236 -0.99982756
16.888235 -1.001734
16.896235 -1.0035878
16.904234 -1.0053695
16.912233 -1.0070605
16.920233 -1.0086435
16.928232 -1.0101029
16.936232 -1.0114245
16.944231 -1.0125962
16.95223 -1.0136076
16.96023 -1.0144501
16.96823 -1.0151173
16.976229 -1.015605
16.984228 -1.0159107
16.992228 -1.0160345
17.000227 -1.0159779
17.008226 -1.0157448
17.016226 -1.0153408
17.024225 -1.0147735
17.032225 -1.0140519
17.040224 -1.0131868
17.048223 -1.0121902
17.056223 -1.0110757
17.064222 -1.0098575
17.072222 -1.0085511
17.080221 -1.0071725
17.08822 -1.0057381
17.09622 -1.0042652
17.10422 -1.0027704
17.112219 -1.0012711
17.120218 -0.99978375
17.128218 -0.9983247
17.136217 -0.99690974
17.144217 -0.99555385
17.152216 -0.994271
17.160215 -0.99307406
17.168215 -0.99197507
17.176214 -0.9909844
17.184214 -0.9901111
17.192213 -0.98936296
17.200212 -0.988746
17.208212 -0.98826486
17.216211 -0.9879225
17.22421 -0.98772025
17.23221 -0.98765796
17.24021 -0.9877339
17.248209 -0.9879447
17.256208 -0.9882859
17.264208 -0.9887512
17.272207 -0.98933333
17.280207 -0.99002385
17.288206 -0.99081314
17.296206 -0.99169075
17.304205 -0.9926453
17.312204 -0.993665
17.320204 -0.99473727
17.328203 -0.99584925
17.336203 -0.99698794
17.344202 -0.9981403
17.352201 -0.99929315
17.3602 -1.0004338
17.3682 -1.0015496
17.3762 -1.0026289
17.3842 -1.0036601
17.392199 -1.0046326
17.400198 -1.0055367
17.408197 -1.0063635
17.416197 -1.0071052
17.424196 -1.007755
17.432196 -1.0083075
17.440195 -1.0087578
17.448195 -1.0091031
17.456194 -1.0093411
17.464193 -1.0094713
17.472193 -1.009494
17.480192 -1.0094107
17.488192 -1.0092244
17.496191 -1.0089389
17.50419 -1.0
17.51219 -1.0
17.52019 -1.0
17.528189 -1.0
17.536188 -1.0
17.544188 -1.0
17.552187 -1.0
17.560186 -1.0
17.568186 -1.0
17.576185 -1.0
17.584185 -1.0
17.592184 -1.0
17.600183 -1.0
17.608183 -1.0
17.616182 -1.0
17.624182 -1.0
17.632181 -1.0
17.64018 -1.0
17.64818 -1.0
17.65618 -1.0
17.664179 -1.0
17.672178 -1.0
17.680178 -1.0
17.688177 -1.0
17.696177 -1.0
17.704176 -1.0
17.712175 -1.0
17.720175 -1.0
17.728174 -1.0
17.736174 -1.0
17.744173 -1.0
17.752172 -1.0
17.760172 -1.0
17.768171 -1.0
17.77617 -1.0
17.78417 -1.0
17.79217 -1.0
17.800169 -1.0
17.808168 -1.0
17.816168 -1.0
17.824167 -1.0
17.832167 -1.0
17.840166 -1.0
17.848166 -1.0
17.856165 -1.0
17.864164 -1.0
17.872164 -1.0
17.880163 -1.0
17.888163 -1.0
17.896162 -1.0
17.904161 -1.0
17.91216 -1.0
17.92016 -1.0
17.92816 -1.0
17.93616 -1.0
17.944159 -1.0
17.952158 -1.0
17.960157 -1.0
17.968157 -1.0
17.976156 -1.0
17.984156 -1.0
17.992155 -1.0
18.000154 -1.0
18.008154 -1.0
18.016153 -1.0
18.024153 -1.0
18.032152 -1.0
18.040152 -1.0
18.048151 -1.0
18.05615 -1.0
18.06415 -1.0
18.07215 -1.0
18.080149 -1.0
18.088148 -1.0
18.096148 -1.0
18.104147 -1.0
18.112146 -1.0
18.120146 -1.0
18.128145 -1.0
18.136145 -1.0
18.144144 -1.0
18.152143 -1.0
18.160143 -1.0
18.168142 -1.0
18.176142 -1.0
18.184141 -1.0
18.19214 -1.0
18.20014 -1.0
18.20814 -1.0
18.216139 -1.0
18.224138 -1.0
18.232138 -1.0
18.240137 -1.0
18.248137 -1.0
18.256136 -1.0
18.264135 -1.0
18.272135 -1.0
18.280134 -1.0
18.288134 -1.0
18.296133 -1.0
18.304132 -1.0
18.312132 -1.0
18.320131 -1.0
18.32813 -1.0
18.33613 -1.0
18.34413 -1.0
18.352129 -1.0
18.360128 -1.0
18.368128 -1.0
18.376127 -1.0
18.384127 -1.0
18.392126 -1.0
18.400126 -1.0
18.408125 -1.0
18.416124 -1.0
18.424124 -1.0
18.432123 -1.0
18.440123 -1.0
18.448122 -1.0
18.456121 -1.0
18.46412 -1.0
18.47212 -1.0
18.48012 -1.0
18.48812 -1.0
18.496119 -1.0
18.504118 -1.0
18.512117 -1.0
18.520117 -1.0
18.528116 -1.0
18.536116 -1.0
18.544115 -1.0
18.552114 -1.0
18.560114 -1.0
18.568113 -1.0
18.576113 -1.0
18.584112 -1.0
18.592112 -1.0
18.600111 -1.0
18.60811 -1.0
18.61611 -1.0
18.62411 -1.0
18.632109 -1.0
18.640108 -1.0
18.648108 -1.0
18.656107 -1.0
18.664106 -1.0
18.672106 -1.0
18.680105 -1.0
18.688105 -1.0
18.696104 -1.0
18.704103 -1.0
18.712103 -1.0
18.720102 -1.0
18.728102 -1.0
18.736101 -1.0
18.7441 -1.0
18.7521 -1.0
18.7601 -1.0
18.768099 -1.0
18.776098 -1.0
18.784098 -1.0
18.792097 -1.0
18.800097 -1.0
18.808096 -1.0
18.816095 -1.0
18.824095 -1.0
18.832094 -1.0
18.840094 -1.0
18.848093 -1.0
18.856092 -1.0
18.864092 -1.0
18.872091 -1.0
18.88009 -1.0
18.88809 -1.0
18.89609 -1.0
18.904089 -1.0
18.912088 -1.0
18.920088 -1.0
18.928087 -1.0
18.936087 -1.0
18.944086 -1.0
18.952085 -1.0
18.960085 -1.0
18.968084 -1.0
18.976084 -1.0
18.984083 -1.0
18.992083 -1.0
19.000082 -1.0
19.008081 -1.0
19.01608 -1.0
19.02408 -1.0
19.03208 -1.0
19.04008 -1.0
19.048079 -1.0
19.056078 -1.0
19.064077 -1.0
19.072077 -1.0
19.080076 -1.0
19.088076 -1.0
19.096075 -1.0
19.104074 -1.0
19.112074 -1.0
19.120073 -1.0
19.128073 -1.0
19.136072 -1.0
19.144072 -1.0
19.152071 -1.0
19.16007 -1.0
19.16807 -1.0
19.17607 -1.0
19.184069 -1.0
19.192068 -1.0
19.200068 -1.0
19.208067 -1.0
19.216066 -1.0
19.224066 -1.0
19.232065 -1.0
19.240065 -1.0
19.248064 -1.0
19.256063 -1.0
19.264063 -1.0
19.272062 -1.0
19.280062 -1.0
19.288061 -1.0
19.29606 -1.0
19.30406 -1.0
19.31206 -1.0
19.320059 -1.0
19.328058 -1.0
19.336058 -1.0
19.344057 -1.0
19.352057 -1.0
19.360056 -1.0
19.368055 -1.0
19.376055 -1.0
19.384054 -1.0
19.392054 -1.0
19.400053 -1.0
19.408052 -1.0
19.416052 -1.0
19.424051 -1.0
19.43205 -1.0
19.44005 -1.0
19.44805 -1.0
19.456049 -1.0
19.464048 -1.0
19.472048 -1.0
19.480047 -1.0
19.488047 -1.0
19.496046 -1.0
19.504045 -1.0
19.512045 -1.0
19.520044 -1.0
19.528044 -1.0
19.536043 -1.0
19.544043 -1.0
19.552042 -1.0
19.560041 -1.0
19.56804 -1.0
19.57604 -1.0
19.58404 -1.0
19.59204 -1.0
19.600039 -1.0
19.608038 -1.0
19.616037 -1.0
19.624037 -1.0
19.632036 -1.0
19.640036 -1.0
19.648035 -1.0
19.656034 -1.0
19.664034 -1.0
19.672033 -1.0
19.680033 -1.0
19.688032 -1.0
19.696032 -1.0
19.704031 -1.0
19.71203 -1.0
19.72003 -1.0
19.72803 -1.0
19.736029 -1.0
19.744028 -1.0
19.752028 -1.0
19.760027 -1.0
19.768026 -1.0
19.776026 -1.0
19.784025 -1.0
19.792025 -1.0
19.800024 -1.0
19.808023 -1.0
19.816023 -1.0
19.824022 -1.0
19.832022 -1.0
19.840021 -1.0
19.84802 -1.0
19.85602 -1.0
19.86402 -1.0
19.872019 -1.0
19.880018 -1.0
19.888018 -1.0
19.896017 -1.0
19.904016 -1.0
19.912016 -1.0
19.920015 -1.0
19.928015 -1.0
19.936014 -1.0
19.944014 -1.0
19.952013 -1.0
19.960012 -1.0
19.968012 -1.0
19.976011 -1.0
19.98401 -1.0
19.99201 -1.0
| Gnuplot | 0 | ocharles/ghc | testsuite/tests/programs/barton-mangler-bug/piece.plt | [
"BSD-3-Clause"
] |
// MIR for `<impl at $DIR/retag.rs:11:1: 19:2>::foo_shr` after SimplifyCfg-elaborate-drops
fn <impl at $DIR/retag.rs:11:1: 19:2>::foo_shr(_1: &Test, _2: &i32) -> &i32 {
debug self => _1; // in scope 0 at $DIR/retag.rs:16:20: 16:25
debug x => _2; // in scope 0 at $DIR/retag.rs:16:27: 16:28
let mut _0: &i32; // return place in scope 0 at $DIR/retag.rs:16:42: 16:49
bb0: {
Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:16:5: 18:6
Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:16:5: 18:6
_0 = _2; // scope 0 at $DIR/retag.rs:17:9: 17:10
Retag(_0); // scope 0 at $DIR/retag.rs:17:9: 17:10
return; // scope 0 at $DIR/retag.rs:18:6: 18:6
}
}
| Mirah | 3 | Eric-Arellano/rust | src/test/mir-opt/retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.mir | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
#! /bin/sh /usr/share/dpatch/dpatch-run
## 13_pop_with_version.dpatch by Luciano Bello <luciano@linux.org.ar>
##
## DP: distinguish between pop versions
@DPATCH@
diff -urNad trunk~/decode.c trunk/decode.c
--- trunk~/decode.c 2007-08-11 18:43:41.000000000 -0300
+++ trunk/decode.c 2007-08-11 19:01:08.000000000 -0300
@@ -63,7 +63,8 @@
{ "http", decode_http },
{ "ospf", decode_ospf },
{ "poppass", decode_poppass },
- { "pop", decode_pop },
+ { "pop2", decode_pop },
+ { "pop3", decode_pop },
{ "nntp", decode_nntp },
{ "smb", decode_smb },
{ "imap", decode_imap },
diff -urNad trunk~/dsniff.services trunk/dsniff.services
--- trunk~/dsniff.services 2007-08-11 18:43:41.000000000 -0300
+++ trunk/dsniff.services 2007-08-11 19:00:21.000000000 -0300
@@ -10,8 +10,8 @@
ospf 89/ip
http 98/tcp
poppass 106/tcp
-pop 109/tcp
-pop 110/tcp
+pop2 109/tcp
+pop3 110/tcp
portmap 111/tcp
portmap -111/tcp
portmap 111/udp
| Darcs Patch | 3 | acheong08/dsniff | debian/patches/13_pop_with_version.dpatch | [
"BSD-3-Clause"
] |
#include "script_component.hpp"
/*
Name: TFAR_fnc_swRadioSubMenu
Author: NKey, Garth de Wet (L-H)
Returns a sub menu for a particular radio.
Arguments:
None
Return Value:
Flexi-menu <ARRAY>
Example:
call TFAR_fnc_swRadioSubMenu;
Public: No
*/
[
["secondary", localize LSTRING(select_action), "buttonList", "", false],
[
[localize LSTRING(select_action_setup), "[{call TFAR_fnc_onSwDialogOpen;}, [], 0.2] call CBA_fnc_waitAndExecute;", "", localize LSTRING(select_action_setup_tooltip), "", -1, true, true],
[localize LSTRING(select_action_use), "TF_sw_dialog_radio call TFAR_fnc_setActiveSwRadio;[(call TFAR_fnc_activeSwRadio), false] call TFAR_fnc_showRadioInfo;", "", localize LSTRING(select_action_use_tooltip), "", -1, true, true],
[localize LSTRING(select_action_copy_settings_from), "", "", localize LSTRING(select_action_copy_settings_from_tooltip), "_this call TFAR_fnc_copyRadioSettingMenu", -1, true, true]
]
]
| SQF | 4 | MrDj200/task-force-arma-3-radio | addons/core/functions/flexiUI/fnc_swRadioSubMenu.sqf | [
"RSA-MD"
] |
#!/bin/sh
# jps.sh version 1.0.2
# there might be multiple java processes, e.g. log-agent
JPS_CMDS=($(ps aux | grep java | grep -v 'grep java' | awk '{print $11}' | sed -n 's/java$/jps/p'))
# find the first executable jps command
JPS_CMD=""
for jps in ${JPS_CMDS[@]}; do
if [ -x $jps ]; then
JPS_CMD=$jps
break
fi
done
if [ "$JPS_CMD" == "" ]; then
echo "No Java Process Found on this Machine."
exit 1
else
result=`$JPS_CMD -lmv | grep -v jps`
if [ "$result" == "" ]; then
ps aux | grep -E '^admin.*java.*' | grep -v grep | awk 'BEGIN{ORS=""}{print $2" ";for(j=NF;j>=12;j--){if(match($j, /^\-[a-zA-Z0-9]/)) {break;} } for(i=j+1;i<=NF;i++) {print $i" "} for(i=12;i<=j;i++) {print $i" "} print "\n" }'
else
echo "$result"
fi
fi
| Shell | 4 | weihubeats/arthas | bin/jps.sh | [
"Apache-2.0"
] |
---
etherWisDeviceTable: 1.3.6.1.2.1.10.134.1.1.1
etherWisDeviceRxTestPatternErrors: 1.3.6.1.2.1.10.134.1.1.1.1.3
etherWisSectionCurrentJ0Received: 1.3.6.1.2.1.10.134.1.2.1.1.2
etherWisPathCurrentStatus: 1.3.6.1.2.1.10.134.2.1.1.1.1
etherWisFarEndPathCurrentEntry: 1.3.6.1.2.1.10.134.2.2.1.1
etherWisDeviceEntry: 1.3.6.1.2.1.10.134.1.1.1.1
etherWisDeviceTxTestPatternMode: 1.3.6.1.2.1.10.134.1.1.1.1.1
etherWisPathCurrentJ1Received: 1.3.6.1.2.1.10.134.2.1.1.1.3
etherWisSectionCurrentTable: 1.3.6.1.2.1.10.134.1.2.1
etherWisObjects: 1.3.6.1.2.1.10.134.1
etherWisDeviceRxTestPatternMode: 1.3.6.1.2.1.10.134.1.1.1.1.2
etherWisSection: 1.3.6.1.2.1.10.134.1.2
etherWisSectionCurrentEntry: 1.3.6.1.2.1.10.134.1.2.1.1
etherWisSectionCurrentJ0Transmitted: 1.3.6.1.2.1.10.134.1.2.1.1.1
etherWisFarEndPathCurrentTable: 1.3.6.1.2.1.10.134.2.2.1
etherWisMIB: 1.3.6.1.2.1.10.134
etherWisPath: 1.3.6.1.2.1.10.134.2.1
etherWisGroups: 1.3.6.1.2.1.10.134.3.1
etherWisPathCurrentEntry: 1.3.6.1.2.1.10.134.2.1.1.1
etherWisPathCurrentJ1Transmitted: 1.3.6.1.2.1.10.134.2.1.1.1.2
etherWisFarEndPathCurrentStatus: 1.3.6.1.2.1.10.134.2.2.1.1.1
etherWisCompliances: 1.3.6.1.2.1.10.134.3.2
etherWisObjectsPath: 1.3.6.1.2.1.10.134.2
etherWisFarEndPath: 1.3.6.1.2.1.10.134.2.2
etherWisConformance: 1.3.6.1.2.1.10.134.3
etherWisDevice: 1.3.6.1.2.1.10.134.1.1
etherWisPathCurrentTable: 1.3.6.1.2.1.10.134.2.1.1
| YAML | 2 | OsmanDere/metasploit-framework | data/snmp/mibs/ETHER-WIS.yaml | [
"BSD-2-Clause",
"BSD-3-Clause"
] |
dnl @synopsis AC_C99_FUNC_LRINT
dnl
dnl Check whether C99's lrint function is available.
dnl @version 1.1
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
dnl
dnl Permission to use, copy, modify, distribute, and sell this file for any
dnl purpose is hereby granted without fee, provided that the above copyright
dnl and this permission notice appear in all copies. No representations are
dnl made about the suitability of this software for any purpose. It is
dnl provided "as is" without express or implied warranty.
dnl
AC_DEFUN([AC_C99_FUNC_LRINT],
[AC_CACHE_CHECK(for lrint,
ac_cv_c99_lrint,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC99 1
#define __USE_ISOC9X 1
#include <math.h>]], [[ int value = lrint (0.432) ; ]])],[ac_cv_c99_lrint=yes],[ac_cv_c99_lrint=no])])
if test "x$ac_cv_c99_lrint" = "xyes"; then
AC_DEFINE(HAVE_LRINT, 1,
[Define if you have C99's lrint function.])
fi
])# AC_C99_LRINT
| M4 | 4 | joshrose/audacity | lib-src/libsbsms/m4/ac_c99_func_lrint.m4 | [
"CC-BY-3.0"
] |
---
title: Radio
desc: The QRadio Vue component is a basic element for user input. It can be used to supply a way for the user to pick an option from multiple choices.
keys: QRadio
related:
- /vue-components/option-group
- /vue-components/button-toggle
- /vue-components/checkbox
- /vue-components/toggle
---
The QRadio component is another basic element for user input. You can use this to supply a way for the user to pick an option from multiple choices.
::: tip
Please also refer to the [QOptionGroup](/vue-components/option-group) on other possibilities for creating groups of Radios.
:::
## QRadio API
<doc-api file="QRadio" />
## Usage
### Standard
<doc-example title="Standard" file="QRadio/Standard" />
### Dense
<doc-example title="Dense" file="QRadio/Dense" />
### Coloring
In the second row in the example below, the property `keep-color` is being used to retain the passed in color when the radio button is not in a toggled state.
<doc-example title="Coloring" file="QRadio/Coloring" />
### Dark and disable
<doc-example title="On a dark background" file="QRadio/OnDarkBackground" dark />
<doc-example title="Disable" file="QRadio/Disable" />
### Label on left-side
<doc-example title="Label on left side" file="QRadio/LabelPosition" />
### Sizes
Apart from the standard sizes below, you can define your own through the `size` property (last one is a custom size).
<doc-example title="Standard sizes" file="QRadio/StandardSizes" />
### With QOptionGroup
::: tip
You can also use [QOptionGroup](/vue-components/option-group), which simplifies the usage when you have groups of radios, like in example below.
:::
<doc-example title="Usage with QOptionGroup" file="QRadio/OptionGroup" />
### With QItem
In the example below, we are rendering a `<label>` tag (notice `tag="label"`) so the QRadio will respond to clicks on QItems to change toggle state.
<doc-example title="With QItem" file="QRadio/InaList" />
### Native form submit
When dealing with a native form which has an `action` and a `method` (eg. when using Quasar with ASP.NET controllers), you need to specify the `name` property on QRadio, otherwise formData will not contain it (if it should) - all value are converted to string (native behaviour, so do not use Object values):
<doc-example title="Native form" file="QRadio/NativeForm" />
| Markdown | 4 | RaphaelWoude/quasar | docs/src/pages/vue-components/radio.md | [
"MIT"
] |
# Check the handling of a missing depfile.
# RUN: rm -rf %t.build
# RUN: mkdir -p %t.build
# RUN: cp %s %t.build/build.ninja
# RUN: %{llbuild} ninja build --strict --jobs 1 --chdir %t.build --no-db &> %t1.out || true
# RUN: %{FileCheck} --check-prefix CHECK-STRICT --input-file %t1.out %s
#
# CHECK-STRICT: [1/{{.*}}] true
# CHECK-STRICT: unable to read dependency
# RUN: rm -rf %t.build
# RUN: mkdir -p %t.build
# RUN: cp %s %t.build/build.ninja
# RUN: %{llbuild} ninja build --jobs 1 --chdir %t.build --no-db &> %t2.out
# RUN: %{FileCheck} --check-prefix CHECK-NONSTRICT --input-file %t2.out %s
#
# CHECK-NONSTRICT: [1/{{.*}}] true
# CHECK-NONSTRICT-NOT: unable to read dependency
rule TRUE
depfile = ${out}.d
command = true
build output: TRUE
| Ninja | 4 | trombonehero/swift-llbuild | tests/Ninja/Build/missing-depfile.ninja | [
"Apache-2.0"
] |
$TTL 3D
@ IN SOA test. root.test. (
199609203 ; Serial
28800 ; Refresh
7200 ; Retry
604800 ; Expire
86400) ; Minimum TTL
NS test.test.
test IN A 127.0.0.1
* IN MX 10 test
* IN MX 20 test2
* IN AAAA ::1
test2 IN CNAME test
| DNS Zone | 3 | Corvus-R/android_external_honggfuzz | examples/bind/test.zone | [
"Apache-2.0"
] |
/*
Copyright © 2011, 2012 MLstate
This file is part of Opa.
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 stdlib.core.rpc.core
/**
* {1 Interface} This is deprecated, use module Limits in stdlib.core.rpc
*/
@deprecated({use="Limits.min_int"})
min_int = Limits.min_int
@deprecated({use="Limits.max_int"})
max_int = Limits.max_int
| Opa | 4 | Machiaweliczny/oppailang | lib/stdlib/core/rpc/maxint/max_int.opa | [
"MIT"
] |
//
// Copyright (c) XSharp B.V. All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/ampm/*" />
FUNCTION AmPm(c24HrTime AS STRING) AS STRING
LOCAL nSeconds AS DWORD
LOCAL nHours AS DWORD
LOCAL nMinutes AS DWORD
IF String.IsNullOrEmpty(c24HrTime)
RETURN ""
ENDIF
nSeconds := Secs(c24HrTime)
IF (nSeconds) > 86400
RETURN ""
ENDIF
nSeconds := nSeconds % 86400
nHours := nSeconds / 3600
nSeconds := nSeconds % 3600
nMinutes := nSeconds / 60
nSeconds := nSeconds % 60
RETURN _TimeString(nHours, nMinutes, nSeconds, TRUE, GetAMExt(), GetPMExt())
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/elaptime/*" />
FUNCTION ElapTime(cStartTime AS STRING,cEndTime AS STRING) AS STRING
LOCAL nStart AS DWORD
LOCAL nEnd AS DWORD
LOCAL nDiff AS DWORD
nStart := Secs(cStartTime)
nEnd := Secs(cEndTime)
IF nStart > nEnd
nDiff := 86400U + nEnd - nStart
ELSE
nDiff := nEnd - nStart
ENDIF
RETURN TString(nDiff)
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/contime/*" />
FUNCTION ConTime(dwHour AS DWORD,dwMinute AS DWORD,dwSeconds AS DWORD) AS STRING
RETURN _TimeString( dwHour, dwMinute, dwSeconds, FALSE, "", "" )
/// <summary>
/// Return the timestring from a DateTime structure
/// </summary>
/// <param name="dt">DateTime values that needs to be converted</param>
/// <returns>A (military) time that corresponds to the passed arguments in the format HH:MM:SS without AM/PM notation.</returns>
FUNCTION ConTime(dt AS DateTime) AS STRING
RETURN _TimeString((DWORD) dt:Hour,(DWORD) dt:Minute,(DWORD) dt:Second, FALSE, "","")
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/ntocdow/*" />
FUNCTION NToCDoW(dwDayNum AS DWORD) AS STRING
LOCAL result AS STRING
IF dwDayNum < 1 .OR. dwDayNum > 7
result := ""
ELSEIF RuntimeState.International == CollationMode.Clipper
result := __CavoStr(VOErrors.RT_MSG_DAY1 + dwDayNum -1)
ELSE
VAR culture := System.Globalization.CultureInfo.CurrentCulture
result := culture:DateTimeFormat:GetDayName((DayOfWeek) (dwDayNum-1))
ENDIF
RETURN result
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/ntocmonth/*" />
FUNCTION NToCMonth(dwMonthNum AS DWORD) AS STRING
LOCAL result AS STRING
IF dwMonthNum < 1 .OR. dwMonthNum > 12
result := ""
ELSEIF RuntimeState.International == CollationMode.Clipper
result := __CavoStr(VOErrors.RT_MSG_MONTH1 + dwMonthNum -1)
ELSE
VAR culture := System.Globalization.CultureInfo.CurrentCulture
result := culture:DateTimeFormat:GetMonthName((INT)dwMonthNum)
ENDIF
RETURN result
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/secs/*" />
FUNCTION Secs(cTime AS STRING) AS DWORD
// Note that VO "accepts" practically any format, even say "0:#23:&1" and returns semi random results, but we will not emulate all that
// Instead, we support formats that make sense, like "HH", "HH:MM" and "HH:MM:SS". And, oh, we do support also "10:99:99" that VO allows as well..
LOCAL cSeparator AS STRING
LOCAL nHours AS INT
LOCAL nMinutes AS INT
LOCAL nSeconds AS INT
LOCAL result AS DWORD
IF String.IsNullOrEmpty(cTime)
RETURN 0
ENDIF
cSeparator := Chr(GetTimeSep())
LOCAL nOffSet := 0 AS INT
TRY
nHours := Int32.Parse(cTime:Substring(nOffSet,2))
CATCH
nHours := 0
END TRY
nOffSet += cSeparator:Length +2
TRY
nMinutes := Int32.Parse(cTime:Substring(nOffSet,2))
CATCH
nMinutes := 0
END TRY
nOffSet += cSeparator:Length +2
TRY
nSeconds := Int32.Parse(cTime:Substring(nOffSet,2))
CATCH
nSeconds := 0
END TRY
result := (DWORD) (nHours * 3600 + nMinutes * 60 + nSeconds)
RETURN result
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/days/*" />
FUNCTION Days(nSeconds AS REAL8) AS INT
RETURN (INT) (nSeconds / 84600) // 24*60*60
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/seconds/*" />
FUNCTION Seconds() AS REAL8
VAR dt := DateTime.Now
LOCAL result AS REAL8
result := dt:Hour * 3600 + dt:Minute * 60 + dt:Second + (REAL8) (dt:Millisecond)/1000.0
IF XSharp.RuntimeState.Dialect == XSharpDialect.FoxPro
result := Math.Round(result,3)
ELSE
result := Math.Round(result,2)
ENDIF
RETURN result
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/time/*" />
FUNCTION Time() AS STRING
VAR d := DateTime.Now
RETURN _TimeString(d)
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/time24/*" />
FUNCTION Time24() AS STRING
LOCAL d := DateTime.Now AS DateTime
RETURN _TimeString((DWORD) d:Hour,(DWORD) d:Minute,(DWORD) d:Second,FALSE,"","")
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/tstring/*" />
FUNCTION TString(nSeconds AS REAL8) AS STRING
RETURN TString( (DWORD) Math.Round( nSeconds, MidpointRounding.ToEven ) )
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/tstring/*" />
FUNCTION TString(nSeconds AS DWORD) AS STRING
LOCAL dwHours AS DWORD
LOCAL dwMinutes AS DWORD
// truncate to one day
nSeconds := nSeconds % (24 * 60 * 60)
dwHours := nSeconds / (60 * 60)
nSeconds := nSeconds % (60 * 60)
dwMinutes := nSeconds / 60
nSeconds := nSeconds % 60
RETURN _TimeString(dwHours, dwMinutes, nSeconds, GetAmPm(), GetAMExt(), GetPMExt())
INTERNAL FUNCTION _TimeString( d AS DateTime ) AS STRING
RETURN _TimeString( (DWORD) d:Hour, (DWORD) d:Minute, (DWORD) d:Second, SetAmPm(), GetAMExt(), GetPMExt() )
INTERNAL FUNCTION _TimeString( h AS DWORD, m AS DWORD, s AS DWORD, lAMPM AS LOGIC, cAM AS STRING, cPM AS STRING ) AS STRING
LOCAL cTimeSep AS STRING
LOCAL lAfternoon AS LOGIC
// no exceptions, vo simply returns an empty string
IF h < 0 || h > 23
RETURN ""
ELSEIF m < 0 || m > 59
RETURN ""
ELSEIF s < 0 || s > 59
RETURN ""
ENDIF
IF s == 60
s := 0
m += 1
IF m == 60
m := 0
h += 1
ENDIF
IF h == 24
h := 0
ENDIF
ENDIF
cTimeSep := Chr( GetTimeSep() )
lAfternoon := h >= 12
IF lAMPM
IF h > 12
h -= 12
ELSEIF h == 0
h := 12
ENDIF
ENDIF
RETURN String.Format( "{0:00}{3}{1:00}{3}{2:00}{4}", h, m, s, cTimeSep, IIF( lAMPM, IIF( lAfternoon, cPM, cAM ), "" ) )
/// <summary>
/// Format a set of numbers representing a year, month, and day as a Date.
/// </summary>
/// <param name="dwY">A valid year. If the century digits are not specified, the century is determined by the rules of SetEpoch(). </param>
/// <param name="dwM">A number from 1 through 12 representing a valid month. </param>
/// <param name="dwDay">A number representing a valid day of dwMonth.</param>
/// <returns>The date that corresponds to the passed arguments. If any of the arguments specified do not represent a valid year, month, or day, a DateTime.MinValue is returned.</returns>
FUNCTION ConDateTime(dwY AS DWORD,dwM AS DWORD,dwDay AS DWORD) AS DateTime
IF dwM == 0 .OR. dwDay == 0
RETURN DateTime.MinValue
ENDIF
IF dwY < 100
LOCAL lAfter AS LOGIC
lAfter := dwY > XSharp.RuntimeState.EpochYear
dwY += XSharp.RuntimeState.EpochCent
IF lAfter
dwY -= 100
ENDIF
ENDIF
TRY
RETURN DateTime{(INT) dwY,(INT) dwM,(INT) dwDay}
CATCH
RETURN DateTime.MinValue
END TRY
STATIC FUNCTION _SplitDate(cDate AS STRING) AS STRING[]
LOCAL aNums := STRING[]{3} AS STRING[]
LOCAL cCurrent := "" AS STRING
LOCAL nCurrent := __ARRAYBASE__ AS INT
LOCAL lFirstCharFound := FALSE AS LOGIC
FOREACH cChar AS CHAR IN cDate
IF cChar >= '0' .AND. cChar <= '9'
lFirstCharFound := TRUE
cCurrent += cChar:ToString()
ELSEIF cChar == ' ' .and. .not. lFirstCharFound
NOP
ELSE
lFirstCharFound := TRUE
aNums[nCurrent] := cCurrent
cCurrent := ""
nCurrent++
IF nCurrent > 2 + __ARRAYBASE__
EXIT
END IF
END IF
NEXT
IF nCurrent == 2 + __ARRAYBASE__
aNums[nCurrent] := cCurrent
END IF
RETURN aNums
/// <summary>
/// Convert a Date string to DateTime.
/// </summary>
/// <param name="cDate">A string of numbers representing the month, day, and year, separated by any character other than a number. The month, day, and year digits must be in the format set by SetDateFormat() or SetDateCountry(). If the century digits are not specified, the century is determined by the rules of SetEpoch().</param>
/// <param name="cDateFormat">A string representating the date format to use when converting the string to a date. Should consist of D, M and Y characters and separators.</param>
/// <returns>The DateTime value that corresponds to the numbers specified in <paramref name="cDate"/>. If <paramref name="cDate"/> is not a valid date, CToDt() returns a DateTime.MinValue.
/// </returns>
FUNCTION CToDt(cDate AS STRING, cDateFormat AS STRING) AS DateTime
LOCAL dDate AS DateTime
LOCAL nDay, nMonth, nYear AS DWORD
LOCAL nDayPos, nMonthPos, nYearPos AS INT
dDate := DateTime.MinValue
IF String.IsNullOrEmpty(cDate) .OR. String.IsNullOrEmpty(cDateFormat) .OR. cDate == RuntimeState.GetValue<STRING>(Set.DateFormatEmpty)
RETURN dDate
ENDIF
LOCAL nPos AS INT
// LOCAL cSep AS STRING
nDayPos := nMonthPos := nYearPos := -1
// cSep := "./-"
nPos :=-1
FOREACH c AS CHAR IN cDateFormat
SWITCH c
CASE 'D'
IF nDayPos == -1
++nPos
nDayPos := nPos
ENDIF
CASE 'M'
IF nMonthPos == -1
++nPos
nMonthPos := nPos
ENDIF
CASE 'Y'
IF nYearPos == -1
++nPos
nYearPos := nPos
ENDIF
OTHERWISE
NOP
/* IF cSep:IndexOf(c) == -1
cSep += c:ToString()
ENDIF*/
END SWITCH
NEXT
IF nDayPos == -1 .OR. nMonthPos == -1 .OR. nYearPos == -1
RETURN dDate
ENDIF
TRY
// we now know the seperators and the positions in the string
// LOCAL aNums := cDate:Split(cSep:ToCharArray()) AS STRING[]
// VO's CToD() "correctly" parses dates with any char used as separator
LOCAL aNums := _SplitDate(cDate) AS STRING[]
IF UInt32.TryParse(aNums[nDayPos], OUT nDay) .AND. ;
UInt32.TryParse(aNums[nMonthPos], OUT nMonth) .AND. ;
UInt32.TryParse(aNums[nYearPos], OUT nYear)
IF aNums[nYearPos]:Length < 4
// Century missing ?
dDate := ConDateTime(nYear, nMonth, nDay)
ELSE
dDate := DateTime{(INT)nYear, (INT)nMonth, (INT)nDay}
ENDIF
ELSE
dDate := DateTime.MinValue
ENDIF
CATCH
dDate := DateTime.MinValue
END TRY
RETURN dDate
/// <summary>
/// Convert an ANSI date string to DateTime
/// </summary>
/// <param name="cDate">A string in the ANSI form yyyy.mm.dd, where yy, mm, and dd represent year, month, and day respectively.
/// The year, month, and day can be separated by any character other than a number.
/// cDate is always interpreted as an ANSI string and is not dependent on SetDateFormat() or SetDateCountry().
/// If the century digits are not specified, the century is determined by the rules of SetEpoch().</param>
/// <returns>The date value that corresponds to the numbers specified in <paramref name="cDate"/>. If cDate is not a valid ANSI date, CToDAnsi() returns a DateTime.MinValue.
/// </returns>
FUNCTION CToDtAnsi(cDate AS STRING) AS DateTime
RETURN CToDt(cDate, "YYYY.MM.DD")
/// <summary>
/// Convert a DateTime to a string.
/// </summary>
/// <param name="d">The DateTime to be converted.</param>
/// <returns>
/// A string representation of the given Date, formatted in the current Date format.
/// </returns>
FUNCTION DtToC(d AS DateTime) AS STRING
LOCAL result:="" AS STRING
LOCAL cFormat := XSharp.RuntimeState.GetValue<STRING>(Set.DateFormatNet) AS STRING
IF d != DateTime.MinValue
LOCAL dt := d AS DateTime
result := dt:ToString(cFormat)
ELSE
result := RuntimeState.NullDateString
ENDIF
RETURN result
/// <summary>
/// Convert a DateTime value to a string formatted as string in ANSI format
/// </summary>
/// <param name="dDate">The DateTime to be converted</param>
/// <returns>
/// An 8-character string in the format yyyymmdd. If dDate is a DateTime.MinValue, a string of eight spaces is returned. The return value is not affected by the current date format.
/// </returns>
FUNCTION DtToS(dDate AS DateTime) AS STRING
LOCAL result := NULL AS STRING
IF dDate != DateTime.MinValue
result := dDate:ToString("yyyyMMdd")
ELSE
result:=" "
ENDIF
RETURN result
/// <summary>
/// Convert an Date string to DateTime
/// </summary>
/// <param name="cDate"></param>
/// <returns><inheritdoc cref='M:XSharp.RT.Functions.CToD(System.String)'/></returns>
FUNCTION SToDt(cDate AS STRING) AS DateTime
LOCAL convertedDate AS DateTime
TRY
IF String.IsNullOrWhiteSpace(cDate)
convertedDate := DateTime.MinValue
ELSE
IF cDate:Length == 8 .AND. cDate[0] == c'0' .AND. cDate[1] == c'0'
// VO adjusts date strings like "00yyMMdd" to epoch-based year
LOCAL dwY AS DWORD
dwY := UInt32.Parse(cDate:Substring(0,4))
// same code as in ConDate(), probably better adjust SToD() to use ConDate() directly
LOCAL lAfter AS LOGIC
lAfter := dwY > XSharp.RuntimeState.EpochYear
dwY += XSharp.RuntimeState.EpochCent
IF lAfter
dwY -= 100
ENDIF
cDate := dwY:ToString():PadLeft(4 , c'0') + cDate:Substring(4)
END IF
convertedDate := DateTime.ParseExact(cDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture)
ENDIF
CATCH
convertedDate := DateTime.MinValue
END TRY
RETURN convertedDate
FUNCTION @@DateTime() AS DateTime
RETURN DateTime.Now
FUNCTION @@DateTime(nYear AS INT, nMonth AS INT, nDay AS INT) AS DateTime
RETURN System.DateTime{nYear, nMonth, nDay}
FUNCTION @@DateTime(nYear AS INT, nMonth AS INT, nDay AS INT, nHours AS INT) AS DateTime
RETURN System.DateTime{nYear, nMonth, nDay,nHours, 0, 0}
FUNCTION @@DateTime(nYear AS INT, nMonth AS INT, nDay AS INT, nHours AS INT, nMinutes AS INT) AS DateTime
RETURN System.DateTime{nYear, nMonth, nDay,nHours, nMinutes, 0}
FUNCTION @@DateTime(nYear AS INT, nMonth AS INT, nDay AS INT, nHours AS INT, nMinutes AS INT, nSeconds AS INT) AS DateTime
RETURN System.DateTime{nYear, nMonth, nDay,nHours, nMinutes, nSeconds}
| xBase | 5 | orangesocks/XSharpPublic | Runtime/XSharp.Core/Functions/DT.prg | [
"Apache-2.0"
] |
// Copyright (c) 2016-2020 Bluespec, Inc. All Rights Reserved.
package Cache;
// ================================================================
// Organization: in-order, blocking, "write-back" policy:
// On a miss,
// - A victim way is identified in the addressed cache set
// - If the cache line is MODIFIED, it is written back ("writeback")
// - The required cache line is loaded ("refill")
// Storage is in two separate SRAMs, the tag-ram and the data ram.
// Each tag ram address holds a set of tags (set-associativity)
// Each data RAM address holds 64b (exploiting RAM-internal muxes) for 64-bit read/write.
// TODO:
// LR/SC reservation management
// ================================================================
// BSV lib imports
import Vector :: *;
import BRAMCore :: *;
import FIFOF :: *;
import GetPut :: *;
import ClientServer :: *;
import Assert :: *;
// ----------------
// BSV additional libs
import Cur_Cycle :: *;
import GetPut_Aux :: *;
// ================================================================
// Project imports
import ISA_Decls :: *;
import Near_Mem_IFC :: *;
import Cache_Decls :: *;
import MMU_Cache_Common :: *;
// ================================================================
export Cache_Result_Type (..), Cache_Result (..), fshow_Cache_Result;
export Cache_IFC (..);
export mkCache;
// ================================================================
// MODULE INTERFACE
typedef enum { CACHE_MISS, CACHE_READ_HIT, CACHE_WRITE_HIT } Cache_Result_Type
deriving (Bits, Eq, FShow);
typedef struct {
Cache_Result_Type outcome;
Bit #(64) final_ld_val;
Bit #(64) final_st_val;
} Cache_Result
deriving (Bits, FShow);
function Fmt fshow_Cache_Result (Cache_Result result);
return case (result.outcome)
CACHE_MISS: $format ("CACHE_MISS");
CACHE_READ_HIT: $format ("CACHE_READ_HIT (ld_val %0h)", result.final_ld_val);
CACHE_WRITE_HIT: $format ("CACHE_WRITE_HIT (st_val %0h)", result.final_st_val);
endcase;
endfunction
// ----------------
interface Cache_IFC;
// This starts a new request (with virt addr)
// while the virt addr is being translated to a phys addr
(* always_ready *)
method Action ma_request_va (WordXL va);
// This completes a new request with the phys addr
method ActionValue #(Cache_Result) mav_request_pa (MMU_Cache_Req req, PA pa);
// ----------------
// Stalls until refill done and then returns ok (True) or error (False)
method Bool mv_refill_ok ();
// ----------------
// Cache flush request/response
// Bit #(1) request specifies new meta-state: 0=INVALID, 1=SHARED
interface Server #(Bit #(1), Token) flush_server;
// ----------------
// Interface to next level (for refills, writebacks)
interface Get #(Line_Req) g_mem_req;
interface Get #(Bit #(64)) g_write_data;
interface Put #(Read_Data) p_mem_read_data;
endinterface
// ================================================================
// Constants used in RAM instantiation and access API
Bool bram_with_output_reg = False;
Bool bram_cmd_read = False;
Bool bram_cmd_write = True;
// ================================================================
// Overall state of the cache module FSM
typedef enum {FSM_INITIALIZE,
FSM_IDLE,
FSM_REPLACE_START,
FSM_WRITEBACK_LOOP,
FSM_REFILL_START, // On cache miss, initiate refill of cache line in cache
FSM_REFILL_LOOP, // Refill
FSM_REFILL_FINAL_DELAY, // 1-cycle delay after refill due to SRAM-write requirement
FSM_FLUSH_LOOP,
FSM_FLUSH_LOOP_WRITEBACK_SEQUEL
} FSM_State
deriving (Bits, Eq, FShow);
// ================================================================
// Cache entries and sets
// A cache entry is: meta information (state, ctag) and data
typedef struct {
Meta_State state;
CTag ctag;
} Meta
deriving (Bits, FShow);
// A CSet of Meta information
typedef Vector #(Ways_per_CSet, Meta) CSet_Meta;
// A CSet of CWords
typedef Vector #(Ways_per_CSet, Bit #(64)) CSet_CWord;
function Fmt fshow_cset_meta (CSet_in_Cache cset_in_cache,
CSet_Meta cset_meta);
Fmt fmt = $format ("CSet[%0h] (state, tag){", cset_in_cache);
for (Integer j = 0; j < ways_per_cset; j = j + 1) begin
fmt = fmt + $format (" way%0d (", j, fshow (cset_meta [j].state));
if (cset_meta [j].state != META_INVALID)
fmt = fmt + $format (", ctag %0h", cset_meta [j].ctag);
fmt = fmt + $format (")");
end
fmt = fmt + $format ("}");
return fmt;
endfunction
function Fmt fshow_cset_cword (CSet_CWord cset_cword);
Fmt fmt = $format ("CSet_CWord {");
for (Integer j = 0; j < ways_per_cset; j = j + 1) begin
if (j != 0)
fmt = fmt + $format (", ");
fmt = fmt + $format ("%0h", cset_cword [j]);
end
fmt = fmt + $format ("}");
return fmt;
endfunction
// ================================================================
// Choose a victim for eviction
// TODO: improve this, to a per-cset round-robin, or LRU, ...
function Way_in_CSet fn_incr_way (Way_in_CSet w);
// The extend/truncate trickery below is because Way_in_CSet could
// be Bit #(0) (in direct-mapped case). for which the '1' in the
// '+ 1' expr below is not a valid literal. Extend/truncate here
// allows +1 to occur at a minimum of Bit #(1).
Bit #(TAdd #(1, Bits_per_Way_in_CSet)) tmp = extend (w);
tmp = tmp + 1;
Way_in_CSet new_way = truncate (tmp);
return new_way;
endfunction
function Way_in_CSet fv_choose_victim_way (CSet_Meta cset_meta,
Way_in_CSet old_way);
// ----------------
// Pick a victim 'way'
// Start by looking for an EMPTY way
Bool victim_found = False;
Way_in_CSet victim_way = 0;
for (Integer way = 0; way < ways_per_cset; way = way + 1) begin
Bool is_empty = (cset_meta [way].state == META_INVALID);
if ((! victim_found) && is_empty) begin
victim_found = True;
victim_way = fromInteger (way);
end
end
// If no EMPTY way found, increment old_way.
// Note: this victim may be SHARED or MODIFIED.
if (! victim_found)
victim_way = fn_incr_way (old_way);
return victim_way;
endfunction
// ================================================================
// Help functions for RAM access
// ----------------------------------------------------------------
// RAM read-output hit/miss info
typedef struct {
Bool hit;
Bit #(64) data; // valid if hit
Way_in_CSet way; // valid if hit, for subsequent updates
// Assertion error if multi-way hit (at most one way should hit)
Bool multi_way_hit;
} Hit_Miss_Info
deriving (Bits, Eq, FShow);
// ----------------------------------------------------------------
// Update a byte, halfword, word or doubleword in a CWord at Way in a CSet_CWord
function CSet_CWord fn_update_cset_cword (CSet_CWord old_cset_cword,
Way_in_CSet way,
Bit #(n) addr,
Bit #(3) f3,
Bit #(64) cword);
let old_cword = old_cset_cword [way];
let old_B0 = old_cword [7:0];
let old_B1 = old_cword [15:8];
let old_B2 = old_cword [23:16];
let old_B3 = old_cword [31:24];
let old_B4 = old_cword [39:32];
let old_B5 = old_cword [47:40];
let old_B6 = old_cword [55:48];
let old_B7 = old_cword [63:56];
let new_cset_cword = old_cset_cword;
let new_cword = old_cword;
Bit #(3) addr_lsbs = addr [2:0];
// Replace relevant bytes in new_cword
case (f3)
f3_SB: case (addr_lsbs)
'h0 : new_cword [ 7:0 ] = cword [7:0];
'h1 : new_cword [15:8 ] = cword [7:0];
'h2 : new_cword [23:16] = cword [7:0];
'h3 : new_cword [31:24] = cword [7:0];
'h4 : new_cword [39:32] = cword [7:0];
'h5 : new_cword [47:40] = cword [7:0];
'h6 : new_cword [55:48] = cword [7:0];
'h7 : new_cword [63:56] = cword [7:0];
endcase
f3_SH: case (addr_lsbs)
'h0 : new_cword [15:0 ] = cword [15:0];
'h2 : new_cword [31:16] = cword [15:0];
'h4 : new_cword [47:32] = cword [15:0];
'h6 : new_cword [63:48] = cword [15:0];
endcase
f3_SW: case (addr_lsbs)
'h0 : new_cword [31:0] = cword [31:0];
'h4 : new_cword [63:32] = cword [31:0];
endcase
f3_SD: new_cword = cword;
endcase
new_cset_cword [way] = new_cword;
return new_cset_cword;
endfunction: fn_update_cset_cword
// ================================================================
// MODULE IMPLEMENTATION
(* synthesize *)
module mkCache #(parameter Bit #(3) verbosity)
(Cache_IFC);
// 0: quiet; 1: rules; 2: loop iterations
// Integer verbosity = 2;
Reg #(FSM_State) rg_fsm_state <- mkReg (FSM_INITIALIZE);
// After a writeback, we may refill (for mem ops) or leave cache empty (flushes)
// FSM_REFILL_START or FSM_IDLE
Reg #(FSM_State) rg_writeback_sequel <- mkRegU;
// The address of the current request.
Reg #(WordXL) rg_va <- mkRegU; // Virtual addr, used to probe the cache
Reg #(PA) rg_pa <- mkRegU; // Physical addr, 1 cycle later and sustained
Wire #(PA) dw_pa <- mkDWire (rg_pa); // Physical addr on 'mav_request_pa', else rg_pa
// Cache RAMs
// Port A used for the main hit/miss path (for MMU_Cache client)
// Port B is used for writebacks and refills (to/from main memory)
// Meta-data RAM
BRAM_DUAL_PORT #(CSet_in_Cache,
CSet_Meta) ram_cset_meta <- mkBRAMCore2 (csets_per_cache,
bram_with_output_reg);
// Data RAM
// Note: a cset_cword is addressed by { cset_in_cache, cword_in_cline },
BRAM_DUAL_PORT #(CSet_CWord_in_Cache,
CSet_CWord) ram_cset_cword <- mkBRAMCore2 (cset_cwords_per_cache,
bram_with_output_reg);
// ----------------
// Reservation regs for AMO LR/SC (Load-Reserved/Store-Conditional)
`ifdef ISA_A
Reg #(Bool) rg_lrsc_valid <- mkReg (False);
Reg #(PA) rg_lrsc_pa <- mkRegU; // Phys. address for an active LR
Reg #(MemReqSize) rg_lrsc_size <- mkRegU;
`endif
// ----------------
// State for choosing next eviction victim
// TODO: this cache-global state be replaced by per-set state (e.g., LRU, random, ...)
Reg #(Way_in_CSet) rg_victim_way <- mkReg (0);
// ----------------
// Loop-control index registers
// These are used to loop over csets, ways, and cword-in-lines.
Reg #(CSet_in_Cache) rg_cset_in_cache <- mkReg (0); // ready for initialization loop
Reg #(CWord_in_CLine) rg_cword_in_cline <- mkRegU;
Reg #(Way_in_CSet) rg_way_in_cset <- mkRegU;
// Record if there was a fabric error during any beats of a refill
Reg #(Bool) rg_error_during_refill <- mkRegU;
// ----------------
// Memory interface (for refills, writebacks)
FIFOF #(Line_Req) f_line_reqs <- mkFIFOF;
FIFOF #(Bit #(64)) f_write_data <- mkFIFOF;
FIFOF #(Read_Data) f_read_data <- mkFIFOF;
// ****************************************************************
// ****************************************************************
// BEHAVIOR: RAM Port A outputs continuously indicate hit/miss
// based on address request on port A and tag-match with physical
// address dw_pa. Request is at cset_in_cache address derived from
// virtual address.
// ----------------
// Continuous values derived from rg_va
let va_cset_in_cache = fn_Addr_to_CSet_in_Cache (rg_va);
let va_cword_in_cline = fn_Addr_to_CWord_in_CLine (rg_va);
let va_cset_cword_in_cache = fn_Addr_to_CSet_CWord_in_Cache (rg_va);
// ----------------
// Continuous output values from RAM ports A
let ram_A_cset_meta = ram_cset_meta.a.read;
let ram_A_cset_cword = ram_cset_cword.a.read;
// ----------------
// Hit/Miss is a pure combinational function of the B-outputs of
// the RAMs (current cache set) and the phys addr (tag-match)
function Hit_Miss_Info fv_ram_A_hit_miss (PA pa);
Bool hit = False;
Bool multi_way_hit = False;
Way_in_CSet way_hit = 0;
Bit #(64) cword = 0;
CTag pa_ctag = fn_PA_to_CTag (pa);
for (Integer way = 0; way < ways_per_cset; way = way + 1) begin
let hit_at_way = ( (ram_A_cset_meta [way].state != META_INVALID)
&& (ram_A_cset_meta [way].ctag == pa_ctag));
if (hit && hit_at_way) multi_way_hit = True;
let cword_at_way = ram_A_cset_cword [way];
hit = hit || hit_at_way;
if (hit_at_way) way_hit = fromInteger (way);
cword = (cword | (cword_at_way & pack (replicate (hit_at_way))));
end
return Hit_Miss_Info {hit: hit,
data: cword,
way: way_hit, // For possible subsequent update
multi_way_hit: multi_way_hit}; // Assertion error if true
endfunction
// ****************************************************************
// ****************************************************************
// Request RAMs (on request methods, and when returning to IDLE
// after refills.
function Action fa_req_rams_A (WordXL va);
action
// Request meta RAM
let cset_in_cache = fn_Addr_to_CSet_in_Cache (va);
ram_cset_meta.a.put (bram_cmd_read, cset_in_cache, ?);
// Request data RAM
let cset_cword_in_cache = fn_Addr_to_CSet_CWord_in_Cache (va);
ram_cset_cword.a.put (bram_cmd_read, cset_cword_in_cache, ?);
if (verbosity >= 2)
$display (" fa_request_va %0h cset_in_cache %0h, cset_cword_in_cache %0h",
va, cset_in_cache, cset_cword_in_cache);
endaction
endfunction
// ****************************************************************
// ****************************************************************
// Write actions on a cache hit
function Action fa_write (PA pa, Bit #(3) f3, Bit #(64) st_value);
action
let hit_miss_info = fv_ram_A_hit_miss (pa);
let way = hit_miss_info.way;
// Assert: current mv_response is SHARED/MODIFIED
// Writes data into that currently probed cache line
if (! hit_miss_info.hit)
begin
$display ("%0d: %m.fa_write: INTERNAL_ERROR", cur_cycle);
$display (" va_cset_cword_in_cache %0h way %0d pa %0h f3 %0d st_value %0h",
va_cset_cword_in_cache, way, pa, f3, st_value);
$display (" Cache write on a miss (need SHARED/MODIFIED)");
$finish (1);
end
// Update cache line data
let new_cset_cword = fn_update_cset_cword (ram_A_cset_cword,
way,
pa,
f3,
st_value);
ram_cset_cword.b.put (bram_cmd_write, va_cset_cword_in_cache, new_cset_cword);
if (verbosity >= 1) begin
$display (" cache.fa_write: va_cset_cword_in_cache %0h way %0d pa %0h f3 %0d st_value %0h",
va_cset_cword_in_cache, way, pa, f3, st_value);
$display (" from: ", fshow_cset_cword (ram_A_cset_cword));
$display (" to: ", fshow_cset_cword (new_cset_cword));
end
// Update cache meta info to MODIFIED
let new_cset_meta = ram_A_cset_meta;
new_cset_meta [way] = Meta {state: META_MODIFIED, ctag: fn_PA_to_CTag (pa)};
ram_cset_meta.b.put (bram_cmd_write, va_cset_in_cache, new_cset_meta);
endaction
endfunction
// ****************************************************************
// ****************************************************************
// BEHAVIOR: CACHE-LINE WRITEBACK (preceding refills, and for flushes)
// These rules are a "subroutine" to writeback a cache line
// - in normal cache operation (writeback before refill)
// - in flush operations (writeback and stay empty)
// rg_writeback_sequel specifies fsm state after writeback.
//
// function fa_cache_writeback_loop_prequel is called before rl_writeback_loop
// Preconditions:
// - ram_cset_meta.b has been requested for target cset_in_cache
function Action fa_cache_writeback_loop_prequel (CSet_in_Cache cset_in_cache,
Way_in_CSet way_in_cset);
action
if (verbosity >= 1)
$display (" fa_cache_writeback_loop_prequel: cset %0h, way %0h",
cset_in_cache, way_in_cset);
// Send write-burst request to mem
Byte_in_CLine byte_in_cline = 0;
PA wb_cline_pa = {ram_cset_meta.a.read [way_in_cset].ctag,
cset_in_cache,
byte_in_cline };
f_line_reqs.enq (Line_Req {is_read: False, addr: zeroExtend (wb_cline_pa)});
if (verbosity >= 1)
$display (" line addr: %0h", wb_cline_pa);
// Request data RAM A for first CSet_CWord for this line
CWord_in_CLine cword_in_cline = 0;
CSet_CWord_in_Cache cset_cword_in_cache = { cset_in_cache, cword_in_cline };
ram_cset_cword.a.put (bram_cmd_read, cset_cword_in_cache, ?);
rg_cword_in_cline <= 0;
endaction
endfunction
// ----------------
// rl_writeback_loop:
// Assume proper setup of loop index regs and rg_writeback_sequel
// and that a cword_cset has been requested from data RAM B
rule rl_writeback_loop (rg_fsm_state == FSM_WRITEBACK_LOOP);
// Writeback a cword
CSet_CWord cset_cword = ram_cset_cword.a.read;
Bit #(64) cword = cset_cword [rg_way_in_cset];
f_write_data.enq (cword);
if ( ((verbosity >= 1) && (rg_cword_in_cline == 0))
|| (verbosity >= 2))
$display ("%0d: %m.rl_writeback_loop [cset %0h way %0h cword %0h] data %0h",
cur_cycle, rg_cset_in_cache, rg_way_in_cset, rg_cword_in_cline, cword);
// If last cset_cword in cline, return to continuation
Bool last = (rg_cword_in_cline == fromInteger (cwords_per_cline - 1));
if (last) begin
rg_fsm_state <= rg_writeback_sequel;
if (verbosity >= 1)
$display ("%0d: %m.rl_writeback_loop: done; goto ", cur_cycle, fshow (rg_writeback_sequel));
end
else begin
// Request next cset_cword from data RAM B to be written back and increment index
CWord_in_CLine cword_in_cline = rg_cword_in_cline + 1;
CSet_CWord_in_Cache cset_cword_in_cache = { rg_cset_in_cache, cword_in_cline };
ram_cset_cword.a.put (bram_cmd_read, cset_cword_in_cache, ?);
rg_cword_in_cline <= cword_in_cline;
if (verbosity >= 2)
$display (" Requested cword_in_cline %0d", cword_in_cline);
end
endrule
// ****************************************************************
// ****************************************************************
// BEHAVIOR: REPLACEMENT
// On a miss, do a replace (cache-line writeback followed by refill)
rule rl_replace (rg_fsm_state == FSM_REPLACE_START);
if (verbosity >= 1)
$display ("%0d: %m.rl_replace", cur_cycle);
let victim_way = fv_choose_victim_way (ram_A_cset_meta, rg_victim_way);
// Record state, for future victim selection
rg_victim_way <= victim_way;
// Initialize loop-control index regs
rg_cset_in_cache <= va_cset_in_cache;
rg_way_in_cset <= victim_way;
if (ram_A_cset_meta [victim_way].state == META_MODIFIED) begin
if (verbosity >= 1)
$display (" Writeback needed: loop prequel: cset %0h way %0h",
va_cset_in_cache, victim_way);
fa_cache_writeback_loop_prequel (va_cset_in_cache, victim_way);
rg_fsm_state <= FSM_WRITEBACK_LOOP;
rg_writeback_sequel <= FSM_REFILL_START;
end
else begin
if (verbosity >= 1)
$display (" Writeback not needed: start refill: cset %0h way %0h",
va_cset_in_cache, victim_way);
rg_fsm_state <= FSM_REFILL_START;
end
endrule
// ================================================================
// CACHE-LINE REFILLS
// Start cache-line refill loop only when no write-responses are
// outstanding (to avoid dealing with out-of-order read/write
// paths through the fabric).
// Send burst request into fabric for cache line.
// Update meta-data.
// Assume rg_cset_in_cache has been initialized.
rule rl_refill_start (rg_fsm_state == FSM_REFILL_START);
if (verbosity >= 1)
$display ("%0d: %m.rl_refill_start: cset %0h way %0h", cur_cycle,
rg_cset_in_cache, rg_way_in_cset);
// Update meta-data to SHARED, optimistically.
// If any bus response during the refill is an error-response,
// we'll change the meta-data to INVALID at the end of the refill.
let new_ram_A_cset_meta = ram_A_cset_meta;
new_ram_A_cset_meta [rg_way_in_cset] = Meta {state: META_SHARED,
ctag: fn_PA_to_CTag (rg_pa)};
ram_cset_meta.b.put (bram_cmd_write, va_cset_in_cache, new_ram_A_cset_meta);
// Send read-burst request into fabric for full cache line
PA cline_pa = fn_align_Addr_to_CLine (rg_pa);
f_line_reqs.enq (Line_Req {is_read: True, addr: zeroExtend (cline_pa)});
// Request read of first CSet_CWord in CLine (BRAM port B)
// for cset_cword read-modify-write
let cword_in_cline = 0;
CSet_CWord_in_Cache cset_cword_in_cache = { rg_cset_in_cache, cword_in_cline };
ram_cset_cword.a.put (bram_cmd_read, cset_cword_in_cache, ?);
// Enter cache refill loop, awaiting refill responses from mem
// Note: loop-control index regs rg_cset_in_cache and rg_way_in_cset
// were initialized in rl_writeback_start, whether or not
// a writeback was needed.
rg_cword_in_cline <= 0;
rg_error_during_refill <= False;
rg_fsm_state <= FSM_REFILL_LOOP;
if (verbosity >= 2) begin
$display (" Requesting line at mem addr %0h", cline_pa);
$display (" Requesting ram_cset_cword.a: cword-in-cache: 0x%0h", cset_cword_in_cache);
$display (" goto FSM_REFILL_LOOP");
end
endrule: rl_refill_start
// ----------------------------------------------------------------
// Loop that receives responses from the fabric with fabric-words of the cline (from mem).
// Update cword in cset_cword ram, and
// initiate read of next cset_cword from ram.
// On last cword, update meta state to SHARED (normal case)
// or INVALID (if there was a fabric error on refill).
rule rl_refill_loop (rg_fsm_state == FSM_REFILL_LOOP);
if ( (verbosity >= 2)
|| ((verbosity >= 1) && (rg_cword_in_cline == 0)))
begin
$display ("%0d: %m.rl_refill_loop", cur_cycle);
$display (" set 0x%0h way %0d word %0d",
rg_cset_in_cache, rg_way_in_cset, rg_cword_in_cline);
end
let read_data <- pop (f_read_data);
if (verbosity >= 2)
$display (" mem rsp: ok %0d data %0h", pack (read_data.ok), read_data.data);
// Bus errors; remember it, and handle after all the refill responses
if ((! read_data.ok) && (verbosity >= 2))
$display (" Fabric ERROR in load-response");
Bool err = (! read_data.ok) || rg_error_during_refill;
rg_error_during_refill <= err;
// Update the CSet_CWord (BRAM port B) (if this response was not an error)
if (! err) begin
let new_cset_cword = ram_cset_cword.a.read;
new_cset_cword [rg_way_in_cset] = read_data.data;
let cset_cword_in_cache = { va_cset_in_cache, rg_cword_in_cline };
ram_cset_cword.b.put (bram_cmd_write, cset_cword_in_cache, new_cset_cword);
end
Bool last_cword_in_cline = (rg_cword_in_cline == fromInteger (cwords_per_cline - 1));
if (last_cword_in_cline) begin
if (verbosity >= 1)
$display ("%0d: %m.rl_refill_loop: done", cur_cycle);
// If error during refill, update cset meta-data to INVALID
if (err) begin
let new_ram_A_cset_meta = ram_A_cset_meta;
new_ram_A_cset_meta [rg_way_in_cset] = Meta {state: META_INVALID,
ctag: fn_PA_to_CTag (rg_pa)};
ram_cset_meta.b.put (bram_cmd_write, va_cset_in_cache, new_ram_A_cset_meta);
if (verbosity >= 1)
$display (" Setting meta-data to INVALID (err during refill)");
end
// Re-request the cset from the RAMs.
// Except: if the memory request is for the last
// cword-in-cline (which is written in this rule) re-request
// after a 1-cycle delay to allow this write to propagate in
// the SRAM.
if (va_cword_in_cline == fromInteger (cwords_per_cline - 1))
rg_fsm_state <= FSM_REFILL_FINAL_DELAY;
else begin
fa_req_rams_A (rg_va);
rg_fsm_state <= FSM_IDLE;
end
end
else begin
// Not last cword in line; initiate RAM read for next cword_set
let next_cword_in_cline = rg_cword_in_cline + 1;
let next_cset_cword_in_cache = { va_cset_in_cache, next_cword_in_cline };
ram_cset_cword.a.put (bram_cmd_read, next_cset_cword_in_cache, ?);
rg_cword_in_cline <= next_cword_in_cline;
if (verbosity >= 2)
$display (" Requesting ram_cset_cword.a cword-in-cache: 0x%0h", next_cset_cword_in_cache);
end
endrule: rl_refill_loop
rule rl_refill_loop_final (rg_fsm_state == FSM_REFILL_FINAL_DELAY);
if (verbosity >= 1)
$display ("%0d: %m.rl_refill_loop_final; re-request RAM", cur_cycle);
fa_req_rams_A (rg_va);
rg_fsm_state <= FSM_IDLE;
endrule
// ****************************************************************
// ****************************************************************
// BEHAVIOR: FLUSH
// Visits all lines, writing back those that are MODIFIED.
// If flush_req is 0, new meta-state is INVALID
// If flush_req is 1, new meta-state is SHARED
FIFOF #(Bit #(1)) f_flush_reqs <- mkFIFOF;
FIFOF #(Token) f_flush_rsps <- mkFIFOF;
Bool last_cset_and_way = ( (rg_cset_in_cache == fromInteger (csets_per_cache - 1))
&& (rg_way_in_cset == fromInteger (ways_per_cset - 1)));
// New meta state is SHARED or INVALID, depending on type of flush required
Reg #(Meta_State) rg_new_meta_state <- mkRegU;
// This reg holds the current cset_meta as we iterate across its associative ways
Reg #(CSet_Meta) rg_new_cset_meta <- mkRegU;
rule rl_flush_start (rg_fsm_state == FSM_IDLE);
if (verbosity >= 1)
$display ("%0d: %m.rl_flush_start", cur_cycle);
let new_state_code <- pop (f_flush_reqs);
rg_cset_in_cache <= 0;
rg_way_in_cset <= 0;
rg_new_meta_state <= ((new_state_code == 0) ? META_INVALID : META_SHARED);
rg_fsm_state <= FSM_FLUSH_LOOP;
// Initiate RAM read of first CSet
ram_cset_meta.a.put (bram_cmd_read, 0, ?);
endrule
function Action fa_incr_flush_loop_indexes;
action
if (rg_way_in_cset == fromInteger (ways_per_cset - 1)) begin
// This cset done; move to next cset, way 0
let next_cset_in_cache = rg_cset_in_cache + 1;
rg_way_in_cset <= 0;
rg_cset_in_cache <= next_cset_in_cache;
// Initiate read of next CSet
ram_cset_meta.a.put (bram_cmd_read, next_cset_in_cache, ?);
end
else
// This way done, move to next way in this cset
rg_way_in_cset <= rg_way_in_cset + 1;
endaction
endfunction
// This rule loops over all csets and ways, writing back any modified
// lines and marking all lines EMPTY.
// Uses rl_writeback_loop as a subroutine to writeback modified lines.
rule rl_flush_loop ( (rg_fsm_state == FSM_FLUSH_LOOP)
&& (rg_cset_in_cache <= fromInteger (csets_per_cache - 1))
&& (rg_way_in_cset <= fromInteger (ways_per_cset - 1)));
if (verbosity >= 1)
$display ("%0d: %m.rl_flush_loop: line [cset %0x, way %0d]",
cur_cycle, rg_cset_in_cache, rg_way_in_cset);
// Update line state
let old_cset_meta = ((rg_way_in_cset == 0) ? ram_cset_meta.a.read : rg_new_cset_meta);
let old_meta = old_cset_meta [rg_way_in_cset];
let new_meta = Meta {state: rg_new_meta_state, ctag: old_meta.ctag};
let new_cset_meta = old_cset_meta;
new_cset_meta [rg_way_in_cset] = new_meta;
rg_new_cset_meta <= new_cset_meta;
if (verbosity >= 1) begin
$display (" Updating cset_meta:");
$display (" Old: ", fshow_cset_meta (rg_cset_in_cache, old_cset_meta));
$display (" New: ", fshow_cset_meta (rg_cset_in_cache, new_cset_meta));
end
let line_state = old_meta.state;
if (line_state == META_MODIFIED) begin
if (verbosity >= 2) begin
$display (" MODIFIED; writeback");
$display ("%0d: %m.rl_flush_loop: writeback line [cset %0x, way %0d]",
cur_cycle, rg_cset_in_cache, rg_way_in_cset);
end
// Prepare for 'writeback-loop' (start burst-write request, etc.)
fa_cache_writeback_loop_prequel (rg_cset_in_cache, rg_way_in_cset);
// Invoke 'writeback-loop' subroutine for this [cset][way],
rg_writeback_sequel <= FSM_FLUSH_LOOP_WRITEBACK_SEQUEL;
rg_fsm_state <= FSM_WRITEBACK_LOOP;
end
else begin // EMPTY or SHARED
if (verbosity >= 2)
$display (" Line cstate: ", fshow (line_state));
// Write new cset_meta back if it's the last way in this set
if (rg_way_in_cset == fromInteger (ways_per_cset - 1))
ram_cset_meta.b.put (bram_cmd_write, rg_cset_in_cache, new_cset_meta);
if (last_cset_and_way) begin
// Respond ack to requestor and goto IDLE
f_flush_rsps.enq (?);
rg_fsm_state <= FSM_IDLE;
if (verbosity >= 2)
$display ("%0d: %m.rl_flush_loop: done; goto IDLE", cur_cycle);
end
else begin
fa_incr_flush_loop_indexes;
end
end
endrule
rule rl_flush_loop_writeback_sequel (rg_fsm_state == FSM_FLUSH_LOOP_WRITEBACK_SEQUEL);
// Write new cset_meta back if it's the last way in this set
if (rg_way_in_cset == fromInteger (ways_per_cset - 1))
ram_cset_meta.b.put (bram_cmd_write, rg_cset_in_cache, rg_new_cset_meta);
if (last_cset_and_way) begin
// Respond ack to requestor and goto IDLE
f_flush_rsps.enq (?);
fa_req_rams_A (rg_va);
rg_fsm_state <= FSM_IDLE;
if (verbosity >= 1)
$display ("%0d: %m.rl_flush_writeback_sequel; flush loop done; goto IDLE", cur_cycle);
end
else begin
fa_incr_flush_loop_indexes;
rg_fsm_state <= FSM_FLUSH_LOOP;
if (verbosity >= 1)
$display ("%0d: %m.rl_flush_writeback_sequel; continue", cur_cycle);
end
endrule
// ****************************************************************
// ****************************************************************
// BEHAVIOR: INITIALIZING AFTER RESET
// ****************************************************************
// ****************************************************************
// This rule loops over csets, setting state of each cline in the set to INVALID
// Assumes rg_cset_in_cache resets to 0
rule rl_initialize (rg_fsm_state == FSM_INITIALIZE);
let meta = Meta { state: META_INVALID, ctag: ? };
ram_cset_meta.a.put (bram_cmd_write, rg_cset_in_cache, replicate (meta));
if (rg_cset_in_cache == fromInteger (csets_per_cache - 1)) begin
rg_fsm_state <= FSM_IDLE;
$display ("%0d: INFO: %m.rl_initialize", cur_cycle);
$display (" Size %0d KB, Associativity %0d, Line size %0d bytes (= %0d XLEN words)",
kb_per_cache, ways_per_cset, (cwords_per_cline * 8),
`ifdef RV32
(cwords_per_cline * 2)
`else
(cwords_per_cline * 1)
`endif
);
if (verbosity >= 1)
$display (" All lines (%0d sets %0d ways) initialized to INVALID",
cur_cycle, csets_per_cache, ways_per_cset);
end
rg_cset_in_cache <= rg_cset_in_cache + 1;
endrule
// ****************************************************************
// ****************************************************************
// INTERFACE
// This starts a new request (with virt addr)
// while the virt addr is being translated to a phys addr
method Action ma_request_va (WordXL va); // if (rg_fsm_state == FSM_IDLE);
fa_req_rams_A (va);
rg_va <= va;
rg_error_during_refill <= False;
if (verbosity >= 1)
$display ("%0d: %m.ma_request_va: %0h", cur_cycle, va);
endmethod
// This completes a new request with the phys addr
method ActionValue #(Cache_Result)
mav_request_pa (MMU_Cache_Req req, PA pa)
if ((rg_fsm_state == FSM_IDLE) && (! f_flush_reqs.notEmpty));
actionvalue
Cache_Result result = ?;
rg_pa <= pa;
let hit_miss_info = fv_ram_A_hit_miss (pa);
let data = fv_from_byte_lanes (zeroExtend (req.va), req.f3 [1:0], hit_miss_info.data);
data = fv_extend (req.f3, data);
if (hit_miss_info.multi_way_hit) begin
// Assertion failure: # cannot match more than 1 item in a set
$display ("%0d: %m.mav_request_pa: INTERNAL ERROR", cur_cycle);
$display (" ", fshow (req.op), " va %0h pa %0h", req.va, pa);
$display (" # of hits in set > 1 (should be 0 or 1)");
$display (fshow_cset_meta (fn_Addr_to_CSet_in_Cache (rg_va), ram_A_cset_meta));
$finish (1);
end
if (! hit_miss_info.hit) begin
if (verbosity >= 1) begin
$display ("%0d: %m.mav_request_pa: MISS: va %0h pa %0h", cur_cycle, req.va, pa);
$display (" Starting replacement");
end
rg_fsm_state <= FSM_REPLACE_START;
result = Cache_Result {outcome: CACHE_MISS,
final_ld_val: ?,
final_st_val: ?};
`ifdef ISA_A
// If the line being replaced contains the LRSC reserved addr,
// cancel the reservation.
Bool cancel = (hit_miss_info.hit
&& (ram_A_cset_meta [hit_miss_info.way].ctag == fn_PA_to_CTag (rg_lrsc_pa)));
if (cancel)
rg_lrsc_valid <= False;
`endif
end
else begin
// Hit
// Load
if (req.op == CACHE_LD) begin
if (verbosity >= 1)
$display ("%0d: %m.mav_request_pa: Load-hit: va %0h pa %0h data %0h",
cur_cycle, req.va, pa, data);
result = Cache_Result {outcome: CACHE_READ_HIT, final_ld_val: data, final_st_val:?};
end
// Store
else if (req.op == CACHE_ST) begin
if (verbosity >= 1)
$display ("%0d: %m.mav_request_pa: Store-hit: va %0h pa %0h data %0h",
cur_cycle, req.va, pa, req.st_value);
fa_write (pa, req.f3, req.st_value);
result = Cache_Result {outcome: CACHE_WRITE_HIT, final_ld_val: 0, final_st_val: req.st_value};
`ifdef ISA_A
// Cancel LR/SC reservation if this store is for this addr
// TODO: should we cancel it on ANY store?
if (rg_lrsc_pa == pa)
rg_lrsc_valid <= False;
`endif
end
`ifdef ISA_A
// AMO LR
else if (fv_is_AMO_LR (req)) begin
if (verbosity >= 1)
$display ("%0d: %m.mav_request_pa: LR-hit: va %0h pa %0h data %0h",
cur_cycle, req.va, pa, data);
rg_lrsc_valid <= True;
rg_lrsc_pa <= pa;
rg_lrsc_size <= req.f3 [1:0];
result = Cache_Result {outcome: CACHE_READ_HIT, final_ld_val: data, final_st_val: ?};
end
// AMO SC
else if (fv_is_AMO_SC (req)) begin
if (rg_lrsc_valid && (rg_lrsc_pa == pa)) begin
if (verbosity >= 1)
$display ("%0d: %m.mav_request_pa: SC-hit and success: va %0h pa %0h data %0h",
cur_cycle, req.va, pa, req.st_value);
rg_lrsc_valid <= False;
fa_write (pa, req.f3, req.st_value);
result = Cache_Result {outcome: CACHE_WRITE_HIT,
final_ld_val: 0, // SC success
final_st_val: req.st_value};
end
else begin
if (verbosity >= 1)
$display ("%0d: %m.mav_request_pa: SC-hit and fail: va %0h pa %0h data %0h",
cur_cycle, req.va, pa, req.st_value);
result = Cache_Result {outcome: CACHE_READ_HIT,
final_ld_val: 1, // SC fail
final_st_val: 0};
end
end
// All AMO read-modify-writes (i.e., AMO other than LR and SC)
else begin
dynamicAssert ((req.op == CACHE_AMO), "Cache: expecting AMO op here");
Fmt fmt_op = fshow_f5_AMO_op (req.amo_funct7 [6:2]);
if (verbosity >= 1) begin
$display ("%0d: %m.mav_request_pa: f3 %3b AMO ", cur_cycle, req.f3, fmt_op);
$display (" va %0h pa %0h rs2_val %0h", req.va, pa, req.st_value);
$display (" Cache cword %0h, load-result %0h", hit_miss_info.data, hit_miss_info.data);
end
let size_code = req.f3 [1:0];
let cache_data = fv_from_byte_lanes (zeroExtend (req.va), size_code, hit_miss_info.data);
// Do the AMO op on the loaded value and the store value
match {.new_ld_val,
.new_st_val} = fv_amo_op (size_code, req.amo_funct7 [6:2], cache_data, req.st_value);
if (verbosity >= 1)
$display (" ", fmt_op, " (%0h, %0h) -> %0h", cache_data, req.st_value, new_st_val);
fa_write (pa, req.f3, new_st_val);
result = Cache_Result {outcome: CACHE_WRITE_HIT,
final_ld_val: new_ld_val,
final_st_val: new_st_val};
// Cancel LR/SC reservation if this store is for this addr
if (rg_lrsc_pa == pa)
rg_lrsc_valid <= False;
end
`endif
end
return result;
endactionvalue
endmethod
// ----------------
// Stalls until refill done and then returns ok (True) or error (False)
method Bool mv_refill_ok () if (rg_fsm_state == FSM_IDLE);
return (! rg_error_during_refill);
endmethod
// ----------------
// Flushes
interface Server flush_server = toGPServer (f_flush_reqs, f_flush_rsps);
// ----------------
// Memory interface (for refills, writebacks)
interface Get g_mem_req = toGet (f_line_reqs);
interface Get g_write_data = toGet (f_write_data);
interface Put p_mem_read_data = toPut (f_read_data);
endmodule
// ================================================================
endpackage
| Bluespec | 5 | faddat/Flute | src_Core/Near_Mem_VM_WB_L1/Cache.bsv | [
"Apache-2.0"
] |
"""Tests for the dte_energy_bridge component."""
| Python | 0 | domwillcode/home-assistant | tests/components/dte_energy_bridge/__init__.py | [
"Apache-2.0"
] |
vcl 4.1;
acl invalidators {
"127.0.0.1";
}
sub vcl_recv {
if (req.method == "PURGE") {
if (!client.ip ~ invalidators) {
return (synth(405, "Not allowed"));
}
return (purge);
}
}
backend default {
.host = "nginx";
.port = "80";
}
| VCL | 4 | B-Galati/http-broadcast | examples/docker/varnish/files/etc/varnish/default.vcl | [
"MIT"
] |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "67c2d127-c955-4313-b7d2-c584f037f85b",
"metadata": {},
"outputs": [],
"source": [
"import syft as sy\n",
"sy.logger.remove()\n",
"import numpy as np\n",
"data = sy.Tensor(np.array([1,2,3],dtype=np.int32))"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "aa74bb27-e8aa-404b-a32f-cdff0c36390b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Connecting to http://localhost:8081... done! \t Logging into jolly_schmidhuber... done!\n",
"Connecting to http://localhost:8082... done! \t Logging into amazing_bengio... done!\n",
"Connecting to http://localhost:8083... done! \t Logging into quirky_brockman... done!\n"
]
}
],
"source": [
"gryffindor = sy.login(email=\"info@openmined.org\",password=\"changethis\",port=\"8081\")\n",
"slytherin = sy.login(email=\"info@openmined.org\",password=\"changethis\",port=\"8082\")\n",
"hufflepuff = sy.login(email=\"info@openmined.org\",password=\"changethis\",port=\"8083\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c85840d0-a2d0-4988-94fc-5a233672aa81",
"metadata": {},
"outputs": [],
"source": [
"tensor_1 = data.send(gryffindor)\n",
"tensor_2 = data.send(slytherin)\n",
"tensor_3 = data.send(hufflepuff)"
]
},
{
"cell_type": "markdown",
"id": "10d307ac-ea31-46a4-8c4b-2789b38e41b6",
"metadata": {},
"source": [
"During Private Multiplication , we require the parties to be able to communicate with each other.\n",
"We make sure that our Actions are **Idempotent** and **Atomic** such that when a given action is not able to execute, it requeues itself to the back of the queue.\n",
"\n",
"We set a maximum amount of retries,until eventually failing, when one of the parties nodes are not able to send their intermediate results.\n",
"\n",
"We also create proxy clients with minimal permissions such that the parties are able to communicate with each other.\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "9bcebd23-bdef-42bb-bbdb-5b3d750d5785",
"metadata": {},
"outputs": [],
"source": [
"out = tensor_1 + tensor_2"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "ea95aebc-3bfa-4880-9a56-999d90aa7a64",
"metadata": {},
"outputs": [],
"source": [
"out2 = out > 3"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6f7d43b9-66ee-43a4-916a-7b4926a8f61b",
"metadata": {},
"outputs": [],
"source": [
"out2.block.reconstruct()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "5fd152fd-a162-4995-b85c-3401b79744ef",
"metadata": {},
"outputs": [],
"source": [
"mpc_1 = tensor_1 * tensor_2\n",
"mpc_2 = tensor_2 * tensor_3\n",
"mpc = mpc_1 * mpc_2 * 3"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "06322e2c-bc06-4f97-89e8-db930dcd3384",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 7, 11, 15], dtype=int32)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mpc.block.reconstruct()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "dc5f4447-a857-413c-96e7-a2be7b4416e4",
"metadata": {},
"outputs": [],
"source": [
"mpc_1 = tensor_1 + tensor_2\n",
"mpc_2 = tensor_2 + tensor_3\n",
"mpc3 = mpc_1 + mpc_2 + 3"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "80d607a9-a09d-4012-89eb-402e3b5852f3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 7, 11, 15], dtype=int32)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mpc3.block.reconstruct()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "af5e56e5-2759-4b10-866b-2c72fe29340a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
| Jupyter Notebook | 4 | jackbandy/PySyft | notebooks/smpc/Private Mul Tensor Abstraction.ipynb | [
"Apache-2.0"
] |
=pod
=head1 NAME
ossl_cmp_ctx_set1_caPubs,
ossl_cmp_ctx_set0_validatedSrvCert,
ossl_cmp_ctx_set_status,
ossl_cmp_ctx_set0_statusString,
ossl_cmp_ctx_set_failInfoCode,
ossl_cmp_ctx_set0_newCert,
ossl_cmp_ctx_set1_extraCertsIn,
ossl_cmp_ctx_set1_recipNonce
- internal functions for managing the CMP client context datastructure
=head1 SYNOPSIS
#include <openssl/cmp.h>
int ossl_cmp_ctx_set1_caPubs(OSSL_CMP_CTX *ctx, STACK_OF(X509) *caPubs);
int ossl_cmp_ctx_set0_validatedSrvCert(OSSL_CMP_CTX *ctx, X509 *cert);
int ossl_cmp_ctx_set_status(OSSL_CMP_CTX *ctx, int status);
int ossl_cmp_ctx_set0_statusString(OSSL_CMP_CTX *ctx,
OSSL_CMP_PKIFREETEXT *text);
int ossl_cmp_ctx_set_failInfoCode(OSSL_CMP_CTX *ctx, int fail_info);
int ossl_cmp_ctx_set0_newCert(OSSL_CMP_CTX *ctx, X509 *cert);
int ossl_cmp_ctx_set1_extraCertsIn(OSSL_CMP_CTX *ctx,
STACK_OF(X509) *extraCertsIn);
int ossl_cmp_ctx_set1_recipNonce(OSSL_CMP_CTX *ctx,
const ASN1_OCTET_STRING *nonce);
=head1 DESCRIPTION
ossl_cmp_ctx_set1_caPubs() copies the given stack of CA certificates
to the caPubs field of the context.
The reference counts of those certificates handled successfully are increased.
ossl_cmp_ctx_set0_validatedSrvCert() sets the validatedSrvCert of the context,
which caches any already validated server cert, or NULL if not available.
ossl_cmp_ctx_set_status() sets the status field of the context.
ossl_cmp_ctx_set0_statusString() sets the statusString field of the context.
ossl_cmp_ctx_set_failInfoCode() sets the error code bits in the failInfoCode
field of the context based on the given OSSL_CMP_PKIFAILUREINFO structure.
ossl_cmp_ctx_set0_newCert() sets the given (newly enrolled) certificate
in the context.
ossl_cmp_ctx_set1_extraCertsIn() sets the extraCertsIn field of the context.
The reference counts of those certificates handled successfully are increased.
ossl_cmp_ctx_set1_recipNonce() sets the given recipient nonce in the context.
=head1 NOTES
CMP is defined in RFC 4210 (and CRMF in RFC 4211).
=head1 RETURN VALUES
All functions return 1 on success, 0 on error.
=head1 HISTORY
The OpenSSL CMP support was added in OpenSSL 3.0.
=head1 COPYRIGHT
Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
| Pod | 4 | pmesnier/openssl | doc/internal/man3/ossl_cmp_ctx_set1_caPubs.pod | [
"Apache-2.0"
] |
SELECT * WHERE { <a><b>1.0e0 }
| SPARQL | 0 | alpano-unibz/ontop | test/sparql-compliance/src/test/resources/testcases-dawg/data-r2/syntax-sparql2/syntax-general-09.rq | [
"Apache-2.0"
] |
header {
/*
[The "BSD licence"]
Copyright (c) 2005-2008 Terence Parr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 org.antlr.grammar.v2;
import java.util.*;
import org.antlr.misc.*;
import org.antlr.tool.*;
}
class DefineGrammarItemsWalker extends TreeParser;
options {
importVocab = ANTLR;
ASTLabelType = "GrammarAST";
codeGenBitsetTestThreshold=999;
}
{
protected Grammar grammar;
protected GrammarAST root;
protected String currentRuleName;
protected GrammarAST currentRewriteBlock;
protected GrammarAST currentRewriteRule;
protected int outerAltNum = 0;
protected int blockLevel = 0;
public void reportError(RecognitionException ex) {
Token token = null;
if ( ex instanceof MismatchedTokenException ) {
token = ((MismatchedTokenException)ex).token;
}
else if ( ex instanceof NoViableAltException ) {
token = ((NoViableAltException)ex).token;
}
ErrorManager.syntaxError(
ErrorManager.MSG_SYNTAX_ERROR,
grammar,
token,
"define: "+ex.toString(),
ex);
}
protected void finish() {
trimGrammar();
}
/** Remove any lexer rules from a COMBINED; already passed to lexer */
protected void trimGrammar() {
if ( grammar.type!=Grammar.COMBINED ) {
return;
}
// form is (header ... ) ( grammar ID (scope ...) ... ( rule ... ) ( rule ... ) ... )
GrammarAST p = root;
// find the grammar spec
while ( !p.getText().equals("grammar") ) {
p = (GrammarAST)p.getNextSibling();
}
p = (GrammarAST)p.getFirstChild(); // jump down to first child of grammar
// look for first RULE def
GrammarAST prev = p; // points to the ID (grammar name)
while ( p.getType()!=RULE ) {
prev = p;
p = (GrammarAST)p.getNextSibling();
}
// prev points at last node before first rule subtree at this point
while ( p!=null ) {
String ruleName = p.getFirstChild().getText();
//System.out.println("rule "+ruleName+" prev="+prev.getText());
if ( Character.isUpperCase(ruleName.charAt(0)) ) {
// remove lexer rule
prev.setNextSibling(p.getNextSibling());
}
else {
prev = p; // non-lexer rule; move on
}
p = (GrammarAST)p.getNextSibling();
}
//System.out.println("root after removal is: "+root.toStringList());
}
protected void trackInlineAction(GrammarAST actionAST) {
Rule r = grammar.getRule(currentRuleName);
if ( r!=null ) {
r.trackInlineAction(actionAST);
}
}
}
grammar[Grammar g]
{
grammar = g;
root = #grammar;
}
: ( #( LEXER_GRAMMAR {grammar.type = Grammar.LEXER;} grammarSpec )
| #( PARSER_GRAMMAR {grammar.type = Grammar.PARSER;} grammarSpec )
| #( TREE_GRAMMAR {grammar.type = Grammar.TREE_PARSER;} grammarSpec )
| #( COMBINED_GRAMMAR {grammar.type = Grammar.COMBINED;} grammarSpec )
)
{finish();}
;
attrScope
: #( "scope" name:ID attrs:ACTION )
{
AttributeScope scope = grammar.defineGlobalScope(name.getText(),#attrs.token);
scope.isDynamicGlobalScope = true;
scope.addAttributes(attrs.getText(), ';');
}
;
grammarSpec
{
Map opts=null;
Token optionsStartToken=null;
}
: id:ID
(cmt:DOC_COMMENT)?
//(#(OPTIONS .))? // already parsed these in assign.types.g
( {optionsStartToken=((GrammarAST)_t).getToken();}
optionsSpec
)?
(delegateGrammars)?
(tokensSpec)?
(attrScope)*
(actions)?
rules
;
actions
: ( action )+
;
action
{
String scope=null;
GrammarAST nameAST=null, actionAST=null;
}
: #(amp:AMPERSAND id1:ID
( id2:ID a1:ACTION
{scope=#id1.getText(); nameAST=#id2; actionAST=#a1;}
| a2:ACTION
{scope=null; nameAST=#id1; actionAST=#a2;}
)
)
{
grammar.defineNamedAction(#amp,scope,nameAST,actionAST);
}
;
optionsSpec
: OPTIONS
;
delegateGrammars
: #( "import" ( #(ASSIGN ID ID) | ID )+ )
;
tokensSpec
: #( TOKENS ( tokenSpec )+ )
;
tokenSpec
: t:TOKEN_REF
| #( ASSIGN
t2:TOKEN_REF
( s:STRING_LITERAL
| c:CHAR_LITERAL
)
)
;
rules
: ( rule )+
;
rule
{
String mod=null;
String name=null;
Map opts=null;
Rule r = null;
}
: #( RULE id:ID {opts = #RULE.getBlockOptions();}
(mod=modifier)?
#( ARG (args:ARG_ACTION)? )
#( RET (ret:ARG_ACTION)? )
(optionsSpec)?
{
name = #id.getText();
currentRuleName = name;
if ( Character.isUpperCase(name.charAt(0)) &&
grammar.type==Grammar.COMBINED )
{
// a merged grammar spec, track lexer rules and send to another grammar
grammar.defineLexerRuleFoundInParser(#id.getToken(), #rule);
}
else {
int numAlts = countAltsForRule(#rule);
grammar.defineRule(#id.getToken(), mod, opts, #rule, #args, numAlts);
r = grammar.getRule(name);
if ( #args!=null ) {
r.parameterScope = grammar.createParameterScope(name,#args.token);
r.parameterScope.addAttributes(#args.getText(), ',');
}
if ( #ret!=null ) {
r.returnScope = grammar.createReturnScope(name,#ret.token);
r.returnScope.addAttributes(#ret.getText(), ',');
}
}
}
(ruleScopeSpec[r])?
(ruleAction[r])*
{this.blockLevel=0;}
b:block
(exceptionGroup)?
EOR
{
// copy rule options into the block AST, which is where
// the analysis will look for k option etc...
#b.setBlockOptions(opts);
}
)
;
countAltsForRule returns [int n=0]
: #( RULE id:ID (modifier)? ARG RET (OPTIONS)? ("scope")? (AMPERSAND)*
#( BLOCK (OPTIONS)? (ALT (REWRITE)* {n++;})+ EOB )
(exceptionGroup)?
EOR
)
;
ruleAction[Rule r]
: #(amp:AMPERSAND id:ID a:ACTION ) {if (r!=null) r.defineNamedAction(#amp,#id,#a);}
;
modifier returns [String mod]
{
mod = #modifier.getText();
}
: "protected"
| "public"
| "private"
| "fragment"
;
ruleScopeSpec[Rule r]
: #( "scope"
( attrs:ACTION
{
r.ruleScope = grammar.createRuleScope(r.name,#attrs.token);
r.ruleScope.isDynamicRuleScope = true;
r.ruleScope.addAttributes(#attrs.getText(), ';');
}
)?
( uses:ID
{
if ( grammar.getGlobalScope(#uses.getText())==null ) {
ErrorManager.grammarError(ErrorManager.MSG_UNKNOWN_DYNAMIC_SCOPE,
grammar,
#uses.token,
#uses.getText());
}
else {
if ( r.useScopes==null ) {r.useScopes=new ArrayList();}
r.useScopes.add(#uses.getText());
}
}
)*
)
;
block
{
this.blockLevel++;
if ( this.blockLevel==1 ) {this.outerAltNum=1;}
}
: #( BLOCK
(optionsSpec)?
(blockAction)*
( alternative rewrite
{if ( this.blockLevel==1 ) {this.outerAltNum++;}}
)+
EOB
)
{this.blockLevel--;}
;
// TODO: this does nothing now! subrules cannot have init actions. :(
blockAction
: #(amp:AMPERSAND id:ID a:ACTION ) // {r.defineAction(#amp,#id,#a);}
;
alternative
{
if ( grammar.type!=Grammar.LEXER && grammar.getOption("output")!=null && blockLevel==1 ) {
GrammarAST aRewriteNode = #alternative.findFirstType(REWRITE); // alt itself has rewrite?
GrammarAST rewriteAST = (GrammarAST)#alternative.getNextSibling();
// we have a rewrite if alt uses it inside subrule or this alt has one
// but don't count -> ... rewrites, which mean "do default auto construction"
if ( aRewriteNode!=null||
(rewriteAST!=null &&
rewriteAST.getType()==REWRITE &&
rewriteAST.getFirstChild()!=null &&
rewriteAST.getFirstChild().getType()!=ETC) )
{
Rule r = grammar.getRule(currentRuleName);
r.trackAltsWithRewrites(#alternative,this.outerAltNum);
}
}
}
: #( ALT (element)+ EOA )
;
exceptionGroup
: ( exceptionHandler )+ (finallyClause)?
| finallyClause
;
exceptionHandler
: #("catch" ARG_ACTION ACTION) {trackInlineAction(#ACTION);}
;
finallyClause
: #("finally" ACTION) {trackInlineAction(#ACTION);}
;
element
: #(ROOT element)
| #(BANG element)
| atom[null]
| #(NOT element)
| #(RANGE atom[null] atom[null])
| #(CHAR_RANGE atom[null] atom[null])
| #(ASSIGN id:ID el:element)
{
if ( #el.getType()==ANTLRParser.ROOT ||
#el.getType()==ANTLRParser.BANG )
{
#el = (GrammarAST)#el.getFirstChild();
}
if ( #el.getType()==RULE_REF) {
grammar.defineRuleRefLabel(currentRuleName,#id.getToken(),#el);
}
else if ( #el.getType()==WILDCARD && grammar.type==Grammar.TREE_PARSER ) {
grammar.defineWildcardTreeLabel(currentRuleName,#id.getToken(),#el);
}
else {
grammar.defineTokenRefLabel(currentRuleName,#id.getToken(),#el);
}
}
| #( PLUS_ASSIGN id2:ID a2:element
{
if ( #a2.getType()==ANTLRParser.ROOT ||
#a2.getType()==ANTLRParser.BANG )
{
#a2 = (GrammarAST)#a2.getFirstChild();
}
if ( #a2.getType()==RULE_REF ) {
grammar.defineRuleListLabel(currentRuleName,#id2.getToken(),#a2);
}
else if ( #a2.getType()==WILDCARD && grammar.type==Grammar.TREE_PARSER ) {
grammar.defineWildcardTreeListLabel(currentRuleName,#id2.getToken(),#a2);
}
else {
grammar.defineTokenListLabel(currentRuleName,#id2.getToken(),#a2);
}
}
)
| ebnf
| tree
| #( SYNPRED block )
| act:ACTION
{
#act.outerAltNum = this.outerAltNum;
trackInlineAction(#act);
}
| act2:FORCED_ACTION
{
#act2.outerAltNum = this.outerAltNum;
trackInlineAction(#act2);
}
| SEMPRED
{
#SEMPRED.outerAltNum = this.outerAltNum;
trackInlineAction(#SEMPRED);
}
| SYN_SEMPRED
| BACKTRACK_SEMPRED
| GATED_SEMPRED
{
#GATED_SEMPRED.outerAltNum = this.outerAltNum;
trackInlineAction(#GATED_SEMPRED);
}
| EPSILON
;
ebnf: (dotLoop)=> dotLoop // .* or .+
| block
| #( OPTIONAL block )
| #( CLOSURE block )
| #( POSITIVE_CLOSURE block )
;
/** Track the .* and .+ idioms and make them nongreedy by default.
*/
dotLoop
{
GrammarAST block = (GrammarAST)#dotLoop.getFirstChild();
}
: ( #( CLOSURE dotBlock )
| #( POSITIVE_CLOSURE dotBlock )
)
{
Map opts=new HashMap();
opts.put("greedy", "false");
if ( grammar.type!=Grammar.LEXER ) {
// parser grammars assume k=1 for .* loops
// otherwise they (analysis?) look til EOF!
opts.put("k", Utils.integer(1));
}
block.setOptions(grammar,opts);
}
;
dotBlock
: #( BLOCK #( ALT WILDCARD EOA ) EOB )
;
tree: #(TREE_BEGIN element (element)*)
;
atom[GrammarAST scope]
: #( rr:RULE_REF (rarg:ARG_ACTION)? )
{
grammar.altReferencesRule(currentRuleName, scope, #rr, this.outerAltNum);
if ( #rarg!=null ) {
#rarg.outerAltNum = this.outerAltNum;
trackInlineAction(#rarg);
}
}
| #( t:TOKEN_REF (targ:ARG_ACTION )? )
{
if ( #targ!=null ) {
#targ.outerAltNum = this.outerAltNum;
trackInlineAction(#targ);
}
if ( grammar.type==Grammar.LEXER ) {
grammar.altReferencesRule(currentRuleName, scope, #t, this.outerAltNum);
}
else {
grammar.altReferencesTokenID(currentRuleName, #t, this.outerAltNum);
}
}
| c:CHAR_LITERAL
{
if ( grammar.type!=Grammar.LEXER ) {
Rule rule = grammar.getRule(currentRuleName);
if ( rule!=null ) {
rule.trackTokenReferenceInAlt(#c, outerAltNum);
}
}
}
| s:STRING_LITERAL
{
if ( grammar.type!=Grammar.LEXER ) {
Rule rule = grammar.getRule(currentRuleName);
if ( rule!=null ) {
rule.trackTokenReferenceInAlt(#s, outerAltNum);
}
}
}
| WILDCARD
| #(DOT ID atom[#ID]) // scope override on rule
;
ast_suffix
: ROOT
| BANG
;
rewrite
{
currentRewriteRule = #rewrite; // has to execute during guessing
if ( grammar.buildAST() ) {
#rewrite.rewriteRefsDeep = new HashSet<GrammarAST>();
}
}
: (
#( REWRITE (pred:SEMPRED)? rewrite_alternative )
{
if ( #pred!=null ) {
#pred.outerAltNum = this.outerAltNum;
trackInlineAction(#pred);
}
}
)*
//{System.out.println("-> refs = "+#rewrite.rewriteRefs);}
;
rewrite_block
{
GrammarAST enclosingBlock = currentRewriteBlock;
if ( inputState.guessing==0 ) { // don't do if guessing
currentRewriteBlock=#rewrite_block; // pts to BLOCK node
currentRewriteBlock.rewriteRefsShallow = new HashSet<GrammarAST>();
currentRewriteBlock.rewriteRefsDeep = new HashSet<GrammarAST>();
}
}
: #( BLOCK rewrite_alternative EOB )
//{System.out.println("atoms="+currentRewriteBlock.rewriteRefs);}
{
// copy the element refs in this block to the surrounding block
if ( enclosingBlock!=null ) {
enclosingBlock.rewriteRefsDeep
.addAll(currentRewriteBlock.rewriteRefsShallow);
}
currentRewriteBlock = enclosingBlock; // restore old BLOCK ptr
}
;
rewrite_alternative
: {grammar.buildAST()}?
#( a:ALT ( ( rewrite_element )+ | EPSILON ) EOA )
| {grammar.buildTemplate()}? rewrite_template
| ETC {this.blockLevel==1}? // only valid as outermost rewrite
;
rewrite_element
: rewrite_atom
| rewrite_ebnf
| rewrite_tree
;
rewrite_ebnf
: #( OPTIONAL rewrite_block )
| #( CLOSURE rewrite_block )
| #( POSITIVE_CLOSURE rewrite_block )
;
rewrite_tree
: #( TREE_BEGIN rewrite_atom ( rewrite_element )* )
;
rewrite_atom
{
Rule r = grammar.getRule(currentRuleName);
Set tokenRefsInAlt = r.getTokenRefsInAlt(outerAltNum);
boolean imaginary =
#rewrite_atom.getType()==TOKEN_REF &&
!tokenRefsInAlt.contains(#rewrite_atom.getText());
if ( !imaginary && grammar.buildAST() &&
(#rewrite_atom.getType()==RULE_REF ||
#rewrite_atom.getType()==LABEL ||
#rewrite_atom.getType()==TOKEN_REF ||
#rewrite_atom.getType()==CHAR_LITERAL ||
#rewrite_atom.getType()==STRING_LITERAL) )
{
// track per block and for entire rewrite rule
if ( currentRewriteBlock!=null ) {
currentRewriteBlock.rewriteRefsShallow.add(#rewrite_atom);
currentRewriteBlock.rewriteRefsDeep.add(#rewrite_atom);
}
currentRewriteRule.rewriteRefsDeep.add(#rewrite_atom);
}
}
: RULE_REF
| ( #(TOKEN_REF
(arg:ARG_ACTION)?
)
| CHAR_LITERAL
| STRING_LITERAL
)
{
if ( #arg!=null ) {
#arg.outerAltNum = this.outerAltNum;
trackInlineAction(#arg);
}
}
| LABEL
| ACTION
{
#ACTION.outerAltNum = this.outerAltNum;
trackInlineAction(#ACTION);
}
;
rewrite_template
: #( ALT EPSILON EOA )
| #( TEMPLATE (id:ID|ind:ACTION)
#( ARGLIST
( #( ARG arg:ID a:ACTION )
{
#a.outerAltNum = this.outerAltNum;
trackInlineAction(#a);
}
)*
)
{
if ( #ind!=null ) {
#ind.outerAltNum = this.outerAltNum;
trackInlineAction(#ind);
}
}
( DOUBLE_QUOTE_STRING_LITERAL
| DOUBLE_ANGLE_STRING_LITERAL
)?
)
| act:ACTION
{
#act.outerAltNum = this.outerAltNum;
trackInlineAction(#act);
}
;
| G-code | 4 | DanielMabadeje/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | java/java2py/antlr-3.1.3/tool/src/main/antlr2/org/antlr/grammar/v2/define.g | [
"Apache-2.0"
] |
apiVersion: release-notes/v2
kind: bug-fix
area: telemetry
issue:
- 31270
releaseNotes:
- |
**Fixed** an issue where envoy does not start up properly when
duplicated extra stats tags are configured.
| YAML | 2 | rveerama1/istio | releasenotes/notes/duplicated-extra-stats-tag.yaml | [
"Apache-2.0"
] |
import kmKH from '../../date-picker/locale/km_KH';
export default kmKH;
| TypeScript | 1 | fanerge/ant-design | components/calendar/locale/km_KH.tsx | [
"MIT"
] |
#tag Class
Protected Class AVSpeechSynthesizer
Inherits NSObject
#tag Method, Flags = &h21
Private Shared Function ClassRef() As Ptr
static ref as ptr = NSClassFromString("AVSpeechSynthesizer")
return ref
End Function
#tag EndMethod
#tag Method, Flags = &h1000
Sub Constructor()
// Calling the overridden superclass constructor.
// Note that this may need modifications if there are multiple constructor choices.
// Possible constructor calls:
// Constructor() -- From NSObject
// Constructor(ref as ptr) -- From NSObject
Super.Constructor(Initialize(Allocate(ClassRef)))
needsExtraRelease = True
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Function ContinueSpeaking() As Boolean
declare function continueSpeaking_ lib AVFoundationLib selector "continueSpeaking" (obj_id as ptr) as Boolean
Return continueSpeaking_(self)
End Function
#tag EndMethod
#tag Method, Flags = &h0
Function PauseSpeakingAtBoundary(boundary as AVSpeechBoundary) As Boolean
declare function pauseSpeakingAtBoundary_ lib AVFoundationLib selector "pauseSpeakingAtBoundary:" (obj_id as ptr, boundary as AVSpeechBoundary) as Boolean
Return pauseSpeakingAtBoundary_(self, boundary)
End Function
#tag EndMethod
#tag Method, Flags = &h0
Sub SpeakUtterance(utterance as AVSpeechUtterance)
declare sub speakUtterance_ lib AVFoundationLib selector "speakUtterance:" (obj_id as ptr, utterance as ptr)
speakUtterance_(self, utterance)
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Function StopSpeakingAtBoundary(boundary as AVSpeechBoundary) As Boolean
declare function stopSpeakingAtBoundary_ lib AVFoundationLib selector "stopSpeakingAtBoundary:" (obj_id as ptr, boundary as AVSpeechBoundary) as Boolean
Return stopSpeakingAtBoundary_(self, boundary)
End Function
#tag EndMethod
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
declare function delegate_ lib AVFoundationLib selector "delegate" (obj_id as ptr) as ptr
Return (delegate_(self))
End Get
#tag EndGetter
#tag Setter
Set
declare sub delegate_ lib AVFoundationLib selector "setDelegate:" (obj_id as ptr, del as ptr)
delegate_(self, value)
End Set
#tag EndSetter
mdelegate As Ptr
#tag EndComputedProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
declare function paused_ lib AVFoundationLib selector "isPaused" (obj_id as ptr) as Boolean
Return paused_(self)
End Get
#tag EndGetter
paused As Boolean
#tag EndComputedProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
declare function speaking_ lib AVFoundationLib selector "isSpeaking" (obj_id as ptr) as Boolean
Return speaking_(self)
End Get
#tag EndGetter
speaking As Boolean
#tag EndComputedProperty
#tag Enum, Name = AVSpeechBoundary, Type = Integer, Flags = &h0
Immediate = 0
Word = 1
#tag EndEnum
#tag ViewBehavior
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
InitialValue=""
Type="String"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="paused"
Visible=false
Group="Behavior"
InitialValue=""
Type="Boolean"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="speaking"
Visible=false
Group="Behavior"
InitialValue=""
Type="Boolean"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
InitialValue=""
Type="String"
EditorType=""
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
EditorType=""
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass
| Xojo | 5 | kingj5/iOSKit | Modules/AVFoundation/AVSpeechSynthesizer.xojo_code | [
"MIT"
] |
diagram "bidirectional" {
generic.component a;
generic.component b;
generic.component c;
group g1 {
generic.component g11;
generic.component g12;
}
group g2 {
generic.component g21;
generic.component g22;
}
a -> b <-> c;
b => g1;
c <=> g2;
}
| Redcode | 3 | ralphtq/cloudgram | tests/fixtures/bidirectional.cw | [
"Apache-2.0"
] |
Import rockout
Const TEMP_AVG:Int = 10
Class DeltaTimer
' Usage...
' 1) Create DeltaTimer object, eg.
' "Local dt:DeltaTimer = New DeltaTimer (60)"
' where 60 is your game's intended frame rate,
' regardless of device frame rate.
' 2) Call dt.UpdateDelta at start of OnUpdate...
' 3) Multiply all speeds by dt.delta...
' 4) That's it.
Field targetfps:Float = 60
Field currentticks:Float
Field lastticks:Float
Field frametime:Float
Field delta:Float
Field average:Float [TEMP_AVG]
Method New (fps:Float)
targetfps = fps
lastticks = Millisecs
End
Method UpdateDelta ()
currentticks = Millisecs
frametime = currentticks - lastticks
Local total:Float
For Local loop:Int = 1 Until TEMP_AVG
average [loop - 1] = average [loop]
total = total + average [loop - 1]
Next
average [TEMP_AVG - 1] = currentticks - lastticks
total = total + average [TEMP_AVG - 1]
frametime = total / Float (TEMP_AVG - 1)
delta = frametime / (1000.0 / targetfps)
lastticks = currentticks
End
End
| Monkey | 5 | blitz-research/monkey | bananas/hitoro/rockout/imports/delta.monkey | [
"Zlib"
] |
<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="a" uri="/WEB-INF/app.tld"%>
<%@ taglib prefix="w" uri="http://www.unidal.org/web/core"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%>
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.dependency.Context" scope="request"/>
<jsp:useBean id="payload" type="com.dianping.cat.report.page.dependency.Payload" scope="request"/>
<jsp:useBean id="model" type="com.dianping.cat.report.page.dependency.Model" scope="request"/>
<a:hourly_report title="Dependency Report"
navUrlPrefix="op=lineChart&domain=${model.domain}">
<jsp:attribute name="subtitle">${w:format(model.report.startTime,'yyyy-MM-dd HH:mm:ss')} to ${w:format(model.report.endTime,'yyyy-MM-dd HH:mm:ss')}</jsp:attribute>
<jsp:body>
<div class='report'>
<div class="tabbable text-danger" id="content"> <!-- Only required for left/right tabs -->
<%@ include file="dependencyLineGraph.jsp"%>
</div>
</jsp:body>
</a:hourly_report>
<script type="text/javascript">
$(document).ready(function() {
var tab = '${payload.tab}';
if(tab=='tab3'){
$('#tab3Href').trigger('click');
}else if(tab=='tab2'){
$('#tab2Href').trigger('click');
}else if(tab=='tab1'){
$('#tab1Href').trigger('click');
}
$('.contents').dataTable({
"sPaginationType": "full_numbers",
'iDisplayLength': 50,
"bPaginate": false,
//"bFilter": false,
});
$('.contentsDependency').dataTable({
"sPaginationType": "full_numbers",
'iDisplayLength': 50,
"bPaginate": false,
});
$('#zabbixTab0').addClass('active');
$('#leftTab0').addClass('active');
$('.switch').css('display','none');
$('.dataTables_info').css('display','none');
});
</script>
<style>
.pagination{
margin:4px 0;
}
.pagination ul{
margin-top:0px;
}
.pagination ul > li > a, .pagination ul > li > span{
padding:3px 10px;
}
.graph {
width: 450px;
height: 200px;
margin: 4px auto;
}
</style>
| Java Server Pages | 2 | woozhijun/cat | cat-home/src/main/webapp/jsp/report/dependency/dependency.jsp | [
"Apache-2.0"
] |
"""
But you do see this...
1 2 3
<debug>
2+2: 4
"""
import System
import System.IO
import System.Diagnostics
debug "You don't see this..."
Debug.Listeners.Add(TextWriterTraceListener(Console.Out))
debug "But you do see this..."
debug 1, 2, 3
debug
debug "2+2:", 4
| Boo | 3 | popcatalin81/boo | tests/testcases/macros/debug-1.boo | [
"BSD-3-Clause"
] |
// Licensed to the Apache Software Foundation(ASF) under one
// or more contributor license agreements.See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.The ASF licenses this file
// to you 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.
unit DataFactory;
interface
uses
SysUtils,
Thrift.Collections,
Thrift.Test;
type
TestDataFactory = class
strict protected
class function CreateSetField(const count : Integer) : IHashSet< IInsanity>; static;
class function CreateInsanity(const count : Integer) : IInsanity; static;
class function CreateBytesArray(const count : Integer) : TBytes; static;
class function CreateXtructs(const count : Integer) : IThriftList< IXtruct>; static;
class function CreateXtruct(const count : Integer) : IXtruct; static;
class function CreateListField(const count : Integer) : IThriftList< IThriftDictionary< IHashSet< Integer>, IThriftDictionary< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>>>; static;
class function CreateUserMap(const count : Integer) : IThriftDictionary< TNumberz, Int64>; static;
class function CreateListFieldData(const count : Integer) : IThriftDictionary< IHashSet< Integer>, IThriftDictionary< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>>; static;
class function CreateIntHashSet(const count : Integer) : IHashSet< Integer>; static;
class function CreateListFieldDataDict(const count : Integer) : IThriftDictionary< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>; static;
class function CreateListFieldDataDictValue(const count : Integer) : IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>; static;
class function CreateListFieldDataDictValueList(const count : Integer) : IThriftList< IThriftDictionary< IInsanity, string>>; static;
class function CreateListFieldDataDictValueListDict(const count : Integer) : IThriftDictionary< IInsanity, string>; static;
public
class function CreateCrazyNesting(const count : Integer = 10) : ICrazyNesting; static;
end;
implementation
class function TestDataFactory.CreateCrazyNesting(const count : Integer = 10) : ICrazyNesting;
begin
if (count <= 0)
then Exit(nil);
result := TCrazyNestingImpl.Create;
result.Binary_field := CreateBytesArray(count);
result.List_field := CreateListField(count);
result.Set_field := CreateSetField(count);
result.String_field := Format('data level %d', [count]);
end;
class function TestDataFactory.CreateSetField(const count : Integer) : IHashSet< IInsanity>;
var i : Integer;
begin
result := THashSetImpl< IInsanity>.Create;
for i := 0 to count-1 do begin
result.Add(CreateInsanity(count));
end;
end;
class function TestDataFactory.CreateInsanity(const count : Integer) : IInsanity;
begin
result := TInsanityImpl.Create;
result.UserMap := CreateUserMap(count);
result.Xtructs := CreateXtructs(count);
end;
class function TestDataFactory.CreateXtructs(const count : Integer) : IThriftList< IXtruct>;
var i : Integer;
begin
result := TThriftListImpl< IXtruct>.Create;
for i := 0 to count-1 do begin
result.Add(CreateXtruct(count));
end;
end;
class function TestDataFactory.CreateXtruct(const count : Integer) : IXtruct;
begin
result := TXtructImpl.Create;
result.Byte_thing := SmallInt(count mod 128);
result.I32_thing := count;
result.I64_thing := count;
result.String_thing := Format('data level %d', [count]);
end;
class function TestDataFactory.CreateUserMap(const count : Integer) : IThriftDictionary< TNumberz, Int64>;
begin
result := TThriftDictionaryImpl< TNumberz, Int64>.Create;
result.Add(TNumberz.ONE, count);
result.Add(TNumberz.TWO, count);
result.Add(TNumberz.THREE, count);
result.Add(TNumberz.FIVE, count);
result.Add(TNumberz.SIX, count);
result.Add(TNumberz.EIGHT, count);
end;
class function TestDataFactory.CreateListField(const count : Integer) : IThriftList< IThriftDictionary< IHashSet< Integer>, IThriftDictionary< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>>>;
var i : Integer;
begin
result := TThriftListImpl< IThriftDictionary< IHashSet< Integer>, IThriftDictionary< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>>>.Create;
for i := 0 to count-1 do begin
result.Add(CreateListFieldData(count));
end;
end;
class function TestDataFactory.CreateListFieldData(const count : Integer) : IThriftDictionary< IHashSet< Integer>, IThriftDictionary< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>>;
var i : Integer;
begin
result := TThriftDictionaryImpl< IHashSet< Integer>, IThriftDictionary< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>>.Create;
for i := 0 to count-1 do begin
result.Add( CreateIntHashSet(count), CreateListFieldDataDict(count));
end;
end;
class function TestDataFactory.CreateIntHashSet(const count : Integer) : IHashSet< Integer>;
var i : Integer;
begin
result := THashSetImpl< Integer>.Create;
for i := 0 to count-1 do begin
result.Add(i);
end;
end;
class function TestDataFactory.CreateListFieldDataDict(const count : Integer) : IThriftDictionary< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>;
var i : Integer;
begin
result := TThriftDictionaryImpl< Integer, IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>>.Create;
for i := 0 to count-1 do begin
result.Add(i, CreateListFieldDataDictValue(count));
end;
end;
class function TestDataFactory.CreateListFieldDataDictValue(const count : Integer) : IHashSet< IThriftList< IThriftDictionary< IInsanity, string>>>;
var i : Integer;
begin
result := THashSetImpl< IThriftList< IThriftDictionary< IInsanity, string>>>.Create;
for i := 0 to count-1 do begin
result.Add( CreateListFieldDataDictValueList(count));
end;
end;
class function TestDataFactory.CreateListFieldDataDictValueList(const count : Integer) : IThriftList< IThriftDictionary< IInsanity, string>>;
var i : Integer;
begin
result := TThriftListImpl< IThriftDictionary< IInsanity, string>>.Create;
for i := 0 to count-1 do begin
result.Add(CreateListFieldDataDictValueListDict(count));
end;
end;
class function TestDataFactory.CreateListFieldDataDictValueListDict(const count : Integer) : IThriftDictionary< IInsanity, string>;
begin
result := TThriftDictionaryImpl< IInsanity, string>.Create;
result.Add(CreateInsanity(count), Format('data level %d', [count]));
end;
class function TestDataFactory.CreateBytesArray(const count : Integer) : TBytes;
var i : Integer;
begin
SetLength( result, count);
for i := 0 to count-1 do begin
result[i] := i mod $FF;
end;
end;
end.
| Pascal | 4 | Jimexist/thrift | lib/delphi/test/Performance/DataFactory.pas | [
"Apache-2.0"
] |
fun main () : transaction page = return <xml><body>
<a link={main ()} rel="whoKnows">Here</a>
</body></xml>
| UrWeb | 1 | apple314159/urweb | tests/arel.ur | [
"BSD-3-Clause"
] |
diff ← {1↓⍵−¯1⌽⍵}
signal ← {¯50⌈50⌊50×(diff 0,⍵)÷0.01+⍵}
+/ signal ⍳ 100
| APL | 3 | mbudde/apltail | tests/signal.apl | [
"MIT"
] |
.class public Larrays/TestCls;
.super Ljava/lang/Object;
.method public test()[J
.registers 4
const/16 v3, 0x2
move/from16 v0, v3
new-array v0, v0, [J
move-object/from16 v1, v0
fill-array-data v1, :array_0
.local v1, "arr":[J
return v1
:array_0
.array-data 8
0x0
0x1
.end array-data
.end method
| Smali | 4 | DSYliangweihao/jadx | jadx-core/src/test/smali/arrays/TestArrayFillWithMove/TestCls.smali | [
"Apache-2.0"
] |
@aws
runtime nodejs12.x
timeout 12
# concurrency 1
# memory 1152
| Arc | 2 | copperinc/sandbox | test/mock/normal/src/http/get-nodejs12_x/config.arc | [
"Apache-2.0"
] |
BsplitJ | PureBasic | 0 | pchandrasekaran1595/onnx | onnx/backend/test/data/node/test_split_zero_size_splits/test_data_set_0/input_1.pb | [
"Apache-2.0"
] |
: main
"a" 1 "b" 2 "c" 3 3
array_make_dict
;
| MUF | 1 | revarbat/mufsim | tests/array_make_dict.muf | [
"BSD-2-Clause"
] |
package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.CatModel;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
* Result view for CatCommand
* @author gongdewei 2020/5/11
*/
public class CatView extends ResultView<CatModel> {
@Override
public void draw(CommandProcess process, CatModel result) {
process.write(result.getContent()).write("\n");
}
}
| Java | 4 | weihubeats/arthas | core/src/main/java/com/taobao/arthas/core/command/view/CatView.java | [
"Apache-2.0"
] |
#%RAML 1.0 Library
types:
Foo:
type: object
properties:
content:
type: string
| RAML | 3 | fquesnel/marathon | type-generator/src/test/resources/test.raml | [
"Apache-2.0"
] |
package com.baeldung.kubernetes.admission.service;
import static org.junit.jupiter.api.Assertions.*;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Base64;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import com.baeldung.kubernetes.admission.config.AdmissionControllerProperties;
import com.baeldung.kubernetes.admission.dto.AdmissionReviewResponse;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@SpringBootTest
@ActiveProfiles("test")
@EnableConfigurationProperties(AdmissionControllerProperties.class)
class AdmissionServiceUnitTest {
@Autowired
private ObjectMapper mapper;
@Autowired
private AdmissionService admissionService;
@Test
void whenAnnotationPresent_thenAddContainer() throws Exception {
InputStream is = this.getClass()
.getClassLoader()
.getResourceAsStream("test1.json");
JsonNode body = mapper.readTree(is);
AdmissionReviewResponse response = admissionService.processAdmission((ObjectNode) body);
assertNotNull(response);
assertNotNull(response.getResponse());
assertNotNull(response.getResponse());
assertTrue(response.getResponse()
.isAllowed());
String jsonResponse = mapper.writeValueAsString(response);
System.out.println(jsonResponse);
// Decode Patch data
String b64patch = response.getResponse()
.getPatch();
assertNotNull(b64patch);
byte[] patch = Base64.getDecoder()
.decode(b64patch);
JsonNode root = mapper.reader()
.readTree(new ByteArrayInputStream(patch));
assertTrue(root instanceof ArrayNode);
assertEquals(1, ((ArrayNode) root).size());
}
}
| Java | 4 | DBatOWL/tutorials | kubernetes/k8s-admission-controller/src/test/java/com/baeldung/kubernetes/admission/service/AdmissionServiceUnitTest.java | [
"MIT"
] |
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Json response template for the contents of the auth_opt.json file created by
/// goldctl.
String authTemplate({
bool gsutil = false,
}) {
return '''
{
"Luci":false,
"ServiceAccount":"${gsutil ? '' : '/packages/flutter/test/widgets/serviceAccount.json'}",
"GSUtil":$gsutil
}
''';
}
/// Json response template for Skia Gold image request:
/// https://flutter-gold.skia.org/img/images/[imageHash].png
List<List<int>> imageResponseTemplate() {
return <List<int>>[
<int>[137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73,
72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0, 0, 0, 31, 21, 196, 137, 0],
<int>[0, 0, 11, 73, 68, 65, 84, 120, 1, 99, 97, 0, 2, 0,
0, 25, 0, 5, 144, 240, 54, 245, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96,
130],
];
}
| Dart | 4 | Mayb3Nots/flutter | packages/flutter_goldens/test/json_templates.dart | [
"BSD-3-Clause"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.